input stringlengths 109 5.2k | output stringlengths 7 509 |
|---|---|
Summarize the following code: def add_user(user)
raise 'InvalidUser' unless user.respond_to?(:dn)
direct_members = @raw_ldap_data[Cratus.config.group_member_attribute]
return true if direct_members.include?(user.dn)
direct_members << user.dn
Cratus::LDAP.replace_attribute(
dn,
... | Add a User to the group |
Summarize the following code: def create_annotation_service(mod, name)
@integrator = Annotation::Integrator.new(mod)
Annotation::AnnotationService.new(@database, name, @integrator)
end | Initializes a new Annotator for the given database . |
Summarize the following code: def name
middle = middle_name if respond_to?(:middle_name)
Name.new(last_name, first_name, middle) if last_name
end | Returns this Person s name as a Name structure or nil if there is no last name . |
Summarize the following code: def name=(value)
value = Name.parse(value) if String === value
# a missing name is equivalent to an empty name for our purposes here
value = Name.new(nil, nil) if value.nil?
unless Name === value then
raise ArgumentError.new("Name argument type invalid; expe... | Sets this Person s name to the name string or Name object . A string name argument is parsed using Name . parse . |
Summarize the following code: def find(public_id_or_alias, value, recursive=false)
pid = ControlledValue.standard_public_id(public_id_or_alias)
value_cv_hash = @pid_value_cv_hash[pid]
cv = value_cv_hash[value]
if recursive then
fetch_descendants(cv, value_cv_hash)
end
cv
... | Returns the CV with the given public_id_or_alias and value . Loads the CV if necessary from the database . The loaded CV does not have a parent or children . |
Summarize the following code: def create(cv)
if cv.public_id.nil? then
raise ArgumentError.new("Controlled value create is missing a public id")
end
if cv.value.nil? then
raise ArgumentError.new("Controlled value create is missing a value")
end
cv.identifier ||= next_id
... | Creates a new controlled value record in the database from the given ControlledValue cv . The default identifier is the next identifier in the permissible values table . |
Summarize the following code: def delete(cv)
@executor.transact do |dbh|
sth = dbh.prepare(DELETE_STMT)
delete_recursive(cv, sth)
sth.finish
end
end | Deletes the given ControlledValue record in the database . Recursively deletes the transitive closure of children as well . |
Summarize the following code: def make_controlled_value(value_hash)
cv = ControlledValue.new(value_hash[:value], value_hash[:parent])
cv.identifier = value_hash[:identifier]
cv.public_id = value_hash[:public_id]
cv
end | Returns a new ControlledValue with attributes set by the given attribute = > value hash . |
Summarize the following code: def with (hash, quiet: false)
old_values = data.values_at(hash.keys)
log.debug "with #{hash}", quiet: quiet do
set hash
yield
end
ensure
hash.keys.each.with_index do |key, i|
@data[key] = old_values[i]
end
end | Yield with the hash temporary merged into the context variables . Only variables specifically named in + hash + will be reset when the yield returns . |
Summarize the following code: def on (*hosts, quiet: false)
let :@hosts => hosts.flatten do
log.info "on #{@hosts.map(&:name).join(", ")}", quiet: quiet do
yield
end
end
end | Yield with a temporary host list |
Summarize the following code: def as (user, quiet: false)
let :@user => user do
log.info "as #{user}", quiet: quiet do
yield
end
end
end | Yield with a temporary username override |
Summarize the following code: def sh (command, as: user, on: hosts, quiet: false, once: nil)
self.once once, quiet: quiet do
log.info "sh #{command}", quiet: quiet do
hash_map(hosts) do |host|
host.sh command, as: as, quiet: quiet
end
end
end
end | Execute a shell command on each host |
Summarize the following code: def cp (from, to, as: user, on: hosts, quiet: false, once: nil)
self.once once, quiet: quiet do
log.info "cp: #{from} -> #{to}", quiet: quiet do
Dir.chdir File.dirname(file) do
hash_map(hosts) do |host|
host.cp from, to, as: as, quiet: quie... | Copy a file or readable to the host filesystems . |
Summarize the following code: def read (filename, as: user, on: hosts, quiet: false)
log.info "read: #{filename}", quiet: quiet do
hash_map(hosts) do |host|
host.read filename, as: as
end
end
end | Reads a remote file from each host . |
Summarize the following code: def write (string, to, as: user, on: hosts, quiet: false, once: nil)
self.once once, quiet: quiet do
log.info "write: #{string.bytesize} bytes -> #{to}", quiet: quiet do
hash_map(hosts) do |host|
host.write string, to, as: as, quiet: quiet
end
... | Writes a string to a file on the host filesystems . |
Summarize the following code: def ping (on: hosts, quiet: false)
log.info "ping", quiet: quiet do
hash_map(hosts) do |host|
host.ping
end
end
end | Ping each host by trying to connect to port 22 |
Summarize the following code: def once (key, store: "/var/cache/blower.json", quiet: false)
return yield unless key
log.info "once: #{key}", quiet: quiet do
hash_map(hosts) do |host|
done = begin
JSON.parse(host.read(store, quiet: true))
rescue => e
{}
... | Execute a block only once per host . It is usually preferable to make tasks idempotent but when that isn t possible + once + will only execute the block on hosts where a block with the same key hasn t previously been successfully executed . |
Summarize the following code: def update(attributes = {})
assert_valid_keys(attributes, :name, :status, :laptop_name, :twitter_id, :facebook_url, :website, :about, :top_artists, :hangout)
# Update status
status = attributes.delete(:status)
update_status(status) if status
# Update laptop
... | Updates this user s profile information . |
Summarize the following code: def buddies
data = api('user.get_buddies')
data['buddies'].map {|id| User.new(client, :_id => id)}
end | Loads the list of users that are connected to the current user through a social network like Facebook or Twitter . |
Summarize the following code: def fan_of
data = api('user.get_fan_of')
data['fanof'].map {|id| User.new(client, :_id => id)}
end | Loads the list of users that the current user is a fan of . |
Summarize the following code: def fans
data = api('user.get_fans')
data['fans'].map {|id| User.new(client, :_id => id)}
end | Loads the list of users that are a fan of the current user . |
Summarize the following code: def stickers_purchased
data = api('sticker.get_purchased_stickers')
data['stickers'].map {|sticker_id| Sticker.new(client, :_id => sticker_id)}
end | Gets the stickers that have been purchased by this user . |
Summarize the following code: def blocks
data = api('block.list_all')
data['blocks'].map {|attrs| User.new(client, attrs['block']['blocked'])}
end | Gets the users that have been blocked by this user . |
Summarize the following code: def update_profile(attributes = {})
assert_valid_keys(attributes, :name, :twitter_id, :facebook_url, :website, :about, :top_artists, :hangout)
# Convert attribute names over to their Turntable equivalent
{:twitter_id => :twitter, :facebook_url => :facebook, :top_artists ... | Updates the user s profile information |
Summarize the following code: def update_laptop(name)
assert_valid_values(name, *%w(mac pc linux chrome iphone cake intel android))
api('user.modify', :laptop => name)
self.attributes = {'laptop' => name}
true
end | Updates the laptop currently being used |
Summarize the following code: def update_status(status = self.status)
assert_valid_values(status, *%w(available unavailable away))
now = Time.now.to_i
result = api('presence.update', :status => status)
client.reset_keepalive(result['interval'])
client.clock_delta = ((now + Time.now.to_i)... | Sets the user s current status |
Summarize the following code: def <<(input)
if input.index(/\s+/).nil?
word = normalize_word input
self.word = word unless word == ''
elsif input.scan(SENTENCE_DELIMITER).length < 2
self.sentence = input.gsub(SENTENCE_DELIMITER, '')
else
self.passage = input
... | Prepares selectors and weights storage Analyze input and add appropriate part |
Summarize the following code: def weighted(type, group)
if @weights[type].has_key?(group)
selector = WeightedSelect::Selector.new @weights[type][group]
selector.select
end
end | Generate weighted - random value |
Summarize the following code: def run(event)
if conditions_match?(event.data)
# Run the block for each individual result
event.results.each do |args|
begin
@block.call(*args)
rescue StandardError => ex
logger.error(([ex.message] + ex.backtrace) * "\n")
... | Builds a new handler bound to the given event . |
Summarize the following code: def conditions_match?(data)
if conditions
conditions.all? {|(key, value)| data[key] == value}
else
true
end
end | Determines whether the conditions configured for this handler match the event data |
Summarize the following code: def add(storable, *coordinate)
validate_type(storable)
loc = create_location(coordinate)
pos = storable.position || storable.position_class.new
pos.location = loc
pos.occupant = storable
pos.holder = self
logger.debug { "Added #{storable.qp} to #{q... | Moves the given Storable from its current Position if any to this Container at the optional coordinate . The default coordinate is the first available slot within this Container . The storable Storable position is updated to reflect the new location . Returns self . |
Summarize the following code: def copy_container_type_capacity
return unless container_type and container_type.capacity
self.capacity = cpc = container_type.capacity.copy(:rows, :columns)
logger.debug { "Initialized #{qp} capacity from #{container_type.qp} capacity #{cpc}." }
update_full_flag
... | Copies this Container s ContainerType capacity if it exists to the Container capacity . |
Summarize the following code: def load
data = api('user.get_prefs')
self.attributes = data['result'].inject({}) do |result, (preference, value, *)|
result[preference] = value
result
end
super
end | Loads the user s current Turntable preferences . |
Summarize the following code: def execute
File.open(out_file, 'w') do |o|
File.new(in_file, 'r').each_with_index do |line, index|
extraction = col_filter.process(row_filter.process(line.chomp, row: index))
o.puts extraction unless extraction.nil?
end
end
end | Creates a new extractor Executes the extractor |
Summarize the following code: def teams(summoner, optional={})
region = optional[:region] || @sightstone.region
id = if summoner.is_a? Summoner
summoner.id
else
summoner
end
uri = "https://prod.api.pvp.net/api/lol/#{region}/v2.2/team/by-summoner/#{id}"
response = _get_api_respo... | call to receive all teams for a summoner |
Summarize the following code: def get_doctype(path)
doc_type = nil
begin
metadata = YAML.load_file(path + 'template.yml')
doc_type = metadata['type']
if doc_type.nil?
say 'Type value not found. Check template.yml in the document directory', :red
say 'Make sure the... | Get the document type from the YAML file next to the document . |
Summarize the following code: def execute
allocation = {}
File.open(infile).each_with_index do |line, index|
row = row_filter.process(line, row: index)
next if row.nil? or row.empty?
key = key_filter.process(row)
allocation[key] = [] if allocation[key].nil?
allocation... | Creates a new allocator . Options are infile outfile key rows and columns to allocate to key Executes the allocator and assigns column values to the key |
Summarize the following code: def span_to(spanner)
Vector.new((@x - spanner.x).abs, (@y - spanner.y).abs)
end | Find the span between two Vectors |
Summarize the following code: def build
log_configuration_information
if subscription_list.empty?
Mako.logger.warn 'No feeds were found in your subscriptions file. Please add feeds and try again.'
return
end
log_time do
request_and_build_feeds
renderers.each do ... | Gets list of feed_urls requests each of them and uses the constructor to make Feed and Article objects then calls to the renderers to render the page and stylesheets . |
Summarize the following code: def log_configuration_information
Mako.logger.info "Configuration File: #{Mako.config.config_file}"
Mako.logger.info "Theme: #{Mako.config.theme}"
Mako.logger.info "Destination: #{Mako.config.destination}"
end | Prints configuration file source and destination directory to STDOUT . |
Summarize the following code: def log_time
Mako.logger.info 'Generating...'
start_time = Time.now.to_f
yield
generation_time = Time.now.to_f - start_time
Mako.logger.info "done in #{generation_time} seconds"
end | Provides build time logging information and writes it to STDOUT . |
Summarize the following code: def execute
result = eval(operation)
if outfile
if result.is_a?(SpreadSheet)
result.write(outfile)
else
puts
puts "Warning: Result is no spread sheet and not written to file!"
puts " To view the result use -p... | Executes the operation and writes the result to the outfile |
Summarize the following code: def create_operands(opts)
files = opts[:files].split(',')
rlabels = opts[:rlabels].split(',').collect { |l| l.upcase == "TRUE" }
clabels = opts[:clabels].split(',').collect { |l| l.upcase == "TRUE" }
operands = {}
opts[:aliases].split(',').each_wi... | Creates the spread sheet operands for the arithmetic operation |
Summarize the following code: def publish(params)
params[:msgid] = message_id = next_message_id
params = @default_params.merge(params)
logger.debug "Message sent: #{params.inspect}"
if HTTP_APIS.include?(params[:api])
publish_to_http(params)
else
publish_to_socket(params)... | Publishes the given params to the underlying web socket . The defaults initially configured as part of the connection will also be included in the message . |
Summarize the following code: def publish_to_socket(params)
message = params.is_a?(String) ? params : params.to_json
data = "~m~#{message.length}~m~#{message}"
@socket.send(data)
end | Publishes the given params to the web socket |
Summarize the following code: def publish_to_http(params)
api = params.delete(:api)
message_id = params[:msgid]
http = EventMachine::HttpRequest.new("http://turntable.fm/api/#{api}").get(:query => params)
if http.response_header.status == 200
# Command executed properly: parse the resul... | Publishes the given params to the HTTP API |
Summarize the following code: def on_message(event)
data = event.data
response = data.match(/~m~\d*~m~(.*)/)[1]
message =
case response
when /no_session/
{'command' => 'no_session'}
when /(~h~[0-9]+)/
# Send the heartbeat command back to the server
... | Callback when a message has been received from the remote server on the open socket . |
Summarize the following code: def add_defaults_local
super
self.capacity ||= Capacity.new.add_defaults
self.row_label ||= capacity.rows && capacity.rows > 0 ? 'Row' : 'Unused'
self.column_label ||= capacity.columns && capacity.columns > 0 ? 'Column' : 'Unused'
end | Adds an empty capacity and default dimension labels if necessary . The default + one_dimension_label + is Column if there is a non - zero dimension capacity Unused otherwise . The default + two_dimension_label + is Row if there is a non - zero dimension capacity Unused otherwise . |
Summarize the following code: def ping ()
log.debug "Pinging"
Timeout.timeout(1) do
TCPSocket.new(address, 22).close
end
true
rescue Timeout::Error, Errno::ECONNREFUSED
fail "Failed to ping #{self}"
end | Attempt to connect to port 22 on the host . |
Summarize the following code: def cp (froms, to, as: nil, quiet: false)
as ||= @user
output = ""
synchronize do
[froms].flatten.each do |from|
if from.is_a?(String)
to += "/" if to[-1] != "/" && from.is_a?(Array)
command = ["rsync", "-e", ssh_command, "-r"]
... | Copy files or directories to the host . |
Summarize the following code: def write (string, to, as: nil, quiet: false)
cp StringIO.new(string), to, as: as, quiet: quiet
end | Write a string to a host file . |
Summarize the following code: def read (filename, as: nil, quiet: false)
Base64.decode64 sh("cat #{filename.shellescape} | base64", as: as, quiet: quiet)
end | Read a host file . |
Summarize the following code: def sh (command, as: nil, quiet: false)
as ||= @user
output = ""
synchronize do
log.debug "sh #{command}", quiet: quiet
result = nil
ch = ssh(as).open_channel do |ch|
ch.request_pty do |ch, success|
"failed to acquire pty" unl... | Execute a command on the host and return its output . |
Summarize the following code: def can_hold_child?(storable)
Specimen === storable and storable.specimen_class == specimen_class and specimen_types.include?(storable.specimen_type)
end | Returns true if Storable is a Specimen and supported by this SpecimenArrayType . |
Summarize the following code: def process_aggregation
File.new(infile).each_with_index do |line, index|
result = col_filter.process(row_filter.process(line.chomp, row: index))
unless result.nil? or result.empty?
if heading.empty? and not headerless
heading << result.split(';'... | Process the aggregation of the key values . The result will be written to _outfile_ |
Summarize the following code: def write_result
sum_line = [sum_row_title]
(heading.size - 2).times { sum_line << "" }
sum_line << sums[sum_col_title]
row = 0;
File.open(outfile, 'w') do |out|
out.puts sum_line.join(';') if row == sum_row ; row += 1
out.puts heading.join(';'... | Writes the aggration results |
Summarize the following code: def init_sum_scheme(sum_scheme)
row_scheme, col_scheme = sum_scheme.split(',') unless sum_scheme.nil?
unless row_scheme.nil?
@sum_row_title, @sum_row = row_scheme.split(':') unless row_scheme.empty?
end
@sum_row.nil? ? @sum_row = 0 : @sum... | Initializes the sum row title an positions as well as the sum column title and position |
Summarize the following code: def attributes(&block)
raise ArgumentError, "You should provide block" unless block_given?
attributes = Morf::AttributesParser.parse(&block)
self.class_variable_set(:@@attributes, attributes)
end | Defines casting rules |
Summarize the following code: def resolve(dep_hashes, repos)
logger.info 'resolving dependencies'
session = MavenRepositorySystemSession.new
local_repo = LocalRepository.new(local_repository_path)
local_manager = @system.newLocalRepositoryManager(local_repo)
session.setLocalReposito... | Resolve a set of dependencies + dep_hashes + from repositories + repos + . |
Summarize the following code: def place(stone)
x, y = stone.to_coord
internal_board[y][x] = stone
end | Board shouldn t care about game rules |
Summarize the following code: def parse(argv)
OptionParser.new do |options|
usage_and_help options
assign_text_file options
assign_weights_file options
assign_output_file options
begin
options.parse argv
rescue OptionParser::ParseError => error
... | Parse given arguments |
Summarize the following code: def execute(command, params)
params[:Bugzilla_login] ||= username
params[:Bugzilla_password] ||= password
self.last_command = command_string(command, params)
xmlrpc_client.call(command, params)
end | Clone of an existing bug |
Summarize the following code: def leagues(summoner, optional={})
region = optional[:region] || @sightstone.region
id = if summoner.is_a? Summoner
summoner.id
else
summoner
end
uri = "https://prod.api.pvp.net/api/lol/#{region}/v2.3/league/by-summoner/#{id}"
response = _get_api_re... | Provides league information of a summoner |
Summarize the following code: def league_entries(summoner, optional={})
region = optional[:region] || @sightstone.region
id = if summoner.is_a? Summoner
summoner.id
else
summoner
end
uri = "https://prod.api.pvp.net/api/lol/#{region}/v2.3/league/by-summoner/#{id}/entry"
response ... | Get all entries for the given summoner |
Summarize the following code: def place(top, left, angle)
api('sticker.place', :placement => [:sticker_id => id, :top => top, :left => left, :angle => angle], :is_dj => client.user.dj?, :roomid => room.id, :section => room.section)
true
end | Sets the current user s stickers . |
Summarize the following code: def find
request_uris.map do |request|
if request[:body].nil?
request[:uri]
else
html = Nokogiri::HTML(request[:body])
potential_feed_uris = html.xpath(XPATHS.detect { |path| !html.xpath(path).empty? })
if potential_feed_uris.em... | From an array of supplied URIs will request each one and attempt to find a feed URI on the page . If one is found it will be added to an array and returned . |
Summarize the following code: def collection_status=(value)
if value == 'Complete' then
specimens.each { |spc| spc.collection_status = 'Collected' if spc.pending? }
end
setCollectionStatus(value)
end | Sets the collection status for this SCG . If the SCG status is set to + Complete + then the status of each of the SCG Specimens with status + Pending + is reset to + Collected + . |
Summarize the following code: def make_default_consent_tier_statuses
return if registration.nil? or registration.consent_tier_responses.empty?
# the consent tiers
ctses = consent_tier_statuses.map { |cts| cts.consent_tier }
# ensure that there is a CT status for each consent tier
re... | Makes a consent status for each registration consent . |
Summarize the following code: def default_collection_event
return if registration.nil?
pcl = registration.protocol || return
# if no protocol event, then add the default event
pcl.add_defaults if pcl.events.empty?
ev = pcl.sorted_events.first || return
logger.debug { "Default #{qp} c... | Returns the first event in the protocol registered with this SCG . |
Summarize the following code: def default_receiver
cep = collection_event_parameters
cltr = cep.user if cep
return cltr if cltr
cp = collection_protocol || return
rcv = cp.coordinators.first
return rcv if rcv or cp.fetched?
# Try to fetch the CP coordinator
return cp.coo... | Returns the collection protocol coordinator . Fetches the CP if necessary and possible . Adds defaults to the CP if necessary which sets a default coordinator if possible . |
Summarize the following code: def decrement_derived_quantity(child)
return unless specimen_type == child.specimen_type and child.initial_quantity
if available_quantity.nil? then
raise Jinx::ValidationError.new("Derived specimen has an initial quantity #{child.initial_quantity} but the parent is miss... | Decrements this parent s available quantity by the given child s initial quantity if the specimen types are the same and there are the relevant quantities . |
Summarize the following code: def update_changed_dependent(owner, property, dependent, autogenerated)
# Save the changed collectible event parameters directly rather than via a cascade.
if CollectibleEventParameters === dependent then
logger.debug { "Work around a caTissue bug by resaving the collec... | Updates the given dependent . |
Summarize the following code: def update_user_address(user, address)
logger.debug { "Work around caTissue prohibition of #{user} address #{address} update by creating a new address record for a dummy user..." }
address.identifier = nil
perform(:create, address) { create_object(address) }
logger.... | Updates the given user address . |
Summarize the following code: def add_position_to_specimen_template(specimen, template)
pos = specimen.position
# the non-domain position attributes
pas = pos.class.nondomain_attributes
# the template position reflects the old values, if available
ss = pos.snapshot
# the attribute =>... | Adds the specimen position to its save template . |
Summarize the following code: def ensure_primary_annotation_has_hook(annotation)
hook = annotation.hook
if hook.nil? then
raise CaRuby::DatabaseError.new("Cannot save annotation #{annotation} since it does not reference a hook entity")
end
if hook.identifier.nil? then
logger.debu... | Ensures that a primary annotation hook exists . |
Summarize the following code: def copy_annotation_proxy_owner_to_template(obj, template)
prop = obj.class.proxy_property
# Ignore the proxy attribute if it is defined by caRuby rather than caTissue.
return unless prop and prop.java_property?
rdr, wtr = prop.java_accessors
pxy = obj.send(rd... | The annotation proxy is not copied because the attribute redirects to the hook rather than the proxy . Set the template copy source proxy to the target object proxy using the low - level Java property methods instead . |
Summarize the following code: def create_table_data
processed_header = false
File.open(infile).each_with_index do |line, index|
line = line.chomp
next if line.empty?
line = unstring(line).chomp
header.process line, processed_header
unless processed_header... | Create the table |
Summarize the following code: def write_to_file
File.open(outfile, 'w') do |out|
out.puts header.to_s
out.puts create_sum_row if @sum_row_pos == 'TOP'
rows.each do |key, row|
line = [] << row[:key]
header.clear_header_cols.each_with_index do |col, index|
nex... | Write table to _outfile_ |
Summarize the following code: def to_number(value)
value = convert_to_en(value)
return value.to_i unless value =~ /\./
return value.to_f if value =~ /\./
end | Casts a string to an integer or float depending whether the value has a decimal point |
Summarize the following code: def prepare_sum_row(pattern)
return if pattern.nil? || pattern.empty?
@sum_row_pos, sum_row_pattern = pattern.split(/(?<=^top|^eof):/i)
@sum_row_pos.upcase!
@sum_row = Hash.new
@sum_row_patterns = split_by_comma_regex(sum_row_pattern)
end | Initializes sum_row_pos sum_row and sum_row_patterns based on the provided sum option |
Summarize the following code: def add_to_sum_row(value, column)
return unless @sum_row_patterns
@sum_row_patterns.each do |pattern|
if pattern =~ /^\(?c\d+[=~+.]/
header_column = evaluate(pattern, "")
else
header_column = pattern
end
if he... | Adds a value in the specified column to the sum_row |
Summarize the following code: def create_sum_row
line = []
header.clear_header_cols.each do |col|
line << @sum_row[col] || ""
end
line.flatten.join(';')
end | Creates the sum_row when the file has been completely processed |
Summarize the following code: def _rewrap_array(result)
if @wrap_results
newcoll = @collection.class.new(result)
self.class.new(newcoll, @wrapfunc_in, @wrapfunc_out)
else
@collection.class.new(result.map(&@wrapfunc_out))
end
end | Used to wrap results from various Enumerable methods that are defined to return an array |
Summarize the following code: def add_dependency(key, dependencies = [])
raise SelfDependencyError, "An object's dependencies cannot contain itself" if dependencies.include? key
node = node_for_key_or_new key
dependencies.each do |dependency|
node.addEdge(node_for_key_or_new(dependency))
... | Add a new node causing dependencies to be re - evaluated |
Summarize the following code: def resolve_dependency(node)
node.seen = true
@seen_this_pass << node
node.edges.each do |edge|
unless @resolved.include? edge
unless @seen_this_pass.include? edge
unless edge.seen?
resolve_dependency edge
end
... | Recurse through node edges |
Summarize the following code: def with_friends
data = api('room.directory_graph')
data['rooms'].map do |(attrs, friends)|
Room.new(client, attrs.merge(:friends => friends))
end
end | Gets the rooms where the current user s friends are currently listening . |
Summarize the following code: def find(query, options = {})
assert_valid_keys(options, :limit, :skip)
options = {:limit => 20, :skip => 0}.merge(options)
data = api('room.search', :query => query, :skip => options[:skip])
data['rooms'].map {|(attrs, *)| Room.new(client, attrs)}
end | Finds rooms that match the given query string . |
Summarize the following code: def load(options = {})
assert_valid_keys(options, :minimal)
options = {:minimal => false}.merge(options)
data = api('playlist.all', options)
self.attributes = data
super()
end | Loads the attributes for this playlist . Attributes will automatically load when accessed but this allows data to be forcefully loaded upfront . |
Summarize the following code: def update(attributes = {})
assert_valid_keys(attributes, :id)
# Update id
id = attributes.delete(:id)
update_id(id) if id
true
end | Updates this playlist s information . |
Summarize the following code: def active
@active = client.user.playlists.all.any? {|playlist| playlist == self && playlist.active?} if @active.nil?
@active
end | Whether this is the currently active playlist |
Summarize the following code: def add(name, options = {}, &coercer)
name = name.to_sym
value = Attribute.new(name, options, &coercer)
clone_with do
@attributes = attributes.merge(name => value)
@transformer = nil
end
end | Initializes the attribute from given arguments and returns new immutable collection with the attribute |
Summarize the following code: def add_specimens(*args)
hash = args.pop
spcs = args
# validate arguments
unless Hash === hash then
raise ArgumentError.new("Collection parameters are missing when adding specimens to protocol #{self}")
end
# Make the default registration, if nec... | Adds specimens to this protocol . The argumentes includes the specimens to add followed by a Hash with parameters and options . If the SCG registration parameter is not set then a default registration is created which registers the given participant to this protocol . |
Summarize the following code: def summoner(name_or_id, optional={})
region = optional[:region] || @sightstone.region
uri = if name_or_id.is_a? Integer
"https://prod.api.pvp.net/api/lol/#{region}/v1.3/summoner/#{name_or_id}"
else
"https://prod.api.pvp.net/api/lol/#{region}/v1.3/summoner/by-name/#... | returns a summoner object |
Summarize the following code: def names(ids, optional={})
region = optional[:region] || @sightstone.region
ids = ids.join(',')
uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.3/summoner/#{ids}/name"
response = _get_api_response(uri)
_parse_response(response) { |resp|
data = JSON.parse(res... | returns the names for the ids |
Summarize the following code: def runebook(summoner, optional={})
region = optional[:region] || @sightstone.region
id = if summoner.is_a? Summoner
summoner.id
else
summoner
end
uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.3/summoner/#{id}/runes"
response = _get_api_response(u... | returns the runebook of a summoner |
Summarize the following code: def runebooks(summoners, optional={})
return {} if summoners.empty?
region = optional[:region] || @sightstone.region
ids = summoners.collect { |summoner|
if summoner.is_a? Summoner
summoner.id
else
summoner
end
}
uri = "https://prod.ap... | returns the runebook for multiple summoners |
Summarize the following code: def write
buffer = create_zip(@entries, @ignore_entries)
puts "\nwrite file #{@output_file}"
File.open(@output_file, "wb") {|f| f.write buffer.string }
end | Initialize with the json config . Zip the input entries . |
Summarize the following code: def collect(opts)
raise Jinx::ValidationError.new("#{self} is already collected") if received?
specimen_event_parameters.merge!(extract_event_parameters(opts))
end | Collects and receives this Collectible with the given options . |
Summarize the following code: def method_missing(id, *args, &block)
boolean_row_regex = %r{
BEGIN(\(*[nsd]\d+[<!=~>]{1,2}
(?:[A-Z][A-Za-z]*\.new\(.*?\)|\d+|['"].*?['"])
(?:\)*(?:&&|\|\||$)
\(*[nsd]\d+[<!=~>]{1,2}
(?:[A-Z][A-Za-z]*\.new\(.*?\)|\d+|['"].*?['"])\)*)*)END
... | Creates a new filter Creates the filters based on the given patterns |
Summarize the following code: def match_boolean_filter?(values=[])
return false if boolean_filter.empty? or values.empty?
expression = boolean_filter
columns = expression.scan(/(([nsd])(\d+))([<!=~>]{1,2})(.*?)(?:[\|&]{2}|$)/)
columns.each do |c|
value = case c[1]
when 'n'
... | Checks whether the values match the boolean filter |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.