_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3
values | text stringlengths 66 10.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q1600 | Sorted.Set.c | train | def c(memo)
each do |order|
unless memo.keys.include?(order[0])
memo << order
end
end
end | ruby | {
"resource": ""
} |
q1601 | Sorted.Set.d | train | def d(memo, other)
other.each do |sort|
unless memo.keys.include?(sort[0])
memo << sort
end
end
end | ruby | {
"resource": ""
} |
q1602 | Hawkular::Alerts.Client.list_triggers | train | def list_triggers(ids = [], tags = [])
query = generate_query_params 'triggerIds' => ids, 'tags' => tags
sub_url = '/triggers' + query
ret = http_get(sub_url)
val = []
ret.each { |t| val.push(Trigger.new(t)) }
val
end | ruby | {
"resource": ""
} |
q1603 | Hawkular::Alerts.Client.get_single_trigger | train | def get_single_trigger(trigger_id, full = false)
the_trigger = '/triggers/' + trigger_id
ret = http_get(the_trigger)
trigger = Trigger.new(ret)
if full
ret = http_get(the_trigger + '/conditions')
ret.each { |c| trigger.conditions.push(Trigger::Condition.new(c)) }
ret = h... | ruby | {
"resource": ""
} |
q1604 | Hawkular::Alerts.Client.create_trigger | train | def create_trigger(trigger, conditions = [], dampenings = [], _actions = [])
full_trigger = {}
full_trigger[:trigger] = trigger.to_h
conds = []
conditions.each { |c| conds.push(c.to_h) }
full_trigger[:conditions] = conds
damps = []
dampenings.each { |d| damps.push(d.to_h) } unl... | ruby | {
"resource": ""
} |
q1605 | Hawkular::Alerts.Client.set_group_conditions | train | def set_group_conditions(trigger_id, trigger_mode, group_conditions_info)
ret = http_put "triggers/groups/#{trigger_id}/conditions/#{trigger_mode}", group_conditions_info.to_h
conditions = []
ret.each { |c| conditions.push(Trigger::Condition.new(c)) }
conditions
end | ruby | {
"resource": ""
} |
q1606 | Hawkular::Alerts.Client.list_members | train | def list_members(trigger_id, orphans = false)
ret = http_get "triggers/groups/#{trigger_id}/members?includeOrphans=#{orphans}"
ret.collect { |t| Trigger.new(t) }
end | ruby | {
"resource": ""
} |
q1607 | Hawkular::Alerts.Client.create_group_dampening | train | def create_group_dampening(dampening)
ret = http_post "triggers/groups/#{dampening.trigger_id}/dampenings", dampening.to_h
Trigger::Dampening.new(ret)
end | ruby | {
"resource": ""
} |
q1608 | Hawkular::Alerts.Client.update_group_dampening | train | def update_group_dampening(dampening)
ret = http_put "triggers/groups/#{dampening.trigger_id}/dampenings/#{dampening.dampening_id}", dampening.to_h
Trigger::Dampening.new(ret)
end | ruby | {
"resource": ""
} |
q1609 | Hawkular::Alerts.Client.create_action | train | def create_action(plugin, action_id, properties = {})
the_plugin = hawk_escape plugin
# Check if plugin exists
http_get("/plugins/#{the_plugin}")
payload = { actionId: action_id, actionPlugin: plugin, properties: properties }
ret = http_post('/actions', payload)
Trigger::Action.new(... | ruby | {
"resource": ""
} |
q1610 | Hawkular::Alerts.Client.get_action | train | def get_action(plugin, action_id)
the_plugin = hawk_escape plugin
the_action_id = hawk_escape action_id
ret = http_get "/actions/#{the_plugin}/#{the_action_id}"
Trigger::Action.new(ret)
end | ruby | {
"resource": ""
} |
q1611 | Hawkular::Alerts.Client.delete_action | train | def delete_action(plugin, action_id)
the_plugin = hawk_escape plugin
the_action_id = hawk_escape action_id
http_delete "/actions/#{the_plugin}/#{the_action_id}"
end | ruby | {
"resource": ""
} |
q1612 | Hawkular::Alerts.Client.get_alerts_for_trigger | train | def get_alerts_for_trigger(trigger_id)
# TODO: add additional filters
return [] unless trigger_id
url = '/?triggerIds=' + trigger_id
ret = http_get(url)
val = []
ret.each { |a| val.push(Alert.new(a)) }
val
end | ruby | {
"resource": ""
} |
q1613 | Hawkular::Alerts.Client.alerts | train | def alerts(criteria: {}, tenants: nil)
query = generate_query_params(criteria)
uri = tenants ? '/admin/alerts/' : '/'
ret = http_get(uri + query, multi_tenants_header(tenants))
val = []
ret.each { |a| val.push(Alert.new(a)) }
val
end | ruby | {
"resource": ""
} |
q1614 | Hawkular::Alerts.Client.get_single_alert | train | def get_single_alert(alert_id)
ret = http_get('/alert/' + alert_id)
val = Alert.new(ret)
val
end | ruby | {
"resource": ""
} |
q1615 | Hawkular::Alerts.Client.resolve_alert | train | def resolve_alert(alert_id, by = nil, comment = nil)
sub_url = "/resolve/#{alert_id}"
query = generate_query_params 'resolvedBy' => by, 'resolvedNotes' => comment
sub_url += query
http_put(sub_url, {})
true
end | ruby | {
"resource": ""
} |
q1616 | Hawkular::Alerts.Client.create_event | train | def create_event(id, category, text, extras)
event = {}
event['id'] = id
event['ctime'] = Time.now.to_i * 1000
event['category'] = category
event['text'] = text
event.merge!(extras) { |_key, v1, _v2| v1 }
http_post('/events', event)
end | ruby | {
"resource": ""
} |
q1617 | Hawkular::Alerts.Client.add_tags | train | def add_tags(alert_ids, tags)
query = generate_query_params(alertIds: alert_ids, tags: tags)
http_put('/tags' + query, {})
end | ruby | {
"resource": ""
} |
q1618 | Hawkular::Alerts.Client.remove_tags | train | def remove_tags(alert_ids, tag_names)
query = generate_query_params(alertIds: alert_ids, tagNames: tag_names)
http_delete('/tags' + query)
end | ruby | {
"resource": ""
} |
q1619 | CZTop.CertStore.lookup | train | def lookup(pubkey)
ptr = ffi_delegate.lookup(pubkey)
return nil if ptr.null?
Certificate.from_ffi_delegate(ptr)
end | ruby | {
"resource": ""
} |
q1620 | CZTop.CertStore.insert | train | def insert(cert)
raise ArgumentError unless cert.is_a?(Certificate)
@_inserted_pubkeys ||= Set.new
pubkey = cert.public_key
raise ArgumentError if @_inserted_pubkeys.include? pubkey
ffi_delegate.insert(cert.ffi_delegate)
@_inserted_pubkeys << pubkey
end | ruby | {
"resource": ""
} |
q1621 | Declarative.Heritage.record | train | def record(method, *args, &block)
self << {method: method, args: DeepDup.(args), block: block} # DISCUSS: options.dup.
end | ruby | {
"resource": ""
} |
q1622 | Protocol.Utilities.find_method_module | train | def find_method_module(methodname, ancestors)
methodname = methodname.to_s
ancestors.each do |a|
begin
a.instance_method(methodname)
return a
rescue NameError
end
end
nil
end | ruby | {
"resource": ""
} |
q1623 | CZTop.Monitor.listen | train | def listen(*events)
events.each do |event|
EVENTS.include?(event) or
raise ArgumentError, "invalid event: #{event.inspect}"
end
@actor << [ "LISTEN", *events ]
end | ruby | {
"resource": ""
} |
q1624 | Jshint::Reporters.Junit.print_errors_for_code | train | def print_errors_for_code(code, errors)
name = fetch_error_messages(code, errors)
output << " <testcase classname=\"jshint.#{code}\" name=\"#{escape(name)}\">\n"
errors.each do |error|
output << add_error_message(code, error)
end
output << " </testcase>\n"
output
en... | ruby | {
"resource": ""
} |
q1625 | Protocol.ProtocolModule.to_ruby | train | def to_ruby(result = '')
result << "#{name} = Protocol do"
first = true
if messages.empty?
result << "\n"
else
messages.each do |m|
result << "\n"
m.to_ruby(result)
end
end
result << "end\n"
end | ruby | {
"resource": ""
} |
q1626 | Protocol.ProtocolModule.understand? | train | def understand?(name, arity = nil)
name = name.to_s
!!find { |m| m.name == name && (!arity || m.arity == arity) }
end | ruby | {
"resource": ""
} |
q1627 | Protocol.ProtocolModule.check_failures | train | def check_failures(object)
check object
rescue CheckFailed => e
return e.errors.map { |e| e.protocol_message }
end | ruby | {
"resource": ""
} |
q1628 | Protocol.ProtocolModule.inherit | train | def inherit(modul, methodname, block_expected = nil)
Module === modul or
raise TypeError, "expected Module not #{modul.class} as modul argument"
methodnames = methodname.respond_to?(:to_ary) ?
methodname.to_ary :
[ methodname ]
methodnames.each do |methodname|
m = parse... | ruby | {
"resource": ""
} |
q1629 | Protocol.ProtocolModule.method_added | train | def method_added(methodname)
methodname = methodname.to_s
if specification? and methodname !~ /^__protocol_check_/
protocol_check = instance_method(methodname)
parser = MethodParser.new(self, methodname)
if parser.complex?
define_method("__protocol_check_#{methodname}", pro... | ruby | {
"resource": ""
} |
q1630 | CZTop.Actor.<< | train | def <<(message)
message = Message.coerce(message)
if TERM == message[0]
# NOTE: can't just send this to the actor. The sender might call
# #terminate immediately, which most likely causes a hang due to race
# conditions.
terminate
else
begin
@mtx.sync... | ruby | {
"resource": ""
} |
q1631 | CZTop.Actor.send_picture | train | def send_picture(picture, *args)
@mtx.synchronize do
raise DeadActorError if not @running
Zsock.send(ffi_delegate, picture, *args)
end
end | ruby | {
"resource": ""
} |
q1632 | CZTop.Actor.terminate | train | def terminate
@mtx.synchronize do
return false if not @running
Message.new(TERM).send_to(self)
await_handler_death
true
end
rescue IO::EAGAINWaitWritable
# same as in #<<
retry
end | ruby | {
"resource": ""
} |
q1633 | Genealogy.QueryMethods.ancestors | train | def ancestors(options = {})
ids = []
if options[:generations]
raise ArgumentError, ":generations option must be an Integer" unless options[:generations].is_a? Integer
generation_count = 0
generation_ids = parents.compact.map(&:id)
while (generation_count < options[:generation... | ruby | {
"resource": ""
} |
q1634 | Genealogy.QueryMethods.descendants | train | def descendants(options = {})
ids = []
if options[:generations]
generation_count = 0
generation_ids = children.map(&:id)
while (generation_count < options[:generations]) && (generation_ids.length > 0)
next_gen_ids = []
ids += generation_ids
until generat... | ruby | {
"resource": ""
} |
q1635 | Genealogy.QueryMethods.uncles_and_aunts | train | def uncles_and_aunts(options={})
relation = case options[:lineage]
when :paternal
[father]
when :maternal
[mother]
else
parents
end
ids = relation.compact.inject([]){|memo,parent| memo |= parent.siblings(half: options[:half]).pluck(:id)}
gclass.where(id:... | ruby | {
"resource": ""
} |
q1636 | CZTop.Poller.modify | train | def modify(socket, events)
ptr = ptr_for_socket(socket)
rc = ZMQ.poller_modify(@poller_ptr, ptr, events)
HasFFIDelegate.raise_zmq_err if rc == -1
remember_socket(socket, events)
end | ruby | {
"resource": ""
} |
q1637 | CZTop.Poller.remove | train | def remove(socket)
ptr = ptr_for_socket(socket)
rc = ZMQ.poller_remove(@poller_ptr, ptr)
HasFFIDelegate.raise_zmq_err if rc == -1
forget_socket(socket)
end | ruby | {
"resource": ""
} |
q1638 | CZTop.Poller.remove_reader | train | def remove_reader(socket)
if event_mask_for_socket(socket) == ZMQ::POLLIN
remove(socket)
return
end
raise ArgumentError, "not registered for readability only: %p" % socket
end | ruby | {
"resource": ""
} |
q1639 | CZTop.Poller.remove_writer | train | def remove_writer(socket)
if event_mask_for_socket(socket) == ZMQ::POLLOUT
remove(socket)
return
end
raise ArgumentError, "not registered for writability only: %p" % socket
end | ruby | {
"resource": ""
} |
q1640 | CZTop.Poller.wait | train | def wait(timeout = -1)
rc = ZMQ.poller_wait(@poller_ptr, @event_ptr, timeout)
if rc == -1
case CZMQ::FFI::Errors.errno
# NOTE: ETIMEDOUT for backwards compatibility, although this API is
# still DRAFT.
when Errno::EAGAIN::Errno, Errno::ETIMEDOUT::Errno
return nil
... | ruby | {
"resource": ""
} |
q1641 | Hawkular::Operations.Client.invoke_specific_operation | train | def invoke_specific_operation(operation_payload, operation_name, &callback)
fail Hawkular::ArgumentError, 'Operation must be specified' if operation_name.nil?
required = %i[resourceId feedId]
check_pre_conditions operation_payload, required, &callback
invoke_operation_helper(operation_payload, ... | ruby | {
"resource": ""
} |
q1642 | Hawkular::Operations.Client.add_deployment | train | def add_deployment(hash, &callback)
hash[:enabled] = hash.key?(:enabled) ? hash[:enabled] : true
hash[:force_deploy] = hash.key?(:force_deploy) ? hash[:force_deploy] : false
required = %i[resource_id feed_id destination_file_name binary_content]
check_pre_conditions hash, required, &callback
... | ruby | {
"resource": ""
} |
q1643 | Hawkular::Operations.Client.undeploy | train | def undeploy(hash, &callback)
hash[:remove_content] = hash.key?(:remove_content) ? hash[:remove_content] : true
required = %i[resource_id feed_id deployment_name]
check_pre_conditions hash, required, &callback
hash[:destination_file_name] = hash[:deployment_name]
operation_payload = prep... | ruby | {
"resource": ""
} |
q1644 | Hawkular::Operations.Client.enable_deployment | train | def enable_deployment(hash, &callback)
required = %i[resource_id feed_id deployment_name]
check_pre_conditions hash, required, &callback
hash[:destination_file_name] = hash[:deployment_name]
operation_payload = prepare_payload_hash([:deployment_name], hash)
invoke_operation_helper(operat... | ruby | {
"resource": ""
} |
q1645 | Hawkular::Operations.Client.export_jdr | train | def export_jdr(resource_id, feed_id, delete_immediately = false, sender_request_id = nil, &callback)
fail Hawkular::ArgumentError, 'resource_id must be specified' if resource_id.nil?
fail Hawkular::ArgumentError, 'feed_id must be specified' if feed_id.nil?
check_pre_conditions(&callback)
invoke... | ruby | {
"resource": ""
} |
q1646 | Hawkular::Operations.Client.update_collection_intervals | train | def update_collection_intervals(hash, &callback)
required = %i[resourceId feedId metricTypes availTypes]
check_pre_conditions hash, required, &callback
invoke_specific_operation(hash, 'UpdateCollectionIntervals', &callback)
end | ruby | {
"resource": ""
} |
q1647 | Geometry.Polyline.close! | train | def close!
unless @edges.empty?
# NOTE: parallel? is use here instead of collinear? because the
# edges are connected, and will therefore be collinear if
# they're parallel
if closed?
if @edges.first.parallel?(@edges.last)
unshift_edge Edge.new(@edges.last.first, shift_edge.last)
end
elsi... | ruby | {
"resource": ""
} |
q1648 | Geometry.Polyline.bisector_map | train | def bisector_map
winding = 0
tangent_loop.each_cons(2).map do |v1,v2|
k = v1[0]*v2[1] - v1[1]*v2[0] # z-component of v1 x v2
winding += k
if v1 == v2 # collinear, same direction?
bisector = Vector[-v1[1], v1[0]]
block_given? ? (bisector * yield(bisector, 1)) : bisector
elsif 0 == k # c... | ruby | {
"resource": ""
} |
q1649 | Geometry.Polyline.tangent_loop | train | def tangent_loop
edges.map {|e| e.direction }.tap do |tangents|
# Generating a bisector for each vertex requires an edge on both sides of each vertex.
# Obviously, the first and last vertices each have only a single adjacent edge, unless the
# Polyline happens to be closed (like a Polygon). When not closed, ... | ruby | {
"resource": ""
} |
q1650 | Geometry.Polyline.find_next_intersection | train | def find_next_intersection(edges, i, e)
for j in i..(edges.count-1)
e2 = edges[j][:edge]
next if !e2 || e.connected?(e2)
intersection = e.intersection(e2)
return [intersection, j] if intersection
end
nil
end | ruby | {
"resource": ""
} |
q1651 | Geometry.Polyline.find_last_intersection | train | def find_last_intersection(edges, i, e)
intersection, intersection_at = nil, nil
for j in i..(edges.count-1)
e2 = edges[j][:edge]
next if !e2 || e.connected?(e2)
_intersection = e.intersection(e2)
intersection, intersection_at = _intersection, j if _intersection
end
[intersection, intersecti... | ruby | {
"resource": ""
} |
q1652 | CZTop.Config.[] | train | def [](path, default = "")
ptr = ffi_delegate.get(path, default)
return nil if ptr.null?
ptr.read_string
end | ruby | {
"resource": ""
} |
q1653 | XMLRPC.Create.methodResponse | train | def methodResponse(is_ret, *params)
if is_ret
resp = params.collect do |param|
@writer.ele("param", conv2value(param))
end
resp = [@writer.ele("params", *resp)]
else
if params.size != 1 or params[0] === XMLRPC::FaultException
raise ArgumentError, "no val... | ruby | {
"resource": ""
} |
q1654 | SM.LineCollection.add_list_start_and_ends | train | def add_list_start_and_ends
level = 0
res = []
type_stack = []
@fragments.each do |fragment|
# $stderr.puts "#{level} : #{fragment.class.name} : #{fragment.level}"
new_level = fragment.level
while (level < new_level)
level += 1
type = fragment.type
... | ruby | {
"resource": ""
} |
q1655 | Rake.PackageTask.init | train | def init(name, version)
@name = name
@version = version
@package_files = Rake::FileList.new
@package_dir = 'pkg'
@need_tar = false
@need_tar_gz = false
@need_tar_bz2 = false
@need_zip = false
@tar_command = 'tar'
@zip_command = 'zip'
end | ruby | {
"resource": ""
} |
q1656 | ESX.Host.create_vm | train | def create_vm(specification)
spec = specification
spec[:cpus] = (specification[:cpus] || 1).to_i
spec[:cpu_cores] = (specification[:cpu_cores] || 1).to_i
spec[:guest_id] = specification[:guest_id] || 'otherGuest'
spec[:hw_version] = (specification[:hw_version] || 8).to_i
if specificatio... | ruby | {
"resource": ""
} |
q1657 | ESX.Host.host_info | train | def host_info
[
@_host.summary.config.product.fullName,
@_host.summary.config.product.apiType,
@_host.summary.config.product.apiVersion,
@_host.summary.config.product.osType,
@_host.summary.config.product.productLineId,
@_host.summary.config.product.vendor,
@_host.... | ruby | {
"resource": ""
} |
q1658 | ESX.Host.remote_command | train | def remote_command(cmd)
output = ""
Net::SSH.start(@address, @user, :password => @password) do |ssh|
output = ssh.exec! cmd
end
output
end | ruby | {
"resource": ""
} |
q1659 | ESX.Host.copy_from_template | train | def copy_from_template(template_disk, destination)
Log.debug "Copying from template #{template_disk} to #{destination}"
raise "Template does not exist" if not template_exist?(template_disk)
source = File.join(@templates_dir, File.basename(template_disk))
Net::SSH.start(@address, @user, :password... | ruby | {
"resource": ""
} |
q1660 | ESX.Host.import_disk | train | def import_disk(source, destination, print_progress = false, params = {})
use_template = params[:use_template] || false
if use_template
Log.debug "import_disk :use_template => true"
if !template_exist?(source)
Log.debug "import_disk, template does not exist, importing."
i... | ruby | {
"resource": ""
} |
q1661 | ESX.Host.import_disk_convert | train | def import_disk_convert(source, destination, print_progress = false)
tmp_dest = destination + ".tmp"
Net::SSH.start(@address, @user, :password => @password) do |ssh|
if not (ssh.exec! "ls #{destination} 2>/dev/null").nil?
raise Exception.new("Destination file #{destination} already exists"... | ruby | {
"resource": ""
} |
q1662 | ESX.Host.create_disk_spec | train | def create_disk_spec(params)
disk_type = params[:disk_type] || :flat
disk_file = params[:disk_file]
if disk_type == :sparse and disk_file.nil?
raise Exception.new("Creating sparse disks in ESX is not supported. Use an existing image.")
end
disk_size = params[:disk_size]
datas... | ruby | {
"resource": ""
} |
q1663 | ESX.VM.destroy | train | def destroy
#disks = vm_object.config.hardware.device.grep(RbVmomi::VIM::VirtualDisk)
unless host.free_license
vm_object.Destroy_Task.wait_for_completion
else
host.remote_command "vim-cmd vmsvc/power.off #{vmid}"
host.remote_command "vim-cmd vmsvc/destroy #{vmid}"
end
... | ruby | {
"resource": ""
} |
q1664 | RI.AttributeFormatter.write_attribute_text | train | def write_attribute_text(prefix, line)
print prefix
line.each do |achar|
print achar.char
end
puts
end | ruby | {
"resource": ""
} |
q1665 | RI.OverstrikeFormatter.bold_print | train | def bold_print(text)
text.split(//).each do |ch|
print ch, BS, ch
end
end | ruby | {
"resource": ""
} |
q1666 | RI.SimpleFormatter.display_heading | train | def display_heading(text, level, indent)
text = strip_attributes(text)
case level
when 1
puts "= " + text.upcase
when 2
puts "-- " + text
else
print indent, text, "\n"
end
end | ruby | {
"resource": ""
} |
q1667 | Rack.Request.POST | train | def POST
if @env["rack.request.form_input"].eql? @env["rack.input"]
@env["rack.request.form_hash"]
elsif form_data? || parseable_data?
@env["rack.request.form_input"] = @env["rack.input"]
unless @env["rack.request.form_hash"] =
Utils::Multipart.parse_multipart(env)
... | ruby | {
"resource": ""
} |
q1668 | Rack.Request.url | train | def url
url = scheme + "://"
url << host
if scheme == "https" && port != 443 ||
scheme == "http" && port != 80
url << ":#{port}"
end
url << fullpath
url
end | ruby | {
"resource": ""
} |
q1669 | DRb.DRbProtocol.open | train | def open(uri, config, first=true)
@protocol.each do |prot|
begin
return prot.open(uri, config)
rescue DRbBadScheme
rescue DRbConnError
raise($!)
rescue
raise(DRbConnError, "#{uri} - #{$!.inspect}")
end
end
if first && (config[:auto_load] != false)
auto_load(uri, config)
return open(ur... | ruby | {
"resource": ""
} |
q1670 | DRb.DRbProtocol.open_server | train | def open_server(uri, config, first=true)
@protocol.each do |prot|
begin
return prot.open_server(uri, config)
rescue DRbBadScheme
end
end
if first && (config[:auto_load] != false)
auto_load(uri, config)
return open_server(uri, config, false)
end
raise DRbBadURI, 'can\'t parse uri:' ... | ruby | {
"resource": ""
} |
q1671 | DRb.DRbTCPSocket.send_request | train | def send_request(ref, msg_id, arg, b)
@msg.send_request(stream, ref, msg_id, arg, b)
end | ruby | {
"resource": ""
} |
q1672 | DRb.DRbObject.method_missing | train | def method_missing(msg_id, *a, &b)
if DRb.here?(@uri)
obj = DRb.to_obj(@ref)
DRb.current_server.check_insecure_method(obj, msg_id)
return obj.__send__(msg_id, *a, &b)
end
succ, result = self.class.with_friend(@uri) do
DRbConn.open(@uri) do |conn|
conn.send_message(self, msg_id, ... | ruby | {
"resource": ""
} |
q1673 | DRb.DRbServer.stop_service | train | def stop_service
DRb.remove_server(self)
if Thread.current['DRb'] && Thread.current['DRb']['server'] == self
Thread.current['DRb']['stop_service'] = true
else
@thread.kill
end
end | ruby | {
"resource": ""
} |
q1674 | DRb.DRbServer.to_obj | train | def to_obj(ref)
return front if ref.nil?
return front[ref.to_s] if DRbURIOption === ref
@idconv.to_obj(ref)
end | ruby | {
"resource": ""
} |
q1675 | DRb.DRbServer.check_insecure_method | train | def check_insecure_method(obj, msg_id)
return true if Proc === obj && msg_id == :__drb_yield
raise(ArgumentError, "#{any_to_s(msg_id)} is not a symbol") unless Symbol == msg_id.class
raise(SecurityError, "insecure method `#{msg_id}'") if insecure_method?(msg_id)
if obj.private_methods.inc... | ruby | {
"resource": ""
} |
q1676 | DRb.DRbServer.main_loop | train | def main_loop
Thread.start(@protocol.accept) do |client|
@grp.add Thread.current
Thread.current['DRb'] = { 'client' => client ,
'server' => self }
loop do
begin
succ = false
invoke_method = InvokeMethod.new(self, client)
succ, result = invoke_method.perform
if ... | ruby | {
"resource": ""
} |
q1677 | ::JdbcSpec.PostgreSQL.supports_standard_conforming_strings? | train | def supports_standard_conforming_strings?
# Temporarily set the client message level above error to prevent unintentional
# error messages in the logs when working on a PostgreSQL database server that
# does not support standard conforming strings.
client_min_messages_old = client_min_messages
... | ruby | {
"resource": ""
} |
q1678 | Rake.RDocTask.define | train | def define
if rdoc_task_name != "rdoc"
desc "Build the RDOC HTML Files"
else
desc "Build the #{rdoc_task_name} HTML Files"
end
task rdoc_task_name
desc "Force a rebuild of the RDOC files"
task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
... | ruby | {
"resource": ""
} |
q1679 | RUNIT.Assert.assert_match | train | def assert_match(actual_string, expected_re, message="")
_wrap_assertion {
full_message = build_message(message, "Expected <?> to match <?>", actual_string, expected_re)
assert_block(full_message) {
expected_re =~ actual_string
}
Regexp.last_match
}
end | ruby | {
"resource": ""
} |
q1680 | Rake.GemPackageTask.init | train | def init(gem)
super(gem.name, gem.version)
@gem_spec = gem
@package_files += gem_spec.files if gem_spec.files
end | ruby | {
"resource": ""
} |
q1681 | ActiveSupport.XmlMini_REXML.parse | train | def parse(string)
require 'rexml/document' unless defined?(REXML::Document)
doc = REXML::Document.new(string)
merge_element!({}, doc.root)
end | ruby | {
"resource": ""
} |
q1682 | SM.ToHtml.init_tags | train | def init_tags
@attr_tags = [
InlineTag.new(SM::Attribute.bitmap_for(:BOLD), "<b>", "</b>"),
InlineTag.new(SM::Attribute.bitmap_for(:TT), "<tt>", "</tt>"),
InlineTag.new(SM::Attribute.bitmap_for(:EM), "<em>", "</em>"),
]
end | ruby | {
"resource": ""
} |
q1683 | SM.ToHtml.add_tag | train | def add_tag(name, start, stop)
@attr_tags << InlineTag.new(SM::Attribute.bitmap_for(name), start, stop)
end | ruby | {
"resource": ""
} |
q1684 | Net.HTTPHeader.set_form_data | train | def set_form_data(params, sep = '&')
self.body = params.map {|k,v| "#{urlencode(k.to_s)}=#{urlencode(v.to_s)}" }.join(sep)
self.content_type = 'application/x-www-form-urlencoded'
end | ruby | {
"resource": ""
} |
q1685 | Rinda.Tuple.each | train | def each # FIXME
if Hash === @tuple
@tuple.each { |k, v| yield(k, v) }
else
@tuple.each_with_index { |v, k| yield(k, v) }
end
end | ruby | {
"resource": ""
} |
q1686 | Rinda.Tuple.init_with_ary | train | def init_with_ary(ary)
@tuple = Array.new(ary.size)
@tuple.size.times do |i|
@tuple[i] = ary[i]
end
end | ruby | {
"resource": ""
} |
q1687 | Rinda.Tuple.init_with_hash | train | def init_with_hash(hash)
@tuple = Hash.new
hash.each do |k, v|
raise InvalidHashTupleKey unless String === k
@tuple[k] = v
end
end | ruby | {
"resource": ""
} |
q1688 | XSD.XSDFloat.narrow32bit | train | def narrow32bit(f)
if f.nan? || f.infinite?
f
elsif f.abs < MIN_POSITIVE_SINGLE
XSDFloat.positive?(f) ? POSITIVE_ZERO : NEGATIVE_ZERO
else
f
end
end | ruby | {
"resource": ""
} |
q1689 | XSD.XSDHexBinary.set_encoded | train | def set_encoded(value)
if /^[0-9a-fA-F]*$/ !~ value
raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
end
@data = String.new(value).strip
@is_nil = false
end | ruby | {
"resource": ""
} |
q1690 | ActiveSupport.Rescuable.rescue_with_handler | train | def rescue_with_handler(exception)
if handler = handler_for_rescue(exception)
handler.arity != 0 ? handler.call(exception) : handler.call
true # don't rely on the return value of the handler
end
end | ruby | {
"resource": ""
} |
q1691 | SM.PreProcess.handle | train | def handle(text)
text.gsub!(/^([ \t#]*):(\w+):\s*(.+)?\n/) do
prefix = $1
directive = $2.downcase
param = $3
case directive
when "include"
filename = param.split[0]
include_file(filename, prefix)
else
yield(directive, param)
... | ruby | {
"resource": ""
} |
q1692 | SM.PreProcess.include_file | train | def include_file(name, indent)
if (full_name = find_include_file(name))
content = File.open(full_name) {|f| f.read}
# strip leading '#'s, but only if all lines start with them
if content =~ /^[^#]/
content.gsub(/^/, indent)
else
content.gsub(/^#?/, indent)
... | ruby | {
"resource": ""
} |
q1693 | SM.PreProcess.find_include_file | train | def find_include_file(name)
to_search = [ File.dirname(@input_file_name) ].concat @include_path
to_search.each do |dir|
full_name = File.join(dir, name)
stat = File.stat(full_name) rescue next
return full_name if stat.readable?
end
nil
end | ruby | {
"resource": ""
} |
q1694 | RDoc.Fortran95parser.parse_subprogram | train | def parse_subprogram(subprogram, params, comment, code,
before_contains=nil, function=nil, prefix=nil)
subprogram.singleton = false
prefix = "" if !prefix
arguments = params.sub(/\(/, "").sub(/\)/, "").split(",") if params
args_comment, params_opt =
find_argume... | ruby | {
"resource": ""
} |
q1695 | RDoc.Fortran95parser.collect_first_comment | train | def collect_first_comment(body)
comment = ""
not_comment = ""
comment_start = false
comment_end = false
body.split("\n").each{ |line|
if comment_end
not_comment << line
not_comment << "\n"
elsif /^\s*?!\s?(.*)$/i =~ line
comment_start = true
... | ruby | {
"resource": ""
} |
q1696 | RDoc.Fortran95parser.find_namelists | train | def find_namelists(text, before_contains=nil)
return nil if !text
result = ""
lines = "#{text}"
before_contains = "" if !before_contains
while lines =~ /^\s*?namelist\s+\/\s*?(\w+)\s*?\/([\s\w\,]+)$/i
lines = $~.post_match
nml_comment = COMMENTS_ARE_UPPER ?
fin... | ruby | {
"resource": ""
} |
q1697 | RDoc.Fortran95parser.find_comments | train | def find_comments text
return "" unless text
lines = text.split("\n")
lines.reverse! if COMMENTS_ARE_UPPER
comment_block = Array.new
lines.each do |line|
break if line =~ /^\s*?\w/ || line =~ /^\s*?$/
if COMMENTS_ARE_UPPER
comment_block.unshift line.sub(/^\s*?!\s?... | ruby | {
"resource": ""
} |
q1698 | RDoc.Fortran95parser.initialize_public_method | train | def initialize_public_method(method, parent)
return if !method || !parent
new_meth = AnyMethod.new("External Alias for module", method.name)
new_meth.singleton = method.singleton
new_meth.params = method.params.clone
new_meth.comment = remove_trailing_alias(method.comment.cl... | ruby | {
"resource": ""
} |
q1699 | RDoc.Fortran95parser.initialize_external_method | train | def initialize_external_method(new, old, params, file, comment, token=nil,
internal=nil, nolink=nil)
return nil unless new || old
if internal
external_alias_header = "#{INTERNAL_ALIAS_MES} "
external_alias_text = external_alias_header + old
elsif ... | ruby | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.