_id
stringlengths
2
6
title
stringlengths
9
130
partition
stringclasses
3 values
text
stringlengths
30
4.3k
language
stringclasses
1 value
meta_information
dict
q1600
Sorted.Set.c
train
def c(memo) each do |order| unless memo.keys.include?(order[0])
ruby
{ "resource": "" }
q1601
Sorted.Set.d
train
def d(memo, other) other.each do |sort| unless memo.keys.include?(sort[0])
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
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)) }
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|
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 =
ruby
{ "resource": "" }
q1606
Hawkular::Alerts.Client.list_members
train
def list_members(trigger_id, orphans = false) ret = http_get "triggers/groups/#{trigger_id}/members?in
ruby
{ "resource": "" }
q1607
Hawkular::Alerts.Client.create_group_dampening
train
def create_group_dampening(dampening) ret = http_post "triggers/groups/#{dampening.trigger_id}/dampenings",
ruby
{ "resource": "" }
q1608
Hawkular::Alerts.Client.update_group_dampening
train
def update_group_dampening(dampening) ret = http_put "triggers/groups/#{dampening.trigger_id}/dampenings/#{d
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 =
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
ruby
{ "resource": "" }
q1611
Hawkular::Alerts.Client.delete_action
train
def delete_action(plugin, action_id) the_plugin = hawk_escape plugin
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
ruby
{ "resource": "" }
q1613
Hawkular::Alerts.Client.alerts
train
def alerts(criteria: {}, tenants: nil) query = generate_query_params(criteria) uri = tenants ? '/admin/alerts/' : '/' ret
ruby
{ "resource": "" }
q1614
Hawkular::Alerts.Client.get_single_alert
train
def get_single_alert(alert_id) ret = http_get('/alert/'
ruby
{ "resource": "" }
q1615
Hawkular::Alerts.Client.resolve_alert
train
def resolve_alert(alert_id, by = nil, comment = nil) sub_url = "/resolve/#{alert_id}" query
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']
ruby
{ "resource": "" }
q1617
Hawkular::Alerts.Client.add_tags
train
def add_tags(alert_ids, tags) query = generate_query_params(alertIds: alert_ids, tags: tags)
ruby
{ "resource": "" }
q1618
Hawkular::Alerts.Client.remove_tags
train
def remove_tags(alert_ids, tag_names) query = generate_query_params(alertIds: alert_ids, tagNames:
ruby
{ "resource": "" }
q1619
CZTop.CertStore.lookup
train
def lookup(pubkey) ptr = ffi_delegate.lookup(pubkey)
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
ruby
{ "resource": "" }
q1621
Declarative.Heritage.record
train
def record(method, *args, &block) self << {method:
ruby
{ "resource": "" }
q1622
Protocol.Utilities.find_method_module
train
def find_method_module(methodname, ancestors) methodname = methodname.to_s ancestors.each do |a|
ruby
{ "resource": "" }
q1623
CZTop.Monitor.listen
train
def listen(*events) events.each do |event| EVENTS.include?(event) or
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|
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|
ruby
{ "resource": "" }
q1626
Protocol.ProtocolModule.understand?
train
def understand?(name, arity = nil) name = name.to_s !!find { |m|
ruby
{ "resource": "" }
q1627
Protocol.ProtocolModule.check_failures
train
def check_failures(object) check object rescue CheckFailed => e
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|
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}", protocol_check) understand methodname, protocol_check.arity, parser.block_arg?
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.synchronize do raise DeadActorError if not @running message.send_to(self) end rescue IO::EAGAINWaitWritable # The sndtimeo has been reached.
ruby
{ "resource": "" }
q1631
CZTop.Actor.send_picture
train
def send_picture(picture, *args) @mtx.synchronize do raise DeadActorError if not @running
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
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[:generations]) && (generation_ids.length > 0) next_gen_ids = [] ids += generation_ids until generation_ids.empty? ids.unshift(generation_ids.shift) next_gen_ids += gclass.find(ids.first).parents.compact.map(&:id) end
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 generation_ids.empty? ids.unshift(generation_ids.shift) next_gen_ids += gclass.find(ids.first).children.map(&:id) end generation_ids = next_gen_ids generation_count += 1 end else
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
ruby
{ "resource": "" }
q1636
CZTop.Poller.modify
train
def modify(socket, events) ptr = ptr_for_socket(socket) rc = ZMQ.poller_modify(@poller_ptr,
ruby
{ "resource": "" }
q1637
CZTop.Poller.remove
train
def remove(socket) ptr = ptr_for_socket(socket) rc = ZMQ.poller_remove(@poller_ptr,
ruby
{ "resource": "" }
q1638
CZTop.Poller.remove_reader
train
def remove_reader(socket) if event_mask_for_socket(socket) == ZMQ::POLLIN remove(socket) return
ruby
{ "resource": "" }
q1639
CZTop.Poller.remove_writer
train
def remove_writer(socket) if event_mask_for_socket(socket) == ZMQ::POLLOUT remove(socket) return
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
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]
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]
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
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_specific_operation({ resourceId: resource_id, feedId: feed_id,
ruby
{ "resource": "" }
q1646
Hawkular::Operations.Client.update_collection_intervals
train
def update_collection_intervals(hash, &callback) required = %i[resourceId feedId metricTypes availTypes]
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 elsif closing_edge = Edge.new(@edges.last.last, @edges.first.first) # If the closing edge is collinear with the last
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 # collinear, reverse direction nil else bisector_y =
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, duplicate the # first and last direction vectors to fake the adjacent edges. This causes the first and last # edges to have bisectors that are perpendicular to themselves. if closed? # Prepend
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)
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]
ruby
{ "resource": "" }
q1652
CZTop.Config.[]
train
def [](path, default = "") ptr = ffi_delegate.get(path, default) return nil
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 valid fault-structure given" end resp
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 res << ListStart.new(level, fragment.param, type) if type type_stack.push type # $stderr.puts "Start: #{level}" end while level > new_level type = type_stack.pop
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
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 specification[:disk_size] spec[:disk_size] = (specification[:disk_size].to_i * 1024) else spec[:disk_size] = 4194304 end spec[:memory] = (specification[:memory] || 128).to_i if specification[:datastore] spec[:datastore] = "[#{specification[:datastore]}]" else spec[:datastore] = '[datastore1]' end vm_cfg = { :name => spec[:vm_name], :guestId => spec[:guest_id], :files => { :vmPathName => spec[:datastore] }, :numCPUs => spec[:cpus], :numCoresPerSocket => spec[:cpu_cores], :memoryMB => spec[:memory], :deviceChange => [ { :operation => :add, :device => RbVmomi::VIM.VirtualLsiLogicController( :key => 1000, :busNumber => 0, :sharedBus => :noSharing) } ], :version => 'vmx-'+spec[:hw_version].to_s.rjust(2,'0'), :extraConfig => [ { :key => 'bios.bootOrder', :value => 'ethernet0' } ] } #Add multiple nics nics_count = 0 if spec[:nics] spec[:nics].each do |nic_spec| vm_cfg[:deviceChange].push( { :operation => :add, :device => RbVmomi::VIM.VirtualE1000(create_net_dev(nics_count, nic_spec)) } ) nics_count += 1 end end # VMDK provided, replace the empty vmdk vm_cfg[:deviceChange].push(create_disk_spec(:disk_file => spec[:disk_file], :disk_type => spec[:disk_type],
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,
ruby
{ "resource": "" }
q1658
ESX.Host.remote_command
train
def remote_command(cmd) output = "" Net::SSH.start(@address, @user, :password => @password) do |ssh|
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 => @password) do
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)
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") end Log.info "Uploading file... (#{File.basename(source)})" if print_progress ssh.scp.upload!(source, tmp_dest) do |ch, name, sent, total| if print_progress print "\rProgress: #{(sent.to_f * 100 / total.to_f).to_i}%" end end
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] datastore = params[:datastore] datastore = datastore + " #{disk_file}" if not disk_file.nil? spec = {} if disk_type == :sparse spec = { :operation => :add, :device => RbVmomi::VIM.VirtualDisk( :key => 0, :backing => RbVmomi::VIM.VirtualDiskSparseVer2BackingInfo(
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
ruby
{ "resource": "" }
q1664
RI.AttributeFormatter.write_attribute_text
train
def write_attribute_text(prefix, line) print prefix
ruby
{ "resource": "" }
q1665
RI.OverstrikeFormatter.bold_print
train
def bold_print(text) text.split(//).each do |ch|
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
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) form_vars = @env["rack.input"].read # Fix for Safari Ajax postings that always append \0
ruby
{ "resource": "" }
q1668
Rack.Request.url
train
def url url = scheme + "://" url << host if scheme == "https" && port != 443 || scheme == "http" && port
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
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 &&
ruby
{ "resource": "" }
q1671
DRb.DRbTCPSocket.send_request
train
def send_request(ref, msg_id, arg, b)
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
ruby
{ "resource": "" }
q1673
DRb.DRbServer.stop_service
train
def stop_service DRb.remove_server(self) if Thread.current['DRb'] && Thread.current['DRb']['server'] == self
ruby
{ "resource": "" }
q1674
DRb.DRbServer.to_obj
train
def to_obj(ref) return front if ref.nil? return
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.include?(msg_id.to_s) desc = any_to_s(obj) raise NoMethodError, "private method `#{msg_id}' called for #{desc}"
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 =
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 self.client_min_messages = 'panic' # postgres-pr does not raise an exception when client_min_messages is set higher
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] desc "Remove rdoc products" task clobber_task_name do rm_r rdoc_dir rescue nil end task :clobber => [clobber_task_name] directory @rdoc_dir task rdoc_task_name => [rdoc_target] file rdoc_target => @rdoc_files + [Rake.application.rakefile] do rm_r
ruby
{ "resource": "" }
q1679
RUNIT.Assert.assert_match
train
def assert_match(actual_string, expected_re, message="") _wrap_assertion { full_message = build_message(message, "Expected
ruby
{ "resource": "" }
q1680
Rake.GemPackageTask.init
train
def init(gem) super(gem.name, gem.version) @gem_spec = gem
ruby
{ "resource": "" }
q1681
ActiveSupport.XmlMini_REXML.parse
train
def parse(string) require 'rexml/document' unless defined?(REXML::Document)
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>"),
ruby
{ "resource": "" }
q1683
SM.ToHtml.add_tag
train
def add_tag(name, start, stop) @attr_tags
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)}"
ruby
{ "resource": "" }
q1685
Rinda.Tuple.each
train
def each # FIXME if Hash === @tuple @tuple.each { |k, v| yield(k, v) } else
ruby
{ "resource": "" }
q1686
Rinda.Tuple.init_with_ary
train
def init_with_ary(ary) @tuple = Array.new(ary.size) @tuple.size.times do |i|
ruby
{ "resource": "" }
q1687
Rinda.Tuple.init_with_hash
train
def init_with_hash(hash) @tuple = Hash.new hash.each do |k, v|
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) ?
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 }'.")
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
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
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)
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)
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_arguments(arguments, code.sub(/^s*?contains\s*?(!.*?)?$.*/im, ""), nil, nil, true) params_opt = "( " + params_opt + " ) " if params_opt subprogram.params = params_opt || "" namelist_comment = find_namelists(code, before_contains) block_comment = find_comments comment if function subprogram.comment = "<b><em> Function </em></b> :: <em>#{prefix}</em>\n" else subprogram.comment = "<b><em>
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
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 ?
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?/,"") else
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 =
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 file external_alias_header = "#{EXTERNAL_ALIAS_MES} " external_alias_text = external_alias_header + file + "#" + old else return nil end external_meth = AnyMethod.new(external_alias_text, new) external_meth.singleton = false external_meth.params = params
ruby
{ "resource": "" }