_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3
values | text stringlengths 30 4.3k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q18200 | CukeModeler.Gherkin6Adapter.adapt_comment! | train | def adapt_comment!(parsed_comment)
# Saving off the original data
parsed_comment['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_comment))
parsed_comment['text'] | ruby | {
"resource": ""
} |
q18201 | CukeModeler.Feature.to_s | train | def to_s
text = ''
text << tag_output_string + "\n" unless tags.empty?
text << "#{@keyword}:#{name_output_string}"
text << "\n" + | ruby | {
"resource": ""
} |
q18202 | CukeModeler.Step.to_s | train | def to_s
text = "#{keyword} #{self.text}"
text << "\n" + block.to_s.split("\n").collect { |line| | ruby | {
"resource": ""
} |
q18203 | CukeModeler.Gherkin3Adapter.adapt_doc_string! | train | def adapt_doc_string!(parsed_doc_string)
# Saving off the original data
parsed_doc_string['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_doc_string))
| ruby | {
"resource": ""
} |
q18204 | CukeModeler.Outline.to_s | train | def to_s
text = ''
text << tag_output_string + "\n" unless tags.empty?
text << "#{@keyword}:#{name_output_string}"
text << "\n" + description_output_string unless (description.nil? || description.empty?)
text << "\n" unless (steps.empty? || description.nil? || description.empty?) | ruby | {
"resource": ""
} |
q18205 | CukeModeler.Containing.each_descendant | train | def each_descendant(&block)
children.each do |child_model|
block.call(child_model)
child_model.each_descendant(&block) | ruby | {
"resource": ""
} |
q18206 | CukeModeler.Nested.get_ancestor | train | def get_ancestor(ancestor_type)
target_type = {:directory => [Directory],
:feature_file => [FeatureFile],
:feature => [Feature],
:test => [Scenario, Outline, Background],
:background => [Background],
:scenario... | ruby | {
"resource": ""
} |
q18207 | CukeModeler.Example.to_s | train | def to_s
text = ''
text << tag_output_string + "\n" unless tags.empty?
text << "#{@keyword}:#{name_output_string}"
text << "\n" + description_output_string unless (description.nil? || description.empty?)
text << "\n" unless (rows.empty? || description.nil? || description.empty?) | ruby | {
"resource": ""
} |
q18208 | Vines.Stanza.broadcast | train | def broadcast(recipients)
@node[FROM] = stream.user.jid.to_s
recipients.each do |recipient|
| ruby | {
"resource": ""
} |
q18209 | Vines.Stanza.local? | train | def local?
return true unless ROUTABLE_STANZAS.include?(@node.name) | ruby | {
"resource": ""
} |
q18210 | Vines.Stanza.send_unavailable | train | def send_unavailable(from, to)
available = router.available_resources(from, to)
stanzas = available.map {|stream| | ruby | {
"resource": ""
} |
q18211 | Vines.Stanza.unavailable | train | def unavailable(from)
doc = Document.new
doc.create_element('presence',
'from' => from.to_s,
| ruby | {
"resource": ""
} |
q18212 | Vines.Stanza.send_to_remote | train | def send_to_remote(stanzas, to)
return false if local_jid?(to)
to = JID.new(to)
stanzas.each do |el|
el[TO] | ruby | {
"resource": ""
} |
q18213 | Vines.Stanza.send_to_recipients | train | def send_to_recipients(stanzas, recipients)
recipients.each do |recipient|
stanzas.each do |el|
el[TO] | ruby | {
"resource": ""
} |
q18214 | Vines.User.update_from | train | def update_from(user)
@name = user.name
@password = user.password
@roster | ruby | {
"resource": ""
} |
q18215 | Vines.User.contact | train | def contact(jid)
bare = JID.new(jid).bare | ruby | {
"resource": ""
} |
q18216 | Vines.User.remove_contact | train | def remove_contact(jid)
bare = JID.new(jid).bare | ruby | {
"resource": ""
} |
q18217 | Vines.User.request_subscription | train | def request_subscription(jid)
unless contact = contact(jid)
contact = Contact.new(:jid => jid)
@roster << contact
| ruby | {
"resource": ""
} |
q18218 | Vines.User.add_subscription_from | train | def add_subscription_from(jid)
unless contact = contact(jid)
| ruby | {
"resource": ""
} |
q18219 | Vines.User.to_roster_xml | train | def to_roster_xml(id)
doc = Nokogiri::XML::Document.new
doc.create_element('iq', 'id' => id, 'type' => 'result') do |el|
el << doc.create_element('query', 'xmlns' => 'jabber:iq:roster') do |query|
| ruby | {
"resource": ""
} |
q18220 | Vines.Contact.send_roster_push | train | def send_roster_push(recipient)
doc = Nokogiri::XML::Document.new
node = doc.create_element('iq',
'id' => Kit.uuid,
'to' => recipient.user.jid.to_s,
'type' => 'set')
| ruby | {
"resource": ""
} |
q18221 | Vines.CLI.start | train | def start
register_storage
opts = parse(ARGV)
check_config(opts)
command = Command.const_get(opts[:command].capitalize).new
| ruby | {
"resource": ""
} |
q18222 | Vines.CLI.check_config | train | def check_config(opts)
return if %w[bcrypt init].include?(opts[:command])
unless File.exists?(opts[:config])
| ruby | {
"resource": ""
} |
q18223 | Vines.Config.pubsub | train | def pubsub(domain)
host = @vhosts.values.find {|host| | ruby | {
"resource": ""
} |
q18224 | Vines.Config.component? | train | def component?(*jids)
!jids.flatten.index do |jid|
| ruby | {
"resource": ""
} |
q18225 | Vines.Config.component_password | train | def component_password(domain)
host = @vhosts.values.find {|host| host.component?(domain) }
| ruby | {
"resource": ""
} |
q18226 | Vines.Config.local_jid? | train | def local_jid?(*jids)
!jids.flatten.index do |jid|
| ruby | {
"resource": ""
} |
q18227 | Vines.Config.allowed? | train | def allowed?(to, from)
to, from = JID.new(to), JID.new(from)
return false if to.empty? || from.empty?
return true if to.domain == from.domain # same domain always allowed
return cross_domain?(to, from) if local_jid?(to, from) # both virtual hoste... | ruby | {
"resource": ""
} |
q18228 | Vines.Config.strip_domain | train | def strip_domain(jid)
domain = jid.dom | ruby | {
"resource": ""
} |
q18229 | Vines.Config.cross_domain? | train | def cross_domain?(*jids)
!jids.flatten.index do |jid|
| ruby | {
"resource": ""
} |
q18230 | Vines.Cluster.start | train | def start
@connection.connect
@publisher.broadcast(:online)
@subscriber.subscribe
EM.add_periodic_timer(1) { heartbeat }
at_exit do | ruby | {
"resource": ""
} |
q18231 | Vines.Cluster.query | train | def query(name, *args)
fiber, yielding = Fiber.current, true
req = connection.send(name, *args)
req.errback { fiber.resume rescue yielding = false }
| ruby | {
"resource": ""
} |
q18232 | Vines.Storage.authenticate | train | def authenticate(username, password)
user = find_user(username)
hash = | ruby | {
"resource": ""
} |
q18233 | Vines.Storage.authenticate_with_ldap | train | def authenticate_with_ldap(username, password, &block)
op = operation { ldap.authenticate(username, password) }
cb | ruby | {
"resource": ""
} |
q18234 | Vines.Storage.save_ldap_user | train | def save_ldap_user(user, &block)
Fiber.new do
if user.nil?
block.call
elsif found = | ruby | {
"resource": ""
} |
q18235 | Vines.Router.connected_resources | train | def connected_resources(jid, from, proxies=true)
jid, from = JID.new(jid), JID.new(from)
return [] unless @config.allowed?(jid, from)
local = @clients[jid.bare] || EMPTY
| ruby | {
"resource": ""
} |
q18236 | Vines.Router.delete | train | def delete(stream)
case stream_type(stream)
when :client then
return unless stream.connected?
jid = stream.user.jid.bare
| ruby | {
"resource": ""
} |
q18237 | Vines.Router.route | train | def route(stanza)
to, from = %w[to from].map {|attr| JID.new(stanza[attr]) }
return unless @config.allowed?(to, from)
key = [to.domain, from.domain]
if stream = connection_to(to, from)
stream.write(stanza)
elsif @pending.key?(key)
@pending[key] << stanza
elsif @confi... | ruby | {
"resource": ""
} |
q18238 | Vines.Router.size | train | def size
clients = @clients.values.inject(0) {|sum, arr| sum + arr.size }
| ruby | {
"resource": ""
} |
q18239 | Vines.Router.return_pending | train | def return_pending(key)
@pending[key].each do |stanza|
to, from = JID.new(stanza['to']), JID.new(stanza['from'])
xml = StanzaErrors::RemoteServerNotFound.new(stanza, 'cancel').to_xml
if @config.component?(from)
| ruby | {
"resource": ""
} |
q18240 | Vines.Router.clients | train | def clients(jids, from, &filter)
jids = filter_allowed(jids, from)
local = @clients.values_at(*jids).compact.flatten.select(&filter) | ruby | {
"resource": ""
} |
q18241 | Vines.Router.filter_allowed | train | def filter_allowed(jids, from)
from = JID.new(from)
jids.flatten.map {|jid| JID.new(jid).bare }
| ruby | {
"resource": ""
} |
q18242 | Vines.Daemon.running? | train | def running?
begin
pid && Process.kill(0, pid)
rescue Errno::ESRCH
delete_pid
| ruby | {
"resource": ""
} |
q18243 | Vines.Store.domain? | train | def domain?(pem, domain)
if cert = OpenSSL::X509::Certificate.new(pem) rescue nil
| ruby | {
"resource": ""
} |
q18244 | Vines.Store.files_for_domain | train | def files_for_domain(domain)
crt = File.expand_path("#{domain}.crt", @dir)
key = File.expand_path("#{domain}.key", @dir)
return [crt, key] if File.exists?(crt) && File.exists?(key)
# Might be a wildcard cert file.
@@sources.each do |file, certs|
certs.each do |cert|
if O... | ruby | {
"resource": ""
} |
q18245 | Vines.Stream.post_init | train | def post_init
@remote_addr, @local_addr = addresses
@user, @closed, @stanza_size = nil, false, 0
@bucket = TokenBucket.new(100, 10)
| ruby | {
"resource": ""
} |
q18246 | Vines.Stream.receive_data | train | def receive_data(data)
return if @closed
@stanza_size += data.bytesize
if @stanza_size < max_stanza_size
@parser << data rescue error(StreamErrors::NotWellFormed.new)
| ruby | {
"resource": ""
} |
q18247 | Vines.Stream.write | train | def write(data)
log_node(data, :out)
if data.respond_to?(:to_xml)
data | ruby | {
"resource": ""
} |
q18248 | Vines.Stream.error | train | def error(e)
case e
when SaslError, StanzaError
write(e.to_xml)
when StreamError
send_stream_error(e)
| ruby | {
"resource": ""
} |
q18249 | Vines.Stream.addresses | train | def addresses
[get_peername, get_sockname].map do |addr|
| ruby | {
"resource": ""
} |
q18250 | Rosemary.Member.to_xml | train | def to_xml(options = {})
xml = options[:builder] ||= Builder::XmlMarkup.new
| ruby | {
"resource": ""
} |
q18251 | Rosemary.Api.destroy | train | def destroy(element, changeset)
element.changeset = changeset.id
response = delete("/#{element.type.downcase}/#{element.id}", | ruby | {
"resource": ""
} |
q18252 | Rosemary.Api.save | train | def save(element, changeset)
response = if element.id.nil?
create(element, changeset)
else
| ruby | {
"resource": ""
} |
q18253 | Rosemary.Api.create | train | def create(element, changeset)
element.changeset = changeset.id
| ruby | {
"resource": ""
} |
q18254 | Rosemary.Api.update | train | def update(element, changeset)
element.changeset = changeset.id
response = put("/#{element.type.downcase}/#{element.id}", :body => | ruby | {
"resource": ""
} |
q18255 | Rosemary.Api.create_changeset | train | def create_changeset(comment = nil, tags = {})
tags.merge!(:comment => comment) { |key, v1, v2| v1 }
changeset = | ruby | {
"resource": ""
} |
q18256 | Rosemary.Api.do_request | train | def do_request(method, url, options = {})
begin
response = self.class.send(method, api_url(url), options)
check_response_codes(response)
response.parsed_response | ruby | {
"resource": ""
} |
q18257 | Rosemary.Api.do_authenticated_request | train | def do_authenticated_request(method, url, options = {})
begin
response = case client
when BasicAuthClient
self.class.send(method, api_url(url), options.merge(:basic_auth => client.credentials))
when OauthClient
# We have to wr... | ruby | {
"resource": ""
} |
q18258 | Rosemary.Way.<< | train | def <<(stuff)
case stuff
when Array # call this method recursively
stuff.each do |item|
self << item
end
when Rosemary::Node
nodes << stuff.id
when String
nodes << | ruby | {
"resource": ""
} |
q18259 | Rosemary.Tags.to_xml | train | def to_xml(options = {})
xml = options[:builder] ||= Builder::XmlMarkup.new
xml.instruct! unless options[:skip_instruct]
| ruby | {
"resource": ""
} |
q18260 | Rosemary.Changeset.to_xml | train | def to_xml(options = {})
xml = options[:builder] ||= Builder::XmlMarkup.new
xml.instruct! unless options[:skip_instruct]
xml.osm do
xml.changeset(attributes) do
tags.each do |k,v|
| ruby | {
"resource": ""
} |
q18261 | Rosemary.Relation.to_xml | train | def to_xml(options = {})
xml = options[:builder] ||= Builder::XmlMarkup.new
xml.instruct! unless options[:skip_instruct]
xml.osm(:generator => "rosemary v#{Rosemary::VERSION}", :version => Rosemary::Api::API_VERSION) do
xml.relation(attributes) do
members.each do |member|
| ruby | {
"resource": ""
} |
q18262 | Rosemary.Element.add_tags | train | def add_tags(new_tags)
case new_tags
when Array # Called with an array
# Call recursively for each entry
new_tags.each do |tag_hash|
add_tags(tag_hash)
end
when Hash # Called with a hash
#check if it is weird {'k' => 'key', 'v' => 'value'} syntax
if (n... | ruby | {
"resource": ""
} |
q18263 | Rosemary.Element.get_relations_from_api | train | def get_relations_from_api(api=Rosemary::API.new)
| ruby | {
"resource": ""
} |
q18264 | Rosemary.Element.get_history_from_api | train | def get_history_from_api(api=Rosemary::API.new)
| ruby | {
"resource": ""
} |
q18265 | CowProxy.Struct.dig | train | def dig(key, *args)
value = send(key) | ruby | {
"resource": ""
} |
q18266 | CowProxy.Array.map! | train | def map!
__copy_on_write__
return enum_for(:map!) unless block_given?
__getobj__.each.with_index do |_, | ruby | {
"resource": ""
} |
q18267 | Bud.BudDbmTable.tick_deltas | train | def tick_deltas
unless @delta.empty?
merge_to_db(@delta)
@tick_delta.concat(@delta.values) if accumulate_tick_deltas
@delta.clear
end
unless @new_delta.empty?
# We allow @new_delta to contain duplicates but eliminate them here. We
# can't just allow duplicate de... | ruby | {
"resource": ""
} |
q18268 | Bud.BudDbmTable.tick | train | def tick
deleted = nil
@to_delete.each do |tuple|
k = get_key_vals(tuple)
k_str = MessagePack.pack(k)
cols_str = @dbm[k_str]
unless cols_str.nil?
db_cols = MessagePack.unpack(cols_str)
| ruby | {
"resource": ""
} |
q18269 | Bud.BudZkTable.start_watchers | train | def start_watchers
# Watcher callbacks are invoked in a separate Ruby thread. Note that there
# is a possible deadlock between invoking watcher callbacks and calling
# close(): if we get a watcher event and a close at around the same time,
# the close might fire first. Closing the Zk handle will... | ruby | {
"resource": ""
} |
q18270 | Bud.BudChannel.payloads | train | def payloads(&blk)
return self.pro(&blk) if @is_loopback
if @payload_struct.nil?
payload_cols = cols.dup
payload_cols.delete_at(@locspec_idx)
@payload_struct = Bud::TupleStruct.new(*payload_cols) | ruby | {
"resource": ""
} |
q18271 | Mobility.Util.camelize | train | def camelize(str)
call_or_yield str do
str.to_s.sub(/^[a-z\d]*/) { $&.capitalize }.gsub(/(?:_|(\/))([a-z\d]*)/) { | ruby | {
"resource": ""
} |
q18272 | Mobility.Util.call_or_yield | train | def call_or_yield(object)
caller_method = caller_locations(1,1)[0].label
if object.respond_to?(caller_method)
| ruby | {
"resource": ""
} |
q18273 | Helpers.LazyDescribedClass.described_class | train | def described_class
klass = super
return klass if klass
# crawl up metadata tree looking for description that can be constantized
this_metadata = metadata
while this_metadata do
candidate = this_metadata[:description_args].first
begin
return candidate.constantize... | ruby | {
"resource": ""
} |
q18274 | PagSeguro.AuthorizationRequest.create | train | def create
request = Request.post_xml('authorizations/request', api_version, credentials, xml) | ruby | {
"resource": ""
} |
q18275 | PagSeguro.Items.<< | train | def <<(item)
item = ensure_type(Item, item)
original_item = find_item(item)
if original_item
original_item.quantity | ruby | {
"resource": ""
} |
q18276 | PagSeguro.PaymentRequest.register | train | def register
request = if @receivers.empty?
Request.post('checkout', api_version, params)
else
Request.post_xml('checkouts', | ruby | {
"resource": ""
} |
q18277 | PagSeguro.TransactionRequest.create | train | def create
request = if receivers.empty?
Request.post('transactions', api_version, params)
| ruby | {
"resource": ""
} |
q18278 | PagSeguro.Request.get | train | def get(path, api_version, data = {}, headers = {})
execute | ruby | {
"resource": ""
} |
q18279 | PagSeguro.Request.post | train | def post(path, api_version, data = {}, headers = {})
execute | ruby | {
"resource": ""
} |
q18280 | PagSeguro.Request.post_xml | train | def post_xml(path, api_version, credentials, data = '', options={})
credentials_params = credentials_to_params(credentials)
url_path = [api_version, path].reject(&:nil?).join('/')
request.post do
url | ruby | {
"resource": ""
} |
q18281 | PagSeguro.Request.put_xml | train | def put_xml(path, credentials, data)
full_url = PagSeguro.api_url("#{path}?#{credentials_to_params(credentials)}")
request.put do
url full_url
headers "Content-Type" => "application/xml; charset=#{PagSeguro.encoding}",
| ruby | {
"resource": ""
} |
q18282 | PagSeguro.Request.execute | train | def execute(request_method, path, api_version, data, headers) # :nodoc:
request.public_send(
request_method,
| ruby | {
"resource": ""
} |
q18283 | PagSeguro.PaymentReleases.include? | train | def include?(payment)
self.find do |included_payment|
| ruby | {
"resource": ""
} |
q18284 | PagSeguro.SubscriptionDiscount.create | train | def create
request = Request.put_xml("pre-approvals/#{code}/discount", credentials, xml_params)
| ruby | {
"resource": ""
} |
q18285 | GiphyClient.DefaultApi.gifs_categories_category_get | train | def gifs_categories_category_get(api_key, category, opts = {})
data, _status_code, _headers = | ruby | {
"resource": ""
} |
q18286 | GiphyClient.DefaultApi.gifs_categories_get | train | def gifs_categories_get(api_key, opts = {})
data, _status_code, _headers = | ruby | {
"resource": ""
} |
q18287 | GiphyClient.DefaultApi.gifs_get | train | def gifs_get(api_key, ids, opts = {})
data, _status_code, _headers = | ruby | {
"resource": ""
} |
q18288 | GiphyClient.DefaultApi.gifs_gif_id_get | train | def gifs_gif_id_get(api_key, gif_id, opts = {})
data, _status_code, _headers = | ruby | {
"resource": ""
} |
q18289 | GiphyClient.DefaultApi.gifs_random_get | train | def gifs_random_get(api_key, opts = {})
data, _status_code, _headers = | ruby | {
"resource": ""
} |
q18290 | GiphyClient.DefaultApi.gifs_search_get | train | def gifs_search_get(api_key, q, opts = {})
data, _status_code, _headers = | ruby | {
"resource": ""
} |
q18291 | GiphyClient.DefaultApi.gifs_translate_get | train | def gifs_translate_get(api_key, s, opts = {})
data, _status_code, _headers = | ruby | {
"resource": ""
} |
q18292 | GiphyClient.DefaultApi.stickers_random_get | train | def stickers_random_get(api_key, opts = {})
data, _status_code, _headers = | ruby | {
"resource": ""
} |
q18293 | GiphyClient.DefaultApi.stickers_search_get | train | def stickers_search_get(api_key, q, opts = {})
data, _status_code, _headers = | ruby | {
"resource": ""
} |
q18294 | GiphyClient.DefaultApi.stickers_translate_get | train | def stickers_translate_get(api_key, s, opts = {})
data, _status_code, _headers = | ruby | {
"resource": ""
} |
q18295 | Jekyll.Filters.date_to_html_string | train | def date_to_html_string(date)
result = '<span class="month">' + date.strftime('%b').upcase + '</span> '
result += date.strftime('<span class="day">%d</span> ')
| ruby | {
"resource": ""
} |
q18296 | Jekyll.Site.write_category_index | train | def write_category_index(category)
target_dir = GenerateCategories.category_dir(self.config['category_dir'], category)
index = CategoryIndex.new(self, self.source, target_dir, category)
if index.render?
index.render(self.layouts, site_payload)
index.write(self.dest)
# Reco... | ruby | {
"resource": ""
} |
q18297 | Jekyll.Site.write_category_indexes | train | def write_category_indexes
if self.layouts.key? 'category_index'
self.categories.keys.each do |category|
self.write_category_index(category)
end
| ruby | {
"resource": ""
} |
q18298 | Invitation.UserRegistration.process_invite_token | train | def process_invite_token(new_user = nil)
new_user = user_instance_variable if new_user.nil? | ruby | {
"resource": ""
} |
q18299 | Invitation.Invitable.invitable | train | def invitable(options = {})
has_many :invites, as: :invitable
class_attribute :invitable_options
self.invitable_options = {}
case
when options[:named_by] then invitable_options[:named_by] = options[:named_by]
when options[:named] then invitable_options[:named] = options[:named]
| 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.