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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
mojolingo/sippy_cup | lib/sippy_cup/scenario.rb | SippyCup.Scenario.call_length_repartition | def call_length_repartition(min, max, interval)
partition_table 'CallLengthRepartition', min.to_i, max.to_i, interval.to_i
end | ruby | def call_length_repartition(min, max, interval)
partition_table 'CallLengthRepartition', min.to_i, max.to_i, interval.to_i
end | [
"def",
"call_length_repartition",
"(",
"min",
",",
"max",
",",
"interval",
")",
"partition_table",
"'CallLengthRepartition'",
",",
"min",
".",
"to_i",
",",
"max",
".",
"to_i",
",",
"interval",
".",
"to_i",
"end"
] | Create partition table for Call Length
@param [Integer] min An value specifying the minimum time in milliseconds for the table
@param [Integer] max An value specifying the maximum time in milliseconds for the table
@param [Integer] interval An value specifying the interval in milliseconds for the table | [
"Create",
"partition",
"table",
"for",
"Call",
"Length"
] | f778cdf429dc9a95884d05669dd1ed04b07134e4 | https://github.com/mojolingo/sippy_cup/blob/f778cdf429dc9a95884d05669dd1ed04b07134e4/lib/sippy_cup/scenario.rb#L637-L639 | train |
mojolingo/sippy_cup | lib/sippy_cup/scenario.rb | SippyCup.Scenario.response_time_repartition | def response_time_repartition(min, max, interval)
partition_table 'ResponseTimeRepartition', min.to_i, max.to_i, interval.to_i
end | ruby | def response_time_repartition(min, max, interval)
partition_table 'ResponseTimeRepartition', min.to_i, max.to_i, interval.to_i
end | [
"def",
"response_time_repartition",
"(",
"min",
",",
"max",
",",
"interval",
")",
"partition_table",
"'ResponseTimeRepartition'",
",",
"min",
".",
"to_i",
",",
"max",
".",
"to_i",
",",
"interval",
".",
"to_i",
"end"
] | Create partition table for Response Time
@param [Integer] min An value specifying the minimum time in milliseconds for the table
@param [Integer] max An value specifying the maximum time in milliseconds for the table
@param [Integer] interval An value specifying the interval in milliseconds for the table | [
"Create",
"partition",
"table",
"for",
"Response",
"Time"
] | f778cdf429dc9a95884d05669dd1ed04b07134e4 | https://github.com/mojolingo/sippy_cup/blob/f778cdf429dc9a95884d05669dd1ed04b07134e4/lib/sippy_cup/scenario.rb#L646-L648 | train |
mojolingo/sippy_cup | lib/sippy_cup/scenario.rb | SippyCup.Scenario.to_xml | def to_xml(options = {})
pcap_path = options[:pcap_path]
docdup = doc.dup
# Not removing in reverse would most likely remove the wrong
# nodes because of changing indices.
@media_nodes.reverse.each do |nop|
nopdup = docdup.xpath(nop.path)
if pcap_path.nil? or @media.blank... | ruby | def to_xml(options = {})
pcap_path = options[:pcap_path]
docdup = doc.dup
# Not removing in reverse would most likely remove the wrong
# nodes because of changing indices.
@media_nodes.reverse.each do |nop|
nopdup = docdup.xpath(nop.path)
if pcap_path.nil? or @media.blank... | [
"def",
"to_xml",
"(",
"options",
"=",
"{",
"}",
")",
"pcap_path",
"=",
"options",
"[",
":pcap_path",
"]",
"docdup",
"=",
"doc",
".",
"dup",
"@media_nodes",
".",
"reverse",
".",
"each",
"do",
"|",
"nop",
"|",
"nopdup",
"=",
"docdup",
".",
"xpath",
"("... | Dump the scenario to a SIPp XML string
@return [String] the SIPp XML scenario | [
"Dump",
"the",
"scenario",
"to",
"a",
"SIPp",
"XML",
"string"
] | f778cdf429dc9a95884d05669dd1ed04b07134e4 | https://github.com/mojolingo/sippy_cup/blob/f778cdf429dc9a95884d05669dd1ed04b07134e4/lib/sippy_cup/scenario.rb#L654-L679 | train |
mojolingo/sippy_cup | lib/sippy_cup/scenario.rb | SippyCup.Scenario.compile! | def compile!
unless @media.blank?
print "Compiling media to #{@filename}.pcap..."
compile_media.to_file filename: "#{@filename}.pcap"
puts "done."
end
scenario_filename = "#{@filename}.xml"
print "Compiling scenario to #{scenario_filename}..."
File.open scenario_fi... | ruby | def compile!
unless @media.blank?
print "Compiling media to #{@filename}.pcap..."
compile_media.to_file filename: "#{@filename}.pcap"
puts "done."
end
scenario_filename = "#{@filename}.xml"
print "Compiling scenario to #{scenario_filename}..."
File.open scenario_fi... | [
"def",
"compile!",
"unless",
"@media",
".",
"blank?",
"print",
"\"Compiling media to #{@filename}.pcap...\"",
"compile_media",
".",
"to_file",
"filename",
":",
"\"#{@filename}.pcap\"",
"puts",
"\"done.\"",
"end",
"scenario_filename",
"=",
"\"#{@filename}.xml\"",
"print",
"\... | Compile the scenario and its media to disk
Writes the SIPp scenario file to disk at {filename}.xml, and the PCAP media to {filename}.pcap if applicable.
{filename} is taken from the :filename option when creating the scenario, or falls back to a down-snake-cased version of the scenario name.
@return [String] the p... | [
"Compile",
"the",
"scenario",
"and",
"its",
"media",
"to",
"disk"
] | f778cdf429dc9a95884d05669dd1ed04b07134e4 | https://github.com/mojolingo/sippy_cup/blob/f778cdf429dc9a95884d05669dd1ed04b07134e4/lib/sippy_cup/scenario.rb#L697-L712 | train |
mojolingo/sippy_cup | lib/sippy_cup/xml_scenario.rb | SippyCup.XMLScenario.to_tmpfiles | def to_tmpfiles
scenario_file = Tempfile.new 'scenario'
scenario_file.write @xml
scenario_file.rewind
if @media
media_file = Tempfile.new 'media'
media_file.write @media
media_file.rewind
else
media_file = nil
end
{scenario: scenario_file, medi... | ruby | def to_tmpfiles
scenario_file = Tempfile.new 'scenario'
scenario_file.write @xml
scenario_file.rewind
if @media
media_file = Tempfile.new 'media'
media_file.write @media
media_file.rewind
else
media_file = nil
end
{scenario: scenario_file, medi... | [
"def",
"to_tmpfiles",
"scenario_file",
"=",
"Tempfile",
".",
"new",
"'scenario'",
"scenario_file",
".",
"write",
"@xml",
"scenario_file",
".",
"rewind",
"if",
"@media",
"media_file",
"=",
"Tempfile",
".",
"new",
"'media'",
"media_file",
".",
"write",
"@media",
"... | Create a scenario instance
@param [String] name The scenario's name
@param [String] xml The XML document representing the scenario
@param [String] media The media to be invoked by the scenario in PCAP format
@param [Hash] args options to customise the scenario. @see Scenario#initialize.
Write compiled Scenario ... | [
"Create",
"a",
"scenario",
"instance"
] | f778cdf429dc9a95884d05669dd1ed04b07134e4 | https://github.com/mojolingo/sippy_cup/blob/f778cdf429dc9a95884d05669dd1ed04b07134e4/lib/sippy_cup/xml_scenario.rb#L34-L48 | train |
mojolingo/sippy_cup | lib/sippy_cup/runner.rb | SippyCup.Runner.wait | def wait
exit_status = Process.wait2 @sipp_pid.to_i
@err_rd.close if @err_rd
@stdout_rd.close if @stdout_rd
final_result = process_exit_status exit_status, @stderr_buffer
if final_result
@logger.info "Test completed successfully!"
else
@logger.info "Test completed suc... | ruby | def wait
exit_status = Process.wait2 @sipp_pid.to_i
@err_rd.close if @err_rd
@stdout_rd.close if @stdout_rd
final_result = process_exit_status exit_status, @stderr_buffer
if final_result
@logger.info "Test completed successfully!"
else
@logger.info "Test completed suc... | [
"def",
"wait",
"exit_status",
"=",
"Process",
".",
"wait2",
"@sipp_pid",
".",
"to_i",
"@err_rd",
".",
"close",
"if",
"@err_rd",
"@stdout_rd",
".",
"close",
"if",
"@stdout_rd",
"final_result",
"=",
"process_exit_status",
"exit_status",
",",
"@stderr_buffer",
"if",
... | Waits for the runner to finish execution
@raises Errno::ENOENT when the SIPp executable cannot be found
@raises SippyCup::ExitOnInternalCommand when SIPp exits on an internal command. Calls may have been processed
@raises SippyCup::NoCallsProcessed when SIPp exit normally, but has processed no calls
@raises SippyC... | [
"Waits",
"for",
"the",
"runner",
"to",
"finish",
"execution"
] | f778cdf429dc9a95884d05669dd1ed04b07134e4 | https://github.com/mojolingo/sippy_cup/blob/f778cdf429dc9a95884d05669dd1ed04b07134e4/lib/sippy_cup/runner.rb#L70-L85 | train |
notahat/machinist | lib/machinist/machinable.rb | Machinist.Machinable.blueprint | def blueprint(name = :master, &block)
@blueprints ||= {}
if block_given?
parent = (name == :master ? superclass : self) # Where should we look for the parent blueprint?
@blueprints[name] = blueprint_class.new(self, :parent => parent, &block)
end
@blueprints[name]
end | ruby | def blueprint(name = :master, &block)
@blueprints ||= {}
if block_given?
parent = (name == :master ? superclass : self) # Where should we look for the parent blueprint?
@blueprints[name] = blueprint_class.new(self, :parent => parent, &block)
end
@blueprints[name]
end | [
"def",
"blueprint",
"(",
"name",
"=",
":master",
",",
"&",
"block",
")",
"@blueprints",
"||=",
"{",
"}",
"if",
"block_given?",
"parent",
"=",
"(",
"name",
"==",
":master",
"?",
"superclass",
":",
"self",
")",
"@blueprints",
"[",
"name",
"]",
"=",
"blue... | Define a blueprint with the given name for this class.
e.g.
Post.blueprint do
title { "A Post" }
body { "Lorem ipsum..." }
end
If you provide the +name+ argument, a named blueprint will be created.
See the +blueprint_name+ argument to the make method. | [
"Define",
"a",
"blueprint",
"with",
"the",
"given",
"name",
"for",
"this",
"class",
"."
] | dba78a430cd67646a270393c4adfa19a5516f569 | https://github.com/notahat/machinist/blob/dba78a430cd67646a270393c4adfa19a5516f569/lib/machinist/machinable.rb#L15-L22 | train |
notahat/machinist | lib/machinist/machinable.rb | Machinist.Machinable.make! | def make!(*args)
decode_args_to_make(*args) do |blueprint, attributes|
raise BlueprintCantSaveError.new(blueprint) unless blueprint.respond_to?(:make!)
blueprint.make!(attributes)
end
end | ruby | def make!(*args)
decode_args_to_make(*args) do |blueprint, attributes|
raise BlueprintCantSaveError.new(blueprint) unless blueprint.respond_to?(:make!)
blueprint.make!(attributes)
end
end | [
"def",
"make!",
"(",
"*",
"args",
")",
"decode_args_to_make",
"(",
"*",
"args",
")",
"do",
"|",
"blueprint",
",",
"attributes",
"|",
"raise",
"BlueprintCantSaveError",
".",
"new",
"(",
"blueprint",
")",
"unless",
"blueprint",
".",
"respond_to?",
"(",
":make!... | Construct and save an object from a blueprint, if the class allows saving.
:call-seq:
make!([count], [blueprint_name], [attributes = {}])
Arguments are the same as for make. | [
"Construct",
"and",
"save",
"an",
"object",
"from",
"a",
"blueprint",
"if",
"the",
"class",
"allows",
"saving",
"."
] | dba78a430cd67646a270393c4adfa19a5516f569 | https://github.com/notahat/machinist/blob/dba78a430cd67646a270393c4adfa19a5516f569/lib/machinist/machinable.rb#L49-L54 | train |
notahat/machinist | lib/machinist/machinable.rb | Machinist.Machinable.decode_args_to_make | def decode_args_to_make(*args) #:nodoc:
shift_arg = lambda {|klass| args.shift if args.first.is_a?(klass) }
count = shift_arg[Fixnum]
name = shift_arg[Symbol] || :master
attributes = shift_arg[Hash] || {}
raise ArgumentError.new("Couldn't understand arguments") unless args.emp... | ruby | def decode_args_to_make(*args) #:nodoc:
shift_arg = lambda {|klass| args.shift if args.first.is_a?(klass) }
count = shift_arg[Fixnum]
name = shift_arg[Symbol] || :master
attributes = shift_arg[Hash] || {}
raise ArgumentError.new("Couldn't understand arguments") unless args.emp... | [
"def",
"decode_args_to_make",
"(",
"*",
"args",
")",
"shift_arg",
"=",
"lambda",
"{",
"|",
"klass",
"|",
"args",
".",
"shift",
"if",
"args",
".",
"first",
".",
"is_a?",
"(",
"klass",
")",
"}",
"count",
"=",
"shift_arg",
"[",
"Fixnum",
"]",
"name",
"=... | Parses the arguments to make.
Yields a blueprint and an attributes hash to the block, which should
construct an object from them. The block may be called multiple times to
construct multiple objects. | [
"Parses",
"the",
"arguments",
"to",
"make",
"."
] | dba78a430cd67646a270393c4adfa19a5516f569 | https://github.com/notahat/machinist/blob/dba78a430cd67646a270393c4adfa19a5516f569/lib/machinist/machinable.rb#L76-L92 | train |
notahat/machinist | lib/machinist/blueprint.rb | Machinist.Blueprint.make | def make(attributes = {})
lathe = lathe_class.new(@klass, new_serial_number, attributes)
lathe.instance_eval(&@block)
each_ancestor {|blueprint| lathe.instance_eval(&blueprint.block) }
lathe.object
end | ruby | def make(attributes = {})
lathe = lathe_class.new(@klass, new_serial_number, attributes)
lathe.instance_eval(&@block)
each_ancestor {|blueprint| lathe.instance_eval(&blueprint.block) }
lathe.object
end | [
"def",
"make",
"(",
"attributes",
"=",
"{",
"}",
")",
"lathe",
"=",
"lathe_class",
".",
"new",
"(",
"@klass",
",",
"new_serial_number",
",",
"attributes",
")",
"lathe",
".",
"instance_eval",
"(",
"&",
"@block",
")",
"each_ancestor",
"{",
"|",
"blueprint",
... | Generate an object from this blueprint.
Pass in attributes to override values defined in the blueprint. | [
"Generate",
"an",
"object",
"from",
"this",
"blueprint",
"."
] | dba78a430cd67646a270393c4adfa19a5516f569 | https://github.com/notahat/machinist/blob/dba78a430cd67646a270393c4adfa19a5516f569/lib/machinist/blueprint.rb#L23-L30 | train |
zk-ruby/zookeeper | lib/zookeeper/request_registry.rb | Zookeeper.RequestRegistry.get_watcher | def get_watcher(req_id, opts={})
@mutex.synchronize do
if Constants::ZKRB_GLOBAL_CB_REQ == req_id
{ :watcher => @default_watcher, :watcher_context => nil }
elsif opts[:keep]
@watcher_reqs[req_id]
else
@watcher_reqs.delete(req_id)
end
... | ruby | def get_watcher(req_id, opts={})
@mutex.synchronize do
if Constants::ZKRB_GLOBAL_CB_REQ == req_id
{ :watcher => @default_watcher, :watcher_context => nil }
elsif opts[:keep]
@watcher_reqs[req_id]
else
@watcher_reqs.delete(req_id)
end
... | [
"def",
"get_watcher",
"(",
"req_id",
",",
"opts",
"=",
"{",
"}",
")",
"@mutex",
".",
"synchronize",
"do",
"if",
"Constants",
"::",
"ZKRB_GLOBAL_CB_REQ",
"==",
"req_id",
"{",
":watcher",
"=>",
"@default_watcher",
",",
":watcher_context",
"=>",
"nil",
"}",
"el... | Return the watcher hash associated with the req_id. If the req_id
is the ZKRB_GLOBAL_CB_REQ, then does not clear the req from the internal
store, otherwise the req_id is removed. | [
"Return",
"the",
"watcher",
"hash",
"associated",
"with",
"the",
"req_id",
".",
"If",
"the",
"req_id",
"is",
"the",
"ZKRB_GLOBAL_CB_REQ",
"then",
"does",
"not",
"clear",
"the",
"req",
"from",
"the",
"internal",
"store",
"otherwise",
"the",
"req_id",
"is",
"r... | b99cb25195b8c947be0eb82141cc261eec9c8724 | https://github.com/zk-ruby/zookeeper/blob/b99cb25195b8c947be0eb82141cc261eec9c8724/lib/zookeeper/request_registry.rb#L82-L92 | train |
zk-ruby/zookeeper | ext/c_zookeeper.rb | Zookeeper.CZookeeper.wait_until_connected | def wait_until_connected(timeout=10)
time_to_stop = timeout ? Time.now + timeout : nil
return false unless wait_until_running(timeout)
@state_mutex.synchronize do
while true
if timeout
now = Time.now
break if (@state == ZOO_CONNECTED_STATE) || unhealthy? || (now > time_t... | ruby | def wait_until_connected(timeout=10)
time_to_stop = timeout ? Time.now + timeout : nil
return false unless wait_until_running(timeout)
@state_mutex.synchronize do
while true
if timeout
now = Time.now
break if (@state == ZOO_CONNECTED_STATE) || unhealthy? || (now > time_t... | [
"def",
"wait_until_connected",
"(",
"timeout",
"=",
"10",
")",
"time_to_stop",
"=",
"timeout",
"?",
"Time",
".",
"now",
"+",
"timeout",
":",
"nil",
"return",
"false",
"unless",
"wait_until_running",
"(",
"timeout",
")",
"@state_mutex",
".",
"synchronize",
"do"... | this implementation is gross, but i don't really see another way of doing it
without more grossness
returns true if we're connected, false if we're not
if timeout is nil, we never time out, and wait forever for CONNECTED state | [
"this",
"implementation",
"is",
"gross",
"but",
"i",
"don",
"t",
"really",
"see",
"another",
"way",
"of",
"doing",
"it",
"without",
"more",
"grossness"
] | b99cb25195b8c947be0eb82141cc261eec9c8724 | https://github.com/zk-ruby/zookeeper/blob/b99cb25195b8c947be0eb82141cc261eec9c8724/ext/c_zookeeper.rb#L178-L198 | train |
zk-ruby/zookeeper | ext/c_zookeeper.rb | Zookeeper.CZookeeper.submit_and_block | def submit_and_block(meth, *args)
@mutex.synchronize do
raise Exceptions::NotConnected if unhealthy?
end
cnt = Continuation.new(meth, *args)
@reg.synchronize do |r|
if meth == :state
r.state_check << cnt
else
r.pending << cnt
end
end
... | ruby | def submit_and_block(meth, *args)
@mutex.synchronize do
raise Exceptions::NotConnected if unhealthy?
end
cnt = Continuation.new(meth, *args)
@reg.synchronize do |r|
if meth == :state
r.state_check << cnt
else
r.pending << cnt
end
end
... | [
"def",
"submit_and_block",
"(",
"meth",
",",
"*",
"args",
")",
"@mutex",
".",
"synchronize",
"do",
"raise",
"Exceptions",
"::",
"NotConnected",
"if",
"unhealthy?",
"end",
"cnt",
"=",
"Continuation",
".",
"new",
"(",
"meth",
",",
"*",
"args",
")",
"@reg",
... | submits a job for processing
blocks the caller until result has returned | [
"submits",
"a",
"job",
"for",
"processing",
"blocks",
"the",
"caller",
"until",
"result",
"has",
"returned"
] | b99cb25195b8c947be0eb82141cc261eec9c8724 | https://github.com/zk-ruby/zookeeper/blob/b99cb25195b8c947be0eb82141cc261eec9c8724/ext/c_zookeeper.rb#L217-L232 | train |
zk-ruby/zookeeper | lib/zookeeper/continuation.rb | Zookeeper.Continuation.call | def call(hash)
logger.debug { "continuation req_id #{req_id}, got hash: #{hash.inspect}" }
@rval = hash.values_at(*METH_TO_ASYNC_RESULT_KEYS.fetch(meth))
logger.debug { "delivering result #{@rval.inspect}" }
deliver!
end | ruby | def call(hash)
logger.debug { "continuation req_id #{req_id}, got hash: #{hash.inspect}" }
@rval = hash.values_at(*METH_TO_ASYNC_RESULT_KEYS.fetch(meth))
logger.debug { "delivering result #{@rval.inspect}" }
deliver!
end | [
"def",
"call",
"(",
"hash",
")",
"logger",
".",
"debug",
"{",
"\"continuation req_id #{req_id}, got hash: #{hash.inspect}\"",
"}",
"@rval",
"=",
"hash",
".",
"values_at",
"(",
"*",
"METH_TO_ASYNC_RESULT_KEYS",
".",
"fetch",
"(",
"meth",
")",
")",
"logger",
".",
... | receive the response from the server, set @rval, notify caller | [
"receive",
"the",
"response",
"from",
"the",
"server",
"set"
] | b99cb25195b8c947be0eb82141cc261eec9c8724 | https://github.com/zk-ruby/zookeeper/blob/b99cb25195b8c947be0eb82141cc261eec9c8724/lib/zookeeper/continuation.rb#L141-L146 | train |
zk-ruby/zookeeper | ext/zookeeper_base.rb | Zookeeper.ZookeeperBase.close | def close
sd_thread = nil
@mutex.synchronize do
return unless @czk
inst, @czk = @czk, nil
sd_thread = Thread.new(inst) do |_inst|
stop_dispatch_thread!
_inst.close
end
end
# if we're on the event dispatch thread for some stupid reason, then don't join
u... | ruby | def close
sd_thread = nil
@mutex.synchronize do
return unless @czk
inst, @czk = @czk, nil
sd_thread = Thread.new(inst) do |_inst|
stop_dispatch_thread!
_inst.close
end
end
# if we're on the event dispatch thread for some stupid reason, then don't join
u... | [
"def",
"close",
"sd_thread",
"=",
"nil",
"@mutex",
".",
"synchronize",
"do",
"return",
"unless",
"@czk",
"inst",
",",
"@czk",
"=",
"@czk",
",",
"nil",
"sd_thread",
"=",
"Thread",
".",
"new",
"(",
"inst",
")",
"do",
"|",
"_inst",
"|",
"stop_dispatch_threa... | close the connection normally, stops the dispatch thread and closes the
underlying connection cleanly | [
"close",
"the",
"connection",
"normally",
"stops",
"the",
"dispatch",
"thread",
"and",
"closes",
"the",
"underlying",
"connection",
"cleanly"
] | b99cb25195b8c947be0eb82141cc261eec9c8724 | https://github.com/zk-ruby/zookeeper/blob/b99cb25195b8c947be0eb82141cc261eec9c8724/ext/zookeeper_base.rb#L129-L151 | train |
zk-ruby/zookeeper | ext/zookeeper_base.rb | Zookeeper.ZookeeperBase.create | def create(*args)
# since we don't care about the inputs, just glob args
rc, new_path = czk.create(*args)
[rc, @req_registry.strip_chroot_from(new_path)]
end | ruby | def create(*args)
# since we don't care about the inputs, just glob args
rc, new_path = czk.create(*args)
[rc, @req_registry.strip_chroot_from(new_path)]
end | [
"def",
"create",
"(",
"*",
"args",
")",
"rc",
",",
"new_path",
"=",
"czk",
".",
"create",
"(",
"*",
"args",
")",
"[",
"rc",
",",
"@req_registry",
".",
"strip_chroot_from",
"(",
"new_path",
")",
"]",
"end"
] | the C lib doesn't strip the chroot path off of returned path values, which
is pretty damn annoying. this is used to clean things up. | [
"the",
"C",
"lib",
"doesn",
"t",
"strip",
"the",
"chroot",
"path",
"off",
"of",
"returned",
"path",
"values",
"which",
"is",
"pretty",
"damn",
"annoying",
".",
"this",
"is",
"used",
"to",
"clean",
"things",
"up",
"."
] | b99cb25195b8c947be0eb82141cc261eec9c8724 | https://github.com/zk-ruby/zookeeper/blob/b99cb25195b8c947be0eb82141cc261eec9c8724/ext/zookeeper_base.rb#L155-L159 | train |
zk-ruby/zookeeper | ext/zookeeper_base.rb | Zookeeper.ZookeeperBase.strip_chroot_from | def strip_chroot_from(path)
return path unless (chrooted? and path and path.start_with?(chroot_path))
path[chroot_path.length..-1]
end | ruby | def strip_chroot_from(path)
return path unless (chrooted? and path and path.start_with?(chroot_path))
path[chroot_path.length..-1]
end | [
"def",
"strip_chroot_from",
"(",
"path",
")",
"return",
"path",
"unless",
"(",
"chrooted?",
"and",
"path",
"and",
"path",
".",
"start_with?",
"(",
"chroot_path",
")",
")",
"path",
"[",
"chroot_path",
".",
"length",
"..",
"-",
"1",
"]",
"end"
] | if we're chrooted, this method will strip the chroot prefix from +path+ | [
"if",
"we",
"re",
"chrooted",
"this",
"method",
"will",
"strip",
"the",
"chroot",
"prefix",
"from",
"+",
"path",
"+"
] | b99cb25195b8c947be0eb82141cc261eec9c8724 | https://github.com/zk-ruby/zookeeper/blob/b99cb25195b8c947be0eb82141cc261eec9c8724/ext/zookeeper_base.rb#L227-L230 | train |
zk-ruby/zookeeper | spec/support/zookeeper_spec_helpers.rb | Zookeeper.SpecHelpers.rm_rf | def rm_rf(z, path)
z.get_children(:path => path).tap do |h|
if h[:rc].zero?
h[:children].each do |child|
rm_rf(z, File.join(path, child))
end
elsif h[:rc] == ZNONODE
# no-op
else
raise "Oh noes! unexpected return value! #{h.inspect}"
... | ruby | def rm_rf(z, path)
z.get_children(:path => path).tap do |h|
if h[:rc].zero?
h[:children].each do |child|
rm_rf(z, File.join(path, child))
end
elsif h[:rc] == ZNONODE
# no-op
else
raise "Oh noes! unexpected return value! #{h.inspect}"
... | [
"def",
"rm_rf",
"(",
"z",
",",
"path",
")",
"z",
".",
"get_children",
"(",
":path",
"=>",
"path",
")",
".",
"tap",
"do",
"|",
"h",
"|",
"if",
"h",
"[",
":rc",
"]",
".",
"zero?",
"h",
"[",
":children",
"]",
".",
"each",
"do",
"|",
"child",
"|"... | this is not as safe as the one in ZK, just to be used to clean up
when we're the only one adjusting a particular path | [
"this",
"is",
"not",
"as",
"safe",
"as",
"the",
"one",
"in",
"ZK",
"just",
"to",
"be",
"used",
"to",
"clean",
"up",
"when",
"we",
"re",
"the",
"only",
"one",
"adjusting",
"a",
"particular",
"path"
] | b99cb25195b8c947be0eb82141cc261eec9c8724 | https://github.com/zk-ruby/zookeeper/blob/b99cb25195b8c947be0eb82141cc261eec9c8724/spec/support/zookeeper_spec_helpers.rb#L37-L57 | train |
cubesystems/releaf | releaf-content/lib/releaf/content/route.rb | Releaf::Content.Route.params | def params(method_or_path, options = {})
method_or_path = method_or_path.to_s
[
path_for(method_or_path, options),
options_for(method_or_path, options)
]
end | ruby | def params(method_or_path, options = {})
method_or_path = method_or_path.to_s
[
path_for(method_or_path, options),
options_for(method_or_path, options)
]
end | [
"def",
"params",
"(",
"method_or_path",
",",
"options",
"=",
"{",
"}",
")",
"method_or_path",
"=",
"method_or_path",
".",
"to_s",
"[",
"path_for",
"(",
"method_or_path",
",",
"options",
")",
",",
"options_for",
"(",
"method_or_path",
",",
"options",
")",
"]"... | Return node route params which can be used in Rails route options
@param method_or_path [String] string with action and controller for route (Ex. home#index)
@param options [Hash] options to merge with internally built params. Passed params overrides route params.
@return [Hash] route options. Will return at least ... | [
"Return",
"node",
"route",
"params",
"which",
"can",
"be",
"used",
"in",
"Rails",
"route",
"options"
] | 5ea615abcf6e62afbbf82259d0aa533221d6de08 | https://github.com/cubesystems/releaf/blob/5ea615abcf6e62afbbf82259d0aa533221d6de08/releaf-content/lib/releaf/content/route.rb#L18-L24 | train |
cubesystems/releaf | releaf-content/lib/releaf/content/node.rb | Releaf::Content.Node.maintain_name | def maintain_name
postfix = nil
total_count = 0
while self.class.where(parent_id: parent_id, name: "#{name}#{postfix}").where("id != ?", id.to_i).exists? do
total_count += 1
postfix = "(#{total_count})"
end
if postfix
self.name = "#{name}#{postfix}... | ruby | def maintain_name
postfix = nil
total_count = 0
while self.class.where(parent_id: parent_id, name: "#{name}#{postfix}").where("id != ?", id.to_i).exists? do
total_count += 1
postfix = "(#{total_count})"
end
if postfix
self.name = "#{name}#{postfix}... | [
"def",
"maintain_name",
"postfix",
"=",
"nil",
"total_count",
"=",
"0",
"while",
"self",
".",
"class",
".",
"where",
"(",
"parent_id",
":",
"parent_id",
",",
"name",
":",
"\"#{name}#{postfix}\"",
")",
".",
"where",
"(",
"\"id != ?\"",
",",
"id",
".",
"to_i... | Maintain unique name within parent_id scope.
If name is not unique add numeric postfix. | [
"Maintain",
"unique",
"name",
"within",
"parent_id",
"scope",
".",
"If",
"name",
"is",
"not",
"unique",
"add",
"numeric",
"postfix",
"."
] | 5ea615abcf6e62afbbf82259d0aa533221d6de08 | https://github.com/cubesystems/releaf/blob/5ea615abcf6e62afbbf82259d0aa533221d6de08/releaf-content/lib/releaf/content/node.rb#L73-L85 | train |
cubesystems/releaf | releaf-content/lib/releaf/content/node.rb | Releaf::Content.Node.maintain_slug | def maintain_slug
postfix = nil
total_count = 0
while self.class.where(parent_id: parent_id, slug: "#{slug}#{postfix}").where("id != ?", id.to_i).exists? do
total_count += 1
postfix = "-#{total_count}"
end
if postfix
self.slug = "#{slug}#{postfix}"... | ruby | def maintain_slug
postfix = nil
total_count = 0
while self.class.where(parent_id: parent_id, slug: "#{slug}#{postfix}").where("id != ?", id.to_i).exists? do
total_count += 1
postfix = "-#{total_count}"
end
if postfix
self.slug = "#{slug}#{postfix}"... | [
"def",
"maintain_slug",
"postfix",
"=",
"nil",
"total_count",
"=",
"0",
"while",
"self",
".",
"class",
".",
"where",
"(",
"parent_id",
":",
"parent_id",
",",
"slug",
":",
"\"#{slug}#{postfix}\"",
")",
".",
"where",
"(",
"\"id != ?\"",
",",
"id",
".",
"to_i... | Maintain unique slug within parent_id scope.
If slug is not unique add numeric postfix. | [
"Maintain",
"unique",
"slug",
"within",
"parent_id",
"scope",
".",
"If",
"slug",
"is",
"not",
"unique",
"add",
"numeric",
"postfix",
"."
] | 5ea615abcf6e62afbbf82259d0aa533221d6de08 | https://github.com/cubesystems/releaf/blob/5ea615abcf6e62afbbf82259d0aa533221d6de08/releaf-content/lib/releaf/content/node.rb#L89-L101 | train |
cubesystems/releaf | releaf-content/lib/releaf/content/acts_as_node.rb | ActsAsNode.ClassMethods.acts_as_node | def acts_as_node(params: nil, fields: nil)
configuration = {params: params, fields: fields}
ActsAsNode.register_class(self.name)
# Store acts_as_node configuration
cattr_accessor :acts_as_node_configuration
self.acts_as_node_configuration = configuration
end | ruby | def acts_as_node(params: nil, fields: nil)
configuration = {params: params, fields: fields}
ActsAsNode.register_class(self.name)
# Store acts_as_node configuration
cattr_accessor :acts_as_node_configuration
self.acts_as_node_configuration = configuration
end | [
"def",
"acts_as_node",
"(",
"params",
":",
"nil",
",",
"fields",
":",
"nil",
")",
"configuration",
"=",
"{",
"params",
":",
"params",
",",
"fields",
":",
"fields",
"}",
"ActsAsNode",
".",
"register_class",
"(",
"self",
".",
"name",
")",
"cattr_accessor",
... | There are no configuration options yet. | [
"There",
"are",
"no",
"configuration",
"options",
"yet",
"."
] | 5ea615abcf6e62afbbf82259d0aa533221d6de08 | https://github.com/cubesystems/releaf/blob/5ea615abcf6e62afbbf82259d0aa533221d6de08/releaf-content/lib/releaf/content/acts_as_node.rb#L15-L23 | train |
rr/rr | lib/rr/space.rb | RR.Space.verify_ordered_double | def verify_ordered_double(double)
unless double.terminal?
raise RR::Errors.build_error(:DoubleOrderError,
"Ordered Doubles cannot have a NonTerminal TimesCalledExpectation")
end
unless @ordered_doubles.first == double
message = Double.formatted_name(double.method_name, double... | ruby | def verify_ordered_double(double)
unless double.terminal?
raise RR::Errors.build_error(:DoubleOrderError,
"Ordered Doubles cannot have a NonTerminal TimesCalledExpectation")
end
unless @ordered_doubles.first == double
message = Double.formatted_name(double.method_name, double... | [
"def",
"verify_ordered_double",
"(",
"double",
")",
"unless",
"double",
".",
"terminal?",
"raise",
"RR",
"::",
"Errors",
".",
"build_error",
"(",
":DoubleOrderError",
",",
"\"Ordered Doubles cannot have a NonTerminal TimesCalledExpectation\"",
")",
"end",
"unless",
"@orde... | Verifies that the passed in ordered Double is being called
in the correct position. | [
"Verifies",
"that",
"the",
"passed",
"in",
"ordered",
"Double",
"is",
"being",
"called",
"in",
"the",
"correct",
"position",
"."
] | d110480098473531aebff319493dbb95a4d8e706 | https://github.com/rr/rr/blob/d110480098473531aebff319493dbb95a4d8e706/lib/rr/space.rb#L38-L51 | train |
rr/rr | lib/rr/space.rb | RR.Space.reset | def reset
RR.trim_backtrace = false
RR.overridden_error_class = nil
reset_ordered_doubles
Injections::DoubleInjection.reset
reset_method_missing_injections
reset_singleton_method_added_injections
reset_recorded_calls
reset_bound_objects
end | ruby | def reset
RR.trim_backtrace = false
RR.overridden_error_class = nil
reset_ordered_doubles
Injections::DoubleInjection.reset
reset_method_missing_injections
reset_singleton_method_added_injections
reset_recorded_calls
reset_bound_objects
end | [
"def",
"reset",
"RR",
".",
"trim_backtrace",
"=",
"false",
"RR",
".",
"overridden_error_class",
"=",
"nil",
"reset_ordered_doubles",
"Injections",
"::",
"DoubleInjection",
".",
"reset",
"reset_method_missing_injections",
"reset_singleton_method_added_injections",
"reset_recor... | Resets the registered Doubles and ordered Doubles | [
"Resets",
"the",
"registered",
"Doubles",
"and",
"ordered",
"Doubles"
] | d110480098473531aebff319493dbb95a4d8e706 | https://github.com/rr/rr/blob/d110480098473531aebff319493dbb95a4d8e706/lib/rr/space.rb#L61-L70 | train |
rr/rr | spec/fixtures/rubygems_patch_for_187.rb | Gem.SourceIndex.load_gems_in | def load_gems_in(*spec_dirs)
@gems.clear
spec_dirs.reverse_each do |spec_dir|
spec_files = Dir.glob File.join(spec_dir, '*.gemspec')
spec_files.each do |spec_file|
gemspec = self.class.load_specification spec_file.untaint
add_spec gemspec if gemspec
end
en... | ruby | def load_gems_in(*spec_dirs)
@gems.clear
spec_dirs.reverse_each do |spec_dir|
spec_files = Dir.glob File.join(spec_dir, '*.gemspec')
spec_files.each do |spec_file|
gemspec = self.class.load_specification spec_file.untaint
add_spec gemspec if gemspec
end
en... | [
"def",
"load_gems_in",
"(",
"*",
"spec_dirs",
")",
"@gems",
".",
"clear",
"spec_dirs",
".",
"reverse_each",
"do",
"|",
"spec_dir",
"|",
"spec_files",
"=",
"Dir",
".",
"glob",
"File",
".",
"join",
"(",
"spec_dir",
",",
"'*.gemspec'",
")",
"spec_files",
".",... | Reconstruct the source index from the specifications in +spec_dirs+. | [
"Reconstruct",
"the",
"source",
"index",
"from",
"the",
"specifications",
"in",
"+",
"spec_dirs",
"+",
"."
] | d110480098473531aebff319493dbb95a4d8e706 | https://github.com/rr/rr/blob/d110480098473531aebff319493dbb95a4d8e706/spec/fixtures/rubygems_patch_for_187.rb#L119-L132 | train |
rr/rr | spec/fixtures/rubygems_patch_for_187.rb | Gem.SourceIndex.index_signature | def index_signature
require 'digest'
Digest::SHA256.new.hexdigest(@gems.keys.sort.join(',')).to_s
end | ruby | def index_signature
require 'digest'
Digest::SHA256.new.hexdigest(@gems.keys.sort.join(',')).to_s
end | [
"def",
"index_signature",
"require",
"'digest'",
"Digest",
"::",
"SHA256",
".",
"new",
".",
"hexdigest",
"(",
"@gems",
".",
"keys",
".",
"sort",
".",
"join",
"(",
"','",
")",
")",
".",
"to_s",
"end"
] | The signature for the source index. Changes in the signature indicate a
change in the index. | [
"The",
"signature",
"for",
"the",
"source",
"index",
".",
"Changes",
"in",
"the",
"signature",
"indicate",
"a",
"change",
"in",
"the",
"index",
"."
] | d110480098473531aebff319493dbb95a4d8e706 | https://github.com/rr/rr/blob/d110480098473531aebff319493dbb95a4d8e706/spec/fixtures/rubygems_patch_for_187.rb#L228-L232 | train |
rr/rr | spec/fixtures/rubygems_patch_for_187.rb | Gem.SourceIndex.gem_signature | def gem_signature(gem_full_name)
require 'digest'
Digest::SHA256.new.hexdigest(@gems[gem_full_name].to_yaml).to_s
end | ruby | def gem_signature(gem_full_name)
require 'digest'
Digest::SHA256.new.hexdigest(@gems[gem_full_name].to_yaml).to_s
end | [
"def",
"gem_signature",
"(",
"gem_full_name",
")",
"require",
"'digest'",
"Digest",
"::",
"SHA256",
".",
"new",
".",
"hexdigest",
"(",
"@gems",
"[",
"gem_full_name",
"]",
".",
"to_yaml",
")",
".",
"to_s",
"end"
] | The signature for the given gem specification. | [
"The",
"signature",
"for",
"the",
"given",
"gem",
"specification",
"."
] | d110480098473531aebff319493dbb95a4d8e706 | https://github.com/rr/rr/blob/d110480098473531aebff319493dbb95a4d8e706/spec/fixtures/rubygems_patch_for_187.rb#L237-L241 | train |
rr/rr | spec/fixtures/rubygems_patch_for_187.rb | Gem.SourceIndex.find_name | def find_name(gem_name, version_requirement = Gem::Requirement.default)
dep = Gem::Dependency.new gem_name, version_requirement
search dep
end | ruby | def find_name(gem_name, version_requirement = Gem::Requirement.default)
dep = Gem::Dependency.new gem_name, version_requirement
search dep
end | [
"def",
"find_name",
"(",
"gem_name",
",",
"version_requirement",
"=",
"Gem",
"::",
"Requirement",
".",
"default",
")",
"dep",
"=",
"Gem",
"::",
"Dependency",
".",
"new",
"gem_name",
",",
"version_requirement",
"search",
"dep",
"end"
] | Find a gem by an exact match on the short name. | [
"Find",
"a",
"gem",
"by",
"an",
"exact",
"match",
"on",
"the",
"short",
"name",
"."
] | d110480098473531aebff319493dbb95a4d8e706 | https://github.com/rr/rr/blob/d110480098473531aebff319493dbb95a4d8e706/spec/fixtures/rubygems_patch_for_187.rb#L251-L254 | train |
rr/rr | spec/fixtures/rubygems_patch_for_187.rb | Gem.SourceIndex.update | def update(source_uri, all)
source_uri = URI.parse source_uri unless URI::Generic === source_uri
source_uri.path += '/' unless source_uri.path =~ /\/$/
use_incremental = false
begin
gem_names = fetch_quick_index source_uri, all
remove_extra gem_names
missing_gems = find... | ruby | def update(source_uri, all)
source_uri = URI.parse source_uri unless URI::Generic === source_uri
source_uri.path += '/' unless source_uri.path =~ /\/$/
use_incremental = false
begin
gem_names = fetch_quick_index source_uri, all
remove_extra gem_names
missing_gems = find... | [
"def",
"update",
"(",
"source_uri",
",",
"all",
")",
"source_uri",
"=",
"URI",
".",
"parse",
"source_uri",
"unless",
"URI",
"::",
"Generic",
"===",
"source_uri",
"source_uri",
".",
"path",
"+=",
"'/'",
"unless",
"source_uri",
".",
"path",
"=~",
"/",
"\\/",... | Updates this SourceIndex from +source_uri+. If +all+ is false, only the
latest gems are fetched. | [
"Updates",
"this",
"SourceIndex",
"from",
"+",
"source_uri",
"+",
".",
"If",
"+",
"all",
"+",
"is",
"false",
"only",
"the",
"latest",
"gems",
"are",
"fetched",
"."
] | d110480098473531aebff319493dbb95a4d8e706 | https://github.com/rr/rr/blob/d110480098473531aebff319493dbb95a4d8e706/spec/fixtures/rubygems_patch_for_187.rb#L356-L387 | train |
rr/rr | spec/fixtures/rubygems_patch_for_187.rb | Gem.SourceIndex.fetch_quick_index | def fetch_quick_index(source_uri, all)
index = all ? 'index' : 'latest_index'
zipped_index = fetcher.fetch_path source_uri + "quick/#{index}.rz"
unzip(zipped_index).split("\n")
rescue ::Exception => e
unless all then
say "Latest index not found, using quick index" if
Gem.... | ruby | def fetch_quick_index(source_uri, all)
index = all ? 'index' : 'latest_index'
zipped_index = fetcher.fetch_path source_uri + "quick/#{index}.rz"
unzip(zipped_index).split("\n")
rescue ::Exception => e
unless all then
say "Latest index not found, using quick index" if
Gem.... | [
"def",
"fetch_quick_index",
"(",
"source_uri",
",",
"all",
")",
"index",
"=",
"all",
"?",
"'index'",
":",
"'latest_index'",
"zipped_index",
"=",
"fetcher",
".",
"fetch_path",
"source_uri",
"+",
"\"quick/#{index}.rz\"",
"unzip",
"(",
"zipped_index",
")",
".",
"sp... | Get the quick index needed for incremental updates. | [
"Get",
"the",
"quick",
"index",
"needed",
"for",
"incremental",
"updates",
"."
] | d110480098473531aebff319493dbb95a4d8e706 | https://github.com/rr/rr/blob/d110480098473531aebff319493dbb95a4d8e706/spec/fixtures/rubygems_patch_for_187.rb#L455-L471 | train |
rr/rr | spec/fixtures/rubygems_patch_for_187.rb | Gem.SourceIndex.find_missing | def find_missing(spec_names)
unless defined? @originals then
@originals = {}
each do |full_name, spec|
@originals[spec.original_name] = spec
end
end
spec_names.find_all { |full_name|
@originals[full_name].nil?
}
end | ruby | def find_missing(spec_names)
unless defined? @originals then
@originals = {}
each do |full_name, spec|
@originals[spec.original_name] = spec
end
end
spec_names.find_all { |full_name|
@originals[full_name].nil?
}
end | [
"def",
"find_missing",
"(",
"spec_names",
")",
"unless",
"defined?",
"@originals",
"then",
"@originals",
"=",
"{",
"}",
"each",
"do",
"|",
"full_name",
",",
"spec",
"|",
"@originals",
"[",
"spec",
".",
"original_name",
"]",
"=",
"spec",
"end",
"end",
"spec... | Make a list of full names for all the missing gemspecs. | [
"Make",
"a",
"list",
"of",
"full",
"names",
"for",
"all",
"the",
"missing",
"gemspecs",
"."
] | d110480098473531aebff319493dbb95a4d8e706 | https://github.com/rr/rr/blob/d110480098473531aebff319493dbb95a4d8e706/spec/fixtures/rubygems_patch_for_187.rb#L476-L487 | train |
rr/rr | spec/fixtures/rubygems_patch_for_187.rb | Gem.SourceIndex.fetch_single_spec | def fetch_single_spec(source_uri, spec_name)
@fetch_error = nil
begin
marshal_uri = source_uri + "quick/Marshal.#{Gem.marshal_version}/#{spec_name}.gemspec.rz"
zipped = fetcher.fetch_path marshal_uri
return Marshal.load(unzip(zipped))
rescue => ex
@fetch_error = ex
... | ruby | def fetch_single_spec(source_uri, spec_name)
@fetch_error = nil
begin
marshal_uri = source_uri + "quick/Marshal.#{Gem.marshal_version}/#{spec_name}.gemspec.rz"
zipped = fetcher.fetch_path marshal_uri
return Marshal.load(unzip(zipped))
rescue => ex
@fetch_error = ex
... | [
"def",
"fetch_single_spec",
"(",
"source_uri",
",",
"spec_name",
")",
"@fetch_error",
"=",
"nil",
"begin",
"marshal_uri",
"=",
"source_uri",
"+",
"\"quick/Marshal.#{Gem.marshal_version}/#{spec_name}.gemspec.rz\"",
"zipped",
"=",
"fetcher",
".",
"fetch_path",
"marshal_uri",
... | Tries to fetch Marshal representation first, then YAML | [
"Tries",
"to",
"fetch",
"Marshal",
"representation",
"first",
"then",
"YAML"
] | d110480098473531aebff319493dbb95a4d8e706 | https://github.com/rr/rr/blob/d110480098473531aebff319493dbb95a4d8e706/spec/fixtures/rubygems_patch_for_187.rb#L507-L534 | train |
rr/rr | spec/fixtures/rubygems_patch_for_187.rb | Gem.SourceIndex.update_with_missing | def update_with_missing(source_uri, missing_names)
progress = ui.progress_reporter(missing_names.size,
"Updating metadata for #{missing_names.size} gems from #{source_uri}")
missing_names.each do |spec_name|
gemspec = fetch_single_spec(source_uri, spec_name)
if gemspec.nil? then
... | ruby | def update_with_missing(source_uri, missing_names)
progress = ui.progress_reporter(missing_names.size,
"Updating metadata for #{missing_names.size} gems from #{source_uri}")
missing_names.each do |spec_name|
gemspec = fetch_single_spec(source_uri, spec_name)
if gemspec.nil? then
... | [
"def",
"update_with_missing",
"(",
"source_uri",
",",
"missing_names",
")",
"progress",
"=",
"ui",
".",
"progress_reporter",
"(",
"missing_names",
".",
"size",
",",
"\"Updating metadata for #{missing_names.size} gems from #{source_uri}\"",
")",
"missing_names",
".",
"each",... | Update the cached source index with the missing names. | [
"Update",
"the",
"cached",
"source",
"index",
"with",
"the",
"missing",
"names",
"."
] | d110480098473531aebff319493dbb95a4d8e706 | https://github.com/rr/rr/blob/d110480098473531aebff319493dbb95a4d8e706/spec/fixtures/rubygems_patch_for_187.rb#L539-L555 | train |
puppetlabs/beaker-rspec | lib/beaker-rspec/helpers/serverspec.rb | Specinfra::Backend.BeakerBase.ssh_exec! | def ssh_exec!(node, command)
r = on node, command, { :acceptable_exit_codes => (0..127) }
{
:exit_status => r.exit_code,
:stdout => r.stdout,
:stderr => r.stderr
}
end | ruby | def ssh_exec!(node, command)
r = on node, command, { :acceptable_exit_codes => (0..127) }
{
:exit_status => r.exit_code,
:stdout => r.stdout,
:stderr => r.stderr
}
end | [
"def",
"ssh_exec!",
"(",
"node",
",",
"command",
")",
"r",
"=",
"on",
"node",
",",
"command",
",",
"{",
":acceptable_exit_codes",
"=>",
"(",
"0",
"..",
"127",
")",
"}",
"{",
":exit_status",
"=>",
"r",
".",
"exit_code",
",",
":stdout",
"=>",
"r",
".",... | Execute the provided ssh command
@param [String] command The command to be executed
@return [Hash] Returns a hash containing :exit_status, :stdout and :stderr | [
"Execute",
"the",
"provided",
"ssh",
"command"
] | 6f45849544a10889c14b7bff6bb8171956ec2b56 | https://github.com/puppetlabs/beaker-rspec/blob/6f45849544a10889c14b7bff6bb8171956ec2b56/lib/beaker-rspec/helpers/serverspec.rb#L187-L194 | train |
puppetlabs/beaker-rspec | lib/beaker-rspec/helpers/serverspec.rb | Specinfra::Backend.BeakerCygwin.run_command | def run_command(cmd, opt = {})
node = get_working_node
script = create_script(cmd)
#when node is not cygwin rm -rf will fail so lets use native del instead
#There should be a better way to do this, but for now , this works
if node.is_cygwin?
delete_command = "rm -rf"
redire... | ruby | def run_command(cmd, opt = {})
node = get_working_node
script = create_script(cmd)
#when node is not cygwin rm -rf will fail so lets use native del instead
#There should be a better way to do this, but for now , this works
if node.is_cygwin?
delete_command = "rm -rf"
redire... | [
"def",
"run_command",
"(",
"cmd",
",",
"opt",
"=",
"{",
"}",
")",
"node",
"=",
"get_working_node",
"script",
"=",
"create_script",
"(",
"cmd",
")",
"if",
"node",
".",
"is_cygwin?",
"delete_command",
"=",
"\"rm -rf\"",
"redirection",
"=",
"\"< /dev/null\"",
"... | Run a windows style command using serverspec. Defaults to running on the 'default_node'
test node, otherwise uses the node specified in @example.metadata[:node]
@param [String] cmd The serverspec command to executed
@param [Hash] opt No currently supported options
@return [Hash] Returns a hash containing :exit_sta... | [
"Run",
"a",
"windows",
"style",
"command",
"using",
"serverspec",
".",
"Defaults",
"to",
"running",
"on",
"the",
"default_node",
"test",
"node",
"otherwise",
"uses",
"the",
"node",
"specified",
"in"
] | 6f45849544a10889c14b7bff6bb8171956ec2b56 | https://github.com/puppetlabs/beaker-rspec/blob/6f45849544a10889c14b7bff6bb8171956ec2b56/lib/beaker-rspec/helpers/serverspec.rb#L235-L259 | train |
puppetlabs/beaker-rspec | lib/beaker-rspec/helpers/serverspec.rb | Specinfra::Backend.BeakerExec.run_command | def run_command(cmd, opt = {})
node = get_working_node
cmd = build_command(cmd)
cmd = add_pre_command(cmd)
ret = ssh_exec!(node, cmd)
if @example
@example.metadata[:command] = cmd
@example.metadata[:stdout] = ret[:stdout]
end
CommandResult.new ret
end | ruby | def run_command(cmd, opt = {})
node = get_working_node
cmd = build_command(cmd)
cmd = add_pre_command(cmd)
ret = ssh_exec!(node, cmd)
if @example
@example.metadata[:command] = cmd
@example.metadata[:stdout] = ret[:stdout]
end
CommandResult.new ret
end | [
"def",
"run_command",
"(",
"cmd",
",",
"opt",
"=",
"{",
"}",
")",
"node",
"=",
"get_working_node",
"cmd",
"=",
"build_command",
"(",
"cmd",
")",
"cmd",
"=",
"add_pre_command",
"(",
"cmd",
")",
"ret",
"=",
"ssh_exec!",
"(",
"node",
",",
"cmd",
")",
"i... | Run a unix style command using serverspec. Defaults to running on the 'default_node'
test node, otherwise uses the node specified in @example.metadata[:node]
@param [String] cmd The serverspec command to executed
@param [Hash] opt No currently supported options
@return [Hash] Returns a hash containing :exit_status... | [
"Run",
"a",
"unix",
"style",
"command",
"using",
"serverspec",
".",
"Defaults",
"to",
"running",
"on",
"the",
"default_node",
"test",
"node",
"otherwise",
"uses",
"the",
"node",
"specified",
"in"
] | 6f45849544a10889c14b7bff6bb8171956ec2b56 | https://github.com/puppetlabs/beaker-rspec/blob/6f45849544a10889c14b7bff6bb8171956ec2b56/lib/beaker-rspec/helpers/serverspec.rb#L272-L284 | train |
puppetlabs/beaker-rspec | lib/beaker-rspec/beaker_shim.rb | BeakerRSpec.BeakerShim.setup | def setup(args = [])
options_parser = Beaker::Options::Parser.new
options = options_parser.parse_args(args)
options[:debug] = true
RSpec.configuration.logger = Beaker::Logger.new(options)
options[:logger] = logger
RSpec.configuration.hosts = []
RSpec.configuration.options = opt... | ruby | def setup(args = [])
options_parser = Beaker::Options::Parser.new
options = options_parser.parse_args(args)
options[:debug] = true
RSpec.configuration.logger = Beaker::Logger.new(options)
options[:logger] = logger
RSpec.configuration.hosts = []
RSpec.configuration.options = opt... | [
"def",
"setup",
"(",
"args",
"=",
"[",
"]",
")",
"options_parser",
"=",
"Beaker",
"::",
"Options",
"::",
"Parser",
".",
"new",
"options",
"=",
"options_parser",
".",
"parse_args",
"(",
"args",
")",
"options",
"[",
":debug",
"]",
"=",
"true",
"RSpec",
"... | Setup the testing environment
@param [Array<String>] args The argument array of options for configuring Beaker
See 'beaker --help' for full list of supported command line options | [
"Setup",
"the",
"testing",
"environment"
] | 6f45849544a10889c14b7bff6bb8171956ec2b56 | https://github.com/puppetlabs/beaker-rspec/blob/6f45849544a10889c14b7bff6bb8171956ec2b56/lib/beaker-rspec/beaker_shim.rb#L56-L64 | train |
qrush/m | lib/m/executor.rb | M.Executor.suites | def suites
# Since we're not using `ruby -Itest -Ilib` to run the tests, we need to add this directory to the `LOAD_PATH`
$:.unshift "./test", "./spec", "./lib"
begin
# Fire up this Ruby file. Let's hope it actually has tests.
require "./#{testable.file}"
rescue LoadError => e
... | ruby | def suites
# Since we're not using `ruby -Itest -Ilib` to run the tests, we need to add this directory to the `LOAD_PATH`
$:.unshift "./test", "./spec", "./lib"
begin
# Fire up this Ruby file. Let's hope it actually has tests.
require "./#{testable.file}"
rescue LoadError => e
... | [
"def",
"suites",
"$:",
".",
"unshift",
"\"./test\"",
",",
"\"./spec\"",
",",
"\"./lib\"",
"begin",
"require",
"\"./#{testable.file}\"",
"rescue",
"LoadError",
"=>",
"e",
"STDERR",
".",
"puts",
"\"Failed loading test file:\\n#{e.message}\"",
"return",
"[",
"]",
"end",
... | Finds all test suites in this test file, with test methods included. | [
"Finds",
"all",
"test",
"suites",
"in",
"this",
"test",
"file",
"with",
"test",
"methods",
"included",
"."
] | 9bcbf6120588bd8702046cb44c2f7d78aa2047db | https://github.com/qrush/m/blob/9bcbf6120588bd8702046cb44c2f7d78aa2047db/lib/m/executor.rb#L72-L94 | train |
tc/paypal_adaptive | lib/paypal_adaptive/response.rb | PaypalAdaptive.Response.approve_paypal_payment_url | def approve_paypal_payment_url(opts = {})
if opts.is_a?(Symbol) || opts.is_a?(String)
warn "[DEPRECATION] use approve_paypal_payment_url(:type => #{opts})"
opts = {:type => opts}
end
return nil if self['payKey'].nil?
if ['mini', 'light'].include?(opts[:type].to_s)
"#{@pa... | ruby | def approve_paypal_payment_url(opts = {})
if opts.is_a?(Symbol) || opts.is_a?(String)
warn "[DEPRECATION] use approve_paypal_payment_url(:type => #{opts})"
opts = {:type => opts}
end
return nil if self['payKey'].nil?
if ['mini', 'light'].include?(opts[:type].to_s)
"#{@pa... | [
"def",
"approve_paypal_payment_url",
"(",
"opts",
"=",
"{",
"}",
")",
"if",
"opts",
".",
"is_a?",
"(",
"Symbol",
")",
"||",
"opts",
".",
"is_a?",
"(",
"String",
")",
"warn",
"\"[DEPRECATION] use approve_paypal_payment_url(:type => #{opts})\"",
"opts",
"=",
"{",
... | URL to redirect to in order for the user to approve the payment
options:
* country: default country code for the user
* type: mini / light | [
"URL",
"to",
"redirect",
"to",
"in",
"order",
"for",
"the",
"user",
"to",
"approve",
"the",
"payment"
] | cfd2c651057c407d844c470aa28d02b2bdec7579 | https://github.com/tc/paypal_adaptive/blob/cfd2c651057c407d844c470aa28d02b2bdec7579/lib/paypal_adaptive/response.rb#L34-L48 | train |
assaf/scrapi | lib/scraper/base.rb | Scraper.Base.scrape | def scrape()
# Call prepare with the document, but before doing anything else.
prepare document
# Retrieve the document. This may raise HTTPError or HTMLParseError.
case document
when Array
stack = @document.reverse # see below
when HTML::Node
# If a root element is s... | ruby | def scrape()
# Call prepare with the document, but before doing anything else.
prepare document
# Retrieve the document. This may raise HTTPError or HTMLParseError.
case document
when Array
stack = @document.reverse # see below
when HTML::Node
# If a root element is s... | [
"def",
"scrape",
"(",
")",
"prepare",
"document",
"case",
"document",
"when",
"Array",
"stack",
"=",
"@document",
".",
"reverse",
"when",
"HTML",
"::",
"Node",
"root_element",
"=",
"option",
"(",
":root_element",
")",
"root",
"=",
"root_element",
"?",
"@docu... | Create a new scraper instance.
The argument +source+ is a URL, string containing HTML, or HTML::Node.
The optional argument +options+ are options passed to the scraper.
See Base#scrape for more details.
For example:
# The page we want to scrape
url = URI.parse("http://example.com")
# Skip the header
s... | [
"Create",
"a",
"new",
"scraper",
"instance",
"."
] | 08f207ed740660bdf65730dd6bd3cb4df64e6d4b | https://github.com/assaf/scrapi/blob/08f207ed740660bdf65730dd6bd3cb4df64e6d4b/lib/scraper/base.rb#L747-L841 | train |
assaf/scrapi | lib/scraper/base.rb | Scraper.Base.document | def document
if @document.is_a?(URI)
# Attempt to read page. May raise HTTPError.
options = {}
READER_OPTIONS.each { |key| options[key] = option(key) }
request(@document, options)
end
if @document.is_a?(String)
# Parse the page. May raise HTMLParseError.
... | ruby | def document
if @document.is_a?(URI)
# Attempt to read page. May raise HTTPError.
options = {}
READER_OPTIONS.each { |key| options[key] = option(key) }
request(@document, options)
end
if @document.is_a?(String)
# Parse the page. May raise HTMLParseError.
... | [
"def",
"document",
"if",
"@document",
".",
"is_a?",
"(",
"URI",
")",
"options",
"=",
"{",
"}",
"READER_OPTIONS",
".",
"each",
"{",
"|",
"key",
"|",
"options",
"[",
"key",
"]",
"=",
"option",
"(",
"key",
")",
"}",
"request",
"(",
"@document",
",",
"... | Returns the document being processed.
If the scraper was created with a URL, this method will attempt to
retrieve the page and parse it.
If the scraper was created with a string, this method will attempt
to parse the page.
Be advised that calling this method may raise an exception
(HTTPError or HTMLParseError)... | [
"Returns",
"the",
"document",
"being",
"processed",
"."
] | 08f207ed740660bdf65730dd6bd3cb4df64e6d4b | https://github.com/assaf/scrapi/blob/08f207ed740660bdf65730dd6bd3cb4df64e6d4b/lib/scraper/base.rb#L856-L872 | train |
assaf/scrapi | lib/html/node_ext.rb | HTML.Node.next_sibling | def next_sibling()
if siblings = parent.children
siblings.each_with_index do |node, i|
return siblings[i + 1] if node.equal?(self)
end
end
nil
end | ruby | def next_sibling()
if siblings = parent.children
siblings.each_with_index do |node, i|
return siblings[i + 1] if node.equal?(self)
end
end
nil
end | [
"def",
"next_sibling",
"(",
")",
"if",
"siblings",
"=",
"parent",
".",
"children",
"siblings",
".",
"each_with_index",
"do",
"|",
"node",
",",
"i",
"|",
"return",
"siblings",
"[",
"i",
"+",
"1",
"]",
"if",
"node",
".",
"equal?",
"(",
"self",
")",
"en... | Returns the next sibling node. | [
"Returns",
"the",
"next",
"sibling",
"node",
"."
] | 08f207ed740660bdf65730dd6bd3cb4df64e6d4b | https://github.com/assaf/scrapi/blob/08f207ed740660bdf65730dd6bd3cb4df64e6d4b/lib/html/node_ext.rb#L6-L13 | train |
assaf/scrapi | lib/html/node_ext.rb | HTML.Node.previous_sibling | def previous_sibling()
if siblings = parent.children
siblings.each_with_index do |node, i|
return siblings[i - 1] if node.equal?(self)
end
end
nil
end | ruby | def previous_sibling()
if siblings = parent.children
siblings.each_with_index do |node, i|
return siblings[i - 1] if node.equal?(self)
end
end
nil
end | [
"def",
"previous_sibling",
"(",
")",
"if",
"siblings",
"=",
"parent",
".",
"children",
"siblings",
".",
"each_with_index",
"do",
"|",
"node",
",",
"i",
"|",
"return",
"siblings",
"[",
"i",
"-",
"1",
"]",
"if",
"node",
".",
"equal?",
"(",
"self",
")",
... | Returns the previous sibling node. | [
"Returns",
"the",
"previous",
"sibling",
"node",
"."
] | 08f207ed740660bdf65730dd6bd3cb4df64e6d4b | https://github.com/assaf/scrapi/blob/08f207ed740660bdf65730dd6bd3cb4df64e6d4b/lib/html/node_ext.rb#L17-L24 | train |
assaf/scrapi | lib/html/node_ext.rb | HTML.Node.previous_element | def previous_element(name = nil)
if siblings = parent.children
found = nil
siblings.each do |node|
return found if node.equal?(self)
found = node if node.tag? && (name.nil? || node.name == name)
end
end
nil
end | ruby | def previous_element(name = nil)
if siblings = parent.children
found = nil
siblings.each do |node|
return found if node.equal?(self)
found = node if node.tag? && (name.nil? || node.name == name)
end
end
nil
end | [
"def",
"previous_element",
"(",
"name",
"=",
"nil",
")",
"if",
"siblings",
"=",
"parent",
".",
"children",
"found",
"=",
"nil",
"siblings",
".",
"each",
"do",
"|",
"node",
"|",
"return",
"found",
"if",
"node",
".",
"equal?",
"(",
"self",
")",
"found",
... | Return the previous element before this one. Skips sibling text
nodes.
Using the +name+ argument, returns the previous element with
that name, skipping other sibling elements. | [
"Return",
"the",
"previous",
"element",
"before",
"this",
"one",
".",
"Skips",
"sibling",
"text",
"nodes",
"."
] | 08f207ed740660bdf65730dd6bd3cb4df64e6d4b | https://github.com/assaf/scrapi/blob/08f207ed740660bdf65730dd6bd3cb4df64e6d4b/lib/html/node_ext.rb#L51-L60 | train |
assaf/scrapi | lib/html/node_ext.rb | HTML.Node.each | def each(value = nil, &block)
yield self, value
if @children
@children.each do |child|
child.each value, &block
end
end
value
end | ruby | def each(value = nil, &block)
yield self, value
if @children
@children.each do |child|
child.each value, &block
end
end
value
end | [
"def",
"each",
"(",
"value",
"=",
"nil",
",",
"&",
"block",
")",
"yield",
"self",
",",
"value",
"if",
"@children",
"@children",
".",
"each",
"do",
"|",
"child",
"|",
"child",
".",
"each",
"value",
",",
"&",
"block",
"end",
"end",
"value",
"end"
] | Process each node beginning with the current node. | [
"Process",
"each",
"node",
"beginning",
"with",
"the",
"current",
"node",
"."
] | 08f207ed740660bdf65730dd6bd3cb4df64e6d4b | https://github.com/assaf/scrapi/blob/08f207ed740660bdf65730dd6bd3cb4df64e6d4b/lib/html/node_ext.rb#L74-L82 | train |
assaf/scrapi | lib/html/tokenizer.rb | HTML.Tokenizer.scan_tag | def scan_tag
tag = @scanner.getch
if @scanner.scan(/!--/) # comment
tag << @scanner.matched
tag << (@scanner.scan_until(/--\s*>/) || @scanner.scan_until(/\Z/))
elsif @scanner.scan(/!\[CDATA\[/)
tag << @scanner.matched
tag << @scanner.scan_until(/\]\]>/)
... | ruby | def scan_tag
tag = @scanner.getch
if @scanner.scan(/!--/) # comment
tag << @scanner.matched
tag << (@scanner.scan_until(/--\s*>/) || @scanner.scan_until(/\Z/))
elsif @scanner.scan(/!\[CDATA\[/)
tag << @scanner.matched
tag << @scanner.scan_until(/\]\]>/)
... | [
"def",
"scan_tag",
"tag",
"=",
"@scanner",
".",
"getch",
"if",
"@scanner",
".",
"scan",
"(",
"/",
"/",
")",
"tag",
"<<",
"@scanner",
".",
"matched",
"tag",
"<<",
"(",
"@scanner",
".",
"scan_until",
"(",
"/",
"\\s",
"/",
")",
"||",
"@scanner",
".",
... | Treat the text at the current position as a tag, and scan it. Supports
comments, doctype tags, and regular tags, and ignores less-than and
greater-than characters within quoted strings. | [
"Treat",
"the",
"text",
"at",
"the",
"current",
"position",
"as",
"a",
"tag",
"and",
"scan",
"it",
".",
"Supports",
"comments",
"doctype",
"tags",
"and",
"regular",
"tags",
"and",
"ignores",
"less",
"-",
"than",
"and",
"greater",
"-",
"than",
"characters",... | 08f207ed740660bdf65730dd6bd3cb4df64e6d4b | https://github.com/assaf/scrapi/blob/08f207ed740660bdf65730dd6bd3cb4df64e6d4b/lib/html/tokenizer.rb#L50-L65 | train |
assaf/scrapi | lib/html/selector.rb | HTML.Selector.next_element | def next_element(element, name = nil)
if siblings = element.parent.children
found = false
siblings.each do |node|
if node.equal?(element)
found = true
elsif found && node.tag?
return node if (name.nil? || node.name == name)
end
end
... | ruby | def next_element(element, name = nil)
if siblings = element.parent.children
found = false
siblings.each do |node|
if node.equal?(element)
found = true
elsif found && node.tag?
return node if (name.nil? || node.name == name)
end
end
... | [
"def",
"next_element",
"(",
"element",
",",
"name",
"=",
"nil",
")",
"if",
"siblings",
"=",
"element",
".",
"parent",
".",
"children",
"found",
"=",
"false",
"siblings",
".",
"each",
"do",
"|",
"node",
"|",
"if",
"node",
".",
"equal?",
"(",
"element",
... | Return the next element after this one. Skips sibling text nodes.
With the +name+ argument, returns the next element with that name,
skipping other sibling elements. | [
"Return",
"the",
"next",
"element",
"after",
"this",
"one",
".",
"Skips",
"sibling",
"text",
"nodes",
"."
] | 08f207ed740660bdf65730dd6bd3cb4df64e6d4b | https://github.com/assaf/scrapi/blob/08f207ed740660bdf65730dd6bd3cb4df64e6d4b/lib/html/selector.rb#L490-L502 | train |
assaf/scrapi | lib/html/selector.rb | HTML.Selector.only_child | def only_child(of_type)
lambda do |element|
# Element must be inside parent element.
return false unless element.parent and element.parent.tag?
name = of_type ? element.name : nil
other = false
for child in element.parent.children
# Skip text nodes/comments.
... | ruby | def only_child(of_type)
lambda do |element|
# Element must be inside parent element.
return false unless element.parent and element.parent.tag?
name = of_type ? element.name : nil
other = false
for child in element.parent.children
# Skip text nodes/comments.
... | [
"def",
"only_child",
"(",
"of_type",
")",
"lambda",
"do",
"|",
"element",
"|",
"return",
"false",
"unless",
"element",
".",
"parent",
"and",
"element",
".",
"parent",
".",
"tag?",
"name",
"=",
"of_type",
"?",
"element",
".",
"name",
":",
"nil",
"other",
... | Creates a only child lambda. Pass +of-type+ to only look at
elements of its type. | [
"Creates",
"a",
"only",
"child",
"lambda",
".",
"Pass",
"+",
"of",
"-",
"type",
"+",
"to",
"only",
"look",
"at",
"elements",
"of",
"its",
"type",
"."
] | 08f207ed740660bdf65730dd6bd3cb4df64e6d4b | https://github.com/assaf/scrapi/blob/08f207ed740660bdf65730dd6bd3cb4df64e6d4b/lib/html/selector.rb#L769-L786 | train |
assaf/scrapi | lib/html/node.rb | HTML.Node.find_all | def find_all(conditions)
conditions = validate_conditions(conditions)
matches = []
matches << self if match(conditions)
@children.each do |child|
matches.concat child.find_all(conditions)
end
matches
end | ruby | def find_all(conditions)
conditions = validate_conditions(conditions)
matches = []
matches << self if match(conditions)
@children.each do |child|
matches.concat child.find_all(conditions)
end
matches
end | [
"def",
"find_all",
"(",
"conditions",
")",
"conditions",
"=",
"validate_conditions",
"(",
"conditions",
")",
"matches",
"=",
"[",
"]",
"matches",
"<<",
"self",
"if",
"match",
"(",
"conditions",
")",
"@children",
".",
"each",
"do",
"|",
"child",
"|",
"match... | Search for all nodes that match the given conditions, and return them
as an array. | [
"Search",
"for",
"all",
"nodes",
"that",
"match",
"the",
"given",
"conditions",
"and",
"return",
"them",
"as",
"an",
"array",
"."
] | 08f207ed740660bdf65730dd6bd3cb4df64e6d4b | https://github.com/assaf/scrapi/blob/08f207ed740660bdf65730dd6bd3cb4df64e6d4b/lib/html/node.rb#L105-L114 | train |
assaf/scrapi | lib/html/node.rb | HTML.Tag.to_s | def to_s
if @closing == :close
"</#{@name}>"
else
s = "<#{@name}"
@attributes.each do |k,v|
s << " #{k}"
s << "='#{v.gsub(/'/,"\\\\'")}'" if String === v
end
s << " /" if @closing == :self
s << ">"
@children.each { |child| s << chil... | ruby | def to_s
if @closing == :close
"</#{@name}>"
else
s = "<#{@name}"
@attributes.each do |k,v|
s << " #{k}"
s << "='#{v.gsub(/'/,"\\\\'")}'" if String === v
end
s << " /" if @closing == :self
s << ">"
@children.each { |child| s << chil... | [
"def",
"to_s",
"if",
"@closing",
"==",
":close",
"\"</#{@name}>\"",
"else",
"s",
"=",
"\"<#{@name}\"",
"@attributes",
".",
"each",
"do",
"|",
"k",
",",
"v",
"|",
"s",
"<<",
"\" #{k}\"",
"s",
"<<",
"\"='#{v.gsub(/'/,\"\\\\\\\\'\")}'\"",
"if",
"String",
"===",
... | Returns a textual representation of the node | [
"Returns",
"a",
"textual",
"representation",
"of",
"the",
"node"
] | 08f207ed740660bdf65730dd6bd3cb4df64e6d4b | https://github.com/assaf/scrapi/blob/08f207ed740660bdf65730dd6bd3cb4df64e6d4b/lib/html/node.rb#L312-L327 | train |
assaf/scrapi | lib/html/node.rb | HTML.Tag.match_condition | def match_condition(value, condition)
case condition
when String
value && value == condition
when Regexp
value && value.match(condition)
when Numeric
value == condition.to_s
when true
!value.nil?
when false, nil
... | ruby | def match_condition(value, condition)
case condition
when String
value && value == condition
when Regexp
value && value.match(condition)
when Numeric
value == condition.to_s
when true
!value.nil?
when false, nil
... | [
"def",
"match_condition",
"(",
"value",
",",
"condition",
")",
"case",
"condition",
"when",
"String",
"value",
"&&",
"value",
"==",
"condition",
"when",
"Regexp",
"value",
"&&",
"value",
".",
"match",
"(",
"condition",
")",
"when",
"Numeric",
"value",
"==",
... | Match the given value to the given condition. | [
"Match",
"the",
"given",
"value",
"to",
"the",
"given",
"condition",
"."
] | 08f207ed740660bdf65730dd6bd3cb4df64e6d4b | https://github.com/assaf/scrapi/blob/08f207ed740660bdf65730dd6bd3cb4df64e6d4b/lib/html/node.rb#L517-L532 | train |
LoyaltyNZ/hoodoo | lib/hoodoo/client/client.rb | Hoodoo.Client.resource | def resource( resource, version = 1, options = {} )
endpoint_options = {
:discoverer => @discoverer,
:session_id => @session_id,
:locale => options[ :locale ] || @locale
}
Hoodoo::Client::Headers::HEADER_TO_PROPERTY.each do | rack_header, description |
... | ruby | def resource( resource, version = 1, options = {} )
endpoint_options = {
:discoverer => @discoverer,
:session_id => @session_id,
:locale => options[ :locale ] || @locale
}
Hoodoo::Client::Headers::HEADER_TO_PROPERTY.each do | rack_header, description |
... | [
"def",
"resource",
"(",
"resource",
",",
"version",
"=",
"1",
",",
"options",
"=",
"{",
"}",
")",
"endpoint_options",
"=",
"{",
":discoverer",
"=>",
"@discoverer",
",",
":session_id",
"=>",
"@session_id",
",",
":locale",
"=>",
"options",
"[",
":locale",
"]... | Create a client instance. This is used as a factory for endpoint
instances which communicate with Resource implementations.
== Overview
Suppose you have Resources with only +public_actions+ so that no
sessions are needed, with resource implementations running at host
"test.com" on paths which follow downcase/plu... | [
"Create",
"a",
"client",
"instance",
".",
"This",
"is",
"used",
"as",
"a",
"factory",
"for",
"endpoint",
"instances",
"which",
"communicate",
"with",
"Resource",
"implementations",
"."
] | 905940121917ecbb66364bca3455b94b1636470f | https://github.com/LoyaltyNZ/hoodoo/blob/905940121917ecbb66364bca3455b94b1636470f/lib/hoodoo/client/client.rb#L319-L356 | train |
LoyaltyNZ/hoodoo | lib/hoodoo/logger/logger.rb | Hoodoo.Logger.remove | def remove( *writer_instances )
writer_instances.each do | writer_instance |
communicator = @writers[ writer_instance ]
@pool.remove( communicator ) unless communicator.nil?
@writers.delete( writer_instance )
end
end | ruby | def remove( *writer_instances )
writer_instances.each do | writer_instance |
communicator = @writers[ writer_instance ]
@pool.remove( communicator ) unless communicator.nil?
@writers.delete( writer_instance )
end
end | [
"def",
"remove",
"(",
"*",
"writer_instances",
")",
"writer_instances",
".",
"each",
"do",
"|",
"writer_instance",
"|",
"communicator",
"=",
"@writers",
"[",
"writer_instance",
"]",
"@pool",
".",
"remove",
"(",
"communicator",
")",
"unless",
"communicator",
".",... | Remove a writer instance from this logger. If the instance has not been
previously added, no error is raised.
Slow writers may take a while to finish processing and shut down in
the background. As a result, this method might take a while to return.
Internal default timeouts may even mean that the writer is still r... | [
"Remove",
"a",
"writer",
"instance",
"from",
"this",
"logger",
".",
"If",
"the",
"instance",
"has",
"not",
"been",
"previously",
"added",
"no",
"error",
"is",
"raised",
"."
] | 905940121917ecbb66364bca3455b94b1636470f | https://github.com/LoyaltyNZ/hoodoo/blob/905940121917ecbb66364bca3455b94b1636470f/lib/hoodoo/logger/logger.rb#L111-L117 | train |
LoyaltyNZ/hoodoo | lib/hoodoo/logger/logger.rb | Hoodoo.Logger.include_class? | def include_class?( writer_class )
@writers.keys.each do | writer_instance |
return true if writer_instance.is_a?( writer_class )
end
return false
end | ruby | def include_class?( writer_class )
@writers.keys.each do | writer_instance |
return true if writer_instance.is_a?( writer_class )
end
return false
end | [
"def",
"include_class?",
"(",
"writer_class",
")",
"@writers",
".",
"keys",
".",
"each",
"do",
"|",
"writer_instance",
"|",
"return",
"true",
"if",
"writer_instance",
".",
"is_a?",
"(",
"writer_class",
")",
"end",
"return",
"false",
"end"
] | Does this log instance's collection of writers include any writer
instances which are of the given writer _class_? Returns +true+ if so,
else +false+.
This is slower than #include? so try to work with writer instance
queries rather than writer class queries if you can.
+writer_class+:: A _subclass_ (class refere... | [
"Does",
"this",
"log",
"instance",
"s",
"collection",
"of",
"writers",
"include",
"any",
"writer",
"instances",
"which",
"are",
"of",
"the",
"given",
"writer",
"_class_?",
"Returns",
"+",
"true",
"+",
"if",
"so",
"else",
"+",
"false",
"+",
"."
] | 905940121917ecbb66364bca3455b94b1636470f | https://github.com/LoyaltyNZ/hoodoo/blob/905940121917ecbb66364bca3455b94b1636470f/lib/hoodoo/logger/logger.rb#L155-L161 | train |
LoyaltyNZ/hoodoo | lib/hoodoo/errors/errors.rb | Hoodoo.Errors.add_error | def add_error( code, options = nil )
options = Hoodoo::Utilities.stringify( options || {} )
reference = options[ 'reference' ] || {}
message = options[ 'message' ]
# Make sure nobody uses an undeclared error code.
raise UnknownCode, "In \#add_error: Unknown error code '#{code}'" unl... | ruby | def add_error( code, options = nil )
options = Hoodoo::Utilities.stringify( options || {} )
reference = options[ 'reference' ] || {}
message = options[ 'message' ]
# Make sure nobody uses an undeclared error code.
raise UnknownCode, "In \#add_error: Unknown error code '#{code}'" unl... | [
"def",
"add_error",
"(",
"code",
",",
"options",
"=",
"nil",
")",
"options",
"=",
"Hoodoo",
"::",
"Utilities",
".",
"stringify",
"(",
"options",
"||",
"{",
"}",
")",
"reference",
"=",
"options",
"[",
"'reference'",
"]",
"||",
"{",
"}",
"message",
"=",
... | Create an instance.
+descriptions+:: (Optional) Hoodoo::ErrorDescriptions instance with
service-domain-specific error descriptions added, or
omit for a default instance describing +platform+ and
+generic+ error domains only.
Add an error instance to this collect... | [
"Create",
"an",
"instance",
"."
] | 905940121917ecbb66364bca3455b94b1636470f | https://github.com/LoyaltyNZ/hoodoo/blob/905940121917ecbb66364bca3455b94b1636470f/lib/hoodoo/errors/errors.rb#L121-L161 | train |
LoyaltyNZ/hoodoo | lib/hoodoo/errors/errors.rb | Hoodoo.Errors.add_precompiled_error | def add_precompiled_error( code, message, reference, http_status = 500 )
@http_status_code = http_status.to_i if @errors.empty?
error = {
'code' => code,
'message' => message
}
error[ 'reference' ] = reference unless reference.nil? || reference.empty?
@errors << error... | ruby | def add_precompiled_error( code, message, reference, http_status = 500 )
@http_status_code = http_status.to_i if @errors.empty?
error = {
'code' => code,
'message' => message
}
error[ 'reference' ] = reference unless reference.nil? || reference.empty?
@errors << error... | [
"def",
"add_precompiled_error",
"(",
"code",
",",
"message",
",",
"reference",
",",
"http_status",
"=",
"500",
")",
"@http_status_code",
"=",
"http_status",
".",
"to_i",
"if",
"@errors",
".",
"empty?",
"error",
"=",
"{",
"'code'",
"=>",
"code",
",",
"'messag... | Add a precompiled error to the error collection. Pass error code,
error message and reference data directly.
In most cases you should be calling #add_error instead, *NOT* here.
*No* *validation* is performed. You should only really call here if
storing an error / errors from another, trusted source with assumed
... | [
"Add",
"a",
"precompiled",
"error",
"to",
"the",
"error",
"collection",
".",
"Pass",
"error",
"code",
"error",
"message",
"and",
"reference",
"data",
"directly",
"."
] | 905940121917ecbb66364bca3455b94b1636470f | https://github.com/LoyaltyNZ/hoodoo/blob/905940121917ecbb66364bca3455b94b1636470f/lib/hoodoo/errors/errors.rb#L178-L189 | train |
LoyaltyNZ/hoodoo | lib/hoodoo/generator.rb | Hoodoo.Generator.run! | def run!
git = nil
path = nil
return show_usage() if ARGV.length < 1
name = ARGV.shift() if ARGV.first[ 0 ] != '-'
opts = GetoptLong.new(
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
[ '--version', '-v', '-V', GetoptLong::NO_ARGUMENT ],
[ '--... | ruby | def run!
git = nil
path = nil
return show_usage() if ARGV.length < 1
name = ARGV.shift() if ARGV.first[ 0 ] != '-'
opts = GetoptLong.new(
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
[ '--version', '-v', '-V', GetoptLong::NO_ARGUMENT ],
[ '--... | [
"def",
"run!",
"git",
"=",
"nil",
"path",
"=",
"nil",
"return",
"show_usage",
"(",
")",
"if",
"ARGV",
".",
"length",
"<",
"1",
"name",
"=",
"ARGV",
".",
"shift",
"(",
")",
"if",
"ARGV",
".",
"first",
"[",
"0",
"]",
"!=",
"'-'",
"opts",
"=",
"Ge... | Run the +hoodoo+ command implementation. Command line options are
taken from the Ruby ARGV constant. | [
"Run",
"the",
"+",
"hoodoo",
"+",
"command",
"implementation",
".",
"Command",
"line",
"options",
"are",
"taken",
"from",
"the",
"Ruby",
"ARGV",
"constant",
"."
] | 905940121917ecbb66364bca3455b94b1636470f | https://github.com/LoyaltyNZ/hoodoo/blob/905940121917ecbb66364bca3455b94b1636470f/lib/hoodoo/generator.rb#L43-L93 | train |
LoyaltyNZ/hoodoo | lib/hoodoo/transient_store/transient_store.rb | Hoodoo.TransientStore.set | def set( key:, payload:, maximum_lifespan: nil )
key = normalise_key( key, 'set' )
if payload.nil?
raise "Hoodoo::TransientStore\#set: Payloads of 'nil' are prohibited"
end
maximum_lifespan ||= @default_maximum_lifespan
begin
result = @storage_engine_instance.set(
... | ruby | def set( key:, payload:, maximum_lifespan: nil )
key = normalise_key( key, 'set' )
if payload.nil?
raise "Hoodoo::TransientStore\#set: Payloads of 'nil' are prohibited"
end
maximum_lifespan ||= @default_maximum_lifespan
begin
result = @storage_engine_instance.set(
... | [
"def",
"set",
"(",
"key",
":",
",",
"payload",
":",
",",
"maximum_lifespan",
":",
"nil",
")",
"key",
"=",
"normalise_key",
"(",
"key",
",",
"'set'",
")",
"if",
"payload",
".",
"nil?",
"raise",
"\"Hoodoo::TransientStore\\#set: Payloads of 'nil' are prohibited\"",
... | Instantiate a new Transient storage object through which temporary data
can be stored or retrieved.
The TransientStore abstraction is a high level and simple abstraction over
heterogenous data storage engines. It does not expose the many subtle
configuration settings usually available in such. If you need to take
... | [
"Instantiate",
"a",
"new",
"Transient",
"storage",
"object",
"through",
"which",
"temporary",
"data",
"can",
"be",
"stored",
"or",
"retrieved",
"."
] | 905940121917ecbb66364bca3455b94b1636470f | https://github.com/LoyaltyNZ/hoodoo/blob/905940121917ecbb66364bca3455b94b1636470f/lib/hoodoo/transient_store/transient_store.rb#L227-L253 | train |
LoyaltyNZ/hoodoo | lib/hoodoo/transient_store/transient_store.rb | Hoodoo.TransientStore.normalise_key | def normalise_key( key, calling_method_name )
unless key.is_a?( String ) || key.is_a?( Symbol )
raise "Hoodoo::TransientStore\##{ calling_method_name }: Keys must be of String or Symbol class; you provided '#{ key.class }'"
end
key = key.to_s
if key.empty?
raise "Hoodoo::Transi... | ruby | def normalise_key( key, calling_method_name )
unless key.is_a?( String ) || key.is_a?( Symbol )
raise "Hoodoo::TransientStore\##{ calling_method_name }: Keys must be of String or Symbol class; you provided '#{ key.class }'"
end
key = key.to_s
if key.empty?
raise "Hoodoo::Transi... | [
"def",
"normalise_key",
"(",
"key",
",",
"calling_method_name",
")",
"unless",
"key",
".",
"is_a?",
"(",
"String",
")",
"||",
"key",
".",
"is_a?",
"(",
"Symbol",
")",
"raise",
"\"Hoodoo::TransientStore\\##{ calling_method_name }: Keys must be of String or Symbol class; yo... | Given a storage key, make sure it's a String or Symbol, coerce to a
String and ensure it isn't empty. Returns the non-empty String version.
Raises exceptions for bad input classes or empty keys.
+key+:: Key to normalise.
+calling_method_name+:: Name of calling method to declare in exception
... | [
"Given",
"a",
"storage",
"key",
"make",
"sure",
"it",
"s",
"a",
"String",
"or",
"Symbol",
"coerce",
"to",
"a",
"String",
"and",
"ensure",
"it",
"isn",
"t",
"empty",
".",
"Returns",
"the",
"non",
"-",
"empty",
"String",
"version",
".",
"Raises",
"except... | 905940121917ecbb66364bca3455b94b1636470f | https://github.com/LoyaltyNZ/hoodoo/blob/905940121917ecbb66364bca3455b94b1636470f/lib/hoodoo/transient_store/transient_store.rb#L338-L350 | train |
gemfury/gemfury | lib/gemfury/client.rb | Gemfury.Client.push_gem | def push_gem(file, options = {})
ensure_ready!(:authorization)
push_api = connection(:url => self.pushpoint)
response = push_api.post('uploads', options.merge(:file => file))
checked_response_body(response)
end | ruby | def push_gem(file, options = {})
ensure_ready!(:authorization)
push_api = connection(:url => self.pushpoint)
response = push_api.post('uploads', options.merge(:file => file))
checked_response_body(response)
end | [
"def",
"push_gem",
"(",
"file",
",",
"options",
"=",
"{",
"}",
")",
"ensure_ready!",
"(",
":authorization",
")",
"push_api",
"=",
"connection",
"(",
":url",
"=>",
"self",
".",
"pushpoint",
")",
"response",
"=",
"push_api",
".",
"post",
"(",
"'uploads'",
... | Uploading a gem file | [
"Uploading",
"a",
"gem",
"file"
] | edcdf816a9925abf6fbe89fe7896a563e1902582 | https://github.com/gemfury/gemfury/blob/edcdf816a9925abf6fbe89fe7896a563e1902582/lib/gemfury/client.rb#L29-L34 | train |
gemfury/gemfury | lib/gemfury/client.rb | Gemfury.Client.versions | def versions(name, options = {})
ensure_ready!(:authorization)
url = "gems/#{escape(name)}/versions"
response = connection.get(url, options)
checked_response_body(response)
end | ruby | def versions(name, options = {})
ensure_ready!(:authorization)
url = "gems/#{escape(name)}/versions"
response = connection.get(url, options)
checked_response_body(response)
end | [
"def",
"versions",
"(",
"name",
",",
"options",
"=",
"{",
"}",
")",
"ensure_ready!",
"(",
":authorization",
")",
"url",
"=",
"\"gems/#{escape(name)}/versions\"",
"response",
"=",
"connection",
".",
"get",
"(",
"url",
",",
"options",
")",
"checked_response_body",... | List versions for a gem | [
"List",
"versions",
"for",
"a",
"gem"
] | edcdf816a9925abf6fbe89fe7896a563e1902582 | https://github.com/gemfury/gemfury/blob/edcdf816a9925abf6fbe89fe7896a563e1902582/lib/gemfury/client.rb#L44-L49 | train |
gemfury/gemfury | lib/gemfury/client.rb | Gemfury.Client.yank_version | def yank_version(name, version, options = {})
ensure_ready!(:authorization)
url = "gems/#{escape(name)}/versions/#{escape(version)}"
response = connection.delete(url, options)
checked_response_body(response)
end | ruby | def yank_version(name, version, options = {})
ensure_ready!(:authorization)
url = "gems/#{escape(name)}/versions/#{escape(version)}"
response = connection.delete(url, options)
checked_response_body(response)
end | [
"def",
"yank_version",
"(",
"name",
",",
"version",
",",
"options",
"=",
"{",
"}",
")",
"ensure_ready!",
"(",
":authorization",
")",
"url",
"=",
"\"gems/#{escape(name)}/versions/#{escape(version)}\"",
"response",
"=",
"connection",
".",
"delete",
"(",
"url",
",",
... | Delete a gem version | [
"Delete",
"a",
"gem",
"version"
] | edcdf816a9925abf6fbe89fe7896a563e1902582 | https://github.com/gemfury/gemfury/blob/edcdf816a9925abf6fbe89fe7896a563e1902582/lib/gemfury/client.rb#L52-L57 | train |
gemfury/gemfury | lib/gemfury/client.rb | Gemfury.Client.add_collaborator | def add_collaborator(login, options = {})
ensure_ready!(:authorization)
url = "collaborators/#{escape(login)}"
response = connection.put(url, options)
checked_response_body(response)
end | ruby | def add_collaborator(login, options = {})
ensure_ready!(:authorization)
url = "collaborators/#{escape(login)}"
response = connection.put(url, options)
checked_response_body(response)
end | [
"def",
"add_collaborator",
"(",
"login",
",",
"options",
"=",
"{",
"}",
")",
"ensure_ready!",
"(",
":authorization",
")",
"url",
"=",
"\"collaborators/#{escape(login)}\"",
"response",
"=",
"connection",
".",
"put",
"(",
"url",
",",
"options",
")",
"checked_respo... | Add a collaborator to the account | [
"Add",
"a",
"collaborator",
"to",
"the",
"account"
] | edcdf816a9925abf6fbe89fe7896a563e1902582 | https://github.com/gemfury/gemfury/blob/edcdf816a9925abf6fbe89fe7896a563e1902582/lib/gemfury/client.rb#L86-L91 | train |
gemfury/gemfury | lib/gemfury/client.rb | Gemfury.Client.remove_collaborator | def remove_collaborator(login, options = {})
ensure_ready!(:authorization)
url = "collaborators/#{escape(login)}"
response = connection.delete(url, options)
checked_response_body(response)
end | ruby | def remove_collaborator(login, options = {})
ensure_ready!(:authorization)
url = "collaborators/#{escape(login)}"
response = connection.delete(url, options)
checked_response_body(response)
end | [
"def",
"remove_collaborator",
"(",
"login",
",",
"options",
"=",
"{",
"}",
")",
"ensure_ready!",
"(",
":authorization",
")",
"url",
"=",
"\"collaborators/#{escape(login)}\"",
"response",
"=",
"connection",
".",
"delete",
"(",
"url",
",",
"options",
")",
"checked... | Remove a collaborator to the account | [
"Remove",
"a",
"collaborator",
"to",
"the",
"account"
] | edcdf816a9925abf6fbe89fe7896a563e1902582 | https://github.com/gemfury/gemfury/blob/edcdf816a9925abf6fbe89fe7896a563e1902582/lib/gemfury/client.rb#L94-L99 | train |
gemfury/gemfury | lib/gemfury/client.rb | Gemfury.Client.git_repos | def git_repos(options = {})
ensure_ready!(:authorization)
response = connection.get(git_repo_path, options)
checked_response_body(response)
end | ruby | def git_repos(options = {})
ensure_ready!(:authorization)
response = connection.get(git_repo_path, options)
checked_response_body(response)
end | [
"def",
"git_repos",
"(",
"options",
"=",
"{",
"}",
")",
"ensure_ready!",
"(",
":authorization",
")",
"response",
"=",
"connection",
".",
"get",
"(",
"git_repo_path",
",",
"options",
")",
"checked_response_body",
"(",
"response",
")",
"end"
] | List Git repos for this account | [
"List",
"Git",
"repos",
"for",
"this",
"account"
] | edcdf816a9925abf6fbe89fe7896a563e1902582 | https://github.com/gemfury/gemfury/blob/edcdf816a9925abf6fbe89fe7896a563e1902582/lib/gemfury/client.rb#L102-L106 | train |
gemfury/gemfury | lib/gemfury/client.rb | Gemfury.Client.git_update | def git_update(repo, options = {})
ensure_ready!(:authorization)
response = connection.patch(git_repo_path(repo), options)
checked_response_body(response)
end | ruby | def git_update(repo, options = {})
ensure_ready!(:authorization)
response = connection.patch(git_repo_path(repo), options)
checked_response_body(response)
end | [
"def",
"git_update",
"(",
"repo",
",",
"options",
"=",
"{",
"}",
")",
"ensure_ready!",
"(",
":authorization",
")",
"response",
"=",
"connection",
".",
"patch",
"(",
"git_repo_path",
"(",
"repo",
")",
",",
"options",
")",
"checked_response_body",
"(",
"respon... | Update repository name and settings | [
"Update",
"repository",
"name",
"and",
"settings"
] | edcdf816a9925abf6fbe89fe7896a563e1902582 | https://github.com/gemfury/gemfury/blob/edcdf816a9925abf6fbe89fe7896a563e1902582/lib/gemfury/client.rb#L109-L113 | train |
gemfury/gemfury | lib/gemfury/client.rb | Gemfury.Client.git_reset | def git_reset(repo, options = {})
ensure_ready!(:authorization)
response = connection.delete(git_repo_path(repo), options)
checked_response_body(response)
end | ruby | def git_reset(repo, options = {})
ensure_ready!(:authorization)
response = connection.delete(git_repo_path(repo), options)
checked_response_body(response)
end | [
"def",
"git_reset",
"(",
"repo",
",",
"options",
"=",
"{",
"}",
")",
"ensure_ready!",
"(",
":authorization",
")",
"response",
"=",
"connection",
".",
"delete",
"(",
"git_repo_path",
"(",
"repo",
")",
",",
"options",
")",
"checked_response_body",
"(",
"respon... | Reset repository to initial state | [
"Reset",
"repository",
"to",
"initial",
"state"
] | edcdf816a9925abf6fbe89fe7896a563e1902582 | https://github.com/gemfury/gemfury/blob/edcdf816a9925abf6fbe89fe7896a563e1902582/lib/gemfury/client.rb#L116-L120 | train |
gemfury/gemfury | lib/gemfury/client.rb | Gemfury.Client.git_rebuild | def git_rebuild(repo, options = {})
ensure_ready!(:authorization)
url = "#{git_repo_path(repo)}/builds"
api = connection(:api_format => :text)
checked_response_body(api.post(url, options))
end | ruby | def git_rebuild(repo, options = {})
ensure_ready!(:authorization)
url = "#{git_repo_path(repo)}/builds"
api = connection(:api_format => :text)
checked_response_body(api.post(url, options))
end | [
"def",
"git_rebuild",
"(",
"repo",
",",
"options",
"=",
"{",
"}",
")",
"ensure_ready!",
"(",
":authorization",
")",
"url",
"=",
"\"#{git_repo_path(repo)}/builds\"",
"api",
"=",
"connection",
"(",
":api_format",
"=>",
":text",
")",
"checked_response_body",
"(",
"... | Rebuild Git repository package | [
"Rebuild",
"Git",
"repository",
"package"
] | edcdf816a9925abf6fbe89fe7896a563e1902582 | https://github.com/gemfury/gemfury/blob/edcdf816a9925abf6fbe89fe7896a563e1902582/lib/gemfury/client.rb#L123-L128 | train |
celluloid/reel | lib/reel/response.rb | Reel.Response.status= | def status=(status, reason=nil)
case status
when Integer
@status = status
@reason ||= STATUS_CODES[status]
when Symbol
if code = SYMBOL_TO_STATUS_CODE[status]
self.status = code
else
raise ArgumentError, "unrecognized status symbol: #{status}"
... | ruby | def status=(status, reason=nil)
case status
when Integer
@status = status
@reason ||= STATUS_CODES[status]
when Symbol
if code = SYMBOL_TO_STATUS_CODE[status]
self.status = code
else
raise ArgumentError, "unrecognized status symbol: #{status}"
... | [
"def",
"status",
"=",
"(",
"status",
",",
"reason",
"=",
"nil",
")",
"case",
"status",
"when",
"Integer",
"@status",
"=",
"status",
"@reason",
"||=",
"STATUS_CODES",
"[",
"status",
"]",
"when",
"Symbol",
"if",
"code",
"=",
"SYMBOL_TO_STATUS_CODE",
"[",
"st... | Set the status | [
"Set",
"the",
"status"
] | f6dd9922ce0e17dbd1a763d1831ac9d7648bc1d3 | https://github.com/celluloid/reel/blob/f6dd9922ce0e17dbd1a763d1831ac9d7648bc1d3/lib/reel/response.rb#L48-L62 | train |
celluloid/reel | lib/reel/connection.rb | Reel.Connection.request | def request
raise StateError, "already processing a request" if current_request
req = @parser.current_request
@request_fsm.transition :headers
@keepalive = false if req[CONNECTION] == CLOSE || req.version == HTTP_VERSION_1_0
@current_request = req
req
rescue IOError, Errno::ECO... | ruby | def request
raise StateError, "already processing a request" if current_request
req = @parser.current_request
@request_fsm.transition :headers
@keepalive = false if req[CONNECTION] == CLOSE || req.version == HTTP_VERSION_1_0
@current_request = req
req
rescue IOError, Errno::ECO... | [
"def",
"request",
"raise",
"StateError",
",",
"\"already processing a request\"",
"if",
"current_request",
"req",
"=",
"@parser",
".",
"current_request",
"@request_fsm",
".",
"transition",
":headers",
"@keepalive",
"=",
"false",
"if",
"req",
"[",
"CONNECTION",
"]",
... | Read a request object from the connection | [
"Read",
"a",
"request",
"object",
"from",
"the",
"connection"
] | f6dd9922ce0e17dbd1a763d1831ac9d7648bc1d3 | https://github.com/celluloid/reel/blob/f6dd9922ce0e17dbd1a763d1831ac9d7648bc1d3/lib/reel/connection.rb#L54-L67 | train |
celluloid/reel | lib/reel/spy.rb | Reel.Spy.readpartial | def readpartial(maxlen, outbuf = "")
data = @socket.readpartial(maxlen, outbuf)
log :read, data
data
end | ruby | def readpartial(maxlen, outbuf = "")
data = @socket.readpartial(maxlen, outbuf)
log :read, data
data
end | [
"def",
"readpartial",
"(",
"maxlen",
",",
"outbuf",
"=",
"\"\"",
")",
"data",
"=",
"@socket",
".",
"readpartial",
"(",
"maxlen",
",",
"outbuf",
")",
"log",
":read",
",",
"data",
"data",
"end"
] | Read from the client | [
"Read",
"from",
"the",
"client"
] | f6dd9922ce0e17dbd1a763d1831ac9d7648bc1d3 | https://github.com/celluloid/reel/blob/f6dd9922ce0e17dbd1a763d1831ac9d7648bc1d3/lib/reel/spy.rb#L23-L27 | train |
celluloid/reel | lib/reel/spy.rb | Reel.Spy.log | def log(type, str)
case type
when :connect
@logger << Colors.green(str)
when :close
@logger << Colors.red(str)
when :read
@logger << Colors.gold(str)
when :write
@logger << Colors.white(str)
else
raise "unknown event type: #{type.inspect}"
... | ruby | def log(type, str)
case type
when :connect
@logger << Colors.green(str)
when :close
@logger << Colors.red(str)
when :read
@logger << Colors.gold(str)
when :write
@logger << Colors.white(str)
else
raise "unknown event type: #{type.inspect}"
... | [
"def",
"log",
"(",
"type",
",",
"str",
")",
"case",
"type",
"when",
":connect",
"@logger",
"<<",
"Colors",
".",
"green",
"(",
"str",
")",
"when",
":close",
"@logger",
"<<",
"Colors",
".",
"red",
"(",
"str",
")",
"when",
":read",
"@logger",
"<<",
"Col... | Log the given event | [
"Log",
"the",
"given",
"event"
] | f6dd9922ce0e17dbd1a763d1831ac9d7648bc1d3 | https://github.com/celluloid/reel/blob/f6dd9922ce0e17dbd1a763d1831ac9d7648bc1d3/lib/reel/spy.rb#L43-L56 | train |
celluloid/reel | lib/reel/request.rb | Reel.Request.read | def read(length = nil, buffer = nil)
raise ArgumentError, "negative length #{length} given" if length && length < 0
return '' if length == 0
res = buffer.nil? ? '' : buffer.clear
chunk_size = length.nil? ? @connection.buffer_size : length
begin
while chunk_size > 0
chun... | ruby | def read(length = nil, buffer = nil)
raise ArgumentError, "negative length #{length} given" if length && length < 0
return '' if length == 0
res = buffer.nil? ? '' : buffer.clear
chunk_size = length.nil? ? @connection.buffer_size : length
begin
while chunk_size > 0
chun... | [
"def",
"read",
"(",
"length",
"=",
"nil",
",",
"buffer",
"=",
"nil",
")",
"raise",
"ArgumentError",
",",
"\"negative length #{length} given\"",
"if",
"length",
"&&",
"length",
"<",
"0",
"return",
"''",
"if",
"length",
"==",
"0",
"res",
"=",
"buffer",
".",
... | Read a number of bytes, looping until they are available or until
readpartial returns nil, indicating there are no more bytes to read | [
"Read",
"a",
"number",
"of",
"bytes",
"looping",
"until",
"they",
"are",
"available",
"or",
"until",
"readpartial",
"returns",
"nil",
"indicating",
"there",
"are",
"no",
"more",
"bytes",
"to",
"read"
] | f6dd9922ce0e17dbd1a763d1831ac9d7648bc1d3 | https://github.com/celluloid/reel/blob/f6dd9922ce0e17dbd1a763d1831ac9d7648bc1d3/lib/reel/request.rb#L50-L67 | train |
celluloid/reel | lib/reel/request.rb | Reel.Request.readpartial | def readpartial(length = nil)
if length.nil? && @buffer.length > 0
slice = @buffer
@buffer = ""
else
unless finished_reading? || (length && length <= @buffer.length)
@connection.readpartial(length ? length - @buffer.length : @connection.buffer_size)
end
if ... | ruby | def readpartial(length = nil)
if length.nil? && @buffer.length > 0
slice = @buffer
@buffer = ""
else
unless finished_reading? || (length && length <= @buffer.length)
@connection.readpartial(length ? length - @buffer.length : @connection.buffer_size)
end
if ... | [
"def",
"readpartial",
"(",
"length",
"=",
"nil",
")",
"if",
"length",
".",
"nil?",
"&&",
"@buffer",
".",
"length",
">",
"0",
"slice",
"=",
"@buffer",
"@buffer",
"=",
"\"\"",
"else",
"unless",
"finished_reading?",
"||",
"(",
"length",
"&&",
"length",
"<="... | Read a string up to the given number of bytes, blocking until some
data is available but returning immediately if some data is available | [
"Read",
"a",
"string",
"up",
"to",
"the",
"given",
"number",
"of",
"bytes",
"blocking",
"until",
"some",
"data",
"is",
"available",
"but",
"returning",
"immediately",
"if",
"some",
"data",
"is",
"available"
] | f6dd9922ce0e17dbd1a763d1831ac9d7648bc1d3 | https://github.com/celluloid/reel/blob/f6dd9922ce0e17dbd1a763d1831ac9d7648bc1d3/lib/reel/request.rb#L71-L89 | train |
ianwhite/pickle | lib/pickle/session.rb | Pickle.Session.created_model | def created_model(name)
factory, name_or_index = *parse_model(name)
if name_or_index.blank?
models_by_index(factory).last
elsif name_or_index.is_a?(Integer)
models_by_index(factory)[name_or_index]
else
models_by_name(factory)[name_or_index] or raise ModelNotKnownError, n... | ruby | def created_model(name)
factory, name_or_index = *parse_model(name)
if name_or_index.blank?
models_by_index(factory).last
elsif name_or_index.is_a?(Integer)
models_by_index(factory)[name_or_index]
else
models_by_name(factory)[name_or_index] or raise ModelNotKnownError, n... | [
"def",
"created_model",
"(",
"name",
")",
"factory",
",",
"name_or_index",
"=",
"*",
"parse_model",
"(",
"name",
")",
"if",
"name_or_index",
".",
"blank?",
"models_by_index",
"(",
"factory",
")",
".",
"last",
"elsif",
"name_or_index",
".",
"is_a?",
"(",
"Int... | return the original model stored by create_model or find_model | [
"return",
"the",
"original",
"model",
"stored",
"by",
"create_model",
"or",
"find_model"
] | 3970158227375dc62dc8ae7b79305c013b783c7d | https://github.com/ianwhite/pickle/blob/3970158227375dc62dc8ae7b79305c013b783c7d/lib/pickle/session.rb#L114-L124 | train |
ianwhite/pickle | lib/pickle/session.rb | Pickle.Session.model | def model(name)
model = created_model(name)
return nil unless model
Pickle::Adapter.get_model(model.class, model.id)
end | ruby | def model(name)
model = created_model(name)
return nil unless model
Pickle::Adapter.get_model(model.class, model.id)
end | [
"def",
"model",
"(",
"name",
")",
"model",
"=",
"created_model",
"(",
"name",
")",
"return",
"nil",
"unless",
"model",
"Pickle",
"::",
"Adapter",
".",
"get_model",
"(",
"model",
".",
"class",
",",
"model",
".",
"id",
")",
"end"
] | return a newly selected model | [
"return",
"a",
"newly",
"selected",
"model"
] | 3970158227375dc62dc8ae7b79305c013b783c7d | https://github.com/ianwhite/pickle/blob/3970158227375dc62dc8ae7b79305c013b783c7d/lib/pickle/session.rb#L132-L136 | train |
ianwhite/pickle | lib/pickle/session.rb | Pickle.Session.store_model | def store_model(factory, name, record)
store_record(record.class.name, name, record) unless pickle_parser.canonical(factory) == pickle_parser.canonical(record.class.name)
store_record(factory, name, record)
end | ruby | def store_model(factory, name, record)
store_record(record.class.name, name, record) unless pickle_parser.canonical(factory) == pickle_parser.canonical(record.class.name)
store_record(factory, name, record)
end | [
"def",
"store_model",
"(",
"factory",
",",
"name",
",",
"record",
")",
"store_record",
"(",
"record",
".",
"class",
".",
"name",
",",
"name",
",",
"record",
")",
"unless",
"pickle_parser",
".",
"canonical",
"(",
"factory",
")",
"==",
"pickle_parser",
".",
... | if the factory name != the model name, store under both names | [
"if",
"the",
"factory",
"name",
"!",
"=",
"the",
"model",
"name",
"store",
"under",
"both",
"names"
] | 3970158227375dc62dc8ae7b79305c013b783c7d | https://github.com/ianwhite/pickle/blob/3970158227375dc62dc8ae7b79305c013b783c7d/lib/pickle/session.rb#L231-L234 | train |
ianwhite/pickle | lib/pickle/path.rb | Pickle.Path.path_to_pickle | def path_to_pickle(*pickle_names)
options = pickle_names.extract_options!
resources = pickle_names.map{|n| model(n) || n.to_sym}
if options[:extra]
parts = options[:extra].underscore.gsub(' ','_').split("_")
find_pickle_path_using_action_segment_combinations(resources, parts)
els... | ruby | def path_to_pickle(*pickle_names)
options = pickle_names.extract_options!
resources = pickle_names.map{|n| model(n) || n.to_sym}
if options[:extra]
parts = options[:extra].underscore.gsub(' ','_').split("_")
find_pickle_path_using_action_segment_combinations(resources, parts)
els... | [
"def",
"path_to_pickle",
"(",
"*",
"pickle_names",
")",
"options",
"=",
"pickle_names",
".",
"extract_options!",
"resources",
"=",
"pickle_names",
".",
"map",
"{",
"|",
"n",
"|",
"model",
"(",
"n",
")",
"||",
"n",
".",
"to_sym",
"}",
"if",
"options",
"["... | given args of pickle model name, and an optional extra action, or segment, will attempt to find
a matching named route
path_to_pickle 'the user', :action => 'edit' # => /users/3/edit
path_to_pickle 'the user', 'the comment' # => /users/3/comments/1
path_to_pickle 'the user', :segment => 'comm... | [
"given",
"args",
"of",
"pickle",
"model",
"name",
"and",
"an",
"optional",
"extra",
"action",
"or",
"segment",
"will",
"attempt",
"to",
"find",
"a",
"matching",
"named",
"route"
] | 3970158227375dc62dc8ae7b79305c013b783c7d | https://github.com/ianwhite/pickle/blob/3970158227375dc62dc8ae7b79305c013b783c7d/lib/pickle/path.rb#L14-L23 | train |
ianwhite/pickle | lib/pickle/email.rb | Pickle.Email.emails | def emails(fields = nil)
@emails = ActionMailer::Base.deliveries.select {|m| email_has_fields?(m, fields)}
end | ruby | def emails(fields = nil)
@emails = ActionMailer::Base.deliveries.select {|m| email_has_fields?(m, fields)}
end | [
"def",
"emails",
"(",
"fields",
"=",
"nil",
")",
"@emails",
"=",
"ActionMailer",
"::",
"Base",
".",
"deliveries",
".",
"select",
"{",
"|",
"m",
"|",
"email_has_fields?",
"(",
"m",
",",
"fields",
")",
"}",
"end"
] | return the deliveries array, optionally selected by the passed fields | [
"return",
"the",
"deliveries",
"array",
"optionally",
"selected",
"by",
"the",
"passed",
"fields"
] | 3970158227375dc62dc8ae7b79305c013b783c7d | https://github.com/ianwhite/pickle/blob/3970158227375dc62dc8ae7b79305c013b783c7d/lib/pickle/email.rb#L4-L6 | train |
rightscale/right_http_connection | lib/right_http_connection.rb | Rightscale.HttpConnection.error_add | def error_add(error)
message = error
message = "#{error.class.name}: #{error.message}" if error.is_a?(Exception)
@state[@server] = { :count => error_count+1, :time => Time.now, :message => message }
end | ruby | def error_add(error)
message = error
message = "#{error.class.name}: #{error.message}" if error.is_a?(Exception)
@state[@server] = { :count => error_count+1, :time => Time.now, :message => message }
end | [
"def",
"error_add",
"(",
"error",
")",
"message",
"=",
"error",
"message",
"=",
"\"#{error.class.name}: #{error.message}\"",
"if",
"error",
".",
"is_a?",
"(",
"Exception",
")",
"@state",
"[",
"@server",
"]",
"=",
"{",
":count",
"=>",
"error_count",
"+",
"1",
... | add an error for a server | [
"add",
"an",
"error",
"for",
"a",
"server"
] | 9c8450bb6b8ae37a8a662f0e0415700f36ac6f89 | https://github.com/rightscale/right_http_connection/blob/9c8450bb6b8ae37a8a662f0e0415700f36ac6f89/lib/right_http_connection.rb#L231-L235 | train |
rightscale/right_http_connection | lib/right_http_connection.rb | Rightscale.HttpConnection.setup_streaming | def setup_streaming(request)
if(request.body && request.body.respond_to?(:read))
body = request.body
request.content_length = body.respond_to?(:lstat) ? body.lstat.size : body.size
request.body_stream = request.body
true
end
end | ruby | def setup_streaming(request)
if(request.body && request.body.respond_to?(:read))
body = request.body
request.content_length = body.respond_to?(:lstat) ? body.lstat.size : body.size
request.body_stream = request.body
true
end
end | [
"def",
"setup_streaming",
"(",
"request",
")",
"if",
"(",
"request",
".",
"body",
"&&",
"request",
".",
"body",
".",
"respond_to?",
"(",
":read",
")",
")",
"body",
"=",
"request",
".",
"body",
"request",
".",
"content_length",
"=",
"body",
".",
"respond_... | Detects if an object is 'streamable' - can we read from it, and can we know the size? | [
"Detects",
"if",
"an",
"object",
"is",
"streamable",
"-",
"can",
"we",
"read",
"from",
"it",
"and",
"can",
"we",
"know",
"the",
"size?"
] | 9c8450bb6b8ae37a8a662f0e0415700f36ac6f89 | https://github.com/rightscale/right_http_connection/blob/9c8450bb6b8ae37a8a662f0e0415700f36ac6f89/lib/right_http_connection.rb#L277-L284 | train |
rightscale/right_http_connection | lib/right_http_connection.rb | Rightscale.HttpConnection.start | def start(request_params)
# close the previous if exists
finish
# create new connection
@server = request_params[:server]
@port = request_params[:port]
@protocol = request_params[:protocol]
@proxy_host = request_params[:proxy_host]
@proxy_port ... | ruby | def start(request_params)
# close the previous if exists
finish
# create new connection
@server = request_params[:server]
@port = request_params[:port]
@protocol = request_params[:protocol]
@proxy_host = request_params[:proxy_host]
@proxy_port ... | [
"def",
"start",
"(",
"request_params",
")",
"finish",
"@server",
"=",
"request_params",
"[",
":server",
"]",
"@port",
"=",
"request_params",
"[",
":port",
"]",
"@protocol",
"=",
"request_params",
"[",
":protocol",
"]",
"@proxy_host",
"=",
"request_params",
"[",
... | Start a fresh connection. The object closes any existing connection and
opens a new one. | [
"Start",
"a",
"fresh",
"connection",
".",
"The",
"object",
"closes",
"any",
"existing",
"connection",
"and",
"opens",
"a",
"new",
"one",
"."
] | 9c8450bb6b8ae37a8a662f0e0415700f36ac6f89 | https://github.com/rightscale/right_http_connection/blob/9c8450bb6b8ae37a8a662f0e0415700f36ac6f89/lib/right_http_connection.rb#L310-L389 | train |
rightscale/right_http_connection | lib/right_http_connection.rb | Rightscale.HttpConnection.request | def request(request_params, &block)
current_params = @params.merge(request_params)
exception = get_param(:exception, current_params) || RuntimeError
# Re-establish the connection if any of auth params has changed
same_auth_params_as_before = SECURITY_PARAMS.select do |param|
request_par... | ruby | def request(request_params, &block)
current_params = @params.merge(request_params)
exception = get_param(:exception, current_params) || RuntimeError
# Re-establish the connection if any of auth params has changed
same_auth_params_as_before = SECURITY_PARAMS.select do |param|
request_par... | [
"def",
"request",
"(",
"request_params",
",",
"&",
"block",
")",
"current_params",
"=",
"@params",
".",
"merge",
"(",
"request_params",
")",
"exception",
"=",
"get_param",
"(",
":exception",
",",
"current_params",
")",
"||",
"RuntimeError",
"same_auth_params_as_be... | =begin rdoc
Send HTTP request to server
request_params hash:
:server => 'www.HostName.com' # Hostname or IP address of HTTP server
:port => '80' # Port of HTTP server
:protocol => 'https' # http and https are supported on any port
:request => 'requests... | [
"=",
"begin",
"rdoc",
"Send",
"HTTP",
"request",
"to",
"server"
] | 9c8450bb6b8ae37a8a662f0e0415700f36ac6f89 | https://github.com/rightscale/right_http_connection/blob/9c8450bb6b8ae37a8a662f0e0415700f36ac6f89/lib/right_http_connection.rb#L417-L529 | train |
mbleigh/princely | lib/princely/pdf.rb | Princely.Pdf.pdf_from_string | def pdf_from_string(string, output_file = '-')
with_timeout do
pdf = initialize_pdf_from_string(string, output_file, {:output_to_log_file => false})
pdf.close_write
result = pdf.gets(nil)
pdf.close_read
result.force_encoding('BINARY') if RUBY_VERSION >= "1.9"
resul... | ruby | def pdf_from_string(string, output_file = '-')
with_timeout do
pdf = initialize_pdf_from_string(string, output_file, {:output_to_log_file => false})
pdf.close_write
result = pdf.gets(nil)
pdf.close_read
result.force_encoding('BINARY') if RUBY_VERSION >= "1.9"
resul... | [
"def",
"pdf_from_string",
"(",
"string",
",",
"output_file",
"=",
"'-'",
")",
"with_timeout",
"do",
"pdf",
"=",
"initialize_pdf_from_string",
"(",
"string",
",",
"output_file",
",",
"{",
":output_to_log_file",
"=>",
"false",
"}",
")",
"pdf",
".",
"close_write",
... | Makes a pdf from a passed in string.
Returns PDF as a stream, so we can use send_data to shoot
it down the pipe using Rails. | [
"Makes",
"a",
"pdf",
"from",
"a",
"passed",
"in",
"string",
"."
] | 559f374e89089f5206498aa34306c8eac8c2aa25 | https://github.com/mbleigh/princely/blob/559f374e89089f5206498aa34306c8eac8c2aa25/lib/princely/pdf.rb#L69-L79 | train |
jmettraux/ruote | lib/ruote/dashboard.rb | Ruote.Dashboard.attach | def attach(fei_or_fe, definition, opts={})
fe = Ruote.extract_fexp(@context, fei_or_fe).to_h
fei = fe['fei']
cfei = fei.merge(
'expid' => "#{fei['expid']}_0",
'subid' => Ruote.generate_subid(fei.inspect))
tree = @context.reader.read(definition)
tree[0] = 'sequence'
... | ruby | def attach(fei_or_fe, definition, opts={})
fe = Ruote.extract_fexp(@context, fei_or_fe).to_h
fei = fe['fei']
cfei = fei.merge(
'expid' => "#{fei['expid']}_0",
'subid' => Ruote.generate_subid(fei.inspect))
tree = @context.reader.read(definition)
tree[0] = 'sequence'
... | [
"def",
"attach",
"(",
"fei_or_fe",
",",
"definition",
",",
"opts",
"=",
"{",
"}",
")",
"fe",
"=",
"Ruote",
".",
"extract_fexp",
"(",
"@context",
",",
"fei_or_fe",
")",
".",
"to_h",
"fei",
"=",
"fe",
"[",
"'fei'",
"]",
"cfei",
"=",
"fei",
".",
"merg... | Given a flow expression id, locates the corresponding ruote
expression and attaches a subprocess to it.
Accepts the fei as a Hash or as a FlowExpressionId instance.
By default, the workitem of the expression you attach to provides
the initial workitem for the attached branch. By using the
:fields/:workitem or :m... | [
"Given",
"a",
"flow",
"expression",
"id",
"locates",
"the",
"corresponding",
"ruote",
"expression",
"and",
"attaches",
"a",
"subprocess",
"to",
"it",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/dashboard.rb#L194-L222 | train |
jmettraux/ruote | lib/ruote/dashboard.rb | Ruote.Dashboard.apply_mutation | def apply_mutation(wfid, pdef)
Mutation.new(self, wfid, @context.reader.read(pdef)).apply
end | ruby | def apply_mutation(wfid, pdef)
Mutation.new(self, wfid, @context.reader.read(pdef)).apply
end | [
"def",
"apply_mutation",
"(",
"wfid",
",",
"pdef",
")",
"Mutation",
".",
"new",
"(",
"self",
",",
"wfid",
",",
"@context",
".",
"reader",
".",
"read",
"(",
"pdef",
")",
")",
".",
"apply",
"end"
] | Computes mutation and immediately applies it...
See #compute_mutation
Return the mutation instance (forensic?) | [
"Computes",
"mutation",
"and",
"immediately",
"applies",
"it",
"..."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/dashboard.rb#L431-L434 | train |
jmettraux/ruote | lib/ruote/dashboard.rb | Ruote.Dashboard.processes | def processes(opts={})
wfids = @context.storage.expression_wfids(opts)
opts[:count] ? wfids.size : ProcessStatus.fetch(@context, wfids, opts)
end | ruby | def processes(opts={})
wfids = @context.storage.expression_wfids(opts)
opts[:count] ? wfids.size : ProcessStatus.fetch(@context, wfids, opts)
end | [
"def",
"processes",
"(",
"opts",
"=",
"{",
"}",
")",
"wfids",
"=",
"@context",
".",
"storage",
".",
"expression_wfids",
"(",
"opts",
")",
"opts",
"[",
":count",
"]",
"?",
"wfids",
".",
"size",
":",
"ProcessStatus",
".",
"fetch",
"(",
"@context",
",",
... | Returns an array of ProcessStatus instances.
WARNING : this is an expensive operation, but it understands :skip
and :limit, so pagination is our friend.
Please note, if you're interested only in processes that have errors,
Engine#errors is a more efficient means.
To simply list the wfids of the currently runnin... | [
"Returns",
"an",
"array",
"of",
"ProcessStatus",
"instances",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/dashboard.rb#L477-L482 | train |
jmettraux/ruote | lib/ruote/dashboard.rb | Ruote.Dashboard.wait_for | def wait_for(*items)
opts = (items.size > 1 && items.last.is_a?(Hash)) ? items.pop : {}
@context.logger.wait_for(items, opts)
end | ruby | def wait_for(*items)
opts = (items.size > 1 && items.last.is_a?(Hash)) ? items.pop : {}
@context.logger.wait_for(items, opts)
end | [
"def",
"wait_for",
"(",
"*",
"items",
")",
"opts",
"=",
"(",
"items",
".",
"size",
">",
"1",
"&&",
"items",
".",
"last",
".",
"is_a?",
"(",
"Hash",
")",
")",
"?",
"items",
".",
"pop",
":",
"{",
"}",
"@context",
".",
"logger",
".",
"wait_for",
"... | This method expects there to be a logger with a wait_for method in the
context, else it will raise an exception.
*WARNING*: #wait_for() is meant for environments where there is a unique
worker and that worker is nested in this engine. In a multiple worker
environment wait_for doesn't see events handled by 'other' ... | [
"This",
"method",
"expects",
"there",
"to",
"be",
"a",
"logger",
"with",
"a",
"wait_for",
"method",
"in",
"the",
"context",
"else",
"it",
"will",
"raise",
"an",
"exception",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/dashboard.rb#L710-L715 | train |
jmettraux/ruote | lib/ruote/dashboard.rb | Ruote.Dashboard.register_participant | def register_participant(regex, participant=nil, opts={}, &block)
if participant.is_a?(Hash)
opts = participant
participant = nil
end
pa = @context.plist.register(regex, participant, opts, block)
@context.storage.put_msg(
'participant_registered',
'regex' => re... | ruby | def register_participant(regex, participant=nil, opts={}, &block)
if participant.is_a?(Hash)
opts = participant
participant = nil
end
pa = @context.plist.register(regex, participant, opts, block)
@context.storage.put_msg(
'participant_registered',
'regex' => re... | [
"def",
"register_participant",
"(",
"regex",
",",
"participant",
"=",
"nil",
",",
"opts",
"=",
"{",
"}",
",",
"&",
"block",
")",
"if",
"participant",
".",
"is_a?",
"(",
"Hash",
")",
"opts",
"=",
"participant",
"participant",
"=",
"nil",
"end",
"pa",
"=... | Registers a participant in the engine.
Takes the form
dashboard.register_participant name_or_regex, klass, opts={}
With the form
dashboard.register_participant name_or_regex do |workitem|
# ...
end
A BlockParticipant is automatically created.
== name or regex
When registering participants, st... | [
"Registers",
"a",
"participant",
"in",
"the",
"engine",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/dashboard.rb#L859-L873 | train |
jmettraux/ruote | lib/ruote/exp/ro_attributes.rb | Ruote::Exp.FlowExpression.has_attribute | def has_attribute(*args)
args.each { |a| a = a.to_s; return a if attributes[a] != nil }
nil
end | ruby | def has_attribute(*args)
args.each { |a| a = a.to_s; return a if attributes[a] != nil }
nil
end | [
"def",
"has_attribute",
"(",
"*",
"args",
")",
"args",
".",
"each",
"{",
"|",
"a",
"|",
"a",
"=",
"a",
".",
"to_s",
";",
"return",
"a",
"if",
"attributes",
"[",
"a",
"]",
"!=",
"nil",
"}",
"nil",
"end"
] | Given a list of attribute names, returns the first attribute name for
which there is a value. | [
"Given",
"a",
"list",
"of",
"attribute",
"names",
"returns",
"the",
"first",
"attribute",
"name",
"for",
"which",
"there",
"is",
"a",
"value",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/ro_attributes.rb#L37-L42 | train |
jmettraux/ruote | lib/ruote/exp/ro_attributes.rb | Ruote::Exp.FlowExpression.attribute | def attribute(n, workitem=h.applied_workitem, options={})
n = n.to_s
default = options[:default]
escape = options[:escape]
string = options[:to_s] || options[:string]
v = attributes[n]
v = if v == nil
default
elsif escape
v
else
dsub(v, workite... | ruby | def attribute(n, workitem=h.applied_workitem, options={})
n = n.to_s
default = options[:default]
escape = options[:escape]
string = options[:to_s] || options[:string]
v = attributes[n]
v = if v == nil
default
elsif escape
v
else
dsub(v, workite... | [
"def",
"attribute",
"(",
"n",
",",
"workitem",
"=",
"h",
".",
"applied_workitem",
",",
"options",
"=",
"{",
"}",
")",
"n",
"=",
"n",
".",
"to_s",
"default",
"=",
"options",
"[",
":default",
"]",
"escape",
"=",
"options",
"[",
":escape",
"]",
"string"... | Looks up the value for attribute n. | [
"Looks",
"up",
"the",
"value",
"for",
"attribute",
"n",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/ro_attributes.rb#L48-L69 | train |
jmettraux/ruote | lib/ruote/exp/ro_attributes.rb | Ruote::Exp.FlowExpression.att | def att(keys, values, opts={})
default = opts[:default] || values.first
val = Array(keys).collect { |key| attribute(key) }.compact.first.to_s
values.include?(val) ? val : default
end | ruby | def att(keys, values, opts={})
default = opts[:default] || values.first
val = Array(keys).collect { |key| attribute(key) }.compact.first.to_s
values.include?(val) ? val : default
end | [
"def",
"att",
"(",
"keys",
",",
"values",
",",
"opts",
"=",
"{",
"}",
")",
"default",
"=",
"opts",
"[",
":default",
"]",
"||",
"values",
".",
"first",
"val",
"=",
"Array",
"(",
"keys",
")",
".",
"collect",
"{",
"|",
"key",
"|",
"attribute",
"(",
... | Returns the value for attribute 'key', this value should be present
in the array list 'values'. If not, the default value is returned.
By default, the default value is the first element of 'values'. | [
"Returns",
"the",
"value",
"for",
"attribute",
"key",
"this",
"value",
"should",
"be",
"present",
"in",
"the",
"array",
"list",
"values",
".",
"If",
"not",
"the",
"default",
"value",
"is",
"returned",
".",
"By",
"default",
"the",
"default",
"value",
"is",
... | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/ro_attributes.rb#L75-L82 | train |
jmettraux/ruote | lib/ruote/exp/ro_attributes.rb | Ruote::Exp.FlowExpression.lookup_val_prefix | def lookup_val_prefix(prefix, att_options={})
lval(
[ prefix ] + [ 'val', 'value' ].map { |s| "#{prefix}_#{s}" },
%w[ v var variable ].map { |s| "#{prefix}_#{s}" },
%w[ f fld field ].map { |s| "#{prefix}_#{s}" },
att_options)
end | ruby | def lookup_val_prefix(prefix, att_options={})
lval(
[ prefix ] + [ 'val', 'value' ].map { |s| "#{prefix}_#{s}" },
%w[ v var variable ].map { |s| "#{prefix}_#{s}" },
%w[ f fld field ].map { |s| "#{prefix}_#{s}" },
att_options)
end | [
"def",
"lookup_val_prefix",
"(",
"prefix",
",",
"att_options",
"=",
"{",
"}",
")",
"lval",
"(",
"[",
"prefix",
"]",
"+",
"[",
"'val'",
",",
"'value'",
"]",
".",
"map",
"{",
"|",
"s",
"|",
"\"#{prefix}_#{s}\"",
"}",
",",
"%w[",
"v",
"var",
"variable",... | prefix = 'on' => will lookup on, on_val, on_value, on_v, on_var,
on_variable, on_f, on_fld, on_field... | [
"prefix",
"=",
"on",
"=",
">",
"will",
"lookup",
"on",
"on_val",
"on_value",
"on_v",
"on_var",
"on_variable",
"on_f",
"on_fld",
"on_field",
"..."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/ro_attributes.rb#L87-L94 | train |
jmettraux/ruote | lib/ruote/exp/ro_attributes.rb | Ruote::Exp.FlowExpression.compile_atts | def compile_atts(opts={})
attributes.keys.each_with_object({}) { |k, r|
r[dsub(k)] = attribute(k, h.applied_workitem, opts)
}
end | ruby | def compile_atts(opts={})
attributes.keys.each_with_object({}) { |k, r|
r[dsub(k)] = attribute(k, h.applied_workitem, opts)
}
end | [
"def",
"compile_atts",
"(",
"opts",
"=",
"{",
"}",
")",
"attributes",
".",
"keys",
".",
"each_with_object",
"(",
"{",
"}",
")",
"{",
"|",
"k",
",",
"r",
"|",
"r",
"[",
"dsub",
"(",
"k",
")",
"]",
"=",
"attribute",
"(",
"k",
",",
"h",
".",
"ap... | Returns a Hash containing all attributes set for an expression with
their values resolved. | [
"Returns",
"a",
"Hash",
"containing",
"all",
"attributes",
"set",
"for",
"an",
"expression",
"with",
"their",
"values",
"resolved",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/ro_attributes.rb#L108-L113 | train |
jmettraux/ruote | lib/ruote/exp/ro_attributes.rb | Ruote::Exp.FlowExpression.attribute_text | def attribute_text(workitem=h.applied_workitem)
text = attributes.keys.find { |k| attributes[k] == nil }
dsub(text.to_s, workitem)
end | ruby | def attribute_text(workitem=h.applied_workitem)
text = attributes.keys.find { |k| attributes[k] == nil }
dsub(text.to_s, workitem)
end | [
"def",
"attribute_text",
"(",
"workitem",
"=",
"h",
".",
"applied_workitem",
")",
"text",
"=",
"attributes",
".",
"keys",
".",
"find",
"{",
"|",
"k",
"|",
"attributes",
"[",
"k",
"]",
"==",
"nil",
"}",
"dsub",
"(",
"text",
".",
"to_s",
",",
"workitem... | Given something like
sequence do
participant 'alpha'
end
in the context of the participant expression
attribute_text()
will yield 'alpha'.
Note : an empty text returns '', not the nil value. | [
"Given",
"something",
"like"
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/ro_attributes.rb#L129-L134 | train |
jmettraux/ruote | lib/ruote/exp/ro_attributes.rb | Ruote::Exp.FlowExpression.determine_tos | def determine_tos
to_v = attribute(:to_v) || attribute(:to_var) || attribute(:to_variable)
to_f = attribute(:to_f) || attribute(:to_fld) || attribute(:to_field)
if to = attribute(:to)
pre, key = to.split(':')
pre, key = [ 'f', pre ] if key == nil
if pre.match(/^f/)
... | ruby | def determine_tos
to_v = attribute(:to_v) || attribute(:to_var) || attribute(:to_variable)
to_f = attribute(:to_f) || attribute(:to_fld) || attribute(:to_field)
if to = attribute(:to)
pre, key = to.split(':')
pre, key = [ 'f', pre ] if key == nil
if pre.match(/^f/)
... | [
"def",
"determine_tos",
"to_v",
"=",
"attribute",
"(",
":to_v",
")",
"||",
"attribute",
"(",
":to_var",
")",
"||",
"attribute",
"(",
":to_variable",
")",
"to_f",
"=",
"attribute",
"(",
":to_f",
")",
"||",
"attribute",
"(",
":to_fld",
")",
"||",
"attribute"... | 'tos' meaning 'many "to"' | [
"tos",
"meaning",
"many",
"to"
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/ro_attributes.rb#L157-L173 | train |
jmettraux/ruote | lib/ruote/exp/flow_expression.rb | Ruote::Exp.FlowExpression.do_apply | def do_apply(msg)
if msg['state'] == 'paused'
return pause_on_apply(msg)
end
if msg['flavour'].nil? && (aw = attribute(:await))
return await(aw, msg)
end
unless Condition.apply?(attribute(:if), attribute(:unless))
return do_reply_to_parent(h.applied_workitem)
... | ruby | def do_apply(msg)
if msg['state'] == 'paused'
return pause_on_apply(msg)
end
if msg['flavour'].nil? && (aw = attribute(:await))
return await(aw, msg)
end
unless Condition.apply?(attribute(:if), attribute(:unless))
return do_reply_to_parent(h.applied_workitem)
... | [
"def",
"do_apply",
"(",
"msg",
")",
"if",
"msg",
"[",
"'state'",
"]",
"==",
"'paused'",
"return",
"pause_on_apply",
"(",
"msg",
")",
"end",
"if",
"msg",
"[",
"'flavour'",
"]",
".",
"nil?",
"&&",
"(",
"aw",
"=",
"attribute",
"(",
":await",
")",
")",
... | Called by the worker when it has just created this FlowExpression and
wants to apply it. | [
"Called",
"by",
"the",
"worker",
"when",
"it",
"has",
"just",
"created",
"this",
"FlowExpression",
"and",
"wants",
"to",
"apply",
"it",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/flow_expression.rb#L356-L415 | train |
jmettraux/ruote | lib/ruote/exp/flow_expression.rb | Ruote::Exp.FlowExpression.do_reply_to_parent | def do_reply_to_parent(workitem, delete=true)
# propagate the cancel "flavour" back, so that one can know
# why a branch got cancelled.
flavour = if @msg.nil?
nil
elsif @msg['action'] == 'cancel'
@msg['flavour'] || 'cancel'
elsif h.state.nil?
nil
else
... | ruby | def do_reply_to_parent(workitem, delete=true)
# propagate the cancel "flavour" back, so that one can know
# why a branch got cancelled.
flavour = if @msg.nil?
nil
elsif @msg['action'] == 'cancel'
@msg['flavour'] || 'cancel'
elsif h.state.nil?
nil
else
... | [
"def",
"do_reply_to_parent",
"(",
"workitem",
",",
"delete",
"=",
"true",
")",
"flavour",
"=",
"if",
"@msg",
".",
"nil?",
"nil",
"elsif",
"@msg",
"[",
"'action'",
"]",
"==",
"'cancel'",
"@msg",
"[",
"'flavour'",
"]",
"||",
"'cancel'",
"elsif",
"h",
".",
... | The essence of the reply_to_parent job... | [
"The",
"essence",
"of",
"the",
"reply_to_parent",
"job",
"..."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/flow_expression.rb#L477-L602 | train |
jmettraux/ruote | lib/ruote/exp/flow_expression.rb | Ruote::Exp.FlowExpression.do_pause | def do_pause(msg)
return if h.state != nil
h.state = 'paused'
do_persist || return
h.children.each { |i|
@context.storage.put_msg('pause', 'fei' => i)
} unless msg['breakpoint']
end | ruby | def do_pause(msg)
return if h.state != nil
h.state = 'paused'
do_persist || return
h.children.each { |i|
@context.storage.put_msg('pause', 'fei' => i)
} unless msg['breakpoint']
end | [
"def",
"do_pause",
"(",
"msg",
")",
"return",
"if",
"h",
".",
"state",
"!=",
"nil",
"h",
".",
"state",
"=",
"'paused'",
"do_persist",
"||",
"return",
"h",
".",
"children",
".",
"each",
"{",
"|",
"i",
"|",
"@context",
".",
"storage",
".",
"put_msg",
... | Expression received a "pause" message. Will put the expression in the
"paused" state and then pass the message to the children.
If the expression is in a non-nil state (failed, timed_out, ...), the
message will be ignored. | [
"Expression",
"received",
"a",
"pause",
"message",
".",
"Will",
"put",
"the",
"expression",
"in",
"the",
"paused",
"state",
"and",
"then",
"pass",
"the",
"message",
"to",
"the",
"children",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/flow_expression.rb#L787-L798 | train |
jmettraux/ruote | lib/ruote/exp/flow_expression.rb | Ruote::Exp.FlowExpression.ancestor? | def ancestor?(fei)
fei = fei.to_h if fei.respond_to?(:to_h)
return false unless h.parent_id
return true if h.parent_id == fei
parent.ancestor?(fei)
end | ruby | def ancestor?(fei)
fei = fei.to_h if fei.respond_to?(:to_h)
return false unless h.parent_id
return true if h.parent_id == fei
parent.ancestor?(fei)
end | [
"def",
"ancestor?",
"(",
"fei",
")",
"fei",
"=",
"fei",
".",
"to_h",
"if",
"fei",
".",
"respond_to?",
"(",
":to_h",
")",
"return",
"false",
"unless",
"h",
".",
"parent_id",
"return",
"true",
"if",
"h",
".",
"parent_id",
"==",
"fei",
"parent",
".",
"a... | Returns true if the given fei points to an expression in the parent
chain of this expression. | [
"Returns",
"true",
"if",
"the",
"given",
"fei",
"points",
"to",
"an",
"expression",
"in",
"the",
"parent",
"chain",
"of",
"this",
"expression",
"."
] | 30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c | https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/flow_expression.rb#L866-L874 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.