_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3
values | text stringlengths 66 10.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q20100 | Gem.SourceIndex.gem_signature | train | def gem_signature(gem_full_name)
require 'digest'
Digest::SHA256.new.hexdigest(@gems[gem_full_name].to_yaml).to_s
end | ruby | {
"resource": ""
} |
q20101 | Gem.SourceIndex.find_name | train | def find_name(gem_name, version_requirement = Gem::Requirement.default)
dep = Gem::Dependency.new gem_name, version_requirement
search dep
end | ruby | {
"resource": ""
} |
q20102 | Gem.SourceIndex.update | train | 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 | {
"resource": ""
} |
q20103 | Gem.SourceIndex.fetch_quick_index | train | 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 | {
"resource": ""
} |
q20104 | Gem.SourceIndex.find_missing | train | 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 | {
"resource": ""
} |
q20105 | Gem.SourceIndex.fetch_single_spec | train | 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 | {
"resource": ""
} |
q20106 | Gem.SourceIndex.update_with_missing | train | 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 | {
"resource": ""
} |
q20107 | Specinfra::Backend.BeakerBase.ssh_exec! | train | 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 | {
"resource": ""
} |
q20108 | Specinfra::Backend.BeakerCygwin.run_command | train | 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 | {
"resource": ""
} |
q20109 | Specinfra::Backend.BeakerExec.run_command | train | 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 | {
"resource": ""
} |
q20110 | BeakerRSpec.BeakerShim.setup | train | 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 | {
"resource": ""
} |
q20111 | M.Executor.suites | train | 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 | {
"resource": ""
} |
q20112 | PaypalAdaptive.Response.approve_paypal_payment_url | train | 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 | {
"resource": ""
} |
q20113 | Scraper.Base.scrape | train | 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 | {
"resource": ""
} |
q20114 | Scraper.Base.document | train | 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 | {
"resource": ""
} |
q20115 | HTML.Node.next_sibling | train | 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 | {
"resource": ""
} |
q20116 | HTML.Node.previous_sibling | train | 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 | {
"resource": ""
} |
q20117 | HTML.Node.previous_element | train | 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 | {
"resource": ""
} |
q20118 | HTML.Node.each | train | def each(value = nil, &block)
yield self, value
if @children
@children.each do |child|
child.each value, &block
end
end
value
end | ruby | {
"resource": ""
} |
q20119 | HTML.Tokenizer.scan_tag | train | 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 | {
"resource": ""
} |
q20120 | HTML.Selector.next_element | train | 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 | {
"resource": ""
} |
q20121 | HTML.Selector.only_child | train | 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 | {
"resource": ""
} |
q20122 | HTML.Node.find_all | train | 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 | {
"resource": ""
} |
q20123 | HTML.Tag.to_s | train | 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 | {
"resource": ""
} |
q20124 | HTML.Tag.match_condition | train | 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 | {
"resource": ""
} |
q20125 | Hoodoo.Client.resource | train | 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 | {
"resource": ""
} |
q20126 | Hoodoo.Logger.remove | train | 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 | {
"resource": ""
} |
q20127 | Hoodoo.Logger.include_class? | train | 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 | {
"resource": ""
} |
q20128 | Hoodoo.Errors.add_error | train | 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 | {
"resource": ""
} |
q20129 | Hoodoo.Errors.add_precompiled_error | train | 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 | {
"resource": ""
} |
q20130 | Hoodoo.Generator.run! | train | 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 | {
"resource": ""
} |
q20131 | Hoodoo.TransientStore.set | train | 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 | {
"resource": ""
} |
q20132 | Hoodoo.TransientStore.normalise_key | train | 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 | {
"resource": ""
} |
q20133 | Gemfury.Client.push_gem | train | 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 | {
"resource": ""
} |
q20134 | Gemfury.Client.versions | train | def versions(name, options = {})
ensure_ready!(:authorization)
url = "gems/#{escape(name)}/versions"
response = connection.get(url, options)
checked_response_body(response)
end | ruby | {
"resource": ""
} |
q20135 | Gemfury.Client.yank_version | train | 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 | {
"resource": ""
} |
q20136 | Gemfury.Client.add_collaborator | train | def add_collaborator(login, options = {})
ensure_ready!(:authorization)
url = "collaborators/#{escape(login)}"
response = connection.put(url, options)
checked_response_body(response)
end | ruby | {
"resource": ""
} |
q20137 | Gemfury.Client.remove_collaborator | train | def remove_collaborator(login, options = {})
ensure_ready!(:authorization)
url = "collaborators/#{escape(login)}"
response = connection.delete(url, options)
checked_response_body(response)
end | ruby | {
"resource": ""
} |
q20138 | Gemfury.Client.git_repos | train | def git_repos(options = {})
ensure_ready!(:authorization)
response = connection.get(git_repo_path, options)
checked_response_body(response)
end | ruby | {
"resource": ""
} |
q20139 | Gemfury.Client.git_update | train | def git_update(repo, options = {})
ensure_ready!(:authorization)
response = connection.patch(git_repo_path(repo), options)
checked_response_body(response)
end | ruby | {
"resource": ""
} |
q20140 | Gemfury.Client.git_reset | train | def git_reset(repo, options = {})
ensure_ready!(:authorization)
response = connection.delete(git_repo_path(repo), options)
checked_response_body(response)
end | ruby | {
"resource": ""
} |
q20141 | Gemfury.Client.git_rebuild | train | 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 | {
"resource": ""
} |
q20142 | Reel.Response.status= | train | 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 | {
"resource": ""
} |
q20143 | Reel.Connection.request | train | 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 | {
"resource": ""
} |
q20144 | Reel.Spy.readpartial | train | def readpartial(maxlen, outbuf = "")
data = @socket.readpartial(maxlen, outbuf)
log :read, data
data
end | ruby | {
"resource": ""
} |
q20145 | Reel.Spy.log | train | 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 | {
"resource": ""
} |
q20146 | Reel.Request.read | train | 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 | {
"resource": ""
} |
q20147 | Reel.Request.readpartial | train | 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 | {
"resource": ""
} |
q20148 | Pickle.Session.created_model | train | 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 | {
"resource": ""
} |
q20149 | Pickle.Session.model | train | def model(name)
model = created_model(name)
return nil unless model
Pickle::Adapter.get_model(model.class, model.id)
end | ruby | {
"resource": ""
} |
q20150 | Pickle.Session.store_model | train | 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 | {
"resource": ""
} |
q20151 | Pickle.Path.path_to_pickle | train | 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 | {
"resource": ""
} |
q20152 | Pickle.Email.emails | train | def emails(fields = nil)
@emails = ActionMailer::Base.deliveries.select {|m| email_has_fields?(m, fields)}
end | ruby | {
"resource": ""
} |
q20153 | Rightscale.HttpConnection.error_add | train | 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 | {
"resource": ""
} |
q20154 | Rightscale.HttpConnection.setup_streaming | train | 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 | {
"resource": ""
} |
q20155 | Rightscale.HttpConnection.start | train | 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 | {
"resource": ""
} |
q20156 | Rightscale.HttpConnection.request | train | 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 | {
"resource": ""
} |
q20157 | Princely.Pdf.pdf_from_string | train | 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 | {
"resource": ""
} |
q20158 | Ruote.Dashboard.attach | train | 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 | {
"resource": ""
} |
q20159 | Ruote.Dashboard.apply_mutation | train | def apply_mutation(wfid, pdef)
Mutation.new(self, wfid, @context.reader.read(pdef)).apply
end | ruby | {
"resource": ""
} |
q20160 | Ruote.Dashboard.processes | train | def processes(opts={})
wfids = @context.storage.expression_wfids(opts)
opts[:count] ? wfids.size : ProcessStatus.fetch(@context, wfids, opts)
end | ruby | {
"resource": ""
} |
q20161 | Ruote.Dashboard.wait_for | train | def wait_for(*items)
opts = (items.size > 1 && items.last.is_a?(Hash)) ? items.pop : {}
@context.logger.wait_for(items, opts)
end | ruby | {
"resource": ""
} |
q20162 | Ruote.Dashboard.register_participant | train | 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 | {
"resource": ""
} |
q20163 | Ruote::Exp.FlowExpression.has_attribute | train | def has_attribute(*args)
args.each { |a| a = a.to_s; return a if attributes[a] != nil }
nil
end | ruby | {
"resource": ""
} |
q20164 | Ruote::Exp.FlowExpression.attribute | train | 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 | {
"resource": ""
} |
q20165 | Ruote::Exp.FlowExpression.att | train | 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 | {
"resource": ""
} |
q20166 | Ruote::Exp.FlowExpression.lookup_val_prefix | train | 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 | {
"resource": ""
} |
q20167 | Ruote::Exp.FlowExpression.compile_atts | train | def compile_atts(opts={})
attributes.keys.each_with_object({}) { |k, r|
r[dsub(k)] = attribute(k, h.applied_workitem, opts)
}
end | ruby | {
"resource": ""
} |
q20168 | Ruote::Exp.FlowExpression.attribute_text | train | def attribute_text(workitem=h.applied_workitem)
text = attributes.keys.find { |k| attributes[k] == nil }
dsub(text.to_s, workitem)
end | ruby | {
"resource": ""
} |
q20169 | Ruote::Exp.FlowExpression.determine_tos | train | 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 | {
"resource": ""
} |
q20170 | Ruote::Exp.FlowExpression.do_apply | train | 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 | {
"resource": ""
} |
q20171 | Ruote::Exp.FlowExpression.do_reply_to_parent | train | 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 | {
"resource": ""
} |
q20172 | Ruote::Exp.FlowExpression.do_pause | train | 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 | {
"resource": ""
} |
q20173 | Ruote::Exp.FlowExpression.ancestor? | train | 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 | {
"resource": ""
} |
q20174 | Ruote::Exp.FlowExpression.pre_apply_child | train | 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 | {
"resource": ""
} |
q20175 | Ruote::Exp.FlowExpression.apply_child | train | 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 | {
"resource": ""
} |
q20176 | Ruote::Exp.FlowExpression.leave_tag | train | 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 | {
"resource": ""
} |
q20177 | Ruote.RuleSession.do_merge | train | 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 | {
"resource": ""
} |
q20178 | Ruote.ProcessStatus.tags | train | def tags
variables ? Hash[variables.select { |k, v| Ruote.is_a_fei?(v) }] : nil
end | ruby | {
"resource": ""
} |
q20179 | Ruote.ProcessStatus.all_tags | train | 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 | {
"resource": ""
} |
q20180 | Ruote.ProcessStatus.wfid | train | def wfid
l = [ @expressions, @errors, @stored_workitems ].find { |l| l.any? }
l ? l.first.fei.wfid : nil
end | ruby | {
"resource": ""
} |
q20181 | Ruote.ProcessStatus.position | train | 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 | {
"resource": ""
} |
q20182 | Ruote.ProcessStatus.leaves | train | def leaves
expressions.inject([]) { |a, exp|
a.select { |e| ! exp.ancestor?(e.fei) } + [ exp ]
}
end | ruby | {
"resource": ""
} |
q20183 | Ruote.ProcessStatus.workitems | train | 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 | {
"resource": ""
} |
q20184 | Ruote.ProcessStatus.to_dot | train | 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 | {
"resource": ""
} |
q20185 | Ruote.TemplateMixin.render_template | train | 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 | {
"resource": ""
} |
q20186 | Ruote.TemplateMixin.render_default_template | train | 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 | {
"resource": ""
} |
q20187 | Ruote::Exp.ParticipantExpression.consider_participant_timers | train | 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 | {
"resource": ""
} |
q20188 | Ruote.LocalParticipant.re_dispatch | train | 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 | {
"resource": ""
} |
q20189 | Ruote.ErrorHandler.msg_handle | train | def msg_handle(msg, err)
fexp = Ruote::Exp::FlowExpression.fetch(
@context, msg['fei'] || msg['workitem']['fei']
) rescue nil
handle(msg, fexp, err)
end | ruby | {
"resource": ""
} |
q20190 | Ruote.ErrorHandler.msg_raise | train | 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 | {
"resource": ""
} |
q20191 | Ruote.ErrorHandler.handle | train | 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 | {
"resource": ""
} |
q20192 | Ruote.ErrorHandler.deflate | train | 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 | {
"resource": ""
} |
q20193 | Ruote::Exp.ConcurrenceExpression.expected_count | train | 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 | {
"resource": ""
} |
q20194 | Ruote::Exp.ConcurrenceExpression.merge_workitems | train | 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 | {
"resource": ""
} |
q20195 | Ruote.Workitem.as_json | train | def as_json(pretty=false)
pretty ? Rufus::Json.pretty_encode(@h) : Rufus::Json.encode(@h)
end | ruby | {
"resource": ""
} |
q20196 | Ruote.Workitem.remove_tag | train | 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 | {
"resource": ""
} |
q20197 | Ruote.DispatchPool.dispatch | train | 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 | {
"resource": ""
} |
q20198 | Ruote.DispatchPool.do_dispatch | train | def do_dispatch(participant, msg)
do_raw_dispatch(participant, msg)
rescue => err
@context.error_handler.msg_handle(msg, err)
end | ruby | {
"resource": ""
} |
q20199 | Ruote.DispatchPool.do_threaded_dispatch | train | 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 | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.