_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3
values | text stringlengths 30 4.3k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q6600 | BasicCache.TimeCache.prune | train | def prune
@store.keys.reject { |k| include? k }.map | ruby | {
"resource": ""
} |
q6601 | Refheap.Paste.create | train | def create(contents, params = {:language => "Plain Text", :private => false})
params = params.merge({:contents => contents}.merge(@base_params))
| ruby | {
"resource": ""
} |
q6602 | Zomato2.Restaurant.details | train | def details(start: nil, count: nil)
# warn "\tRestaurant#details: This method is currently useless, since, " +
# "as of January 2017, Zomato's API doesn't give any additional info here."
q = {res_id: @id }
q[:start] = start if start
q[:count] = count if count
results = get('restaur... | ruby | {
"resource": ""
} |
q6603 | BarkestCore.FormHelper.label_with_small | train | def label_with_small(f, method, text=nil, options = {}, &block)
if text.is_a?(Hash)
options = text
text = nil
end
small_text = options.delete(:small_text)
text = text || options.delete(:text) || method.to_s.humanize.capitalize
lbl = f.label(method, text, options, &block) #d... | ruby | {
"resource": ""
} |
q6604 | BarkestCore.FormHelper.text_form_group | train | def text_form_group(f, method, options = {})
gopt, lopt, fopt = split_form_group_options(options)
lbl = f.label_with_small method, lopt.delete(:text), lopt
fld = | ruby | {
"resource": ""
} |
q6605 | BarkestCore.FormHelper.multi_input_form_group | train | def multi_input_form_group(f, methods, options = {})
gopt, lopt, fopt = split_form_group_options(options)
lopt[:text] ||= gopt[:label]
if lopt[:text].blank?
| ruby | {
"resource": ""
} |
q6606 | BarkestCore.FormHelper.checkbox_form_group | train | def checkbox_form_group(f, method, options = {})
gopt, lopt, fopt = split_form_group_options({ class: 'checkbox', field_class: ''}.merge(options))
if gopt[:h_align]
gopt[:class] = gopt[:class].blank? ?
"col-sm-#{12-gopt[:h_align]} col-sm-offset-#{gopt[:h_align]}" :
"#{gopt[:... | ruby | {
"resource": ""
} |
q6607 | BarkestCore.FormHelper.select_form_group | train | def select_form_group(f, method, collection, value_method = nil, text_method = nil, options = {})
gopt, lopt, fopt = split_form_group_options({ field_include_blank: true }.merge(options))
lbl = f.label_with_small method, lopt.delete(:text), lopt
value_method ||= :to_s
text_method ||= :to_s
... | ruby | {
"resource": ""
} |
q6608 | Bebox.NodeCommands.generate_node_command | train | def generate_node_command(node_command, command, send_command, description)
node_command.desc description
node_command.command command do |generated_command|
generated_command.action do |global_options,options,args|
environment = get_environment(options)
| ruby | {
"resource": ""
} |
q6609 | Familia.ClassMethods.install_redis_object | train | def install_redis_object name, klass, opts
raise ArgumentError, "Name is blank" if name.to_s.empty?
name = name.to_s.to_sym
opts ||= {}
redis_objects_order << name
redis_objects[name] = OpenStruct.new
redis_objects[name].name = name
redis_objects[name].klass = klass
redis... | ruby | {
"resource": ""
} |
q6610 | Familia.ClassMethods.install_class_redis_object | train | def install_class_redis_object name, klass, opts
raise ArgumentError, "Name is blank" if name.to_s.empty?
name = name.to_s.to_sym
opts = opts.nil? ? {} : opts.clone
opts[:parent] = self unless opts.has_key?(:parent)
# TODO: investigate using metaclass.redis_objects
class_redis_object... | ruby | {
"resource": ""
} |
q6611 | Familia.ClassMethods.load_or_create | train | def load_or_create idx
return from_redis(idx) if exists?(idx)
obj | ruby | {
"resource": ""
} |
q6612 | Familia.ClassMethods.rediskey | train | def rediskey idx, suffix=self.suffix
raise RuntimeError, "No index for #{self}" if idx.to_s.empty?
idx = Familia.join *idx if Array === idx
| ruby | {
"resource": ""
} |
q6613 | Familia.InstanceMethods.initialize_redis_objects | train | def initialize_redis_objects
# Generate instances of each RedisObject. These need to be
# unique for each instance of this class so they can refer
# to the index of this specific instance.
#
# i.e.
# familia_object.rediskey == v1:bone:INDEXVALUE:object
# f... | ruby | {
"resource": ""
} |
q6614 | RHapi.Lead.method_missing | train | def method_missing(method, *args, &block)
attribute = ActiveSupport::Inflector.camelize(method.to_s, false)
if attribute =~ /=$/
attribute = attribute.chop
return super unless self.attributes.include?(attribute)
self.changed_attributes[attribute] = args[0]
| ruby | {
"resource": ""
} |
q6615 | UsBankHolidays.HolidayYear.bank_holidays | train | def bank_holidays
@bank_holidays ||= begin
holidays = [ new_years_day,
mlk_day,
washingtons_birthday,
memorial_day,
independence_day,
| ruby | {
"resource": ""
} |
q6616 | UsBankHolidays.HolidayYear.init_fixed_holidays | train | def init_fixed_holidays
# Third Monday of January
@mlk_day = january.mondays[2]
# Third Monday of February
@washingtons_birthday = february.mondays[2]
# Last Monday of May
| ruby | {
"resource": ""
} |
q6617 | UsBankHolidays.HolidayYear.init_rolled_holidays | train | def init_rolled_holidays
# First of the year, rolls either forward or back.
@new_years_day = roll_nominal(Date.new(year, 1, 1))
# 4'th of July
@independence_day = roll_nominal(Date.new(year, 7, 4))
# November 11
@veterans_day | ruby | {
"resource": ""
} |
q6618 | Guard.Shopify.upgrade_config_file | train | def upgrade_config_file
puts "Old config file found, upgrading..."
credentials = File.read(config_file_path).split("\n")
config = {}
config['api_key'] = credentials[0]
config['password'] = credentials[1]
config['url'] | ruby | {
"resource": ""
} |
q6619 | Seedable.ObjectTracker.contains? | train | def contains?(object)
key, id = to_key_and_id(object)
@graph[key].is_a?(Enumerable) ? | ruby | {
"resource": ""
} |
q6620 | Seedable.ObjectTracker.add | train | def add(object)
key, id = to_key_and_id(object)
@graph[key] ? | ruby | {
"resource": ""
} |
q6621 | Tangle.BaseGraph.subgraph | train | def subgraph(included = nil, &selector)
result = clone
result.select_vertices!(included) | ruby | {
"resource": ""
} |
q6622 | Tangle.BaseGraph.add_vertex | train | def add_vertex(vertex, name: nil)
name ||= callback(vertex, :name)
insert_vertex(vertex, name)
define_currified_methods(vertex, :vertex) | ruby | {
"resource": ""
} |
q6623 | Tangle.BaseGraph.remove_vertex | train | def remove_vertex(vertex)
@vertices[vertex].each do |edge|
remove_edge(edge) if | ruby | {
"resource": ""
} |
q6624 | Tangle.BaseGraph.add_edge | train | def add_edge(*vertices, **kvargs)
edge = new_edge(*vertices, mixins: @mixins, **kvargs) | ruby | {
"resource": ""
} |
q6625 | Tangle.BaseGraph.remove_edge | train | def remove_edge(edge)
delete_edge(edge)
edge.each_vertex { |vertex| | ruby | {
"resource": ""
} |
q6626 | Lightstreamer.Session.disconnect | train | def disconnect
control_request LS_op: :destroy if @stream_connection
@processing_thread.join 5 if @processing_thread
ensure
@stream_connection.disconnect if @stream_connection
@processing_thread.exit if @processing_thread
| ruby | {
"resource": ""
} |
q6627 | Lightstreamer.Session.create_processing_thread | train | def create_processing_thread
@processing_thread = Thread.new do
Thread.current.abort_on_exception = | ruby | {
"resource": ""
} |
q6628 | Lightstreamer.Session.process_stream_line | train | def process_stream_line(line)
return if @mutex.synchronize { @subscriptions.any? { |subscription| subscription.process_stream_data line } }
| ruby | {
"resource": ""
} |
q6629 | Lightstreamer.Session.process_send_message_outcome | train | def process_send_message_outcome(line)
outcome = SendMessageOutcomeMessage.parse line
return unless outcome
@mutex.synchronize do
@callbacks[:on_message_result].each do |callback|
| ruby | {
"resource": ""
} |
q6630 | Mongoid.AtomicVotes.vote | train | def vote(value, voted_by)
mark = Vote.new(value: value, | ruby | {
"resource": ""
} |
q6631 | Mongoid.AtomicVotes.retract | train | def retract(voted_by)
mark = votes.find_by(voted_by_id: | ruby | {
"resource": ""
} |
q6632 | Mongoid.AtomicVotes.voted_by? | train | def voted_by?(voted_by)
!!votes.find_by(voted_by_id: voted_by.id)
| ruby | {
"resource": ""
} |
q6633 | Shells.ShellBase.run | train | def run(&block)
sync do
raise Shells::AlreadyRunning if running?
self.run_flag = true
end
begin
run_hook :on_before_run
debug 'Connecting...'
connect
debug 'Starting output buffering...'
buffer_output
debug 'Starting se... | ruby | {
"resource": ""
} |
q6634 | Ruck.Clock.fast_forward | train | def fast_forward(dt)
adjusted_dt = dt * @relative_rate
@now += adjusted_dt
| ruby | {
"resource": ""
} |
q6635 | Ruck.Clock.schedule | train | def schedule(obj, time = nil)
time ||= now
@occurrences[obj] = time
parent.schedule([:clock, self], | ruby | {
"resource": ""
} |
q6636 | Ruck.Clock.unschedule | train | def unschedule(obj)
if @occurrences.has_key? obj
last_priority = @occurrences.min_priority
obj, time = @occurrences.delete obj
if parent && @occurrences.min_priority != last_priority
if @occurrences.min_priority
| ruby | {
"resource": ""
} |
q6637 | SearchMe.Search.attr_search | train | def attr_search(*attributes)
options = attributes.last.is_a?(Hash) ? attributes.pop : {}
type = (options.fetch(:type) { :simple }).to_sym
accepted_keys = [:simple] + self.reflections.keys.map(&:to_sym)
| ruby | {
"resource": ""
} |
q6638 | Persistable.ClassMethods.reify_from_row | train | def reify_from_row(row)
#the tap method allows preconfigured methods and values to
#be associated with the instance during instantiation while also automatically returning
#the object after its creation is concluded.
self.new.tap do |card|
self.attributes.keys.each.with_index do |key, in... | ruby | {
"resource": ""
} |
q6639 | Shells.ShellBase.exec | train | def exec(command, options = {}, &block)
raise Shells::NotRunning unless running?
options ||= {}
options = { timeout_error: true, get_output: true }.merge(options)
options = self.options.merge(options.inject({}) { |m,(k,v)| m[k.to_sym] = v; m })
options[:retrieve_exit_code] = self.op... | ruby | {
"resource": ""
} |
q6640 | Shells.ShellBase.command_output | train | def command_output(command, expect_command = true) #:doc:
# get everything except for the ending prompt.
ret =
if (prompt_pos = (output =~ prompt_match))
output[0...prompt_pos]
else
output
end
if expect_command
command_regex = c... | ruby | {
"resource": ""
} |
q6641 | Garcon.Crypto.decrypt | train | def decrypt(encrypted_text, password = nil, salt = nil)
password = password.nil? ? Garcon.crypto.password : password
salt = salt.nil? ? Garcon.crypto.salt : salt
iv_ciphertext = Base64.decode64(encrypted_text)
cipher = new_cipher(:decrypt, | ruby | {
"resource": ""
} |
q6642 | Garcon.Crypto.salted_hash | train | def salted_hash(password)
salt = SecureRandom.random_bytes(SALT_BYTE_SIZE)
pbkdf2 = OpenSSL::PKCS5::pbkdf2_hmac_sha1(
password, | ruby | {
"resource": ""
} |
q6643 | Garcon.Crypto.new_cipher | train | def new_cipher(direction, password, salt)
cipher = OpenSSL::Cipher::Cipher.new(CIPHER_TYPE)
direction == :encrypt | ruby | {
"resource": ""
} |
q6644 | Garcon.Crypto.combine_iv_ciphertext | train | def combine_iv_ciphertext(iv, message)
message.force_encoding('BINARY') if message.respond_to?(:force_encoding) | ruby | {
"resource": ""
} |
q6645 | Garcon.Crypto.separate_iv_ciphertext | train | def separate_iv_ciphertext(cipher, iv_ciphertext)
idx | ruby | {
"resource": ""
} |
q6646 | Garcon.Crypto.encrypt_key | train | def encrypt_key(password, salt)
iterations, length = CRYPTERATIONS, | ruby | {
"resource": ""
} |
q6647 | Bebox.EnvironmentCommands.environment_list_command | train | def environment_list_command(environment_command)
environment_command.desc 'List the remote environments in the project'
environment_command.command :list do |environment_list_command|
environment_list_command.action do |global_options,options,args|
environments = Bebox::Environment.list(p... | ruby | {
"resource": ""
} |
q6648 | AnsiSys.CSSFormatter.hash_to_styles | train | def hash_to_styles(hash, separator = '; ')
unless hash.empty?
return hash.map{|e| "#{e[0]}: #{e[1].join(' | ruby | {
"resource": ""
} |
q6649 | AnsiSys.Lexer.lex! | train | def lex!
r = Array.new
@buffer.gsub!(/(?:\r\n|\n\r)/, "\n")
while @code_start_re =~ @buffer
r << [:string, $`] unless $`.empty?
if CODE_EQUIVALENT.has_key?($&)
CODE_EQUIVALENT[$&].each do |c|
r << [:code, c]
| ruby | {
"resource": ""
} |
q6650 | AnsiSys.Characters.echo_on | train | def echo_on(screen, cursor)
each_char do |c|
w = width(c)
cursor.fit!(w) | ruby | {
"resource": ""
} |
q6651 | AnsiSys.Cursor.apply_code! | train | def apply_code!(letter, *pars)
case letter
when 'A'
@cur_row -= pars[0] ? pars[0] : 1
@cur_row = @max_row if @max_row and @cur_row > @max_row
when 'B'
@cur_row += pars[0] ? pars[0] : 1
@cur_row = @max_row if @max_row and @cur_row > @max_row
when 'C'
@cur_col += pars[0] ? pars[0] : 1
w... | ruby | {
"resource": ""
} |
q6652 | AnsiSys.SGR.css_styles | train | def css_styles(colors = Screen.default_css_colors)
r = Hash.new{|h, k| h[k] = Array.new}
# intensity is not (yet) implemented
r['font-style'] << 'italic' if @italic == :on
r['text-decoration'] << 'underline' unless @underline == :none
r['text-decoration'] << 'blink' unless @blink == :off
case @image
... | ruby | {
"resource": ""
} |
q6653 | AnsiSys.Screen.write | train | def write(char, char_width, col, row, sgr)
@lines[Integer(row)][Integer(col)] | ruby | {
"resource": ""
} |
q6654 | PseudoHiki.HtmlPlugin.anchor | train | def anchor
name, anchor_mark = @data.split(/,\s*/o, 2)
anchor_mark = "_" if (anchor_mark.nil? or anchor_mark.empty?)
HtmlElement.create("a", anchor_mark,
| ruby | {
"resource": ""
} |
q6655 | Hornetseye.GCCFunction.params | train | def params
idx = 0
@param_types.collect do |param_type|
args = GCCType.new( param_type ).identifiers.collect do
arg = GCCValue.new self, "param#{idx}"
| ruby | {
"resource": ""
} |
q6656 | NForm.HTML.tag | train | def tag(name, attributes={}, &block)
open = sjoin name, attrs(attributes)
body = block.call if block_given?
if VOID_ELEMENTS.include?(name.to_sym) | ruby | {
"resource": ""
} |
q6657 | Sumac.Objects.process_forget | train | def process_forget(object, quiet: )
reference = convert_object_to_reference(object, build: false)
raise | ruby | {
"resource": ""
} |
q6658 | Sumac.Objects.process_forget_message | train | def process_forget_message(message, quiet: )
reference = convert_properties_to_reference(message.object, build: false)
| ruby | {
"resource": ""
} |
q6659 | Hornetseye.Node.memorise | train | def memorise
if memory
contiguous_strides = (0 ... dimension).collect do |i|
shape[0 ... i].inject 1, | ruby | {
"resource": ""
} |
q6660 | Hornetseye.Node.to_a | train | def to_a
if dimension == 0
force
else
n = shape.last
( 0 | ruby | {
"resource": ""
} |
q6661 | Hornetseye.Node.inspect | train | def inspect( indent = nil, lines = nil )
if variables.empty?
if dimension == 0 and not indent
"#{typecode.inspect}(#{force.inspect})"
else
if indent
prepend = ''
else
prepend = "#{Hornetseye::MultiArray(typecode, dimension).inspect}:\n"
... | ruby | {
"resource": ""
} |
q6662 | Hornetseye.Node.check_shape | train | def check_shape(*args)
_shape = shape
args.each do |arg|
_arg_shape = arg.shape
if _shape.size < _arg_shape.size
raise "#{arg.inspect} has #{arg.dimension} dimension(s) " +
"but should not have more than #{dimension}"
end
if ( _shape + _arg_shape ).a... | ruby | {
"resource": ""
} |
q6663 | Hornetseye.Node.force | train | def force
if finalised?
get
elsif (dimension > 0 and Thread.current[:lazy]) or not variables.empty?
self
elsif compilable?
retval = allocate
GCCFunction.run Store.new(retval, self)
retval.demand.get
| ruby | {
"resource": ""
} |
q6664 | Ruck.ShredConvenienceMethods.yield | train | def yield(dt, clock = nil)
clock ||= $shreduler.clock
$shreduler.shredule(Shred.current, | ruby | {
"resource": ""
} |
q6665 | Ruck.ShredConvenienceMethods.wait_on | train | def wait_on(event)
$shreduler.shredule(Shred.current, | ruby | {
"resource": ""
} |
q6666 | Ruck.Shreduler.run_one | train | def run_one
shred, relative_time = @clock.unschedule_next
return nil | ruby | {
"resource": ""
} |
q6667 | Ruck.Shreduler.run_until | train | def run_until(target_time)
return if target_time < now
loop do
shred, relative_time = next_shred
break | ruby | {
"resource": ""
} |
q6668 | CoinOp::Bit.Transaction.validate_syntax | train | def validate_syntax
update_native
validator = Bitcoin::Validation::Tx.new(@native, nil)
valid = | ruby | {
"resource": ""
} |
q6669 | CoinOp::Bit.Transaction.validate_script_sigs | train | def validate_script_sigs
bad_inputs = []
valid = true
@inputs.each_with_index do |input, index|
# TODO: confirm whether we need to mess with the block_timestamp arg
unless self.native.verify_input_signature(index, input.output.transaction.native)
| ruby | {
"resource": ""
} |
q6670 | CoinOp::Bit.Transaction.add_input | train | def add_input(input, network: @network)
# TODO: allow specifying prev_tx and index with a Hash.
# Possibly stop using SparseInput.
input = Input.new(input.merge(transaction: self,
index: @inputs.size,
| ruby | {
"resource": ""
} |
q6671 | CoinOp::Bit.Transaction.add_output | train | def add_output(output, network: @network)
if output.is_a?(Output)
output.set_transaction(self, @outputs.size)
else
output = Output.new(output.merge(transaction: self,
index: @outputs.size),
network: | ruby | {
"resource": ""
} |
q6672 | CoinOp::Bit.Transaction.set_script_sigs | train | def set_script_sigs(*input_args, &block)
# No sense trying to authorize when the transaction isn't usable.
report = validate_syntax
unless report[:valid] == true
raise "Invalid syntax: #{report[:errors].to_json}"
end
# Array#zip here allows us to iterate over the inputs in lockst... | ruby | {
"resource": ""
} |
q6673 | CoinOp::Bit.Transaction.input_value_for | train | def input_value_for(addresses)
own = inputs.select { |input| addresses.include?(input.output.address) | ruby | {
"resource": ""
} |
q6674 | CoinOp::Bit.Transaction.output_value_for | train | def output_value_for(addresses)
own = outputs.select { |output| | ruby | {
"resource": ""
} |
q6675 | CoinOp::Bit.Transaction.add_change | train | def add_change(address, metadata={})
add_output(
value: change_value,
address: address,
| ruby | {
"resource": ""
} |
q6676 | SwaggerDocsGenerator.Extractor.path | train | def path
temporary = []
actual_route = nil
router do |route|
actual_route = extract_and_format_route(route)
temporary.push(actual_route) | ruby | {
"resource": ""
} |
q6677 | Tst.Assertions.assert_raises | train | def assert_raises(expected=StandardError)
begin
yield
rescue => actual
return actual if actual.kind_of?(expected)
| ruby | {
"resource": ""
} |
q6678 | Tst.Runner.tst | train | def tst(name, &block)
start = Time.now
block.call
status = SUCCEEDED
rescue Failure => exception
status = FAILED
rescue StandardError => exception
| ruby | {
"resource": ""
} |
q6679 | Jinx.Propertied.add_attribute | train | def add_attribute(attribute, type, *flags)
prop = create_nonjava_property(attribute, | ruby | {
"resource": ""
} |
q6680 | Jinx.Propertied.init_property_classifiers | train | def init_property_classifiers
@local_std_prop_hash = {}
@alias_std_prop_map = append_ancestor_enum(@local_std_prop_hash) { |par| par.alias_standard_attribute_hash }
@local_prop_hash = {}
@prop_hash = append_ancestor_enum(@local_prop_hash) { |par| par.property_hash }
| ruby | {
"resource": ""
} |
q6681 | Jinx.Propertied.compose_property | train | def compose_property(property, other)
if other.inverse.nil? then
raise ArgumentError.new("Can't compose #{qp}.#{property} with inverseless #{other.declarer.qp}.#{other}")
end
# the source -> intermediary access methods
sir, siw = property.accessors
# the intermediary -> target acce... | ruby | {
"resource": ""
} |
q6682 | Jinx.Propertied.most_specific_domain_attribute | train | def most_specific_domain_attribute(klass, attributes=nil)
attributes ||= domain_attributes
candidates = attributes.properties
best = candidates.inject(nil) do |better, prop|
# If the attribute can return the klass then the return type is a candidate.
# In that case, the klass replaces ... | ruby | {
"resource": ""
} |
q6683 | Jinx.Propertied.set_attribute_type | train | def set_attribute_type(attribute, klass)
prop = property(attribute)
# degenerate no-op case
return if klass == prop.type
# If this class is the declarer, then simply set the attribute type.
# Otherwise, if the attribute type is unspecified or is a superclass of the given class,
# the... | ruby | {
"resource": ""
} |
q6684 | Jinx.Propertied.remove_attribute | train | def remove_attribute(attribute)
sa = standard_attribute(attribute)
# if the attribute is local, then delete it, otherwise filter out the superclass attribute
sp = @local_prop_hash.delete(sa)
if sp then
# clear the inverse, if any
clear_inverse(sp)
# remove from the mandat... | ruby | {
"resource": ""
} |
q6685 | Jinx.Propertied.register_property_alias | train | def register_property_alias(aliaz, attribute)
std = standard_attribute(attribute)
| ruby | {
"resource": ""
} |
q6686 | IRCSupport.Formatting.strip_color! | train | def strip_color!(string)
[@@mirc_color, @@rgb_color, @@ecma48_color].each do |pattern|
string.gsub!(pattern, '')
end
# strip cancellation codes | ruby | {
"resource": ""
} |
q6687 | Gen.Gen::Code.generate_binding | train | def generate_binding(a_binding=binding)
a_binding.local_variables do |local_var|
a_binding.local_variable_set local_var, nil
end
@bound_procs.each_with_index do |bound_proc, index|
a_binding.local_variable_set "proc_#{index}", bound_proc
| ruby | {
"resource": ""
} |
q6688 | Evvnt.Persistence.save_as_new_record | train | def save_as_new_record
new_attributes = attributes.reject { |k, _v| k.to_s =~ /^(id|uuid)$/ }
| ruby | {
"resource": ""
} |
q6689 | Evvnt.Persistence.save_as_persisted_record | train | def save_as_persisted_record
new_attributes = attributes.reject { |k, _v| k.to_s =~ /^(id|uuid)$/ }
| ruby | {
"resource": ""
} |
q6690 | GodvilleKit.APIRequester.request_raw_hero_data | train | def request_raw_hero_data
return unless authenticated?
response = RestClient.get(
"https://godvillegame.com/fbh/feed?a=#{@hero_guid}",
cookies: | ruby | {
"resource": ""
} |
q6691 | Garcon.Obligation.compare_and_set_state | train | def compare_and_set_state(next_state, expected_current) # :nodoc:
mutex.lock
if @state == expected_current
@state = next_state
| ruby | {
"resource": ""
} |
q6692 | Garcon.Obligation.if_state | train | def if_state(*expected_states)
mutex.lock
raise ArgumentError, 'no block given' unless block_given?
if expected_states.include? @state
| ruby | {
"resource": ""
} |
q6693 | PolyDelegate.Delegator.method_missing | train | def method_missing(name, *args, &block)
super unless respond_to_missing?(name)
# Send self as the delegator
| ruby | {
"resource": ""
} |
q6694 | Observatory.Stack.delete | train | def delete(observer)
old_size = @stack.size
@stack.delete_if do |o|
o[:observer] == observer
| ruby | {
"resource": ""
} |
q6695 | Observatory.Stack.push | train | def push(observer, priority = nil)
raise ArgumentError, 'Observer is not callable' unless observer.respond_to?(:call)
raise ArgumentError, 'Priority | ruby | {
"resource": ""
} |
q6696 | Incline.SafeNameValidator.validate_each | train | def validate_each(record, attribute, value)
unless value.blank?
unless value =~ VALID_MASK
if value =~ /\A[^a-z]/i
record.errors[attribute] << (options[:message] || 'must start with a letter')
elsif value =~ /_\z/
record.errors[attribute] << (options[:message] |... | ruby | {
"resource": ""
} |
q6697 | Kajiki.Runner.validate_command | train | def validate_command(cmd = ARGV)
fail 'Specify one action.' unless cmd.count == 1
cmd = cmd.shift
fail | ruby | {
"resource": ""
} |
q6698 | Kajiki.Runner.validate_options | train | def validate_options
if @opts[:daemonize]
fail 'Must specify PID file.' unless @opts[:pid_given]
end
@opts[:pid] = File.expand_path(@opts[:pid]) if @opts[:pid_given]
@opts[:log] = File.expand_path(@opts[:log]) if @opts[:log_given]
| ruby | {
"resource": ""
} |
q6699 | Kajiki.Runner.start | train | def start(&block)
fail 'No start block given.' if block.nil?
check_existing_pid
puts "Starting process..."
Process.daemon if @opts[:daemonize]
| ruby | {
"resource": ""
} |
Subsets and Splits
SQL Console for CoIR-Retrieval/CodeSearchNet-ccr-ruby-queries-corpus
Retrieves a large number of entries in the 'ruby' language, providing basic information but limited analytical value.