id
int32
0
24.9k
repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
20,100
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
20,101
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
20,102
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
20,103
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
20,104
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
20,105
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
20,106
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
20,107
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
20,108
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", ")", "#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 n...
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
20,109
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
20,110
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
20,111
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", "# 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", "...
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
20,112
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
20,113
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", "(", ")", "# 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 belo...
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
20,114
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", ")", "# Attempt to read page. May raise HTTPError.", "options", "=", "{", "}", "READER_OPTIONS", ".", "each", "{", "|", "key", "|", "options", "[", "key", "]", "=", "option", "(", "key", ")", ...
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
20,115
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
20,116
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
20,117
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
20,118
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
20,119
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", "(", "/", "/", ")", "# comment", "tag", "<<", "@scanner", ".", "matched", "tag", "<<", "(", "@scanner", ".", "scan_until", "(", "/", "\\s", "/", ")", "||", "@scan...
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
20,120
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
20,121
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", "|", "# Element must be inside parent element.", "return", "false", "unless", "element", ".", "parent", "and", "element", ".", "parent", ".", "tag?", "name", "=", "of_type", "?", "element"...
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
20,122
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
20,123
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
20,124
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
20,125
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
20,126
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
20,127
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
20,128
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
20,129
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
20,130
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
20,131
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
20,132
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
20,133
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
20,134
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
20,135
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
20,136
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
20,137
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
20,138
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
20,139
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
20,140
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
20,141
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
20,142
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
20,143
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
20,144
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
20,145
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
20,146
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
20,147
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
20,148
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?", "(", "Integer", ...
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
20,149
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
20,150
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
20,151
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
20,152
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
20,153
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
20,154
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
20,155
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", ")", "# close the previous if exists", "finish", "# create new connection", "@server", "=", "request_params", "[", ":server", "]", "@port", "=", "request_params", "[", ":port", "]", "@protocol", "=", "request_params", "[", ":prot...
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
20,156
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", "# Re-establish the con...
=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
20,157
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
20,158
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
20,159
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
20,160
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
20,161
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
20,162
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
20,163
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
20,164
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
20,165
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
20,166
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
20,167
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
20,168
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
20,169
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
20,170
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
20,171
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", ")", "# propagate the cancel \"flavour\" back, so that one can know", "# why a branch got cancelled.", "flavour", "=", "if", "@msg", ".", "nil?", "nil", "elsif", "@msg", "[", "'action'", "]", "=="...
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
20,172
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
20,173
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
20,174
jmettraux/ruote
lib/ruote/exp/flow_expression.rb
Ruote::Exp.FlowExpression.pre_apply_child
def pre_apply_child(child_index, workitem, forget) child_fei = h.fei.merge( 'expid' => "#{h.fei['expid']}_#{child_index}", 'subid' => Ruote.generate_subid(h.fei.inspect)) h.children << child_fei unless forget msg = { 'fei' => child_fei, 'tree' => tree.last[child_inde...
ruby
def pre_apply_child(child_index, workitem, forget) child_fei = h.fei.merge( 'expid' => "#{h.fei['expid']}_#{child_index}", 'subid' => Ruote.generate_subid(h.fei.inspect)) h.children << child_fei unless forget msg = { 'fei' => child_fei, 'tree' => tree.last[child_inde...
[ "def", "pre_apply_child", "(", "child_index", ",", "workitem", ",", "forget", ")", "child_fei", "=", "h", ".", "fei", ".", "merge", "(", "'expid'", "=>", "\"#{h.fei['expid']}_#{child_index}\"", ",", "'subid'", "=>", "Ruote", ".", "generate_subid", "(", "h", "....
Used locally but also by ConcurrenceExpression, when preparing children before they get applied.
[ "Used", "locally", "but", "also", "by", "ConcurrenceExpression", "when", "preparing", "children", "before", "they", "get", "applied", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/flow_expression.rb#L965-L983
20,175
jmettraux/ruote
lib/ruote/exp/flow_expression.rb
Ruote::Exp.FlowExpression.apply_child
def apply_child(child_index, workitem, forget=false) msg = pre_apply_child(child_index, workitem, forget) persist_or_raise unless forget # no need to persist the parent (this) if the child is to be forgotten @context.storage.put_msg('apply', msg) end
ruby
def apply_child(child_index, workitem, forget=false) msg = pre_apply_child(child_index, workitem, forget) persist_or_raise unless forget # no need to persist the parent (this) if the child is to be forgotten @context.storage.put_msg('apply', msg) end
[ "def", "apply_child", "(", "child_index", ",", "workitem", ",", "forget", "=", "false", ")", "msg", "=", "pre_apply_child", "(", "child_index", ",", "workitem", ",", "forget", ")", "persist_or_raise", "unless", "forget", "# no need to persist the parent (this) if the ...
Used by expressions when, well, applying a child expression of theirs.
[ "Used", "by", "expressions", "when", "well", "applying", "a", "child", "expression", "of", "theirs", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/flow_expression.rb#L987-L995
20,176
jmettraux/ruote
lib/ruote/exp/flow_expression.rb
Ruote::Exp.FlowExpression.leave_tag
def leave_tag(workitem) unset_variable(h.tagname) Ruote::Workitem.new(workitem).send(:remove_tag, h.tagname) @context.storage.put_msg( 'left_tag', 'tag' => h.tagname, 'full_tag' => h.full_tagname, 'fei' => h.fei, 'workitem' => workitem) return unless h...
ruby
def leave_tag(workitem) unset_variable(h.tagname) Ruote::Workitem.new(workitem).send(:remove_tag, h.tagname) @context.storage.put_msg( 'left_tag', 'tag' => h.tagname, 'full_tag' => h.full_tagname, 'fei' => h.fei, 'workitem' => workitem) return unless h...
[ "def", "leave_tag", "(", "workitem", ")", "unset_variable", "(", "h", ".", "tagname", ")", "Ruote", "::", "Workitem", ".", "new", "(", "workitem", ")", ".", "send", "(", ":remove_tag", ",", "h", ".", "tagname", ")", "@context", ".", "storage", ".", "pu...
Called when the expression is about to reply to its parent and wants to get rid of its tags.
[ "Called", "when", "the", "expression", "is", "about", "to", "reply", "to", "its", "parent", "and", "wants", "to", "get", "rid", "of", "its", "tags", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/flow_expression.rb#L1041-L1085
20,177
jmettraux/ruote
lib/ruote/util/filter.rb
Ruote.RuleSession.do_merge
def do_merge(field, target, value) value = Rufus::Json.dup(value) if target.is_a?(Array) target.push(value) elsif value.is_a?(Hash) target.merge!(value) else # deal with non Hash target[field.split('.').last] = value end target.delete('~') target.dele...
ruby
def do_merge(field, target, value) value = Rufus::Json.dup(value) if target.is_a?(Array) target.push(value) elsif value.is_a?(Hash) target.merge!(value) else # deal with non Hash target[field.split('.').last] = value end target.delete('~') target.dele...
[ "def", "do_merge", "(", "field", ",", "target", ",", "value", ")", "value", "=", "Rufus", "::", "Json", ".", "dup", "(", "value", ")", "if", "target", ".", "is_a?", "(", "Array", ")", "target", ".", "push", "(", "value", ")", "elsif", "value", ".",...
Used by both _merge_to and _merge_from
[ "Used", "by", "both", "_merge_to", "and", "_merge_from" ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/util/filter.rb#L275-L289
20,178
jmettraux/ruote
lib/ruote/dboard/process_status.rb
Ruote.ProcessStatus.tags
def tags variables ? Hash[variables.select { |k, v| Ruote.is_a_fei?(v) }] : nil end
ruby
def tags variables ? Hash[variables.select { |k, v| Ruote.is_a_fei?(v) }] : nil end
[ "def", "tags", "variables", "?", "Hash", "[", "variables", ".", "select", "{", "|", "k", ",", "v", "|", "Ruote", ".", "is_a_fei?", "(", "v", ")", "}", "]", ":", "nil", "end" ]
Returns a hash tagname => fei of tags set at the root of the process instance. Returns nil if there is no defined root expression.
[ "Returns", "a", "hash", "tagname", "=", ">", "fei", "of", "tags", "set", "at", "the", "root", "of", "the", "process", "instance", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/dboard/process_status.rb#L153-L156
20,179
jmettraux/ruote
lib/ruote/dboard/process_status.rb
Ruote.ProcessStatus.all_tags
def all_tags all_variables.remap do |(fei, vars), h| vars.each { |k, v| (h[k] ||= []) << v if Ruote.is_a_fei?(v) } end end
ruby
def all_tags all_variables.remap do |(fei, vars), h| vars.each { |k, v| (h[k] ||= []) << v if Ruote.is_a_fei?(v) } end end
[ "def", "all_tags", "all_variables", ".", "remap", "do", "|", "(", "fei", ",", "vars", ")", ",", "h", "|", "vars", ".", "each", "{", "|", "k", ",", "v", "|", "(", "h", "[", "k", "]", "||=", "[", "]", ")", "<<", "v", "if", "Ruote", ".", "is_a...
Returns a hash tagname => array of feis of all the tags set in the process instance.
[ "Returns", "a", "hash", "tagname", "=", ">", "array", "of", "feis", "of", "all", "the", "tags", "set", "in", "the", "process", "instance", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/dboard/process_status.rb#L161-L166
20,180
jmettraux/ruote
lib/ruote/dboard/process_status.rb
Ruote.ProcessStatus.wfid
def wfid l = [ @expressions, @errors, @stored_workitems ].find { |l| l.any? } l ? l.first.fei.wfid : nil end
ruby
def wfid l = [ @expressions, @errors, @stored_workitems ].find { |l| l.any? } l ? l.first.fei.wfid : nil end
[ "def", "wfid", "l", "=", "[", "@expressions", ",", "@errors", ",", "@stored_workitems", "]", ".", "find", "{", "|", "l", "|", "l", ".", "any?", "}", "l", "?", "l", ".", "first", ".", "fei", ".", "wfid", ":", "nil", "end" ]
Returns the unique identifier for this process instance.
[ "Returns", "the", "unique", "identifier", "for", "this", "process", "instance", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/dboard/process_status.rb#L197-L202
20,181
jmettraux/ruote
lib/ruote/dboard/process_status.rb
Ruote.ProcessStatus.position
def position workitems.collect { |wi| r = [ wi.fei.sid, wi.participant_name ] params = (wi.fields['params'] || {}).dup params.delete('ref') if err = errors.find { |e| e.fei == wi.fei } params['error'] = err.message end r << params r } ...
ruby
def position workitems.collect { |wi| r = [ wi.fei.sid, wi.participant_name ] params = (wi.fields['params'] || {}).dup params.delete('ref') if err = errors.find { |e| e.fei == wi.fei } params['error'] = err.message end r << params r } ...
[ "def", "position", "workitems", ".", "collect", "{", "|", "wi", "|", "r", "=", "[", "wi", ".", "fei", ".", "sid", ",", "wi", ".", "participant_name", "]", "params", "=", "(", "wi", ".", "fields", "[", "'params'", "]", "||", "{", "}", ")", ".", ...
Returns the 'position' of the process. pdef = Ruote.process_definition do alpha :task => 'clean car' end wfid = engine.launch(pdef) sleep 0.500 engine.process(wfid) # => [["0_0", "alpha", {"task"=>"clean car"}]] A process with concurrent branches will yield multiple 'positions'. It uses #work...
[ "Returns", "the", "position", "of", "the", "process", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/dboard/process_status.rb#L255-L271
20,182
jmettraux/ruote
lib/ruote/dboard/process_status.rb
Ruote.ProcessStatus.leaves
def leaves expressions.inject([]) { |a, exp| a.select { |e| ! exp.ancestor?(e.fei) } + [ exp ] } end
ruby
def leaves expressions.inject([]) { |a, exp| a.select { |e| ! exp.ancestor?(e.fei) } + [ exp ] } end
[ "def", "leaves", "expressions", ".", "inject", "(", "[", "]", ")", "{", "|", "a", ",", "exp", "|", "a", ".", "select", "{", "|", "e", "|", "!", "exp", ".", "ancestor?", "(", "e", ".", "fei", ")", "}", "+", "[", "exp", "]", "}", "end" ]
Returns the expressions where the flow is currently, ak the leaves of the execution tree. Whereas #position only looks at participant expressions (and errors), #leaves looks at any expressions that is a leave (which has no child at this point). Returns an array of FlowExpression instances. (Note that they may h...
[ "Returns", "the", "expressions", "where", "the", "flow", "is", "currently", "ak", "the", "leaves", "of", "the", "execution", "tree", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/dboard/process_status.rb#L283-L288
20,183
jmettraux/ruote
lib/ruote/dboard/process_status.rb
Ruote.ProcessStatus.workitems
def workitems @expressions.select { |fexp| #fexp.is_a?(Ruote::Exp::ParticipantExpression) fexp.h.name == 'participant' }.collect { |fexp| Ruote::Workitem.new(fexp.h.applied_workitem) } end
ruby
def workitems @expressions.select { |fexp| #fexp.is_a?(Ruote::Exp::ParticipantExpression) fexp.h.name == 'participant' }.collect { |fexp| Ruote::Workitem.new(fexp.h.applied_workitem) } end
[ "def", "workitems", "@expressions", ".", "select", "{", "|", "fexp", "|", "#fexp.is_a?(Ruote::Exp::ParticipantExpression)", "fexp", ".", "h", ".", "name", "==", "'participant'", "}", ".", "collect", "{", "|", "fexp", "|", "Ruote", "::", "Workitem", ".", "new",...
Returns a list of the workitems currently 'out' to participants For example, with an instance of Ruote.process_definition do concurrence do alpha :task => 'clean car' bravo :task => 'sell car' end end calling engine.process(wfid).workitems will yield two workitems (alpha and bravo). ...
[ "Returns", "a", "list", "of", "the", "workitems", "currently", "out", "to", "participants" ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/dboard/process_status.rb#L326-L334
20,184
jmettraux/ruote
lib/ruote/dboard/process_status.rb
Ruote.ProcessStatus.to_dot
def to_dot(opts={}) s = [ "digraph \"process wfid #{wfid}\" {" ] @expressions.each { |e| s.push(*e.send(:to_dot, opts)) } @errors.each { |e| s.push(*e.send(:to_dot, opts)) } s << '}' s.join("\n") end
ruby
def to_dot(opts={}) s = [ "digraph \"process wfid #{wfid}\" {" ] @expressions.each { |e| s.push(*e.send(:to_dot, opts)) } @errors.each { |e| s.push(*e.send(:to_dot, opts)) } s << '}' s.join("\n") end
[ "def", "to_dot", "(", "opts", "=", "{", "}", ")", "s", "=", "[", "\"digraph \\\"process wfid #{wfid}\\\" {\"", "]", "@expressions", ".", "each", "{", "|", "e", "|", "s", ".", "push", "(", "e", ".", "send", "(", ":to_dot", ",", "opts", ")", ")", "}", ...
Returns a 'dot' representation of the process. A graph describing the tree of flow expressions that compose the process.
[ "Returns", "a", "dot", "representation", "of", "the", "process", ".", "A", "graph", "describing", "the", "tree", "of", "flow", "expressions", "that", "compose", "the", "process", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/dboard/process_status.rb#L477-L485
20,185
jmettraux/ruote
lib/ruote/part/template.rb
Ruote.TemplateMixin.render_template
def render_template(template, flow_expression, workitem) template = (File.read(template) rescue nil) if is_a_file?(template) return render_default_template(workitem) unless template template = template.to_s workitem = workitem.to_h if workitem.respond_to?(:to_h) @context.dollar_sub.s(t...
ruby
def render_template(template, flow_expression, workitem) template = (File.read(template) rescue nil) if is_a_file?(template) return render_default_template(workitem) unless template template = template.to_s workitem = workitem.to_h if workitem.respond_to?(:to_h) @context.dollar_sub.s(t...
[ "def", "render_template", "(", "template", ",", "flow_expression", ",", "workitem", ")", "template", "=", "(", "File", ".", "read", "(", "template", ")", "rescue", "nil", ")", "if", "is_a_file?", "(", "template", ")", "return", "render_default_template", "(", ...
Do the rendering.
[ "Do", "the", "rendering", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/part/template.rb#L44-L54
20,186
jmettraux/ruote
lib/ruote/part/template.rb
Ruote.TemplateMixin.render_default_template
def render_default_template(workitem) workitem = workitem.to_h if workitem.respond_to?(:to_h) s = [] s << "workitem for #{workitem['participant_name']}" s << '' s << Rufus::Json.pretty_encode(workitem['fei']) s << '' workitem['fields'].keys.sort.each do |key| s << " -...
ruby
def render_default_template(workitem) workitem = workitem.to_h if workitem.respond_to?(:to_h) s = [] s << "workitem for #{workitem['participant_name']}" s << '' s << Rufus::Json.pretty_encode(workitem['fei']) s << '' workitem['fields'].keys.sort.each do |key| s << " -...
[ "def", "render_default_template", "(", "workitem", ")", "workitem", "=", "workitem", ".", "to_h", "if", "workitem", ".", "respond_to?", "(", ":to_h", ")", "s", "=", "[", "]", "s", "<<", "\"workitem for #{workitem['participant_name']}\"", "s", "<<", "''", "s", ...
Simply returns a pretty-printed view of the workitem
[ "Simply", "returns", "a", "pretty", "-", "printed", "view", "of", "the", "workitem" ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/part/template.rb#L58-L71
20,187
jmettraux/ruote
lib/ruote/exp/fe_participant.rb
Ruote::Exp.ParticipantExpression.consider_participant_timers
def consider_participant_timers(p_info) return if h.has_timers # process definition takes precedence over participant defined timers. timers = nil [ :rtimers, :timers, :rtimeout ].each do |meth| pa = @context.plist.instantiate(p_info, :if_respond_to? => meth) next unless p...
ruby
def consider_participant_timers(p_info) return if h.has_timers # process definition takes precedence over participant defined timers. timers = nil [ :rtimers, :timers, :rtimeout ].each do |meth| pa = @context.plist.instantiate(p_info, :if_respond_to? => meth) next unless p...
[ "def", "consider_participant_timers", "(", "p_info", ")", "return", "if", "h", ".", "has_timers", "# process definition takes precedence over participant defined timers.", "timers", "=", "nil", "[", ":rtimers", ",", ":timers", ",", ":rtimeout", "]", ".", "each", "do", ...
Determines and schedules timeout if any. Note that process definition timeout has priority over participant specified timeout.
[ "Determines", "and", "schedules", "timeout", "if", "any", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/fe_participant.rb#L279-L307
20,188
jmettraux/ruote
lib/ruote/part/local_participant.rb
Ruote.LocalParticipant.re_dispatch
def re_dispatch(wi=nil, opts=nil) wi, opts = [ nil, wi ] if wi.is_a?(Hash) && opts.nil? wi ||= workitem() opts ||= {} wi.h.re_dispatch_count = wi.h.re_dispatch_count.to_s.to_i + 1 msg = { 'action' => 'dispatch', 'fei' => wi.h.fei, 'workitem' => wi.to_h, '...
ruby
def re_dispatch(wi=nil, opts=nil) wi, opts = [ nil, wi ] if wi.is_a?(Hash) && opts.nil? wi ||= workitem() opts ||= {} wi.h.re_dispatch_count = wi.h.re_dispatch_count.to_s.to_i + 1 msg = { 'action' => 'dispatch', 'fei' => wi.h.fei, 'workitem' => wi.to_h, '...
[ "def", "re_dispatch", "(", "wi", "=", "nil", ",", "opts", "=", "nil", ")", "wi", ",", "opts", "=", "[", "nil", ",", "wi", "]", "if", "wi", ".", "is_a?", "(", "Hash", ")", "&&", "opts", ".", "nil?", "wi", "||=", "workitem", "(", ")", "opts", "...
Use this method to re_dispatch the workitem. It takes two options :in and :at for "later re_dispatch". Look at the unschedule_re_dispatch method for an example of participant implementation that uses re_dispatch. Without one of those options, the method is a "reject".
[ "Use", "this", "method", "to", "re_dispatch", "the", "workitem", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/part/local_participant.rb#L156-L183
20,189
jmettraux/ruote
lib/ruote/svc/error_handler.rb
Ruote.ErrorHandler.msg_handle
def msg_handle(msg, err) fexp = Ruote::Exp::FlowExpression.fetch( @context, msg['fei'] || msg['workitem']['fei'] ) rescue nil handle(msg, fexp, err) end
ruby
def msg_handle(msg, err) fexp = Ruote::Exp::FlowExpression.fetch( @context, msg['fei'] || msg['workitem']['fei'] ) rescue nil handle(msg, fexp, err) end
[ "def", "msg_handle", "(", "msg", ",", "err", ")", "fexp", "=", "Ruote", "::", "Exp", "::", "FlowExpression", ".", "fetch", "(", "@context", ",", "msg", "[", "'fei'", "]", "||", "msg", "[", "'workitem'", "]", "[", "'fei'", "]", ")", "rescue", "nil", ...
As used by the dispatch pool and the worker.
[ "As", "used", "by", "the", "dispatch", "pool", "and", "the", "worker", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/svc/error_handler.rb#L59-L66
20,190
jmettraux/ruote
lib/ruote/svc/error_handler.rb
Ruote.ErrorHandler.msg_raise
def msg_raise(msg, err) fei = msg['fei'] wfid = msg['wfid'] || msg.fetch('fei', {})['wfid'] @context.storage.put_msg( 'raise', 'fei' => fei, 'wfid' => wfid, 'msg' => msg, 'error' => deflate(err, fei)) end
ruby
def msg_raise(msg, err) fei = msg['fei'] wfid = msg['wfid'] || msg.fetch('fei', {})['wfid'] @context.storage.put_msg( 'raise', 'fei' => fei, 'wfid' => wfid, 'msg' => msg, 'error' => deflate(err, fei)) end
[ "def", "msg_raise", "(", "msg", ",", "err", ")", "fei", "=", "msg", "[", "'fei'", "]", "wfid", "=", "msg", "[", "'wfid'", "]", "||", "msg", ".", "fetch", "(", "'fei'", ",", "{", "}", ")", "[", "'wfid'", "]", "@context", ".", "storage", ".", "pu...
Packages the error in a 'raise' msg and places it in the storage, for a worker to pick it up. TODO: investigate: is it still used, relevant? (probably yes, ruote-swf)
[ "Packages", "the", "error", "in", "a", "raise", "msg", "and", "places", "it", "in", "the", "storage", "for", "a", "worker", "to", "pick", "it", "up", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/svc/error_handler.rb#L73-L84
20,191
jmettraux/ruote
lib/ruote/svc/error_handler.rb
Ruote.ErrorHandler.handle
def handle(msg, fexp, err) err = RaisedError.new(err) unless err.respond_to?(:backtrace) meta = err.is_a?(Ruote::MetaError) fei = msg['fei'] || (fexp.h.fei rescue nil) wfid = msg['wfid'] || (fei || {})['wfid'] # on_error ? return if ( ! meta) && fexp && fexp.handle_on_error(msg,...
ruby
def handle(msg, fexp, err) err = RaisedError.new(err) unless err.respond_to?(:backtrace) meta = err.is_a?(Ruote::MetaError) fei = msg['fei'] || (fexp.h.fei rescue nil) wfid = msg['wfid'] || (fei || {})['wfid'] # on_error ? return if ( ! meta) && fexp && fexp.handle_on_error(msg,...
[ "def", "handle", "(", "msg", ",", "fexp", ",", "err", ")", "err", "=", "RaisedError", ".", "new", "(", "err", ")", "unless", "err", ".", "respond_to?", "(", ":backtrace", ")", "meta", "=", "err", ".", "is_a?", "(", "Ruote", "::", "MetaError", ")", ...
Called by msg_handle or action_handle.
[ "Called", "by", "msg_handle", "or", "action_handle", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/svc/error_handler.rb#L108-L156
20,192
jmettraux/ruote
lib/ruote/svc/error_handler.rb
Ruote.ErrorHandler.deflate
def deflate(err, fei, fexp=nil) return err unless err.respond_to?(:backtrace) fexp ||= Ruote::Exp::FlowExpression.dummy('fei' => fei, 'original_tree' => nil) fexp.deflate(err) end
ruby
def deflate(err, fei, fexp=nil) return err unless err.respond_to?(:backtrace) fexp ||= Ruote::Exp::FlowExpression.dummy('fei' => fei, 'original_tree' => nil) fexp.deflate(err) end
[ "def", "deflate", "(", "err", ",", "fei", ",", "fexp", "=", "nil", ")", "return", "err", "unless", "err", ".", "respond_to?", "(", ":backtrace", ")", "fexp", "||=", "Ruote", "::", "Exp", "::", "FlowExpression", ".", "dummy", "(", "'fei'", "=>", "fei", ...
Returns a serializable hash with all the details of the error.
[ "Returns", "a", "serializable", "hash", "with", "all", "the", "details", "of", "the", "error", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/svc/error_handler.rb#L160-L168
20,193
jmettraux/ruote
lib/ruote/exp/fe_concurrence.rb
Ruote::Exp.ConcurrenceExpression.expected_count
def expected_count if h.ccount.nil? count_list_size elsif h.ccount >= 0 [ h.ccount, count_list_size ].min else # all but 1, 2, ... i = count_list_size + h.ccount i < 1 ? 1 : i end end
ruby
def expected_count if h.ccount.nil? count_list_size elsif h.ccount >= 0 [ h.ccount, count_list_size ].min else # all but 1, 2, ... i = count_list_size + h.ccount i < 1 ? 1 : i end end
[ "def", "expected_count", "if", "h", ".", "ccount", ".", "nil?", "count_list_size", "elsif", "h", ".", "ccount", ">=", "0", "[", "h", ".", "ccount", ",", "count_list_size", "]", ".", "min", "else", "# all but 1, 2, ...", "i", "=", "count_list_size", "+", "h...
How many branch replies are expected before the concurrence is over ?
[ "How", "many", "branch", "replies", "are", "expected", "before", "the", "concurrence", "is", "over", "?" ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/fe_concurrence.rb#L449-L459
20,194
jmettraux/ruote
lib/ruote/exp/fe_concurrence.rb
Ruote::Exp.ConcurrenceExpression.merge_workitems
def merge_workitems(workitems, merge_type) workitems.inject(nil) do |t, wi| Ruote.merge_workitem(workitem_index(wi), t, wi, merge_type) end end
ruby
def merge_workitems(workitems, merge_type) workitems.inject(nil) do |t, wi| Ruote.merge_workitem(workitem_index(wi), t, wi, merge_type) end end
[ "def", "merge_workitems", "(", "workitems", ",", "merge_type", ")", "workitems", ".", "inject", "(", "nil", ")", "do", "|", "t", ",", "wi", "|", "Ruote", ".", "merge_workitem", "(", "workitem_index", "(", "wi", ")", ",", "t", ",", "wi", ",", "merge_typ...
Given a list of workitems and a merge_type, will merge according to the merge type. The return value is the merged workitem. (Still used when dealing with highest/lowest merge_type and legacy concurrence/citerator expressions)
[ "Given", "a", "list", "of", "workitems", "and", "a", "merge_type", "will", "merge", "according", "to", "the", "merge", "type", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/exp/fe_concurrence.rb#L593-L598
20,195
jmettraux/ruote
lib/ruote/workitem.rb
Ruote.Workitem.as_json
def as_json(pretty=false) pretty ? Rufus::Json.pretty_encode(@h) : Rufus::Json.encode(@h) end
ruby
def as_json(pretty=false) pretty ? Rufus::Json.pretty_encode(@h) : Rufus::Json.encode(@h) end
[ "def", "as_json", "(", "pretty", "=", "false", ")", "pretty", "?", "Rufus", "::", "Json", ".", "pretty_encode", "(", "@h", ")", ":", "Rufus", "::", "Json", ".", "encode", "(", "@h", ")", "end" ]
Encodes this workitem as JSON. If pretty is set to true, will output prettified JSON.
[ "Encodes", "this", "workitem", "as", "JSON", ".", "If", "pretty", "is", "set", "to", "true", "will", "output", "prettified", "JSON", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/workitem.rb#L385-L388
20,196
jmettraux/ruote
lib/ruote/workitem.rb
Ruote.Workitem.remove_tag
def remove_tag(tag) # it's a bit convoluted... trying to cope with potential inconsistencies # # normally, it should only be a tags.pop(), but since user have # access to the workitem and its fields... better be safe than sorry tags = (h.fields['__tags__'] || []) if index = tags.r...
ruby
def remove_tag(tag) # it's a bit convoluted... trying to cope with potential inconsistencies # # normally, it should only be a tags.pop(), but since user have # access to the workitem and its fields... better be safe than sorry tags = (h.fields['__tags__'] || []) if index = tags.r...
[ "def", "remove_tag", "(", "tag", ")", "# it's a bit convoluted... trying to cope with potential inconsistencies", "#", "# normally, it should only be a tags.pop(), but since user have", "# access to the workitem and its fields... better be safe than sorry", "tags", "=", "(", "h", ".", "f...
Used by FlowExpression when leaving a tag.
[ "Used", "by", "FlowExpression", "when", "leaving", "a", "tag", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/workitem.rb#L415-L429
20,197
jmettraux/ruote
lib/ruote/svc/dispatch_pool.rb
Ruote.DispatchPool.dispatch
def dispatch(msg) participant = @context.plist.lookup( msg['participant'] || msg['participant_name'], msg['workitem']) if @context['participant_threads_enabled'] == false || do_not_thread?(participant, msg) then do_dispatch(participant, msg) else do_thre...
ruby
def dispatch(msg) participant = @context.plist.lookup( msg['participant'] || msg['participant_name'], msg['workitem']) if @context['participant_threads_enabled'] == false || do_not_thread?(participant, msg) then do_dispatch(participant, msg) else do_thre...
[ "def", "dispatch", "(", "msg", ")", "participant", "=", "@context", ".", "plist", ".", "lookup", "(", "msg", "[", "'participant'", "]", "||", "msg", "[", "'participant_name'", "]", ",", "msg", "[", "'workitem'", "]", ")", "if", "@context", "[", "'partici...
Dispatching the msg.
[ "Dispatching", "the", "msg", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/svc/dispatch_pool.rb#L53-L66
20,198
jmettraux/ruote
lib/ruote/svc/dispatch_pool.rb
Ruote.DispatchPool.do_dispatch
def do_dispatch(participant, msg) do_raw_dispatch(participant, msg) rescue => err @context.error_handler.msg_handle(msg, err) end
ruby
def do_dispatch(participant, msg) do_raw_dispatch(participant, msg) rescue => err @context.error_handler.msg_handle(msg, err) end
[ "def", "do_dispatch", "(", "participant", ",", "msg", ")", "do_raw_dispatch", "(", "participant", ",", "msg", ")", "rescue", "=>", "err", "@context", ".", "error_handler", ".", "msg_handle", "(", "msg", ",", "err", ")", "end" ]
The raw dispatch work, wrapped in error handling.
[ "The", "raw", "dispatch", "work", "wrapped", "in", "error", "handling", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/svc/dispatch_pool.rb#L93-L99
20,199
jmettraux/ruote
lib/ruote/svc/dispatch_pool.rb
Ruote.DispatchPool.do_threaded_dispatch
def do_threaded_dispatch(participant, msg) msg = Rufus::Json.dup(msg) # # the thread gets its own copy of the message # (especially important if the main thread does something with # the message 'during' the dispatch) # Maybe at some point a limit on the number of dispatch ...
ruby
def do_threaded_dispatch(participant, msg) msg = Rufus::Json.dup(msg) # # the thread gets its own copy of the message # (especially important if the main thread does something with # the message 'during' the dispatch) # Maybe at some point a limit on the number of dispatch ...
[ "def", "do_threaded_dispatch", "(", "participant", ",", "msg", ")", "msg", "=", "Rufus", "::", "Json", ".", "dup", "(", "msg", ")", "#", "# the thread gets its own copy of the message", "# (especially important if the main thread does something with", "# the message 'during' ...
Wraps the call to do_dispatch in a thread.
[ "Wraps", "the", "call", "to", "do_dispatch", "in", "a", "thread", "." ]
30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c
https://github.com/jmettraux/ruote/blob/30a6bb88a4e48ed2e1b9089754f1c8be8c1a879c/lib/ruote/svc/dispatch_pool.rb#L103-L116