id int32 0 24.9k | repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 |
|---|---|---|---|---|---|---|---|---|---|---|---|
20,200 | jmettraux/ruote | lib/ruote/svc/dispatch_pool.rb | Ruote.DispatchPool.dispatch_cancel | 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 | 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' =>... | [
"def",
"dispatch_cancel",
"(",
"msg",
")",
"flavour",
"=",
"msg",
"[",
"'flavour'",
"]",
"participant",
"=",
"@context",
".",
"plist",
".",
"instantiate",
"(",
"msg",
"[",
"'participant'",
"]",
")",
"result",
"=",
"begin",
"Ruote",
".",
"participant_send",
... | Instantiates the participant and calls its cancel method. | [
"Instantiates",
"the",
"participant",
"and",
"calls",
"its",
"cancel",
"method",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/svc/dispatch_pool.rb#L134-L157 |
20,201 | jmettraux/ruote | lib/ruote/receiver/base.rb | Ruote.ReceiverMixin.receive | 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 | 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 | [
"def",
"receive",
"(",
"workitem",
")",
"workitem",
"=",
"workitem",
".",
"to_h",
"if",
"workitem",
".",
"respond_to?",
"(",
":to_h",
")",
"@context",
".",
"storage",
".",
"put_msg",
"(",
"'receive'",
",",
"'fei'",
"=>",
"workitem",
"[",
"'fei'",
"]",
",... | This method pipes back a workitem into the engine, letting it resume
in its flow, hopefully. | [
"This",
"method",
"pipes",
"back",
"a",
"workitem",
"into",
"the",
"engine",
"letting",
"it",
"resume",
"in",
"its",
"flow",
"hopefully",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/receiver/base.rb#L75-L85 |
20,202 | jmettraux/ruote | lib/ruote/receiver/base.rb | Ruote.ReceiverMixin.flunk | 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 | 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
... | [
"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",
"Ex... | Can be used to raise an error in the workflow instance.
Can be called either with an error class and arguments, either with
an error instance (and no arguments), or a string message and no
arguments.
The workitem can be either an instance of Ruote::Workitem or a workitem
in its Hash representation.
receiver.... | [
"Can",
"be",
"used",
"to",
"raise",
"an",
"error",
"in",
"the",
"workflow",
"instance",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/receiver/base.rb#L116-L163 |
20,203 | jmettraux/ruote | lib/ruote/receiver/base.rb | Ruote.ReceiverMixin.launch | 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 | 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] || ... | [
"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",
... | Given a process definitions and optional initial fields and variables,
launches a new process instance.
This method is mostly used from the Ruote::Dashboard class (which
includes this mixin).
process_definition must be a result of Ruote.process_definition call
or XML or JSON serialized process definition, as acc... | [
"Given",
"a",
"process",
"definitions",
"and",
"optional",
"initial",
"fields",
"and",
"variables",
"launches",
"a",
"new",
"process",
"instance",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/receiver/base.rb#L186-L211 |
20,204 | jmettraux/ruote | lib/ruote/receiver/base.rb | Ruote.ReceiverMixin.fetch_flow_expression | def fetch_flow_expression(workitem_or_fei)
Ruote::Exp::FlowExpression.fetch(
@context,
Ruote::FlowExpressionId.extract_h(workitem_or_fei))
end | ruby | def fetch_flow_expression(workitem_or_fei)
Ruote::Exp::FlowExpression.fetch(
@context,
Ruote::FlowExpressionId.extract_h(workitem_or_fei))
end | [
"def",
"fetch_flow_expression",
"(",
"workitem_or_fei",
")",
"Ruote",
"::",
"Exp",
"::",
"FlowExpression",
".",
"fetch",
"(",
"@context",
",",
"Ruote",
"::",
"FlowExpressionId",
".",
"extract_h",
"(",
"workitem_or_fei",
")",
")",
"end"
] | Convenience method, given a workitem or a fei, returns the
corresponding flow expession. | [
"Convenience",
"method",
"given",
"a",
"workitem",
"or",
"a",
"fei",
"returns",
"the",
"corresponding",
"flow",
"expession",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/receiver/base.rb#L225-L230 |
20,205 | jmettraux/ruote | lib/ruote/receiver/base.rb | Ruote.ReceiverMixin.stash_get | 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 | 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 | [
"def",
"stash_get",
"(",
"workitem_or_fei",
",",
"key",
"=",
"nil",
")",
"stash",
"=",
"fetch_flow_expression",
"(",
"workitem_or_fei",
")",
".",
"h",
"[",
"'stash'",
"]",
"rescue",
"nil",
"stash",
"||=",
"{",
"}",
"key",
"?",
"stash",
"[",
"key",
"]",
... | Fetches back a stashed value.
get(fei, 'colour')
# => 'blue'
To return the whole stash
get(fei)
# => { 'colour' => 'blue' }
put & get are useful for a participant that needs to communicate
between its consume and its cancel. | [
"Fetches",
"back",
"a",
"stashed",
"value",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/receiver/base.rb#L306-L312 |
20,206 | jmettraux/ruote | lib/ruote/worker.rb | Ruote.Worker.inactive? | 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 | 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']
}
... | [
"def",
"inactive?",
"# the cheaper tests first",
"return",
"false",
"if",
"@msgs",
".",
"size",
">",
"0",
"return",
"false",
"unless",
"@context",
".",
"storage",
".",
"empty?",
"(",
"'schedules'",
")",
"return",
"false",
"unless",
"@context",
".",
"storage",
... | Returns true if the engine system is inactive, ie if all the process
instances are terminated or are stuck in an error.
NOTE : for now, if a branch of a process is in error while another is
still running, this method will consider the process instance inactive
(and it will return true if all the processes are cons... | [
"Returns",
"true",
"if",
"the",
"engine",
"system",
"is",
"inactive",
"ie",
"if",
"all",
"the",
"process",
"instances",
"are",
"terminated",
"or",
"are",
"stuck",
"in",
"an",
"error",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/worker.rb#L149-L166 |
20,207 | jmettraux/ruote | lib/ruote/worker.rb | Ruote.Worker.turn_schedule_to_msg | 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 | 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 | [
"def",
"turn_schedule_to_msg",
"(",
"schedule",
")",
"return",
"false",
"unless",
"@storage",
".",
"reserve",
"(",
"schedule",
")",
"msg",
"=",
"Ruote",
".",
"fulldup",
"(",
"schedule",
"[",
"'msg'",
"]",
")",
"@storage",
".",
"put_msg",
"(",
"msg",
".",
... | Given a schedule, attempts to trigger it.
It first tries to reserve the schedule. If the reservation fails
(another worker was successful probably), false is returned.
The schedule is triggered if the reservation was successful, true
is returned. | [
"Given",
"a",
"schedule",
"attempts",
"to",
"trigger",
"it",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/worker.rb#L355-L364 |
20,208 | jmettraux/ruote | lib/ruote/worker.rb | Ruote.Worker.process | 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 | 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... | [
"def",
"process",
"(",
"msg",
")",
"return",
"false",
"unless",
"@storage",
".",
"reserve",
"(",
"msg",
")",
"begin",
"@context",
".",
"pre_notify",
"(",
"msg",
")",
"case",
"msg",
"[",
"'action'",
"]",
"when",
"'launch'",
",",
"'apply'",
",",
"'regenera... | Processes one msg.
Will return false immediately if the msg reservation failed (another
worker grabbed the message.
Else will execute the action ordered in the msg, and return true.
Exceptions in execution are intercepted here and passed to the
engine's (context's) error_handler. | [
"Processes",
"one",
"msg",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/worker.rb#L376-L433 |
20,209 | jmettraux/ruote | lib/ruote/worker.rb | Ruote.Worker.launch | 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 | 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... | [
"def",
"launch",
"(",
"msg",
")",
"tree",
"=",
"msg",
"[",
"'tree'",
"]",
"variables",
"=",
"msg",
"[",
"'variables'",
"]",
"wi",
"=",
"msg",
"[",
"'workitem'",
"]",
"exp_class",
"=",
"@context",
".",
"expmap",
".",
"expression_class",
"(",
"tree",
"."... | Works for both the 'launch' and the 'apply' msgs.
Creates a new expression, gives and applies it with the
workitem contained in the msg. | [
"Works",
"for",
"both",
"the",
"launch",
"and",
"the",
"apply",
"msgs",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/worker.rb#L440-L509 |
20,210 | jmettraux/ruote | lib/ruote/worker.rb | Ruote.Worker.pause_process | 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 | 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 | [
"def",
"pause_process",
"(",
"msg",
")",
"root",
"=",
"@storage",
".",
"find_root_expression",
"(",
"msg",
"[",
"'wfid'",
"]",
")",
"return",
"unless",
"root",
"@storage",
".",
"put_msg",
"(",
"msg",
"[",
"'action'",
"]",
"==",
"'pause_process'",
"?",
"'pa... | Handles 'pause_process' and 'resume_process'. | [
"Handles",
"pause_process",
"and",
"resume_process",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/worker.rb#L547-L557 |
20,211 | jmettraux/ruote | lib/ruote/worker.rb | Ruote.Worker.reput | 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 | 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 | [
"def",
"reput",
"(",
"msg",
")",
"if",
"doc",
"=",
"msg",
"[",
"'doc'",
"]",
"r",
"=",
"@storage",
".",
"put",
"(",
"doc",
")",
"return",
"unless",
"r",
".",
"is_a?",
"(",
"Hash",
")",
"doc",
"[",
"'_rev'",
"]",
"=",
"r",
"[",
"'_rev'",
"]",
... | Reputs a doc or a msg.
Used by certain storage implementations to pass documents around workers
or to reschedule msgs (see ruote-swf). | [
"Reputs",
"a",
"doc",
"or",
"a",
"msg",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/worker.rb#L566-L582 |
20,212 | jmettraux/ruote | lib/ruote/exp/fe_filter.rb | Ruote::Exp.FilterExpression.block_filter | 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 | 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... | [
"def",
"block_filter",
"return",
"nil",
"if",
"tree",
".",
"last",
".",
"empty?",
"tree",
".",
"last",
".",
"collect",
"{",
"|",
"line",
"|",
"next",
"'or'",
"if",
"line",
".",
"first",
"==",
"'or'",
"rule",
"=",
"line",
"[",
"1",
"]",
".",
"remap"... | Filter is passed in a block (which is not evaluted as a ruote branch
but immediately translated into a filter.
pdef = Ruote.process_definition do
filter do
field 'x', :type => 'string'
field 'y', :type => 'number'
end
end
Note : 'or' is OK
pdef = Ruote.process_definition do
fi... | [
"Filter",
"is",
"passed",
"in",
"a",
"block",
"(",
"which",
"is",
"not",
"evaluted",
"as",
"a",
"ruote",
"branch",
"but",
"immediately",
"translated",
"into",
"a",
"filter",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/fe_filter.rb#L599-L619 |
20,213 | jmettraux/ruote | lib/ruote/exp/fe_filter.rb | Ruote::Exp.FilterExpression.one_line_filter | 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 | 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 | [
"def",
"one_line_filter",
"if",
"(",
"attributes",
".",
"keys",
"-",
"COMMON_ATT_KEYS",
"-",
"%w[",
"ref",
"original_ref",
"]",
")",
".",
"empty?",
"return",
"nil",
"end",
"[",
"attributes",
".",
"remap",
"{",
"|",
"(",
"k",
",",
"v",
")",
",",
"h",
... | Filter thanks to the attributes of the expression.
pdef = Ruote.process_definition do
filter 'x', :type => 'string', :record => true
filter 'y', :type => 'number', :record => true
end | [
"Filter",
"thanks",
"to",
"the",
"attributes",
"of",
"the",
"expression",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/fe_filter.rb#L662-L675 |
20,214 | jmettraux/ruote | lib/ruote/exp/ro_variables.rb | Ruote::Exp.FlowExpression.compile_variables | def compile_variables
vars = h.parent_id ? parent.compile_variables : {}
vars.merge!(h.variables) if h.variables
vars
end | ruby | def compile_variables
vars = h.parent_id ? parent.compile_variables : {}
vars.merge!(h.variables) if h.variables
vars
end | [
"def",
"compile_variables",
"vars",
"=",
"h",
".",
"parent_id",
"?",
"parent",
".",
"compile_variables",
":",
"{",
"}",
"vars",
".",
"merge!",
"(",
"h",
".",
"variables",
")",
"if",
"h",
".",
"variables",
"vars",
"end"
] | Returns a fresh hash of all the variables visible from this expression.
This is used mainly when forgetting an expression. | [
"Returns",
"a",
"fresh",
"hash",
"of",
"all",
"the",
"variables",
"visible",
"from",
"this",
"expression",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/ro_variables.rb#L44-L50 |
20,215 | jmettraux/ruote | lib/ruote/exp/ro_variables.rb | Ruote::Exp.FlowExpression.unset_variable | 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 | 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 | [
"def",
"unset_variable",
"(",
"var",
",",
"override",
"=",
"false",
")",
"fexp",
",",
"v",
"=",
"locate_set_var",
"(",
"var",
",",
"override",
")",
"||",
"locate_var",
"(",
"var",
")",
"fexp",
".",
"un_set_variable",
"(",
":unset",
",",
"v",
",",
"nil"... | Unbinds a variables. | [
"Unbinds",
"a",
"variables",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/ro_variables.rb#L107-L112 |
20,216 | jmettraux/ruote | lib/ruote/exp/ro_variables.rb | Ruote::Exp.FlowExpression.split_prefix | 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 | 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 | [
"def",
"split_prefix",
"(",
"var",
",",
"prefix",
")",
"if",
"prefix",
".",
"nil?",
"m",
"=",
"VAR_PREFIX_REGEX",
".",
"match",
"(",
"var",
".",
"to_s",
")",
"prefix",
"=",
"m",
"[",
"1",
"]",
"var",
"=",
"m",
"[",
"2",
"]",
"end",
"[",
"var",
... | Used by lookup_variable and set_variable to extract the
prefix in a variable name | [
"Used",
"by",
"lookup_variable",
"and",
"set_variable",
"to",
"extract",
"the",
"prefix",
"in",
"a",
"variable",
"name"
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/ro_variables.rb#L160-L169 |
20,217 | jmettraux/ruote | lib/ruote/dboard/mutation.rb | Ruote.Mutation.walk | 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 | 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... | [
"def",
"walk",
"(",
"fexp",
",",
"tree",
")",
"ftree",
"=",
"Ruote",
".",
"compact_tree",
"(",
"@ps",
".",
"current_tree",
"(",
"fexp",
")",
")",
"if",
"ftree",
"[",
"0",
"]",
"!=",
"tree",
"[",
"0",
"]",
"||",
"ftree",
"[",
"1",
"]",
"!=",
"tr... | Look for mutation points in an expression and its children. | [
"Look",
"for",
"mutation",
"points",
"in",
"an",
"expression",
"and",
"its",
"children",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/dboard/mutation.rb#L146-L183 |
20,218 | jmettraux/ruote | lib/ruote/dboard/mutation.rb | Ruote.Mutation.walk_sequence | 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 | 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... | [
"def",
"walk_sequence",
"(",
"fexp",
",",
"ftree",
",",
"tree",
")",
"i",
"=",
"fexp",
".",
"child_ids",
".",
"first",
"ehead",
"=",
"ftree",
"[",
"2",
"]",
".",
"take",
"(",
"i",
")",
"ecurrent",
"=",
"ftree",
"[",
"2",
"]",
"[",
"i",
"]",
"et... | Look for mutation points in any non-concurrent expression. | [
"Look",
"for",
"mutation",
"points",
"in",
"any",
"non",
"-",
"concurrent",
"expression",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/dboard/mutation.rb#L244-L279 |
20,219 | jmettraux/ruote | lib/ruote/exp/fe_cursor.rb | Ruote::Exp.CursorExpression.move_on | 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 | 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', '... | [
"def",
"move_on",
"(",
"workitem",
"=",
"h",
".",
"applied_workitem",
")",
"position",
"=",
"workitem",
"[",
"'fei'",
"]",
"==",
"h",
".",
"fei",
"?",
"-",
"1",
":",
"Ruote",
"::",
"FlowExpressionId",
".",
"child_id",
"(",
"workitem",
"[",
"'fei'",
"]"... | Determines which child expression of the cursor is to be applied next. | [
"Determines",
"which",
"child",
"expression",
"of",
"the",
"cursor",
"is",
"to",
"be",
"applied",
"next",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/fe_cursor.rb#L259-L287 |
20,220 | jmettraux/ruote | lib/ruote/exp/fe_cursor.rb | Ruote::Exp.CursorExpression.jump_to | 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 | 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'], ... | [
"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",
... | Jumps to an integer position, or the name of an expression
or a tag name of a ref name. | [
"Jumps",
"to",
"an",
"integer",
"position",
"or",
"the",
"name",
"of",
"an",
"expression",
"or",
"a",
"tag",
"name",
"of",
"a",
"ref",
"name",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/fe_cursor.rb#L299-L320 |
20,221 | jmettraux/ruote | lib/ruote/storage/base.rb | Ruote.StorageBase.clear | def clear
%w[ msgs schedules errors expressions workitems ].each do |type|
purge_type!(type)
end
end | ruby | def clear
%w[ msgs schedules errors expressions workitems ].each do |type|
purge_type!(type)
end
end | [
"def",
"clear",
"%w[",
"msgs",
"schedules",
"errors",
"expressions",
"workitems",
"]",
".",
"each",
"do",
"|",
"type",
"|",
"purge_type!",
"(",
"type",
")",
"end",
"end"
] | Used when doing integration tests, removes all
msgs, schedules, errors, expressions and workitems.
NOTE that it doesn't remove engine variables (danger) | [
"Used",
"when",
"doing",
"integration",
"tests",
"removes",
"all",
"msgs",
"schedules",
"errors",
"expressions",
"and",
"workitems",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/storage/base.rb#L267-L272 |
20,222 | jmettraux/ruote | lib/ruote/storage/base.rb | Ruote.StorageBase.remove_process | 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 | 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}") }
... | [
"def",
"remove_process",
"(",
"wfid",
")",
"2",
".",
"times",
"do",
"# two passes",
"Thread",
".",
"pass",
"%w[",
"schedules",
"expressions",
"errors",
"workitems",
"]",
".",
"each",
"do",
"|",
"type",
"|",
"get_many",
"(",
"type",
",",
"wfid",
")",
".",... | Removes a process by removing all its schedules, expressions, errors,
workitems and trackers.
Warning: will not trigger any cancel behaviours at all, just removes
the process. | [
"Removes",
"a",
"process",
"by",
"removing",
"all",
"its",
"schedules",
"expressions",
"errors",
"workitems",
"and",
"trackers",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/storage/base.rb#L280-L297 |
20,223 | jmettraux/ruote | lib/ruote/storage/base.rb | Ruote.StorageBase.prepare_msg_doc | 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 | 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... | [
"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",... | Used by put_msg | [
"Used",
"by",
"put_msg"
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/storage/base.rb#L310-L329 |
20,224 | jmettraux/ruote | lib/ruote/storage/base.rb | Ruote.StorageBase.prepare_schedule_doc | 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 | 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 ... | [
"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",
"::",
"Sche... | Used by put_schedule | [
"Used",
"by",
"put_schedule"
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/storage/base.rb#L333-L362 |
20,225 | jmettraux/ruote | lib/ruote/exp/ro_on_x.rb | Ruote::Exp.FlowExpression.handle_on_error | 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 | 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 == ''
... | [
"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"... | Looks up parent with on_error attribute and triggers it | [
"Looks",
"up",
"parent",
"with",
"on_error",
"attribute",
"and",
"triggers",
"it"
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/ro_on_x.rb#L68-L105 |
20,226 | jmettraux/ruote | lib/ruote/exp/ro_on_x.rb | Ruote::Exp.FlowExpression.local_on_error | 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 | 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... | [
"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?",
... | Given an error, returns the on_error registered for it, or nil if none. | [
"Given",
"an",
"error",
"returns",
"the",
"on_error",
"registered",
"for",
"it",
"or",
"nil",
"if",
"none",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/ro_on_x.rb#L167-L188 |
20,227 | jmettraux/ruote | lib/ruote/svc/tracker.rb | Ruote.Tracker.remove | 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 | 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... | [
"def",
"remove",
"(",
"tracker_ids",
",",
"wfid",
")",
"return",
"if",
"tracker_ids",
".",
"empty?",
"doc",
"||=",
"@context",
".",
"storage",
".",
"get_trackers",
"(",
"wfid",
")",
"return",
"if",
"(",
"doc",
"[",
"'trackers'",
"]",
".",
"keys",
"&",
... | Removes a set of tracker ids and updated the tracker document. | [
"Removes",
"a",
"set",
"of",
"tracker",
"ids",
"and",
"updated",
"the",
"tracker",
"document",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/svc/tracker.rb#L110-L127 |
20,228 | jmettraux/ruote | lib/ruote/svc/tracker.rb | Ruote.Tracker.on_message | 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 | 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... | [
"def",
"on_message",
"(",
"pre",
",",
"message",
")",
"m_wfid",
"=",
"message",
"[",
"'wfid'",
"]",
"||",
"(",
"message",
"[",
"'fei'",
"]",
"[",
"'wfid'",
"]",
"rescue",
"nil",
")",
"m_error",
"=",
"message",
"[",
"'error'",
"]",
"m_action",
"=",
"m... | The method behind on_pre_msg and on_msg. Filters msgs against trackers.
Triggers trackers if there is a match. | [
"The",
"method",
"behind",
"on_pre_msg",
"and",
"on_msg",
".",
"Filters",
"msgs",
"against",
"trackers",
".",
"Triggers",
"trackers",
"if",
"there",
"is",
"a",
"match",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/svc/tracker.rb#L132-L178 |
20,229 | jmettraux/ruote | lib/ruote/svc/tracker.rb | Ruote.Tracker.alter | 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 | 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 | [
"def",
"alter",
"(",
"m_wfid",
",",
"m_error",
",",
"m_action",
",",
"msg",
",",
"tracker",
")",
"case",
"tracker",
"[",
"'msg'",
"]",
".",
"delete",
"(",
"'_alter'",
")",
"when",
"'merge'",
"then",
"msg",
".",
"merge!",
"(",
"tracker",
"[",
"'msg'",
... | Alters the msg, only called in "pre" mode. | [
"Alters",
"the",
"msg",
"only",
"called",
"in",
"pre",
"mode",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/svc/tracker.rb#L182-L188 |
20,230 | jmettraux/ruote | lib/ruote/svc/tracker.rb | Ruote.Tracker.trigger | 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 | 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... | [
"def",
"trigger",
"(",
"m_wfid",
",",
"m_error",
",",
"m_action",
",",
"msg",
",",
"tracker",
")",
"t_action",
"=",
"tracker",
"[",
"'action'",
"]",
"tracker_id",
"=",
"tracker",
"[",
"'id'",
"]",
"m",
"=",
"Ruote",
".",
"fulldup",
"(",
"tracker",
"[",... | Prepares the message that gets placed on the ruote msg queue. | [
"Prepares",
"the",
"message",
"that",
"gets",
"placed",
"on",
"the",
"ruote",
"msg",
"queue",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/svc/tracker.rb#L192-L220 |
20,231 | jmettraux/ruote | lib/ruote/svc/tracker.rb | Ruote.Tracker.does_match? | 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 | 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... | [
"def",
"does_match?",
"(",
"msg",
",",
"conditions",
")",
"return",
"true",
"unless",
"conditions",
"conditions",
".",
"each",
"do",
"|",
"k",
",",
"v",
"|",
"return",
"false",
"unless",
"Array",
"(",
"v",
")",
".",
"find",
"do",
"|",
"vv",
"|",
"# t... | Given a msg and a hash of conditions, returns true if the msg
matches the conditions. | [
"Given",
"a",
"msg",
"and",
"a",
"hash",
"of",
"conditions",
"returns",
"true",
"if",
"the",
"msg",
"matches",
"the",
"conditions",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/svc/tracker.rb#L236-L262 |
20,232 | jmettraux/ruote | lib/ruote/log/wait_logger.rb | Ruote.WaitLogger.on_msg | 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 | 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 | [
"def",
"on_msg",
"(",
"msg",
")",
"puts",
"(",
"fancy_print",
"(",
"msg",
",",
"@noisy",
")",
")",
"if",
"@noisy",
"return",
"if",
"msg",
"[",
"'action'",
"]",
"==",
"'noop'",
"@mutex",
".",
"synchronize",
"do",
"@seen",
"<<",
"msg",
"@log",
"<<",
"m... | The context will call this method for each msg sucessfully processed
by the worker. | [
"The",
"context",
"will",
"call",
"this",
"method",
"for",
"each",
"msg",
"sucessfully",
"processed",
"by",
"the",
"worker",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/log/wait_logger.rb#L96-L110 |
20,233 | jmettraux/ruote | lib/ruote/log/wait_logger.rb | Ruote.WaitLogger.wait_for | 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 | 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 ... | [
"def",
"wait_for",
"(",
"interests",
",",
"opts",
"=",
"{",
"}",
")",
"@waiting",
"<<",
"[",
"Thread",
".",
"current",
",",
"interests",
"]",
"Thread",
".",
"current",
"[",
"'__result__'",
"]",
"=",
"nil",
"start",
"=",
"Time",
".",
"now",
"to",
"=",... | Blocks until one or more interests are satisfied.
interests must be an array of interests. Please refer to
Dashboard#wait_for documentation for allowed values of each interest.
If multiple interests are given, wait_for blocks until
all of the interests are satisfied.
wait_for may only be used by one thread at a... | [
"Blocks",
"until",
"one",
"or",
"more",
"interests",
"are",
"satisfied",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/log/wait_logger.rb#L140-L164 |
20,234 | jmettraux/ruote | lib/ruote/log/wait_logger.rb | Ruote.WaitLogger.matches | 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 | 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... | [
"def",
"matches",
"(",
"interests",
",",
"msg",
")",
"action",
"=",
"msg",
"[",
"'action'",
"]",
"interests",
".",
"each",
"do",
"|",
"interest",
"|",
"satisfied",
"=",
"case",
"interest",
"when",
":or_error",
"#",
"# let's force an immediate reply",
"interest... | Checks whether message msg matches any of interests being waited for.
Some interests look for actions on particular workflows (e.g.,
waiting for some workflow to finish). Other interests are not
attached to any particular workflow (e.g., :inactive waits until
the engine finishes processing all active and pending w... | [
"Checks",
"whether",
"message",
"msg",
"matches",
"any",
"of",
"interests",
"being",
"waited",
"for",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/log/wait_logger.rb#L221-L282 |
20,235 | jmettraux/ruote | lib/ruote/context.rb | Ruote.Context.has_service? | 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 | 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 | [
"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",
... | Returns true if this context has a given service registered. | [
"Returns",
"true",
"if",
"this",
"context",
"has",
"a",
"given",
"service",
"registered",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/context.rb#L216-L222 |
20,236 | jmettraux/ruote | lib/ruote/exp/ro_persist.rb | Ruote::Exp.FlowExpression.do_p | 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 | 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 | [
"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",
... | Does persist or unpersist, if successful then returns true. If the
expression is gone, returns false.
If there is a 'fresher' version of the expression, re-attempt and returns
false. | [
"Does",
"persist",
"or",
"unpersist",
"if",
"successful",
"then",
"returns",
"true",
".",
"If",
"the",
"expression",
"is",
"gone",
"returns",
"false",
".",
"If",
"there",
"is",
"a",
"fresher",
"version",
"of",
"the",
"expression",
"re",
"-",
"attempt",
"an... | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/ro_persist.rb#L151-L163 |
20,237 | jmettraux/ruote | lib/ruote/part/storage_participant.rb | Ruote.StorageParticipant.on_workitem | 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 | 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... | [
"def",
"on_workitem",
"doc",
"=",
"workitem",
".",
"to_h",
"doc",
".",
"merge!",
"(",
"'type'",
"=>",
"'workitems'",
",",
"'_id'",
"=>",
"to_id",
"(",
"doc",
"[",
"'fei'",
"]",
")",
",",
"'participant_name'",
"=>",
"doc",
"[",
"'participant_name'",
"]",
... | This is the method called by ruote when passing a workitem to
this participant. | [
"This",
"is",
"the",
"method",
"called",
"by",
"ruote",
"when",
"passing",
"a",
"workitem",
"to",
"this",
"participant",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/part/storage_participant.rb#L80-L93 |
20,238 | jmettraux/ruote | lib/ruote/part/storage_participant.rb | Ruote.StorageParticipant.proceed | def proceed(workitem)
r = remove_workitem('proceed', workitem)
return proceed(workitem) if r != nil
workitem.h.delete('_rev')
reply_to_engine(workitem)
end | ruby | def proceed(workitem)
r = remove_workitem('proceed', workitem)
return proceed(workitem) if r != nil
workitem.h.delete('_rev')
reply_to_engine(workitem)
end | [
"def",
"proceed",
"(",
"workitem",
")",
"r",
"=",
"remove_workitem",
"(",
"'proceed'",
",",
"workitem",
")",
"return",
"proceed",
"(",
"workitem",
")",
"if",
"r",
"!=",
"nil",
"workitem",
".",
"h",
".",
"delete",
"(",
"'_rev'",
")",
"reply_to_engine",
"(... | Removes the workitem from the storage and replies to the engine. | [
"Removes",
"the",
"workitem",
"from",
"the",
"storage",
"and",
"replies",
"to",
"the",
"engine",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/part/storage_participant.rb#L155-L164 |
20,239 | jmettraux/ruote | lib/ruote/part/storage_participant.rb | Ruote.StorageParticipant.flunk | 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 | 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 | [
"def",
"flunk",
"(",
"workitem",
",",
"err_class_or_instance",
",",
"*",
"err_arguments",
")",
"r",
"=",
"remove_workitem",
"(",
"'reject'",
",",
"workitem",
")",
"return",
"flunk",
"(",
"workitem",
")",
"if",
"r",
"!=",
"nil",
"workitem",
".",
"h",
".",
... | Removes the workitem and hands it back to the flow with an error to
raise for the participant expression that emitted the workitem. | [
"Removes",
"the",
"workitem",
"and",
"hands",
"it",
"back",
"to",
"the",
"flow",
"with",
"an",
"error",
"to",
"raise",
"for",
"the",
"participant",
"expression",
"that",
"emitted",
"the",
"workitem",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/part/storage_participant.rb#L169-L178 |
20,240 | jmettraux/ruote | lib/ruote/part/storage_participant.rb | Ruote.StorageParticipant.all | def all(opts={})
res = fetch_all(opts)
res.is_a?(Array) ? res.map { |hwi| Ruote::Workitem.new(hwi) } : res
end | ruby | def all(opts={})
res = fetch_all(opts)
res.is_a?(Array) ? res.map { |hwi| Ruote::Workitem.new(hwi) } : res
end | [
"def",
"all",
"(",
"opts",
"=",
"{",
"}",
")",
"res",
"=",
"fetch_all",
"(",
"opts",
")",
"res",
".",
"is_a?",
"(",
"Array",
")",
"?",
"res",
".",
"map",
"{",
"|",
"hwi",
"|",
"Ruote",
"::",
"Workitem",
".",
"new",
"(",
"hwi",
")",
"}",
":",
... | Returns all the workitems stored in here. | [
"Returns",
"all",
"the",
"workitems",
"stored",
"in",
"here",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/part/storage_participant.rb#L209-L214 |
20,241 | jmettraux/ruote | lib/ruote/part/storage_participant.rb | Ruote.StorageParticipant.by_wfid | 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 | 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 | [
"def",
"by_wfid",
"(",
"wfid",
",",
"opts",
"=",
"{",
"}",
")",
"if",
"@context",
".",
"storage",
".",
"respond_to?",
"(",
":by_wfid",
")",
"return",
"@context",
".",
"storage",
".",
"by_wfid",
"(",
"'workitems'",
",",
"wfid",
",",
"opts",
")",
"end",
... | Return all workitems for the specified wfid | [
"Return",
"all",
"workitems",
"for",
"the",
"specified",
"wfid"
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/part/storage_participant.rb#L226-L233 |
20,242 | jmettraux/ruote | lib/ruote/part/storage_participant.rb | Ruote.StorageParticipant.by_participant | 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 | 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 | [
"def",
"by_participant",
"(",
"participant_name",
",",
"opts",
"=",
"{",
"}",
")",
"return",
"@context",
".",
"storage",
".",
"by_participant",
"(",
"'workitems'",
",",
"participant_name",
",",
"opts",
")",
"if",
"@context",
".",
"storage",
".",
"respond_to?",... | Returns all workitems for the specified participant name | [
"Returns",
"all",
"workitems",
"for",
"the",
"specified",
"participant",
"name"
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/part/storage_participant.rb#L237-L246 |
20,243 | jmettraux/ruote | lib/ruote/part/storage_participant.rb | Ruote.StorageParticipant.query | 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 | 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... | [
"def",
"query",
"(",
"criteria",
")",
"cr",
"=",
"Ruote",
".",
"keys_to_s",
"(",
"criteria",
")",
"if",
"@context",
".",
"storage",
".",
"respond_to?",
"(",
":query_workitems",
")",
"return",
"@context",
".",
"storage",
".",
"query_workitems",
"(",
"cr",
"... | Queries the store participant for workitems.
Some examples :
part.query(:wfid => @wfid).size
part.query('place' => 'nara').size
part.query('place' => 'heiankyou').size
part.query(:wfid => @wfid, :place => 'heiankyou').size
There are two 'reserved' criterion : 'wfid' and 'participant'
('participant_nam... | [
"Queries",
"the",
"store",
"participant",
"for",
"workitems",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/part/storage_participant.rb#L290-L320 |
20,244 | jmettraux/ruote | lib/ruote/part/storage_participant.rb | Ruote.StorageParticipant.per_participant_count | def per_participant_count
per_participant.remap { |(k, v), h| h[k] = v.size }
end | ruby | def per_participant_count
per_participant.remap { |(k, v), h| h[k] = v.size }
end | [
"def",
"per_participant_count",
"per_participant",
".",
"remap",
"{",
"|",
"(",
"k",
",",
"v",
")",
",",
"h",
"|",
"h",
"[",
"k",
"]",
"=",
"v",
".",
"size",
"}",
"end"
] | Mostly a test method. Returns a Hash were keys are participant names
and values are integers, the count of workitems for a given participant
name. | [
"Mostly",
"a",
"test",
"method",
".",
"Returns",
"a",
"Hash",
"were",
"keys",
"are",
"participant",
"names",
"and",
"values",
"are",
"integers",
"the",
"count",
"of",
"workitems",
"for",
"a",
"given",
"participant",
"name",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/part/storage_participant.rb#L356-L359 |
20,245 | jmettraux/ruote | lib/ruote/part/storage_participant.rb | Ruote.StorageParticipant.delegate | 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 | 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... | [
"def",
"delegate",
"(",
"workitem",
",",
"new_owner",
")",
"hwi",
"=",
"fetch",
"(",
"workitem",
")",
"fail",
"ArgumentError",
".",
"new",
"(",
"\"workitem not found\"",
")",
"if",
"hwi",
"==",
"nil",
"fail",
"ArgumentError",
".",
"new",
"(",
"\"cannot deleg... | Delegates a currently owned workitem to a new owner.
Fails if the workitem can't be found, belongs to noone, or if the
workitem passed as argument is out of date (got modified in the mean
time).
It's OK to delegate to nil, thus freeing the workitem.
See #reserve for an an explanation of the reserve/delegate/pro... | [
"Delegates",
"a",
"currently",
"owned",
"workitem",
"to",
"a",
"new",
"owner",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/part/storage_participant.rb#L405-L430 |
20,246 | jmettraux/ruote | lib/ruote/part/storage_participant.rb | Ruote.StorageParticipant.do_select | 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 | 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|... | [
"def",
"do_select",
"(",
"opts",
",",
"&",
"block",
")",
"skip",
"=",
"opts",
"[",
":offset",
"]",
"||",
"opts",
"[",
":skip",
"]",
"limit",
"=",
"opts",
"[",
":limit",
"]",
"count",
"=",
"opts",
"[",
":count",
"]",
"hwis",
"=",
"fetch_all",
"(",
... | Given a few options and a block, returns all the workitems that match
the block | [
"Given",
"a",
"few",
"options",
"and",
"a",
"block",
"returns",
"all",
"the",
"workitems",
"that",
"match",
"the",
"block"
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/part/storage_participant.rb#L457-L472 |
20,247 | jmettraux/ruote | lib/ruote/part/storage_participant.rb | Ruote.StorageParticipant.to_id | def to_id(fei)
a = [ Ruote.to_storage_id(fei) ]
a.unshift(@store_name) if @store_name
a.unshift('wi')
a.join('!')
end | ruby | def to_id(fei)
a = [ Ruote.to_storage_id(fei) ]
a.unshift(@store_name) if @store_name
a.unshift('wi')
a.join('!')
end | [
"def",
"to_id",
"(",
"fei",
")",
"a",
"=",
"[",
"Ruote",
".",
"to_storage_id",
"(",
"fei",
")",
"]",
"a",
".",
"unshift",
"(",
"@store_name",
")",
"if",
"@store_name",
"a",
".",
"unshift",
"(",
"'wi'",
")",
"a",
".",
"join",
"(",
"'!'",
")",
"end... | Computes the id for the document representing the document in the storage. | [
"Computes",
"the",
"id",
"for",
"the",
"document",
"representing",
"the",
"document",
"in",
"the",
"storage",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/part/storage_participant.rb#L476-L485 |
20,248 | jmettraux/ruote | lib/ruote/exp/fe_command.rb | Ruote::Exp.CommandExpression.fetch_command_target | 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 | 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 | [
"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"... | Walks up the expression tree (process instance and returns the first
expression that includes the CommandMixin
(CommandExpression includes CommandMixin, but since it doesn't have
children, no need to 'evince' it) | [
"Walks",
"up",
"the",
"expression",
"tree",
"(",
"process",
"instance",
"and",
"returns",
"the",
"first",
"expression",
"that",
"includes",
"the",
"CommandMixin"
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/fe_command.rb#L149-L156 |
20,249 | jmettraux/ruote | lib/ruote/part/rev_participant.rb | Ruote.RevParticipant.lookup_code | 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 | 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 ],
... | [
"def",
"lookup_code",
"wi",
"=",
"workitem",
"rev",
"=",
"wi",
".",
"params",
"[",
"'revision'",
"]",
"||",
"wi",
".",
"params",
"[",
"'rev'",
"]",
"[",
"[",
"wi",
".",
"wf_name",
",",
"wi",
".",
"wf_revision",
",",
"wi",
".",
"participant_name",
","... | Maybe "lookup_real_participant_code" would be a better name... | [
"Maybe",
"lookup_real_participant_code",
"would",
"be",
"a",
"better",
"name",
"..."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/part/rev_participant.rb#L143-L175 |
20,250 | jmettraux/ruote | lib/ruote/exp/fe_if.rb | Ruote::Exp.IfExpression.reply | 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 | 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_... | [
"def",
"reply",
"(",
"workitem",
")",
"if",
"workitem",
"[",
"'fei'",
"]",
"==",
"h",
".",
"fei",
"# apply --> reply",
"h",
".",
"test",
"=",
"attribute",
"(",
":test",
")",
"h",
".",
"test",
"=",
"attribute",
"(",
":t",
")",
"if",
"h",
".",
"test"... | called by 'else', 'then' or perhaps 'equals' | [
"called",
"by",
"else",
"then",
"or",
"perhaps",
"equals"
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/fe_if.rb#L169-L193 |
20,251 | jmettraux/ruote | lib/ruote/svc/participant_list.rb | Ruote.ParticipantList.unregister | 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 | 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[... | [
"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",
"... | Removes a participant, given via its name or directly from this
participant list.
Called usually by Engine#unregister_participant. | [
"Removes",
"a",
"participant",
"given",
"via",
"its",
"name",
"or",
"directly",
"from",
"this",
"participant",
"list",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/svc/participant_list.rb#L140-L164 |
20,252 | jmettraux/ruote | lib/ruote/svc/participant_list.rb | Ruote.ParticipantList.lookup | def lookup(participant_name, workitem, opts={})
pinfo = participant_name.is_a?(String) ?
lookup_info(participant_name, workitem) : participant_name
instantiate(pinfo, opts)
end | ruby | def lookup(participant_name, workitem, opts={})
pinfo = participant_name.is_a?(String) ?
lookup_info(participant_name, workitem) : participant_name
instantiate(pinfo, opts)
end | [
"def",
"lookup",
"(",
"participant_name",
",",
"workitem",
",",
"opts",
"=",
"{",
"}",
")",
"pinfo",
"=",
"participant_name",
".",
"is_a?",
"(",
"String",
")",
"?",
"lookup_info",
"(",
"participant_name",
",",
"workitem",
")",
":",
"participant_name",
"insta... | Returns a participant instance, or nil if there is no participant
for the given participant name.
Mostly a combination of #lookup_info and #instantiate. | [
"Returns",
"a",
"participant",
"instance",
"or",
"nil",
"if",
"there",
"is",
"no",
"participant",
"for",
"the",
"given",
"participant",
"name",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/svc/participant_list.rb#L171-L177 |
20,253 | jmettraux/ruote | lib/ruote/svc/participant_list.rb | Ruote.ParticipantList.lookup_info | 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 | 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... | [
"def",
"lookup_info",
"(",
"pname",
",",
"workitem",
")",
"return",
"nil",
"unless",
"pname",
"wi",
"=",
"workitem",
"?",
"Ruote",
"::",
"Workitem",
".",
"new",
"(",
"workitem",
".",
"merge",
"(",
"'participant_name'",
"=>",
"pname",
")",
")",
":",
"nil"... | Given a participant name, returns participant details.
Returns nil if there is no participant registered that covers the given
participant name. | [
"Given",
"a",
"participant",
"name",
"returns",
"participant",
"details",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/svc/participant_list.rb#L184-L207 |
20,254 | jmettraux/ruote | lib/ruote/svc/participant_list.rb | Ruote.ParticipantList.instantiate | 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 | 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... | [
"def",
"instantiate",
"(",
"pinfo",
",",
"opts",
"=",
"{",
"}",
")",
"return",
"nil",
"unless",
"pinfo",
"pa_class_name",
",",
"options",
"=",
"pinfo",
"if",
"rp",
"=",
"options",
"[",
"'require_path'",
"]",
"require",
"(",
"rp",
")",
"end",
"if",
"lp"... | Returns an instance of a participant. | [
"Returns",
"an",
"instance",
"of",
"a",
"participant",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/svc/participant_list.rb#L211-L234 |
20,255 | icoretech/spotify-client | lib/spotify_client.rb | Spotify.Client.create_user_playlist | 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 | 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 | [
"def",
"create_user_playlist",
"(",
"user_id",
",",
"name",
",",
"is_public",
"=",
"true",
")",
"run",
"(",
":post",
",",
"\"/v1/users/#{user_id}/playlists\"",
",",
"[",
"201",
"]",
",",
"JSON",
".",
"dump",
"(",
"name",
":",
"name",
",",
"public",
":",
... | Create a playlist for a Spotify user. The playlist will be empty until you add tracks.
Requires playlist-modify-public for a public playlist.
Requires playlist-modify-private for a private playlist. | [
"Create",
"a",
"playlist",
"for",
"a",
"Spotify",
"user",
".",
"The",
"playlist",
"will",
"be",
"empty",
"until",
"you",
"add",
"tracks",
"."
] | 2368530f0f509a5123c44d40f79a8ea11ce61394 | https://github.com/icoretech/spotify-client/blob/2368530f0f509a5123c44d40f79a8ea11ce61394/lib/spotify_client.rb#L91-L93 |
20,256 | icoretech/spotify-client | lib/spotify_client.rb | Spotify.Client.add_user_tracks_to_playlist | 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 | 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)
... | [
"def",
"add_user_tracks_to_playlist",
"(",
"user_id",
",",
"playlist_id",
",",
"uris",
"=",
"[",
"]",
",",
"position",
"=",
"nil",
")",
"params",
"=",
"{",
"uris",
":",
"Array",
".",
"wrap",
"(",
"uris",
")",
"[",
"0",
"..",
"99",
"]",
".",
"join",
... | Add an Array of track uris to an existing playlist.
Adding tracks to a user's public playlist requires authorization of the playlist-modify-public scope;
adding tracks to a private playlist requires the playlist-modify-private scope.
client.add_user_tracks_to_playlist('1181346016', '7i3thJWDtmX04dJhFwYb0x', %w(spo... | [
"Add",
"an",
"Array",
"of",
"track",
"uris",
"to",
"an",
"existing",
"playlist",
"."
] | 2368530f0f509a5123c44d40f79a8ea11ce61394 | https://github.com/icoretech/spotify-client/blob/2368530f0f509a5123c44d40f79a8ea11ce61394/lib/spotify_client.rb#L101-L107 |
20,257 | icoretech/spotify-client | lib/spotify_client.rb | Spotify.Client.follow | def follow(type, ids)
params = { type: type, ids: Array.wrap(ids).join(',') }
run(:put, "/v1/me/following", [204], params)
end | ruby | def follow(type, ids)
params = { type: type, ids: Array.wrap(ids).join(',') }
run(:put, "/v1/me/following", [204], params)
end | [
"def",
"follow",
"(",
"type",
",",
"ids",
")",
"params",
"=",
"{",
"type",
":",
"type",
",",
"ids",
":",
"Array",
".",
"wrap",
"(",
"ids",
")",
".",
"join",
"(",
"','",
")",
"}",
"run",
"(",
":put",
",",
"\"/v1/me/following\"",
",",
"[",
"204",
... | Follow artists or users
client.follow('artist', ['0BvkDsjIUla7X0k6CSWh1I']) | [
"Follow",
"artists",
"or",
"users"
] | 2368530f0f509a5123c44d40f79a8ea11ce61394 | https://github.com/icoretech/spotify-client/blob/2368530f0f509a5123c44d40f79a8ea11ce61394/lib/spotify_client.rb#L186-L189 |
20,258 | matiaskorhonen/monit | lib/monit/status.rb | Monit.Status.url | 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 | 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 | [
"def",
"url",
"url_params",
"=",
"{",
":host",
"=>",
"@host",
",",
":port",
"=>",
"@port",
",",
":path",
"=>",
"\"/_status\"",
",",
":query",
"=>",
"\"format=xml\"",
"}",
"@ssl",
"?",
"URI",
"::",
"HTTPS",
".",
"build",
"(",
"url_params",
")",
":",
"UR... | Create a new instance of the status class with the given options
<b>Options:</b>
* +host+ - the host for monit, defaults to +localhost+
* +port+ - the Monit port, defaults to +2812+
* +ssl+ - should we use SSL for the connection to Monit (default: false)
* +auth+ - should authentication be used, defaults to false... | [
"Create",
"a",
"new",
"instance",
"of",
"the",
"status",
"class",
"with",
"the",
"given",
"options"
] | ace938155259e269e4ba492bec6e24502d33a8cf | https://github.com/matiaskorhonen/monit/blob/ace938155259e269e4ba492bec6e24502d33a8cf/lib/monit/status.rb#L40-L43 |
20,259 | matiaskorhonen/monit | lib/monit/status.rb | Monit.Status.get | 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 | 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... | [
"def",
"get",
"uri",
"=",
"self",
".",
"url",
"http",
"=",
"Net",
"::",
"HTTP",
".",
"new",
"(",
"uri",
".",
"host",
",",
"uri",
".",
"port",
")",
"if",
"@ssl",
"http",
".",
"use_ssl",
"=",
"true",
"http",
".",
"verify_mode",
"=",
"OpenSSL",
"::"... | Get the status from Monit. | [
"Get",
"the",
"status",
"from",
"Monit",
"."
] | ace938155259e269e4ba492bec6e24502d33a8cf | https://github.com/matiaskorhonen/monit/blob/ace938155259e269e4ba492bec6e24502d33a8cf/lib/monit/status.rb#L46-L75 |
20,260 | matiaskorhonen/monit | lib/monit/status.rb | Monit.Status.parse | 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 | 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... | [
"def",
"parse",
"(",
"xml",
")",
"@hash",
"=",
"Hash",
".",
"from_xml",
"(",
"xml",
")",
"@server",
"=",
"Server",
".",
"new",
"(",
"@hash",
"[",
"\"monit\"",
"]",
"[",
"\"server\"",
"]",
")",
"@platform",
"=",
"Platform",
".",
"new",
"(",
"@hash",
... | Parse the XML from Monit into a hash and into a Ruby representation. | [
"Parse",
"the",
"XML",
"from",
"Monit",
"into",
"a",
"hash",
"and",
"into",
"a",
"Ruby",
"representation",
"."
] | ace938155259e269e4ba492bec6e24502d33a8cf | https://github.com/matiaskorhonen/monit/blob/ace938155259e269e4ba492bec6e24502d33a8cf/lib/monit/status.rb#L78-L102 |
20,261 | berkshelf/solve | lib/solve/graph.rb | Solve.Graph.artifact | 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 | 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 | [
"def",
"artifact",
"(",
"name",
",",
"version",
")",
"unless",
"artifact?",
"(",
"name",
",",
"version",
")",
"artifact",
"=",
"Artifact",
".",
"new",
"(",
"self",
",",
"name",
",",
"version",
")",
"@artifacts",
"[",
"\"#{name}-#{version}\"",
"]",
"=",
"... | Add an artifact to the graph
@param [String] name
@Param [String] version | [
"Add",
"an",
"artifact",
"to",
"the",
"graph"
] | a0e03ede13e2f66b8dd6d0d34c9c9db70fba94d2 | https://github.com/berkshelf/solve/blob/a0e03ede13e2f66b8dd6d0d34c9c9db70fba94d2/lib/solve/graph.rb#L28-L36 |
20,262 | berkshelf/solve | lib/solve/graph.rb | Solve.Graph.versions | 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 | 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... | [
"def",
"versions",
"(",
"name",
",",
"constraint",
"=",
"Semverse",
"::",
"DEFAULT_CONSTRAINT",
")",
"constraint",
"=",
"Semverse",
"::",
"Constraint",
".",
"coerce",
"(",
"constraint",
")",
"if",
"constraint",
"==",
"Semverse",
"::",
"DEFAULT_CONSTRAINT",
"@art... | Return all the artifacts from the collection of artifacts
with the given name.
@param [String] name
@return [Array<Solve::Artifact>] | [
"Return",
"all",
"the",
"artifacts",
"from",
"the",
"collection",
"of",
"artifacts",
"with",
"the",
"given",
"name",
"."
] | a0e03ede13e2f66b8dd6d0d34c9c9db70fba94d2 | https://github.com/berkshelf/solve/blob/a0e03ede13e2f66b8dd6d0d34c9c9db70fba94d2/lib/solve/graph.rb#L51-L61 |
20,263 | berkshelf/solve | lib/solve/constraint.rb | Solve.Constraint.satisfies? | def satisfies?(target)
target = Semverse::Version.coerce(target)
return false if !(version == 0) && greedy_match?(target)
compare(target)
end | ruby | def satisfies?(target)
target = Semverse::Version.coerce(target)
return false if !(version == 0) && greedy_match?(target)
compare(target)
end | [
"def",
"satisfies?",
"(",
"target",
")",
"target",
"=",
"Semverse",
"::",
"Version",
".",
"coerce",
"(",
"target",
")",
"return",
"false",
"if",
"!",
"(",
"version",
"==",
"0",
")",
"&&",
"greedy_match?",
"(",
"target",
")",
"compare",
"(",
"target",
"... | Returns true or false if the given version would be satisfied by
the version constraint.
@param [Semverse::Version, #to_s] target
@return [Boolean] | [
"Returns",
"true",
"or",
"false",
"if",
"the",
"given",
"version",
"would",
"be",
"satisfied",
"by",
"the",
"version",
"constraint",
"."
] | a0e03ede13e2f66b8dd6d0d34c9c9db70fba94d2 | https://github.com/berkshelf/solve/blob/a0e03ede13e2f66b8dd6d0d34c9c9db70fba94d2/lib/solve/constraint.rb#L201-L207 |
20,264 | berkshelf/solve | lib/solve/gecode_solver.rb | Solve.GecodeSolver.solve_demands | 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 | 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::... | [
"def",
"solve_demands",
"(",
"demands_as_constraints",
")",
"selector",
"=",
"DepSelector",
"::",
"Selector",
".",
"new",
"(",
"ds_graph",
",",
"(",
"timeout_ms",
"/",
"1000.0",
")",
")",
"selector",
".",
"find_solution",
"(",
"demands_as_constraints",
",",
"all... | Runs the solver with the set of demands given. If any DepSelector
exceptions are raised, they are rescued and re-raised | [
"Runs",
"the",
"solver",
"with",
"the",
"set",
"of",
"demands",
"given",
".",
"If",
"any",
"DepSelector",
"exceptions",
"are",
"raised",
"they",
"are",
"rescued",
"and",
"re",
"-",
"raised"
] | a0e03ede13e2f66b8dd6d0d34c9c9db70fba94d2 | https://github.com/berkshelf/solve/blob/a0e03ede13e2f66b8dd6d0d34c9c9db70fba94d2/lib/solve/gecode_solver.rb#L94-L111 |
20,265 | berkshelf/solve | lib/solve/ruby_solver.rb | Solve.RubySolver.requirement_satisfied_by? | 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 | 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_... | [
"def",
"requirement_satisfied_by?",
"(",
"requirement",
",",
"activated",
",",
"spec",
")",
"version",
"=",
"spec",
".",
"version",
"return",
"false",
"unless",
"requirement",
".",
"constraint",
".",
"satisfies?",
"(",
"version",
")",
"shared_possibility_versions",
... | Callback required by Molinillo
Determines whether the given `requirement` is satisfied by the given
`spec`, in the context of the current `activated` dependency graph.
@param [Object] requirement
@param [DependencyGraph] activated the current dependency graph in the
resolution process.
@param [Object] spec
@r... | [
"Callback",
"required",
"by",
"Molinillo",
"Determines",
"whether",
"the",
"given",
"requirement",
"is",
"satisfied",
"by",
"the",
"given",
"spec",
"in",
"the",
"context",
"of",
"the",
"current",
"activated",
"dependency",
"graph",
"."
] | a0e03ede13e2f66b8dd6d0d34c9c9db70fba94d2 | https://github.com/berkshelf/solve/blob/a0e03ede13e2f66b8dd6d0d34c9c9db70fba94d2/lib/solve/ruby_solver.rb#L171-L177 |
20,266 | berkshelf/solve | lib/solve/ruby_solver.rb | Solve.RubySolver.possibility_versions | 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 | 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
... | [
"def",
"possibility_versions",
"(",
"requirement",
",",
"activated",
")",
"activated",
".",
"vertices",
".",
"values",
".",
"flat_map",
"do",
"|",
"vertex",
"|",
"next",
"unless",
"vertex",
".",
"payload",
"next",
"unless",
"vertex",
".",
"name",
"==",
"requ... | Searches the current dependency graph to find previously activated
requirements for the current artifact.
@param [Object] requirement
@param [DependencyGraph] activated the current dependency graph in the
resolution process.
@return [Array<Semverse::Version> the list of currently activated versions
of this req... | [
"Searches",
"the",
"current",
"dependency",
"graph",
"to",
"find",
"previously",
"activated",
"requirements",
"for",
"the",
"current",
"artifact",
"."
] | a0e03ede13e2f66b8dd6d0d34c9c9db70fba94d2 | https://github.com/berkshelf/solve/blob/a0e03ede13e2f66b8dd6d0d34c9c9db70fba94d2/lib/solve/ruby_solver.rb#L187-L200 |
20,267 | jwhitehorn/pi_piper | lib/pi_piper/spi.rb | PiPiper.Spi.clock | 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 | 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... | [
"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... | Sets the SPI clock frequency | [
"Sets",
"the",
"SPI",
"clock",
"frequency"
] | bf17c88c8d27f87baf04868482b8082b6a8390ea | https://github.com/jwhitehorn/pi_piper/blob/bf17c88c8d27f87baf04868482b8082b6a8390ea/lib/pi_piper/spi.rb#L64-L81 |
20,268 | jwhitehorn/pi_piper | lib/pi_piper/spi.rb | PiPiper.Spi.chip_select | 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 | 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 | [
"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_... | Activate a specific chip so that communication can begin
When a block is provided, the chip is automatically deactivated after the block completes.
When a block is not provided, the user is responsible for calling chip_select(CHIP_SELECT_NONE)
@example With block (preferred)
spi.chip_select do
spi.write(0x... | [
"Activate",
"a",
"specific",
"chip",
"so",
"that",
"communication",
"can",
"begin"
] | bf17c88c8d27f87baf04868482b8082b6a8390ea | https://github.com/jwhitehorn/pi_piper/blob/bf17c88c8d27f87baf04868482b8082b6a8390ea/lib/pi_piper/spi.rb#L113-L123 |
20,269 | jwhitehorn/pi_piper | lib/pi_piper/spi.rb | PiPiper.Spi.chip_select_active_low | 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 | 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 | [
"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",
"?... | Configure the active state of the chip select line
The default state for most chips is active low.
"active low" means the clock line is kept high during idle, and goes low when communicating.
"active high" means the clock line is kept low during idle, and goes high when communicating.
@param [Boolean] active_lo... | [
"Configure",
"the",
"active",
"state",
"of",
"the",
"chip",
"select",
"line"
] | bf17c88c8d27f87baf04868482b8082b6a8390ea | https://github.com/jwhitehorn/pi_piper/blob/bf17c88c8d27f87baf04868482b8082b6a8390ea/lib/pi_piper/spi.rb#L135-L140 |
20,270 | jwhitehorn/pi_piper | lib/pi_piper/spi.rb | PiPiper.Spi.write | 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 | 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
... | [
"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",
... | Write to the bus
@example Write a single byte
spi.write(0x22)
@example Write multiple bytes
spi.write(0x22, 0x33, 0x44)
@return [Number|Array] data that came out of MISO during write | [
"Write",
"to",
"the",
"bus"
] | bf17c88c8d27f87baf04868482b8082b6a8390ea | https://github.com/jwhitehorn/pi_piper/blob/bf17c88c8d27f87baf04868482b8082b6a8390ea/lib/pi_piper/spi.rb#L172-L192 |
20,271 | infinitered/rmq | motion/ruby_motion_query/subviews.rb | RubyMotionQuery.RMQ.add_subview | 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 | 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 = ... | [
"def",
"add_subview",
"(",
"view_or_constant",
",",
"opts",
"=",
"{",
"}",
")",
"subviews_added",
"=",
"[",
"]",
"selected",
".",
"each",
"do",
"|",
"selected_view",
"|",
"created",
"=",
"false",
"appended",
"=",
"false",
"built",
"=",
"false",
"if",
"vi... | This is used by build, create, and append. You really shouldn't use it
directly. Although it's totally fine if you do
@return [RMQ] | [
"This",
"is",
"used",
"by",
"build",
"create",
"and",
"append",
".",
"You",
"really",
"shouldn",
"t",
"use",
"it",
"directly",
".",
"Although",
"it",
"s",
"totally",
"fine",
"if",
"you",
"do"
] | a8329e1574ce3275c9fe56b91127c8b5e4b7693e | https://github.com/infinitered/rmq/blob/a8329e1574ce3275c9fe56b91127c8b5e4b7693e/motion/ruby_motion_query/subviews.rb#L20-L73 |
20,272 | infinitered/rmq | motion/ruby_motion_query/subviews.rb | RubyMotionQuery.RMQ.find_or_append | 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 | 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 | [
"def",
"find_or_append",
"(",
"view_or_constant",
",",
"style",
"=",
"nil",
",",
"opts",
"=",
"{",
"}",
",",
"&",
"block",
")",
"if",
"style",
"&&",
"(",
"q",
"=",
"self",
".",
"find",
"(",
"style",
")",
")",
"&&",
"q",
".",
"length",
">",
"0",
... | Same as append, but will look for a view with the same name and reapply styles
to it if it finds one. If it doesn't, it'll append as normal.
@example
@my_button = rmq.find_or_append(UIButton, :my_button)
@my_button = rmq.find_or_append(UIButton, :my_button) # Only one created | [
"Same",
"as",
"append",
"but",
"will",
"look",
"for",
"a",
"view",
"with",
"the",
"same",
"name",
"and",
"reapply",
"styles",
"to",
"it",
"if",
"it",
"finds",
"one",
".",
"If",
"it",
"doesn",
"t",
"it",
"ll",
"append",
"as",
"normal",
"."
] | a8329e1574ce3275c9fe56b91127c8b5e4b7693e | https://github.com/infinitered/rmq/blob/a8329e1574ce3275c9fe56b91127c8b5e4b7693e/motion/ruby_motion_query/subviews.rb#L120-L126 |
20,273 | infinitered/rmq | motion/ruby_motion_query/subviews.rb | RubyMotionQuery.RMQ.find_or_append! | def find_or_append!(view_or_constant, style=nil, opts = {}, &block)
find_or_append(view_or_constant, style, opts, &block).get
end | ruby | def find_or_append!(view_or_constant, style=nil, opts = {}, &block)
find_or_append(view_or_constant, style, opts, &block).get
end | [
"def",
"find_or_append!",
"(",
"view_or_constant",
",",
"style",
"=",
"nil",
",",
"opts",
"=",
"{",
"}",
",",
"&",
"block",
")",
"find_or_append",
"(",
"view_or_constant",
",",
"style",
",",
"opts",
",",
"block",
")",
".",
"get",
"end"
] | Same as append!, but will look for a view with the same name and reapply styles
to it if it finds one. If it doesn't, it'll append! as normal.
@example
@my_button = rmq.find_or_append!(UIButton, :my_button)
@my_button = rmq.find_or_append!(UIButton, :my_button) # Only one created | [
"Same",
"as",
"append!",
"but",
"will",
"look",
"for",
"a",
"view",
"with",
"the",
"same",
"name",
"and",
"reapply",
"styles",
"to",
"it",
"if",
"it",
"finds",
"one",
".",
"If",
"it",
"doesn",
"t",
"it",
"ll",
"append!",
"as",
"normal",
"."
] | a8329e1574ce3275c9fe56b91127c8b5e4b7693e | https://github.com/infinitered/rmq/blob/a8329e1574ce3275c9fe56b91127c8b5e4b7693e/motion/ruby_motion_query/subviews.rb#L134-L136 |
20,274 | infinitered/rmq | motion/ruby_motion_query/subviews.rb | RubyMotionQuery.RMQ.unshift | 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 | 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 | [
"def",
"unshift",
"(",
"view_or_constant",
",",
"style",
"=",
"nil",
",",
"opts",
"=",
"{",
"}",
",",
"&",
"block",
")",
"opts",
"[",
":at_index",
"]",
"=",
"0",
"opts",
"[",
":style",
"]",
"=",
"style",
"opts",
"[",
":block",
"]",
"=",
"block",
... | Just like append, but inserts the view at index 0 of the subview array
@return [RMQ] | [
"Just",
"like",
"append",
"but",
"inserts",
"the",
"view",
"at",
"index",
"0",
"of",
"the",
"subview",
"array"
] | a8329e1574ce3275c9fe56b91127c8b5e4b7693e | https://github.com/infinitered/rmq/blob/a8329e1574ce3275c9fe56b91127c8b5e4b7693e/motion/ruby_motion_query/subviews.rb#L141-L146 |
20,275 | infinitered/rmq | motion/ruby_motion_query/subviews.rb | RubyMotionQuery.RMQ.build | 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 | 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 | [
"def",
"build",
"(",
"view",
",",
"style",
"=",
"nil",
",",
"opts",
"=",
"{",
"}",
",",
"&",
"block",
")",
"opts",
"[",
":do_not_add",
"]",
"=",
"true",
"opts",
"[",
":style",
"]",
"=",
"style",
"opts",
"[",
":block",
"]",
"=",
"block",
"if",
"... | Build a view, similar to create and append, but only inits an existing view. Usefull
in collectionview cells for example
@example
# In your collectionview
rmq.build(cell) unless cell.reused
# Then in your cell
def rmq_build
rmq.append(UIView, :foo)
end | [
"Build",
"a",
"view",
"similar",
"to",
"create",
"and",
"append",
"but",
"only",
"inits",
"an",
"existing",
"view",
".",
"Usefull",
"in",
"collectionview",
"cells",
"for",
"example"
] | a8329e1574ce3275c9fe56b91127c8b5e4b7693e | https://github.com/infinitered/rmq/blob/a8329e1574ce3275c9fe56b91127c8b5e4b7693e/motion/ruby_motion_query/subviews.rb#L209-L214 |
20,276 | infinitered/rmq | motion/ruby_motion_query/validation.rb | RubyMotionQuery.Validation.universal_validation_checks | 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 | 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... | [
"def",
"universal_validation_checks",
"(",
"data",
",",
"options",
"=",
"{",
"}",
")",
"# shortcircuit if debugging",
"return",
"true",
"if",
"RubyMotionQuery",
"::",
"RMQ",
".",
"debugging?",
"# allow blank data if specified",
"return",
"true",
"if",
"(",
"options",
... | this method shortcuts specific validation rules. As such it should only be
added to for universal validation needs. It must be kept as efficient as possible. | [
"this",
"method",
"shortcuts",
"specific",
"validation",
"rules",
".",
"As",
"such",
"it",
"should",
"only",
"be",
"added",
"to",
"for",
"universal",
"validation",
"needs",
".",
"It",
"must",
"be",
"kept",
"as",
"efficient",
"as",
"possible",
"."
] | a8329e1574ce3275c9fe56b91127c8b5e4b7693e | https://github.com/infinitered/rmq/blob/a8329e1574ce3275c9fe56b91127c8b5e4b7693e/motion/ruby_motion_query/validation.rb#L110-L119 |
20,277 | infinitered/rmq | motion/ruby_motion_query/debug.rb | RubyMotionQuery.Debug.log_detailed | 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 | 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... | [
"def",
"log_detailed",
"(",
"label",
",",
"params",
"=",
"{",
"}",
")",
"return",
"unless",
"RMQ",
".",
"app",
".",
"development?",
"||",
"RMQ",
".",
"app",
".",
"test?",
"objects",
"=",
"params",
"[",
":objects",
"]",
"skip_first_caller",
"=",
"params",... | Warning, this is very slow | [
"Warning",
"this",
"is",
"very",
"slow"
] | a8329e1574ce3275c9fe56b91127c8b5e4b7693e | https://github.com/infinitered/rmq/blob/a8329e1574ce3275c9fe56b91127c8b5e4b7693e/motion/ruby_motion_query/debug.rb#L41-L71 |
20,278 | infinitered/rmq | motion/ruby_motion_query/debug.rb | RubyMotionQuery.Debug.assert | 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 | 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 | [
"def",
"assert",
"(",
"truthy",
",",
"label",
"=",
"nil",
",",
"objects",
"=",
"nil",
")",
"if",
"(",
"RMQ",
".",
"app",
".",
"development?",
"||",
"RMQ",
".",
"app",
".",
"test?",
")",
"&&",
"!",
"truthy",
"label",
"||=",
"'Assert failed'",
"if",
... | Warning, this is very slow to output log, checking truthy however is
basically as performant as an if statement
@example
# foo and bar are objects we want to inspect
rmq.debug.assert(1==2, 'Bad stuff happened', {
foo: foo,
bar: bar
}) | [
"Warning",
"this",
"is",
"very",
"slow",
"to",
"output",
"log",
"checking",
"truthy",
"however",
"is",
"basically",
"as",
"performant",
"as",
"an",
"if",
"statement"
] | a8329e1574ce3275c9fe56b91127c8b5e4b7693e | https://github.com/infinitered/rmq/blob/a8329e1574ce3275c9fe56b91127c8b5e4b7693e/motion/ruby_motion_query/debug.rb#L83-L91 |
20,279 | infinitered/rmq | motion/ruby_motion_query/position.rb | RubyMotionQuery.RMQ.subviews_bottom_right | 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 | 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 ... | [
"def",
"subviews_bottom_right",
"(",
"view",
",",
"args",
"=",
"{",
"}",
")",
"w",
"=",
"0",
"h",
"=",
"0",
"view",
".",
"subviews",
".",
"each",
"do",
"|",
"subview",
"|",
"rect",
"=",
"subview",
".",
"rmq",
".",
"frame",
"w",
"=",
"[",
"rect",
... | Calculates the bottom right of a view using its subviews
@return [Hash] | [
"Calculates",
"the",
"bottom",
"right",
"of",
"a",
"view",
"using",
"its",
"subviews"
] | a8329e1574ce3275c9fe56b91127c8b5e4b7693e | https://github.com/infinitered/rmq/blob/a8329e1574ce3275c9fe56b91127c8b5e4b7693e/motion/ruby_motion_query/position.rb#L189-L204 |
20,280 | infinitered/rmq | motion/ruby_motion_query/base.rb | RubyMotionQuery.RMQ.context= | 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 | 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... | [
"def",
"context",
"=",
"(",
"value",
")",
"if",
"value",
"if",
"value",
".",
"is_a?",
"(",
"UIViewController",
")",
"@context",
"=",
"RubyMotionQuery",
"::",
"RMQ",
".",
"weak_ref",
"(",
"value",
")",
"elsif",
"value",
".",
"is_a?",
"(",
"UIView",
")",
... | This is mostly used internally
If rmq was called in a view, context will be that view. If it was called
in a UIViewController, it will be that controller. If it is called in another
object, it will be current controller's rmq instance and thus context will be
that controller | [
"This",
"is",
"mostly",
"used",
"internally"
] | a8329e1574ce3275c9fe56b91127c8b5e4b7693e | https://github.com/infinitered/rmq/blob/a8329e1574ce3275c9fe56b91127c8b5e4b7693e/motion/ruby_motion_query/base.rb#L30-L43 |
20,281 | infinitered/rmq | motion/ruby_motion_query/base.rb | RubyMotionQuery.RMQ.selected | 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 | 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... | [
"def",
"selected",
"if",
"@selected_dirty",
"@_selected",
"=",
"[",
"]",
"if",
"RMQ",
".",
"is_blank?",
"(",
"self",
".",
"selectors",
")",
"@_selected",
"<<",
"context_or_context_view",
"else",
"working_selectors",
"=",
"self",
".",
"selectors",
".",
"dup",
"... | The UIViews currently selected
Use {#get} instead to get the actual UIView objects
@return [Array] | [
"The",
"UIViews",
"currently",
"selected"
] | a8329e1574ce3275c9fe56b91127c8b5e4b7693e | https://github.com/infinitered/rmq/blob/a8329e1574ce3275c9fe56b91127c8b5e4b7693e/motion/ruby_motion_query/base.rb#L60-L86 |
20,282 | infinitered/rmq | motion/ruby_motion_query/base.rb | RubyMotionQuery.RMQ.wrap | 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 | def wrap(*views)
views.flatten!
views.select!{ |v| v.is_a?(UIView) }
RMQ.create_with_array_and_selectors(views, views, views.first, self)
end | [
"def",
"wrap",
"(",
"*",
"views",
")",
"views",
".",
"flatten!",
"views",
".",
"select!",
"{",
"|",
"v",
"|",
"v",
".",
"is_a?",
"(",
"UIView",
")",
"}",
"RMQ",
".",
"create_with_array_and_selectors",
"(",
"views",
",",
"views",
",",
"views",
".",
"f... | Wraps 1 or more views in an rmq instance.
Normally you select a view or views using rmq(my_view). Which doesn't
work if you have an instance of a RMQ, in which case it isn't a method.
In some cases you want to save an instance of rmq and use it like the rmq
method, for this you'd use #wrap
@example
q = RubyMo... | [
"Wraps",
"1",
"or",
"more",
"views",
"in",
"an",
"rmq",
"instance",
"."
] | a8329e1574ce3275c9fe56b91127c8b5e4b7693e | https://github.com/infinitered/rmq/blob/a8329e1574ce3275c9fe56b91127c8b5e4b7693e/motion/ruby_motion_query/base.rb#L103-L107 |
20,283 | infinitered/rmq | motion/ruby_motion_query/base.rb | RubyMotionQuery.RMQ.log | 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 | 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 ... | [
"def",
"log",
"(",
"opt",
"=",
"nil",
")",
"if",
"opt",
"==",
":tree",
"puts",
"tree_to_s",
"(",
"selected",
")",
"return",
"end",
"wide",
"=",
"(",
"opt",
"==",
":wide",
")",
"out",
"=",
"\"\\n object_id | class | style_name | fra... | Super useful in the console. log outputs to the console a table of the selected views
@param :wide outputs wide format (really wide, but awesome: rmq.all.log :wide). :tree outputs the
log in a tree form
@return [String]
@example
(main)> rmq(UIImageView).log
object_id | class | style_na... | [
"Super",
"useful",
"in",
"the",
"console",
".",
"log",
"outputs",
"to",
"the",
"console",
"a",
"table",
"of",
"the",
"selected",
"views"
] | a8329e1574ce3275c9fe56b91127c8b5e4b7693e | https://github.com/infinitered/rmq/blob/a8329e1574ce3275c9fe56b91127c8b5e4b7693e/motion/ruby_motion_query/base.rb#L228-L272 |
20,284 | gcao/aspector | lib/aspector/interception.rb | Aspector.Interception.apply_to_method | 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 | 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 | [
"def",
"apply_to_method",
"(",
"method",
")",
"filtered_advices",
"=",
"filter_advices",
"advices",
",",
"method",
"return",
"if",
"filtered_advices",
".",
"empty?",
"logger",
".",
"debug",
"'apply-to-method'",
",",
"method",
"scope",
"||=",
"context",
".",
"insta... | Applies advices to a given method
@note This method is public only because we use it from define_method on a module
@note If will figure out the method scope (private/public/protected) on its own
@param method [Symbol] method to which we want to apply this interception | [
"Applies",
"advices",
"to",
"a",
"given",
"method"
] | c82396dc8678bf632959fdaf25aa28e76b0e4605 | https://github.com/gcao/aspector/blob/c82396dc8678bf632959fdaf25aa28e76b0e4605/lib/aspector/interception.rb#L57-L66 |
20,285 | gcao/aspector | lib/aspector/interception.rb | Aspector.Interception.define_methods_for_advice_blocks | 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 | 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 | [
"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",
",",
... | Defines on a target element new methods that will contain advices logic
as long as their blocks. Then we can invoke advices logic as a normal methods
In a way it just casts a block to methods for peformance reasons
If we have advices that just execute already existing methods, this won't create
anything
@note All ... | [
"Defines",
"on",
"a",
"target",
"element",
"new",
"methods",
"that",
"will",
"contain",
"advices",
"logic",
"as",
"long",
"as",
"their",
"blocks",
".",
"Then",
"we",
"can",
"invoke",
"advices",
"logic",
"as",
"a",
"normal",
"methods",
"In",
"a",
"way",
"... | c82396dc8678bf632959fdaf25aa28e76b0e4605 | https://github.com/gcao/aspector/blob/c82396dc8678bf632959fdaf25aa28e76b0e4605/lib/aspector/interception.rb#L77-L84 |
20,286 | gcao/aspector | lib/aspector/interception.rb | Aspector.Interception.apply_to_methods | 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 | 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... | [
"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",
".",
"c... | Will apply all the advices to all methods that match | [
"Will",
"apply",
"all",
"the",
"advices",
"to",
"all",
"methods",
"that",
"match"
] | c82396dc8678bf632959fdaf25aa28e76b0e4605 | https://github.com/gcao/aspector/blob/c82396dc8678bf632959fdaf25aa28e76b0e4605/lib/aspector/interception.rb#L97-L125 |
20,287 | gcao/aspector | lib/aspector/interception.rb | Aspector.Interception.invoke_deferred_logics | 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 | 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... | [
"def",
"invoke_deferred_logics",
"logics",
"=",
"@aspect",
".",
"class",
".",
"storage",
".",
"deferred_logics",
"return",
"if",
"logics",
".",
"empty?",
"logics",
".",
"each",
"do",
"|",
"logic",
"|",
"result",
"=",
"logic",
".",
"apply",
"context",
",",
... | Invokes deferred logics blocks on a target element and stores deferred logic
invokations results | [
"Invokes",
"deferred",
"logics",
"blocks",
"on",
"a",
"target",
"element",
"and",
"stores",
"deferred",
"logic",
"invokations",
"results"
] | c82396dc8678bf632959fdaf25aa28e76b0e4605 | https://github.com/gcao/aspector/blob/c82396dc8678bf632959fdaf25aa28e76b0e4605/lib/aspector/interception.rb#L141-L152 |
20,288 | gcao/aspector | lib/aspector/interception.rb | Aspector.Interception.add_method_hooks | 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 | 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_... | [
"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",
"(",
":si... | Redefines singleton_method_added and method_added methods so they are monitored
If new method is added we will apply to it appropriate advices | [
"Redefines",
"singleton_method_added",
"and",
"method_added",
"methods",
"so",
"they",
"are",
"monitored",
"If",
"new",
"method",
"is",
"added",
"we",
"will",
"apply",
"to",
"it",
"appropriate",
"advices"
] | c82396dc8678bf632959fdaf25aa28e76b0e4605 | https://github.com/gcao/aspector/blob/c82396dc8678bf632959fdaf25aa28e76b0e4605/lib/aspector/interception.rb#L173-L197 |
20,289 | gcao/aspector | lib/aspector/interception.rb | Aspector.Interception.recreate_method | 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 | 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... | [
"def",
"recreate_method",
"(",
"method",
",",
"advices",
",",
"scope",
")",
"context",
".",
"instance_variable_set",
"(",
":@aspector_creating_method",
",",
"true",
")",
"raw_advices",
"=",
"advices",
".",
"select",
"(",
":raw?",
")",
"if",
"raw_advices",
".",
... | Recreates a given method applying all the advices one by one
@param method [String] method name of a method that we want to recreate
@param advices [Array<Aspector::Advice>] all the advices that
should be applied (after filtering)
@param scope [Symbol] method visibility (private, protected, public) | [
"Recreates",
"a",
"given",
"method",
"applying",
"all",
"the",
"advices",
"one",
"by",
"one"
] | c82396dc8678bf632959fdaf25aa28e76b0e4605 | https://github.com/gcao/aspector/blob/c82396dc8678bf632959fdaf25aa28e76b0e4605/lib/aspector/interception.rb#L214-L261 |
20,290 | gcao/aspector | lib/aspector/logger.rb | Aspector.Logger.message | 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 | 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 | [
"def",
"message",
"(",
"*",
"args",
")",
"msg",
"=",
"[",
"]",
"if",
"context",
".",
"is_a?",
"Aspector",
"::",
"Base",
"msg",
"<<",
"context",
".",
"class",
".",
"to_s",
"msg",
"<<",
"context",
".",
"target",
".",
"to_s",
"else",
"msg",
"<<",
"con... | Creates a full messages that we want to log
@param args any arguments that we want to log based on
@return [String] message string for logging - provides additional context information
@example Create a message based on a single argument
message('action taken') #=> 'Aspector::Base | ExampleClass | action taken' | [
"Creates",
"a",
"full",
"messages",
"that",
"we",
"want",
"to",
"log"
] | c82396dc8678bf632959fdaf25aa28e76b0e4605 | https://github.com/gcao/aspector/blob/c82396dc8678bf632959fdaf25aa28e76b0e4605/lib/aspector/logger.rb#L36-L49 |
20,291 | Fullscreen/squid | lib/squid/plotter.rb | Squid.Plotter.legend | 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 | 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... | [
"def",
"legend",
"(",
"labels",
",",
"height",
":",
",",
"right",
":",
"0",
",",
"colors",
":",
"[",
"]",
")",
"left",
"=",
"@pdf",
".",
"bounds",
".",
"width",
"/",
"2",
"box",
"(",
"x",
":",
"left",
",",
"y",
":",
"@pdf",
".",
"bounds",
"."... | Draws the graph legend with the given labels.
@param [Array<LegendItem>] The labels to write as part of the legend. | [
"Draws",
"the",
"graph",
"legend",
"with",
"the",
"given",
"labels",
"."
] | c8fa02c185d41b880219bc72707b9d72a54b374b | https://github.com/Fullscreen/squid/blob/c8fa02c185d41b880219bc72707b9d72a54b374b/lib/squid/plotter.rb#L25-L37 |
20,292 | Fullscreen/squid | lib/squid/plotter.rb | Squid.Plotter.horizontal_line | 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 | def horizontal_line(y, options = {})
with options do
at = y + @bottom
@pdf.stroke_horizontal_line left, @pdf.bounds.right - right, at: at
end
end | [
"def",
"horizontal_line",
"(",
"y",
",",
"options",
"=",
"{",
"}",
")",
"with",
"options",
"do",
"at",
"=",
"y",
"+",
"@bottom",
"@pdf",
".",
"stroke_horizontal_line",
"left",
",",
"@pdf",
".",
"bounds",
".",
"right",
"-",
"right",
",",
"at",
":",
"a... | Draws a horizontal line. | [
"Draws",
"a",
"horizontal",
"line",
"."
] | c8fa02c185d41b880219bc72707b9d72a54b374b | https://github.com/Fullscreen/squid/blob/c8fa02c185d41b880219bc72707b9d72a54b374b/lib/squid/plotter.rb#L45-L50 |
20,293 | Fullscreen/squid | lib/squid/plotter.rb | Squid.Plotter.legend_item | 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 | 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... | [
"def",
"legend_item",
"(",
"label",
",",
"x",
",",
"color",
",",
"options",
")",
"size",
",",
"symbol_padding",
",",
"entry_padding",
"=",
"5",
",",
"3",
",",
"12",
"x",
"-=",
"@pdf",
".",
"width_of",
"(",
"label",
",",
"size",
":",
"7",
")",
".",
... | Draws a single item of the legend, which includes the label and the
symbol with the matching color. Labels are written from right to left.
@param | [
"Draws",
"a",
"single",
"item",
"of",
"the",
"legend",
"which",
"includes",
"the",
"label",
"and",
"the",
"symbol",
"with",
"the",
"matching",
"color",
".",
"Labels",
"are",
"written",
"from",
"right",
"to",
"left",
"."
] | c8fa02c185d41b880219bc72707b9d72a54b374b | https://github.com/Fullscreen/squid/blob/c8fa02c185d41b880219bc72707b9d72a54b374b/lib/squid/plotter.rb#L172-L181 |
20,294 | Fullscreen/squid | lib/squid/plotter.rb | Squid.Plotter.with | 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 | 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
... | [
"def",
"with",
"(",
"new_values",
"=",
"{",
"}",
")",
"transparency",
"=",
"new_values",
".",
"delete",
"(",
":transparency",
")",
"{",
"1.0",
"}",
"old_values",
"=",
"Hash",
"[",
"new_values",
".",
"map",
"{",
"|",
"k",
",",
"_",
"|",
"[",
"k",
",... | Convenience method to wrap a block by setting and unsetting a Prawn
property such as line_width. | [
"Convenience",
"method",
"to",
"wrap",
"a",
"block",
"by",
"setting",
"and",
"unsetting",
"a",
"Prawn",
"property",
"such",
"as",
"line_width",
"."
] | c8fa02c185d41b880219bc72707b9d72a54b374b | https://github.com/Fullscreen/squid/blob/c8fa02c185d41b880219bc72707b9d72a54b374b/lib/squid/plotter.rb#L185-L193 |
20,295 | poise/application | lib/poise_application/utils.rb | PoiseApplication.Utils.primary_group_for | 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 | 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
... | [
"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",
... | Try to find the primary group name for a given user.
@param user [String, Integer] User to check, if given as an integer this
is used as a UID, otherwise it is the username.
@return [String]
@example
attribute(:group, kind_of: [String, Integer], default: lazy { PoiseApplication::Utils.primary_group_for(user) ... | [
"Try",
"to",
"find",
"the",
"primary",
"group",
"name",
"for",
"a",
"given",
"user",
"."
] | 1c9d273210c5fbbde4329d8809368daeac4711ff | https://github.com/poise/application/blob/1c9d273210c5fbbde4329d8809368daeac4711ff/lib/poise_application/utils.rb#L36-L49 |
20,296 | cmeerbeek/fluent-plugin-splunkhec | lib/fluent/plugin/out_splunkhec.rb | Fluent::Plugin.SplunkHECOutput.write | 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 | 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... | [
"def",
"write",
"(",
"chunk",
")",
"body",
"=",
"''",
"chunk",
".",
"msgpack_each",
"{",
"|",
"(",
"tag",
",",
"time",
",",
"record",
")",
"|",
"# define index and sourcetype dynamically",
"begin",
"index",
"=",
"expand_param",
"(",
"@index",
",",
"tag",
"... | Loop through all records and sent them to Splunk | [
"Loop",
"through",
"all",
"records",
"and",
"sent",
"them",
"to",
"Splunk"
] | 2382bf7e8f8e6dd92679e4060896434b0d7e3d1d | https://github.com/cmeerbeek/fluent-plugin-splunkhec/blob/2382bf7e8f8e6dd92679e4060896434b0d7e3d1d/lib/fluent/plugin/out_splunkhec.rb#L102-L157 |
20,297 | poise/poise | lib/poise/utils.rb | Poise.Utils.find_cookbook_name | 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 | 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)
... | [
"def",
"find_cookbook_name",
"(",
"run_context",
",",
"filename",
")",
"possibles",
"=",
"{",
"}",
"Poise",
".",
"debug",
"(",
"\"[Poise] Checking cookbook for #{filename.inspect}\"",
")",
"run_context",
".",
"cookbook_collection",
".",
"each",
"do",
"|",
"name",
",... | Find the cookbook name for a given filename. The can used to find the
cookbook that corresponds to a caller of a file.
@param run_context [Chef::RunContext] Context to check.
@param filename [String] Absolute filename to check for.
@return [String]
@example
def my_thing
caller_filename = caller.first.spli... | [
"Find",
"the",
"cookbook",
"name",
"for",
"a",
"given",
"filename",
".",
"The",
"can",
"used",
"to",
"find",
"the",
"cookbook",
"that",
"corresponds",
"to",
"a",
"caller",
"of",
"a",
"file",
"."
] | 07c33d4f844cf6e97cf349a12f06448d0db9a8d2 | https://github.com/poise/poise/blob/07c33d4f844cf6e97cf349a12f06448d0db9a8d2/lib/poise/utils.rb#L40-L72 |
20,298 | poise/poise | lib/poise/utils.rb | Poise.Utils.ancestor_send | 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 | 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 ... | [
"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",
"ob... | Try to find an ancestor to call a method on.
@since 2.2.3
@since 2.3.0
Added ignore parameter.
@param obj [Object] Self from the caller.
@param msg [Symbol] Method to try to call.
@param args [Array<Object>] Method arguments.
@param default [Object] Default return value if no valid ancestor exists.
@param ig... | [
"Try",
"to",
"find",
"an",
"ancestor",
"to",
"call",
"a",
"method",
"on",
"."
] | 07c33d4f844cf6e97cf349a12f06448d0db9a8d2 | https://github.com/poise/poise/blob/07c33d4f844cf6e97cf349a12f06448d0db9a8d2/lib/poise/utils.rb#L87-L106 |
20,299 | poise/poise | lib/poise/utils.rb | Poise.Utils.parameterized_module | 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 | 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... | [
"def",
"parameterized_module",
"(",
"mod",
",",
"&",
"block",
")",
"raise",
"Poise",
"::",
"Error",
".",
"new",
"(",
"\"Cannot parameterize an anonymous module\"",
")",
"unless",
"mod",
".",
"name",
"&&",
"!",
"mod",
".",
"name",
".",
"empty?",
"parent_name_pa... | Create a helper to invoke a module with some parameters.
@since 2.3.0
@param mod [Module] The module to wrap.
@param block [Proc] The module to implement to parameterization.
@return [void]
@example
module MyMixin
def self.my_mixin_name(name)
# ...
end
end
Poise::Utils.parameterized_mod... | [
"Create",
"a",
"helper",
"to",
"invoke",
"a",
"module",
"with",
"some",
"parameters",
"."
] | 07c33d4f844cf6e97cf349a12f06448d0db9a8d2 | https://github.com/poise/poise/blob/07c33d4f844cf6e97cf349a12f06448d0db9a8d2/lib/poise/utils.rb#L124-L157 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.