_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3
values | text stringlengths 66 10.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q20200 | Ruote.DispatchPool.dispatch_cancel | train | def dispatch_cancel(msg)
flavour = msg['flavour']
participant = @context.plist.instantiate(msg['participant'])
result = begin
Ruote.participant_send(
participant,
[ :on_cancel, :cancel ],
'fei' => Ruote::FlowExpressionId.new(msg['fei']),
'flavour' =>... | ruby | {
"resource": ""
} |
q20201 | Ruote.ReceiverMixin.receive | train | def receive(workitem)
workitem = workitem.to_h if workitem.respond_to?(:to_h)
@context.storage.put_msg(
'receive',
'fei' => workitem['fei'],
'workitem' => workitem,
'participant_name' => workitem['participant_name'],
'receiver' => sign)
end | ruby | {
"resource": ""
} |
q20202 | Ruote.ReceiverMixin.flunk | train | def flunk(workitem, error_class_or_instance_or_message, *err_arguments)
err = error_class_or_instance_or_message
trace = Ruote.pop_trace(err_arguments)
err =
case err
when Exception
err
when Class
err.new(*err_arguments)
when String
... | ruby | {
"resource": ""
} |
q20203 | Ruote.ReceiverMixin.launch | train | def launch(process_definition, fields={}, variables={}, root_stash=nil)
#puts caller.select { |l|
# ! (l.match(/test\/unit[\.\/]/) or l.match(/\/rspec-core-/))
#} if @context.logger.noisy
#
# this is useful when noisy and running through a set of tests
wfid = fields[:wfid] || ... | ruby | {
"resource": ""
} |
q20204 | Ruote.ReceiverMixin.fetch_flow_expression | train | def fetch_flow_expression(workitem_or_fei)
Ruote::Exp::FlowExpression.fetch(
@context,
Ruote::FlowExpressionId.extract_h(workitem_or_fei))
end | ruby | {
"resource": ""
} |
q20205 | Ruote.ReceiverMixin.stash_get | train | def stash_get(workitem_or_fei, key=nil)
stash = fetch_flow_expression(workitem_or_fei).h['stash'] rescue nil
stash ||= {}
key ? stash[key] : stash
end | ruby | {
"resource": ""
} |
q20206 | Ruote.Worker.inactive? | train | def inactive?
# the cheaper tests first
return false if @msgs.size > 0
return false unless @context.storage.empty?('schedules')
return false unless @context.storage.empty?('msgs')
wfids = @context.storage.get_many('expressions').collect { |exp|
exp['fei']['wfid']
}
... | ruby | {
"resource": ""
} |
q20207 | Ruote.Worker.turn_schedule_to_msg | train | def turn_schedule_to_msg(schedule)
return false unless @storage.reserve(schedule)
msg = Ruote.fulldup(schedule['msg'])
@storage.put_msg(msg.delete('action'), msg)
true
end | ruby | {
"resource": ""
} |
q20208 | Ruote.Worker.process | train | def process(msg)
return false unless @storage.reserve(msg)
begin
@context.pre_notify(msg)
case msg['action']
when 'launch', 'apply', 'regenerate'
launch(msg)
when *EXP_ACTIONS
Ruote::Exp::FlowExpression.do_action(@context, msg)
w... | ruby | {
"resource": ""
} |
q20209 | Ruote.Worker.launch | train | def launch(msg)
tree = msg['tree']
variables = msg['variables']
wi = msg['workitem']
exp_class = @context.expmap.expression_class(tree.first)
# msg['wfid'] only: it's a launch
# msg['fei']: it's a sub launch (a supplant ?)
if is_launch?(msg, exp_class)
name... | ruby | {
"resource": ""
} |
q20210 | Ruote.Worker.pause_process | train | def pause_process(msg)
root = @storage.find_root_expression(msg['wfid'])
return unless root
@storage.put_msg(
msg['action'] == 'pause_process' ? 'pause' : 'resume',
'fei' => root['fei'],
'wfid' => msg['wfid']) # it was triggered by {pause|resume}_process
end | ruby | {
"resource": ""
} |
q20211 | Ruote.Worker.reput | train | def reput(msg)
if doc = msg['doc']
r = @storage.put(doc)
return unless r.is_a?(Hash)
doc['_rev'] = r['_rev']
reput(msg)
elsif msg = msg['msg']
@storage.put_msg(msg['action'], msg)
end
end | ruby | {
"resource": ""
} |
q20212 | Ruote::Exp.FilterExpression.block_filter | train | def block_filter
return nil if tree.last.empty?
tree.last.collect { |line|
next 'or' if line.first == 'or'
rule = line[1].remap { |(k, v), h|
if v == nil
h['field'] = k
else
h[k] = v
end
}
rule['field'] ||= line.first... | ruby | {
"resource": ""
} |
q20213 | Ruote::Exp.FilterExpression.one_line_filter | train | def one_line_filter
if (attributes.keys - COMMON_ATT_KEYS - %w[ ref original_ref ]).empty?
return nil
end
[ attributes.remap { |(k, v), h|
if v.nil?
h['field'] = k
else
h[k] = v
end
} ]
end | ruby | {
"resource": ""
} |
q20214 | Ruote::Exp.FlowExpression.compile_variables | train | def compile_variables
vars = h.parent_id ? parent.compile_variables : {}
vars.merge!(h.variables) if h.variables
vars
end | ruby | {
"resource": ""
} |
q20215 | Ruote::Exp.FlowExpression.unset_variable | train | def unset_variable(var, override=false)
fexp, v = locate_set_var(var, override) || locate_var(var)
fexp.un_set_variable(:unset, v, nil, (fexp.h.fei != h.fei)) if fexp
end | ruby | {
"resource": ""
} |
q20216 | Ruote::Exp.FlowExpression.split_prefix | train | def split_prefix(var, prefix)
if prefix.nil?
m = VAR_PREFIX_REGEX.match(var.to_s)
prefix = m[1]
var = m[2]
end
[ var, prefix ]
end | ruby | {
"resource": ""
} |
q20217 | Ruote.Mutation.walk | train | def walk(fexp, tree)
ftree = Ruote.compact_tree(@ps.current_tree(fexp))
if ftree[0] != tree[0] || ftree[1] != tree[1]
#
# if there is anything different between the current tree and the
# desired tree, let's force a re-apply
register(MutationPoint.new(fexp.fei, tree, :re_a... | ruby | {
"resource": ""
} |
q20218 | Ruote.Mutation.walk_sequence | train | def walk_sequence(fexp, ftree, tree)
i = fexp.child_ids.first
ehead = ftree[2].take(i)
ecurrent = ftree[2][i]
etail = ftree[2].drop(i + 1)
head = tree[2].take(i)
current = tree[2][i]
tail = tree[2].drop(i + 1)
if ehead != head
#
# if the name and/or att... | ruby | {
"resource": ""
} |
q20219 | Ruote::Exp.CursorExpression.move_on | train | def move_on(workitem=h.applied_workitem)
position = workitem['fei'] == h.fei ?
-1 : Ruote::FlowExpressionId.child_id(workitem['fei'])
position += 1
com, arg = get_command(workitem)
return reply_to_parent(workitem) if com == 'break'
case com
when 'rewind', 'continue', '... | ruby | {
"resource": ""
} |
q20220 | Ruote::Exp.CursorExpression.jump_to | train | def jump_to(workitem, position, arg)
pos = Integer(arg) rescue nil
return pos if pos != nil
tree_children.each_with_index do |c, i|
found = [
c[0], # exp_name
c[1]['ref'], # ref
c[1]['tag'], ... | ruby | {
"resource": ""
} |
q20221 | Ruote.StorageBase.clear | train | def clear
%w[ msgs schedules errors expressions workitems ].each do |type|
purge_type!(type)
end
end | ruby | {
"resource": ""
} |
q20222 | Ruote.StorageBase.remove_process | train | def remove_process(wfid)
2.times do
# two passes
Thread.pass
%w[ schedules expressions errors workitems ].each do |type|
get_many(type, wfid).each { |d| delete(d) }
end
doc = get_trackers
doc['trackers'].delete_if { |k, v| k.end_with?("!#{wfid}") }
... | ruby | {
"resource": ""
} |
q20223 | Ruote.StorageBase.prepare_msg_doc | train | def prepare_msg_doc(action, options)
# merge! is way faster than merge (no object creation probably)
@counter ||= 0
t = Time.now.utc
ts = "#{t.strftime('%Y-%m-%d')}!#{t.to_i}.#{'%06d' % t.usec}"
_id = "#{$$}!#{Thread.current.object_id}!#{ts}!#{'%03d' % @counter}"
@counter = (@cou... | ruby | {
"resource": ""
} |
q20224 | Ruote.StorageBase.prepare_schedule_doc | train | def prepare_schedule_doc(flavour, owner_fei, s, msg)
at = if s.is_a?(Time) # at or every
s
elsif Ruote.cron_string?(s) # cron
Rufus::Scheduler::CronLine.new(s).next_time(Time.now + 1)
else # at or every
Ruote.s_to_at(s)
end
at = at.utc
if at <= Time.now.utc ... | ruby | {
"resource": ""
} |
q20225 | Ruote::Exp.FlowExpression.handle_on_error | train | def handle_on_error(msg, error)
return false if h.state == 'failing'
err = deflate(error)
oe_parent = lookup_on_error(err)
return false unless oe_parent
# no parent with on_error attribute found
handler = oe_parent.local_on_error(err)
return false if handler.to_s == ''
... | ruby | {
"resource": ""
} |
q20226 | Ruote::Exp.FlowExpression.local_on_error | train | def local_on_error(err)
if h.on_error.is_a?(String) or Ruote.is_tree?(h.on_error)
return h.on_error
end
if h.on_error.is_a?(Array)
# all for the 'on_error' expression
# see test/functional/eft_38_
h.on_error.each do |oe|
if (he = HandlerEntry.new(oe)).ma... | ruby | {
"resource": ""
} |
q20227 | Ruote.Tracker.remove | train | def remove(tracker_ids, wfid)
return if tracker_ids.empty?
doc ||= @context.storage.get_trackers(wfid)
return if (doc['trackers'].keys & tracker_ids).empty?
doc['wfid'] = wfid
# a little helper for some some storage implementations like ruote-swf
# they need to know what work... | ruby | {
"resource": ""
} |
q20228 | Ruote.Tracker.on_message | train | def on_message(pre, message)
m_wfid = message['wfid'] || (message['fei']['wfid'] rescue nil)
m_error = message['error']
m_action = message['action']
m_action = "pre_#{m_action}" if pre
msg = m_action == 'error_intercepted' ? message['msg'] : message
ids_to_remove = []
trac... | ruby | {
"resource": ""
} |
q20229 | Ruote.Tracker.alter | train | def alter(m_wfid, m_error, m_action, msg, tracker)
case tracker['msg'].delete('_alter')
when 'merge' then msg.merge!(tracker['msg'])
#else ...
end
end | ruby | {
"resource": ""
} |
q20230 | Ruote.Tracker.trigger | train | def trigger(m_wfid, m_error, m_action, msg, tracker)
t_action = tracker['action']
tracker_id = tracker['id']
m = Ruote.fulldup(tracker['msg'])
action = m.delete('action')
m['wfid'] = m_wfid if m['wfid'] == 'replace'
m['wfid'] ||= @context.wfidgen.generate
m['workitem'] = m... | ruby | {
"resource": ""
} |
q20231 | Ruote.Tracker.does_match? | train | def does_match?(msg, conditions)
return true unless conditions
conditions.each do |k, v|
return false unless Array(v).find do |vv|
# the Array(v) is for backward compatibility, although newer
# track conditions are already stored as arrays.
vv = Ruote.regex_or_s(vv... | ruby | {
"resource": ""
} |
q20232 | Ruote.WaitLogger.on_msg | train | def on_msg(msg)
puts(fancy_print(msg, @noisy)) if @noisy
return if msg['action'] == 'noop'
@mutex.synchronize do
@seen << msg
@log << msg
while @log.size > @log_max; @log.shift; end
while @seen.size > @log_max; @seen.shift; end
end
end | ruby | {
"resource": ""
} |
q20233 | Ruote.WaitLogger.wait_for | train | def wait_for(interests, opts={})
@waiting << [ Thread.current, interests ]
Thread.current['__result__'] = nil
start = Time.now
to = opts[:timeout] || @timeout
to = nil if to.nil? || to <= 0
loop do
raise(
Ruote::LoggerTimeout.new(interests, to)
) if to ... | ruby | {
"resource": ""
} |
q20234 | Ruote.WaitLogger.matches | train | def matches(interests, msg)
action = msg['action']
interests.each do |interest|
satisfied = case interest
when :or_error
#
# let's force an immediate reply
interests.clear if action == 'error_intercepted'
when :inactive
(FINA... | ruby | {
"resource": ""
} |
q20235 | Ruote.Context.has_service? | train | def has_service?(service_name)
service_name = service_name.to_s
service_name = "s_#{service_name}" if ! SERVICE_PREFIX.match(service_name)
@services.has_key?(service_name)
end | ruby | {
"resource": ""
} |
q20236 | Ruote::Exp.FlowExpression.do_p | train | def do_p(pers)
case r = pers ? try_persist : try_unpersist
when true
false # do not go on
when Hash
self.h = r
self.send("do_#{@msg['action']}", @msg) if @msg
false # do not go on
else
true # success, do go on
end
end | ruby | {
"resource": ""
} |
q20237 | Ruote.StorageParticipant.on_workitem | train | def on_workitem
doc = workitem.to_h
doc.merge!(
'type' => 'workitems',
'_id' => to_id(doc['fei']),
'participant_name' => doc['participant_name'],
'wfid' => doc['fei']['wfid'])
doc['store_name'] = @store_name if @store_name
@context.storage.put(doc, :update_rev... | ruby | {
"resource": ""
} |
q20238 | Ruote.StorageParticipant.proceed | train | def proceed(workitem)
r = remove_workitem('proceed', workitem)
return proceed(workitem) if r != nil
workitem.h.delete('_rev')
reply_to_engine(workitem)
end | ruby | {
"resource": ""
} |
q20239 | Ruote.StorageParticipant.flunk | train | def flunk(workitem, err_class_or_instance, *err_arguments)
r = remove_workitem('reject', workitem)
return flunk(workitem) if r != nil
workitem.h.delete('_rev')
super(workitem, err_class_or_instance, *err_arguments)
end | ruby | {
"resource": ""
} |
q20240 | Ruote.StorageParticipant.all | train | def all(opts={})
res = fetch_all(opts)
res.is_a?(Array) ? res.map { |hwi| Ruote::Workitem.new(hwi) } : res
end | ruby | {
"resource": ""
} |
q20241 | Ruote.StorageParticipant.by_wfid | train | def by_wfid(wfid, opts={})
if @context.storage.respond_to?(:by_wfid)
return @context.storage.by_wfid('workitems', wfid, opts)
end
wis(@context.storage.get_many('workitems', wfid, opts))
end | ruby | {
"resource": ""
} |
q20242 | Ruote.StorageParticipant.by_participant | train | def by_participant(participant_name, opts={})
return @context.storage.by_participant(
'workitems', participant_name, opts
) if @context.storage.respond_to?(:by_participant)
do_select(opts) do |hwi|
hwi['participant_name'] == participant_name
end
end | ruby | {
"resource": ""
} |
q20243 | Ruote.StorageParticipant.query | train | def query(criteria)
cr = Ruote.keys_to_s(criteria)
if @context.storage.respond_to?(:query_workitems)
return @context.storage.query_workitems(cr)
end
opts = {}
opts[:skip] = cr.delete('offset') || cr.delete('skip')
opts[:limit] = cr.delete('limit')
opts[:count] = cr.d... | ruby | {
"resource": ""
} |
q20244 | Ruote.StorageParticipant.per_participant_count | train | def per_participant_count
per_participant.remap { |(k, v), h| h[k] = v.size }
end | ruby | {
"resource": ""
} |
q20245 | Ruote.StorageParticipant.delegate | train | def delegate(workitem, new_owner)
hwi = fetch(workitem)
fail ArgumentError.new(
"workitem not found"
) if hwi == nil
fail ArgumentError.new(
"cannot delegate, workitem doesn't belong to anyone"
) if hwi['owner'] == nil
fail ArgumentError.new(
"cannot deleg... | ruby | {
"resource": ""
} |
q20246 | Ruote.StorageParticipant.do_select | train | def do_select(opts, &block)
skip = opts[:offset] || opts[:skip]
limit = opts[:limit]
count = opts[:count]
hwis = fetch_all({})
hwis = hwis.select(&block)
hwis = hwis[skip..-1] if skip
hwis = hwis[0, limit] if limit
return hwis.size if count
hwis.collect { |hwi|... | ruby | {
"resource": ""
} |
q20247 | Ruote.StorageParticipant.to_id | train | def to_id(fei)
a = [ Ruote.to_storage_id(fei) ]
a.unshift(@store_name) if @store_name
a.unshift('wi')
a.join('!')
end | ruby | {
"resource": ""
} |
q20248 | Ruote::Exp.CommandExpression.fetch_command_target | train | def fetch_command_target(exp=parent)
case exp
when nil then nil
when Ruote::Exp::CommandedExpression then exp
else fetch_command_target(exp.parent)
end
end | ruby | {
"resource": ""
} |
q20249 | Ruote.RevParticipant.lookup_code | train | def lookup_code
wi = workitem
rev = wi.params['revision'] || wi.params['rev']
[
[ wi.wf_name, wi.wf_revision, wi.participant_name, rev ],
[ wi.wf_name, wi.wf_revision, wi.participant_name ],
[ wi.wf_name, '', wi.participant_name ],
[ wi.participant_name, rev ],
... | ruby | {
"resource": ""
} |
q20250 | Ruote::Exp.IfExpression.reply | train | def reply(workitem)
if workitem['fei'] == h.fei # apply --> reply
h.test = attribute(:test)
h.test = attribute(:t) if h.test.nil?
h.test = attribute_text if h.test.nil?
h.test = nil if h.test == ''
offset = (h.test.nil? || Condition.true?(h.test)) ? 0 : 1
apply_... | ruby | {
"resource": ""
} |
q20251 | Ruote.ParticipantList.unregister | train | def unregister(name_or_participant)
code = nil
entry = nil
list = get_list
name_or_participant = name_or_participant.to_s
entry = list['list'].find { |re, pa| name_or_participant.match(re) }
return nil unless entry
code = entry.last if entry.last.is_a?(String)
list[... | ruby | {
"resource": ""
} |
q20252 | Ruote.ParticipantList.lookup | train | def lookup(participant_name, workitem, opts={})
pinfo = participant_name.is_a?(String) ?
lookup_info(participant_name, workitem) : participant_name
instantiate(pinfo, opts)
end | ruby | {
"resource": ""
} |
q20253 | Ruote.ParticipantList.lookup_info | train | def lookup_info(pname, workitem)
return nil unless pname
wi = workitem ?
Ruote::Workitem.new(workitem.merge('participant_name' => pname)) :
nil
get_list['list'].each do |regex, pinfo|
next unless pname.match(regex)
return pinfo if workitem.nil?
pa = instan... | ruby | {
"resource": ""
} |
q20254 | Ruote.ParticipantList.instantiate | train | def instantiate(pinfo, opts={})
return nil unless pinfo
pa_class_name, options = pinfo
if rp = options['require_path']
require(rp)
end
if lp = options['load_path']
load(lp)
end
pa_class = Ruote.constantize(pa_class_name)
pa_m = pa_class.instance_method... | ruby | {
"resource": ""
} |
q20255 | Spotify.Client.create_user_playlist | train | def create_user_playlist(user_id, name, is_public = true)
run(:post, "/v1/users/#{user_id}/playlists", [201], JSON.dump(name: name, public: is_public), false)
end | ruby | {
"resource": ""
} |
q20256 | Spotify.Client.add_user_tracks_to_playlist | train | def add_user_tracks_to_playlist(user_id, playlist_id, uris = [], position = nil)
params = { uris: Array.wrap(uris)[0..99].join(',') }
if position
params.merge!(position: position)
end
run(:post, "/v1/users/#{user_id}/playlists/#{playlist_id}/tracks", [201], JSON.dump(params), false)
... | ruby | {
"resource": ""
} |
q20257 | Spotify.Client.follow | train | def follow(type, ids)
params = { type: type, ids: Array.wrap(ids).join(',') }
run(:put, "/v1/me/following", [204], params)
end | ruby | {
"resource": ""
} |
q20258 | Monit.Status.url | train | def url
url_params = { :host => @host, :port => @port, :path => "/_status", :query => "format=xml" }
@ssl ? URI::HTTPS.build(url_params) : URI::HTTP.build(url_params)
end | ruby | {
"resource": ""
} |
q20259 | Monit.Status.get | train | def get
uri = self.url
http = Net::HTTP.new(uri.host, uri.port)
if @ssl
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
request = Net::HTTP::Get.new(uri.request_uri)
if @auth
request.basic_auth(@username, @password)
end
req... | ruby | {
"resource": ""
} |
q20260 | Monit.Status.parse | train | def parse(xml)
@hash = Hash.from_xml(xml)
@server = Server.new(@hash["monit"]["server"])
@platform = Platform.new(@hash["monit"]["platform"])
options = {
:host => @host,
:port => @port,
:ssl => @ssl,
:auth => @auth,
:username => @us... | ruby | {
"resource": ""
} |
q20261 | Solve.Graph.artifact | train | def artifact(name, version)
unless artifact?(name, version)
artifact = Artifact.new(self, name, version)
@artifacts["#{name}-#{version}"] = artifact
@artifacts_by_name[name] << artifact
end
@artifacts["#{name}-#{version}"]
end | ruby | {
"resource": ""
} |
q20262 | Solve.Graph.versions | train | def versions(name, constraint = Semverse::DEFAULT_CONSTRAINT)
constraint = Semverse::Constraint.coerce(constraint)
if constraint == Semverse::DEFAULT_CONSTRAINT
@artifacts_by_name[name]
else
@artifacts_by_name[name].select do |artifact|
constraint.satisfies?(artifact.version... | ruby | {
"resource": ""
} |
q20263 | Solve.Constraint.satisfies? | train | def satisfies?(target)
target = Semverse::Version.coerce(target)
return false if !(version == 0) && greedy_match?(target)
compare(target)
end | ruby | {
"resource": ""
} |
q20264 | Solve.GecodeSolver.solve_demands | train | def solve_demands(demands_as_constraints)
selector = DepSelector::Selector.new(ds_graph, (timeout_ms / 1000.0))
selector.find_solution(demands_as_constraints, all_artifacts)
rescue DepSelector::Exceptions::InvalidSolutionConstraints => e
report_invalid_constraints_error(e)
rescue DepSelector::... | ruby | {
"resource": ""
} |
q20265 | Solve.RubySolver.requirement_satisfied_by? | train | def requirement_satisfied_by?(requirement, activated, spec)
version = spec.version
return false unless requirement.constraint.satisfies?(version)
shared_possibility_versions = possibility_versions(requirement, activated)
return false if !shared_possibility_versions.empty? && !shared_possibility_... | ruby | {
"resource": ""
} |
q20266 | Solve.RubySolver.possibility_versions | train | def possibility_versions(requirement, activated)
activated.vertices.values.flat_map do |vertex|
next unless vertex.payload
next unless vertex.name == requirement.name
if vertex.payload.respond_to?(:possibilities)
vertex.payload.possibilities.map(&:version)
else
... | ruby | {
"resource": ""
} |
q20267 | PiPiper.Spi.clock | train | def clock(frequency)
options = {4000 => 0, #4 kHz
8000 => 32768, #8 kHz
15625 => 16384, #15.625 kHz
31250 => 8192, #31.25 kHz
62500 => 4096, #62.5 kHz
125000 => 2048, #125 kHz
2500... | ruby | {
"resource": ""
} |
q20268 | PiPiper.Spi.chip_select | train | def chip_select(chip=CHIP_SELECT_0)
chip = @chip if @chip
PiPiper.driver.spi_chip_select(chip)
if block_given?
begin
yield
ensure
PiPiper.driver.spi_chip_select(CHIP_SELECT_NONE)
end
end
end | ruby | {
"resource": ""
} |
q20269 | PiPiper.Spi.chip_select_active_low | train | def chip_select_active_low(active_low, chip=nil)
chip = @chip if @chip
chip = CHIP_SELECT_0 unless chip
PiPiper.driver.spi_chip_select_polarity(chip, active_low ? 0 : 1)
end | ruby | {
"resource": ""
} |
q20270 | PiPiper.Spi.write | train | def write(*args)
case args.count
when 0
raise ArgumentError, "missing arguments"
when 1
data = args.first
else
data = args
end
enable do
case data
when Numeric
PiPiper.driver.spi_transfer(data)
when Enumerable
... | ruby | {
"resource": ""
} |
q20271 | RubyMotionQuery.RMQ.add_subview | train | def add_subview(view_or_constant, opts={})
subviews_added = []
selected.each do |selected_view|
created = false
appended = false
built = false
if view_or_constant.is_a?(UIView)
new_view = view_or_constant
else
created = true
new_view = ... | ruby | {
"resource": ""
} |
q20272 | RubyMotionQuery.RMQ.find_or_append | train | def find_or_append(view_or_constant, style=nil, opts = {}, &block)
if style && (q = self.find(style)) && q.length > 0
view_or_constant = q.get
end
append(view_or_constant, style, opts, &block)
end | ruby | {
"resource": ""
} |
q20273 | RubyMotionQuery.RMQ.find_or_append! | train | def find_or_append!(view_or_constant, style=nil, opts = {}, &block)
find_or_append(view_or_constant, style, opts, &block).get
end | ruby | {
"resource": ""
} |
q20274 | RubyMotionQuery.RMQ.unshift | train | def unshift(view_or_constant, style=nil, opts = {}, &block)
opts[:at_index] = 0
opts[:style] = style
opts[:block] = block if block
add_subview view_or_constant, opts
end | ruby | {
"resource": ""
} |
q20275 | RubyMotionQuery.RMQ.build | train | def build(view, style = nil, opts = {}, &block)
opts[:do_not_add] = true
opts[:style] = style
opts[:block] = block if block
add_subview view, opts
end | ruby | {
"resource": ""
} |
q20276 | RubyMotionQuery.Validation.universal_validation_checks | train | def universal_validation_checks (data, options={})
# shortcircuit if debugging
return true if RubyMotionQuery::RMQ.debugging?
# allow blank data if specified
return true if (options[:allow_blank] && (data.nil? || data.empty?))
# allow whitelist data if specified
return true if (optio... | ruby | {
"resource": ""
} |
q20277 | RubyMotionQuery.Debug.log_detailed | train | def log_detailed(label, params = {})
return unless RMQ.app.development? || RMQ.app.test?
objects = params[:objects]
skip_first_caller = params[:skip_first_caller]
if block_given? && !objects
objects = yield
end
callers = caller
callers = callers.drop(1) if skip_first... | ruby | {
"resource": ""
} |
q20278 | RubyMotionQuery.Debug.assert | train | def assert(truthy, label = nil, objects = nil)
if (RMQ.app.development? || RMQ.app.test?) && !truthy
label ||= 'Assert failed'
if block_given? && !objects
objects = yield
end
log_detailed label, objects: objects, skip_first_caller: true
end
end | ruby | {
"resource": ""
} |
q20279 | RubyMotionQuery.RMQ.subviews_bottom_right | train | def subviews_bottom_right(view, args = {})
w = 0
h = 0
view.subviews.each do |subview|
rect = subview.rmq.frame
w = [rect.right, w].max
h = [rect.bottom, h].max
end
rect = view.rmq.frame
w = rect.width if (w == 0 || args[:only_height])
h = rect.height ... | ruby | {
"resource": ""
} |
q20280 | RubyMotionQuery.RMQ.context= | train | def context=(value)
if value
if value.is_a?(UIViewController)
@context = RubyMotionQuery::RMQ.weak_ref(value)
elsif value.is_a?(UIView)
@context = value
#else
#debug.log_detailed('Invalid context', objects: {value: value})
end
else
@conte... | ruby | {
"resource": ""
} |
q20281 | RubyMotionQuery.RMQ.selected | train | def selected
if @selected_dirty
@_selected = []
if RMQ.is_blank?(self.selectors)
@_selected << context_or_context_view
else
working_selectors = self.selectors.dup
extract_views_from_selectors(@_selected, working_selectors)
unless RMQ.is_blank?(work... | ruby | {
"resource": ""
} |
q20282 | RubyMotionQuery.RMQ.wrap | train | def wrap(*views)
views.flatten!
views.select!{ |v| v.is_a?(UIView) }
RMQ.create_with_array_and_selectors(views, views, views.first, self)
end | ruby | {
"resource": ""
} |
q20283 | RubyMotionQuery.RMQ.log | train | def log(opt = nil)
if opt == :tree
puts tree_to_s(selected)
return
end
wide = (opt == :wide)
out = "\n object_id | class | style_name | frame |"
out << "\n" unless wide
out << " sv id | superview ... | ruby | {
"resource": ""
} |
q20284 | Aspector.Interception.apply_to_method | train | def apply_to_method(method)
filtered_advices = filter_advices advices, method
return if filtered_advices.empty?
logger.debug 'apply-to-method', method
scope ||= context.instance_method_type(method)
recreate_method method, filtered_advices, scope
end | ruby | {
"resource": ""
} |
q20285 | Aspector.Interception.define_methods_for_advice_blocks | train | def define_methods_for_advice_blocks
advices.each do |advice|
next if advice.raw?
next unless advice.advice_block
context.send :define_method, advice.with_method, advice.advice_block
context.send :private, advice.with_method
end
end | ruby | {
"resource": ""
} |
q20286 | Aspector.Interception.apply_to_methods | train | def apply_to_methods
# If method/methods option is set and all are String or Symbol, apply to those only, instead of
# iterating through all methods
methods = [@options[:method] || @options[:methods]]
methods.compact!
methods.flatten!
if !methods.empty? && methods.all?{ |method| met... | ruby | {
"resource": ""
} |
q20287 | Aspector.Interception.invoke_deferred_logics | train | def invoke_deferred_logics
logics = @aspect.class.storage.deferred_logics
return if logics.empty?
logics.each do |logic|
result = logic.apply context, aspect
if advices.detect { |advice| advice.use_deferred_logic? logic }
@deferred_logic_results ||= {}
@deferred_lo... | ruby | {
"resource": ""
} |
q20288 | Aspector.Interception.add_method_hooks | train | def add_method_hooks
eigen_class = @target.singleton_class
if @options[:class_methods]
return unless @target.is_a?(Module)
orig_singleton_method_added = @target.method(:singleton_method_added)
eigen_class.send :define_method, :singleton_method_added do |method|
aspector_... | ruby | {
"resource": ""
} |
q20289 | Aspector.Interception.recreate_method | train | def recreate_method(method, advices, scope)
context.instance_variable_set(:@aspector_creating_method, true)
raw_advices = advices.select(&:raw?)
if raw_advices.size > 0
raw_advices.each do |advice|
if @target.is_a?(Module) && !@options[:class_methods]
@target.class_exec... | ruby | {
"resource": ""
} |
q20290 | Aspector.Logger.message | train | def message(*args)
msg = []
if context.is_a? Aspector::Base
msg << context.class.to_s
msg << context.target.to_s
else
msg << context.to_s
end
msg += args
msg.join(' | ')
end | ruby | {
"resource": ""
} |
q20291 | Squid.Plotter.legend | train | def legend(labels, height:, right: 0, colors: [])
left = @pdf.bounds.width/2
box(x: left, y: @pdf.bounds.top, w: left, h: height) do
x = @pdf.bounds.right - right
options = {size: 7, height: @pdf.bounds.height, valign: :center}
labels.each.with_index do |label, i|
index = l... | ruby | {
"resource": ""
} |
q20292 | Squid.Plotter.horizontal_line | train | def horizontal_line(y, options = {})
with options do
at = y + @bottom
@pdf.stroke_horizontal_line left, @pdf.bounds.right - right, at: at
end
end | ruby | {
"resource": ""
} |
q20293 | Squid.Plotter.legend_item | train | def legend_item(label, x, color, options)
size, symbol_padding, entry_padding = 5, 3, 12
x -= @pdf.width_of(label, size: 7).ceil
@pdf.text_box label, options.merge(at: [x, @pdf.bounds.height])
x -= (symbol_padding + size)
with fill_color: color do
@pdf.fill_rectangle [x, @pdf.bound... | ruby | {
"resource": ""
} |
q20294 | Squid.Plotter.with | train | def with(new_values = {})
transparency = new_values.delete(:transparency) { 1.0 }
old_values = Hash[new_values.map{|k,_| [k,@pdf.public_send(k)]}]
new_values.each{|k, new_value| @pdf.public_send "#{k}=", new_value }
@pdf.transparent(transparency) do
@pdf.stroke { yield }
end
... | ruby | {
"resource": ""
} |
q20295 | PoiseApplication.Utils.primary_group_for | train | def primary_group_for(user)
# Force a reload in case any users were created earlier in the run.
Etc.endpwent
Etc.endgrent
user = if user.is_a?(Integer)
Etc.getpwuid(user)
else
Etc.getpwnam(user.to_s)
end
Etc.getgrgid(user.gid).name
rescue ArgumentError
... | ruby | {
"resource": ""
} |
q20296 | Fluent::Plugin.SplunkHECOutput.write | train | def write(chunk)
body = ''
chunk.msgpack_each {|(tag,time,record)|
# define index and sourcetype dynamically
begin
index = expand_param(@index, tag, time, record)
sourcetype = expand_param(@sourcetype, tag, time, record)
event_host = expand_param(@event_host, t... | ruby | {
"resource": ""
} |
q20297 | Poise.Utils.find_cookbook_name | train | def find_cookbook_name(run_context, filename)
possibles = {}
Poise.debug("[Poise] Checking cookbook for #{filename.inspect}")
run_context.cookbook_collection.each do |name, ver|
# This special method is added by Halite::Gem#as_cookbook_version.
if ver.respond_to?(:halite_root)
... | ruby | {
"resource": ""
} |
q20298 | Poise.Utils.ancestor_send | train | def ancestor_send(obj, msg, *args, default: nil, ignore: [default])
# Class is a subclass of Module, if we get something else use its class.
obj = obj.class unless obj.is_a?(Module)
ancestors = []
if obj.respond_to?(:superclass)
# Check the superclass first if present.
ancestors ... | ruby | {
"resource": ""
} |
q20299 | Poise.Utils.parameterized_module | train | def parameterized_module(mod, &block)
raise Poise::Error.new("Cannot parameterize an anonymous module") unless mod.name && !mod.name.empty?
parent_name_parts = mod.name.split(/::/)
# Grab the last piece which will be the method name.
mod_name = parent_name_parts.pop
# Find the enclosing mo... | ruby | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.