repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
nsi-iff/nsisam-ruby | lib/nsisam/client.rb | NSISam.Client.delete | def delete(key)
request_data = {:key => key}.to_json
request = prepare_request :DELETE, request_data
Response.new(execute_request(request))
end | ruby | def delete(key)
request_data = {:key => key}.to_json
request = prepare_request :DELETE, request_data
Response.new(execute_request(request))
end | [
"def",
"delete",
"(",
"key",
")",
"request_data",
"=",
"{",
":key",
"=>",
"key",
"}",
".",
"to_json",
"request",
"=",
"prepare_request",
":DELETE",
",",
"request_data",
"Response",
".",
"new",
"(",
"execute_request",
"(",
"request",
")",
")",
"end"
] | Delete data at a given SAM key
@param [Sring] key of the value to delete
@return [Hash] response
* "deleted" [Boolean] true if the key was successfully deleted
@raise [NSISam::Errors::Client::KeyNotFoundError] when the key doesn't exists
@raise [NSISam::Errors::Client::AuthenticationError] when user and passwo... | [
"Delete",
"data",
"at",
"a",
"given",
"SAM",
"key"
] | 344725ba119899f4ac5b869d31f555a2e365cadb | https://github.com/nsi-iff/nsisam-ruby/blob/344725ba119899f4ac5b869d31f555a2e365cadb/lib/nsisam/client.rb#L76-L80 | train |
nsi-iff/nsisam-ruby | lib/nsisam/client.rb | NSISam.Client.get | def get(key, expected_checksum=nil)
request_data = {:key => key}.to_json
request = prepare_request :GET, request_data
response = execute_request(request)
verify_checksum(response["data"], expected_checksum) unless expected_checksum.nil?
Response.new(response)
end | ruby | def get(key, expected_checksum=nil)
request_data = {:key => key}.to_json
request = prepare_request :GET, request_data
response = execute_request(request)
verify_checksum(response["data"], expected_checksum) unless expected_checksum.nil?
Response.new(response)
end | [
"def",
"get",
"(",
"key",
",",
"expected_checksum",
"=",
"nil",
")",
"request_data",
"=",
"{",
":key",
"=>",
"key",
"}",
".",
"to_json",
"request",
"=",
"prepare_request",
":GET",
",",
"request_data",
"response",
"=",
"execute_request",
"(",
"request",
")",
... | Recover data stored at a given SAM key
@param [String] key of the value to acess
@return [Response] response object holding the file and some metadata
@raise [NSISam::Errors::Client::KeyNotFoundError] when the key doesn't exists
@raise [NSISam::Errors::Client::AuthenticationError] when user and password doesn't m... | [
"Recover",
"data",
"stored",
"at",
"a",
"given",
"SAM",
"key"
] | 344725ba119899f4ac5b869d31f555a2e365cadb | https://github.com/nsi-iff/nsisam-ruby/blob/344725ba119899f4ac5b869d31f555a2e365cadb/lib/nsisam/client.rb#L92-L98 | train |
nsi-iff/nsisam-ruby | lib/nsisam/client.rb | NSISam.Client.get_file | def get_file(key, type=:file, expected_checksum = nil)
response = get(key, expected_checksum)
response = Response.new(
'key' => response.key,
'checksum' => response.checksum,
'filename' => response.data['filename'],
'file' => Base64.decode64(response.data[type.to_s]),
... | ruby | def get_file(key, type=:file, expected_checksum = nil)
response = get(key, expected_checksum)
response = Response.new(
'key' => response.key,
'checksum' => response.checksum,
'filename' => response.data['filename'],
'file' => Base64.decode64(response.data[type.to_s]),
... | [
"def",
"get_file",
"(",
"key",
",",
"type",
"=",
":file",
",",
"expected_checksum",
"=",
"nil",
")",
"response",
"=",
"get",
"(",
"key",
",",
"expected_checksum",
")",
"response",
"=",
"Response",
".",
"new",
"(",
"'key'",
"=>",
"response",
".",
"key",
... | Recover a file stored at a given SAM key
@param [String] key of the file to access
@param [Symbol] type of the file to be recovered. Can be either :doc and :video.
@return [Response] response object holding the file and some metadata
@raise [NSISam::Errors::Client::KeyNotFoundError] when the key doesn't exists
@... | [
"Recover",
"a",
"file",
"stored",
"at",
"a",
"given",
"SAM",
"key"
] | 344725ba119899f4ac5b869d31f555a2e365cadb | https://github.com/nsi-iff/nsisam-ruby/blob/344725ba119899f4ac5b869d31f555a2e365cadb/lib/nsisam/client.rb#L115-L123 | train |
nsi-iff/nsisam-ruby | lib/nsisam/client.rb | NSISam.Client.update | def update(key, value)
request_data = {:key => key, :value => value}
request_data[:expire] = @expire if @expire
request = prepare_request :PUT, request_data.to_json
Response.new(execute_request(request))
end | ruby | def update(key, value)
request_data = {:key => key, :value => value}
request_data[:expire] = @expire if @expire
request = prepare_request :PUT, request_data.to_json
Response.new(execute_request(request))
end | [
"def",
"update",
"(",
"key",
",",
"value",
")",
"request_data",
"=",
"{",
":key",
"=>",
"key",
",",
":value",
"=>",
"value",
"}",
"request_data",
"[",
":expire",
"]",
"=",
"@expire",
"if",
"@expire",
"request",
"=",
"prepare_request",
":PUT",
",",
"reque... | Update data stored at a given SAM key
@param [String] key of the data to update
@param [String, Hash, Array] data to be stored at the key
@return [Response] response object holding the file and some metadata
@raise [NSISam::Errors::Client::KeyNotFoundError] when the key doesn't exists
@raise [NSISam::Errors::Cli... | [
"Update",
"data",
"stored",
"at",
"a",
"given",
"SAM",
"key"
] | 344725ba119899f4ac5b869d31f555a2e365cadb | https://github.com/nsi-iff/nsisam-ruby/blob/344725ba119899f4ac5b869d31f555a2e365cadb/lib/nsisam/client.rb#L136-L141 | train |
nsi-iff/nsisam-ruby | lib/nsisam/client.rb | NSISam.Client.update_file | def update_file(key, type=:file, new_content, filename)
encoded = Base64.encode64(new_content)
update(key, type => encoded, filename: filename)
end | ruby | def update_file(key, type=:file, new_content, filename)
encoded = Base64.encode64(new_content)
update(key, type => encoded, filename: filename)
end | [
"def",
"update_file",
"(",
"key",
",",
"type",
"=",
":file",
",",
"new_content",
",",
"filename",
")",
"encoded",
"=",
"Base64",
".",
"encode64",
"(",
"new_content",
")",
"update",
"(",
"key",
",",
"type",
"=>",
"encoded",
",",
"filename",
":",
"filename... | Update file stored at a given SAM key
@param [String] key of the file to update
@param [Symbol] type of the file to be recovered. Can be either :doc and :video.
@param [String] new_content content of the new file
@return [Response] response object holding the file and some metadata
@raise [NSISam::Errors::Client... | [
"Update",
"file",
"stored",
"at",
"a",
"given",
"SAM",
"key"
] | 344725ba119899f4ac5b869d31f555a2e365cadb | https://github.com/nsi-iff/nsisam-ruby/blob/344725ba119899f4ac5b869d31f555a2e365cadb/lib/nsisam/client.rb#L157-L160 | train |
finn-francis/ruby-edit | lib/ruby_edit/cli.rb | RubyEdit.CLI.configure | def configure(*)
if options[:help]
invoke :help, ['configure']
else
require_relative 'commands/configure'
RubyEdit::Commands::Configure.new(options).execute
end
end | ruby | def configure(*)
if options[:help]
invoke :help, ['configure']
else
require_relative 'commands/configure'
RubyEdit::Commands::Configure.new(options).execute
end
end | [
"def",
"configure",
"(",
"*",
")",
"if",
"options",
"[",
":help",
"]",
"invoke",
":help",
",",
"[",
"'configure'",
"]",
"else",
"require_relative",
"'commands/configure'",
"RubyEdit",
"::",
"Commands",
"::",
"Configure",
".",
"new",
"(",
"options",
")",
".",... | Set and view configuration options
# editor [-e --editor]
ruby-edit configure --editor
=> vim
ruby-edit configure --editor emacs
=> emacs
# grep options [-o --grep_options]
ruby-edit configure --grep_options
=> irn
ruby-edit configure --grep_options h
=> Hn | [
"Set",
"and",
"view",
"configuration",
"options"
] | 90022f4de01b420f5321f12c490566d0a1e19a29 | https://github.com/finn-francis/ruby-edit/blob/90022f4de01b420f5321f12c490566d0a1e19a29/lib/ruby_edit/cli.rb#L44-L51 | train |
redding/dassets | lib/dassets/server.rb | Dassets.Server.call! | def call!(env)
if (request = Request.new(env)).for_asset_file?
Response.new(env, request.asset_file).to_rack
else
@app.call(env)
end
end | ruby | def call!(env)
if (request = Request.new(env)).for_asset_file?
Response.new(env, request.asset_file).to_rack
else
@app.call(env)
end
end | [
"def",
"call!",
"(",
"env",
")",
"if",
"(",
"request",
"=",
"Request",
".",
"new",
"(",
"env",
")",
")",
".",
"for_asset_file?",
"Response",
".",
"new",
"(",
"env",
",",
"request",
".",
"asset_file",
")",
".",
"to_rack",
"else",
"@app",
".",
"call",
... | The real Rack call interface.
if an asset file is being requested, this is an endpoint - otherwise, call
on up to the app as normal | [
"The",
"real",
"Rack",
"call",
"interface",
".",
"if",
"an",
"asset",
"file",
"is",
"being",
"requested",
"this",
"is",
"an",
"endpoint",
"-",
"otherwise",
"call",
"on",
"up",
"to",
"the",
"app",
"as",
"normal"
] | d63ea7c6200057c932079493df26c647fdac8957 | https://github.com/redding/dassets/blob/d63ea7c6200057c932079493df26c647fdac8957/lib/dassets/server.rb#L28-L34 | train |
medcat/brandish | lib/brandish/path_set.rb | Brandish.PathSet.find_all | def find_all(short, options = {})
return to_enum(:find_all, short, options) unless block_given?
short = ::Pathname.new(short)
options = DEFAULT_FIND_OPTIONS.merge(options)
@paths.reverse.each do |path|
joined = path_join(path, short, options)
yield joined if (options[:file] && j... | ruby | def find_all(short, options = {})
return to_enum(:find_all, short, options) unless block_given?
short = ::Pathname.new(short)
options = DEFAULT_FIND_OPTIONS.merge(options)
@paths.reverse.each do |path|
joined = path_join(path, short, options)
yield joined if (options[:file] && j... | [
"def",
"find_all",
"(",
"short",
",",
"options",
"=",
"{",
"}",
")",
"return",
"to_enum",
"(",
":find_all",
",",
"short",
",",
"options",
")",
"unless",
"block_given?",
"short",
"=",
"::",
"Pathname",
".",
"new",
"(",
"short",
")",
"options",
"=",
"DEF... | Finds all versions of the short path name in the paths in the path
sets. If no block is given, it returns an enumerable; otherwise, if
a block is given, it yields the joined path if it exists.
@raise NoFileError If no file could be found.
@param short [::String, ::Pathname] The "short" path to resolve.
@param op... | [
"Finds",
"all",
"versions",
"of",
"the",
"short",
"path",
"name",
"in",
"the",
"paths",
"in",
"the",
"path",
"sets",
".",
"If",
"no",
"block",
"is",
"given",
"it",
"returns",
"an",
"enumerable",
";",
"otherwise",
"if",
"a",
"block",
"is",
"given",
"it"... | c63f91dbb356aa0958351ad9bcbdab0c57e7f649 | https://github.com/medcat/brandish/blob/c63f91dbb356aa0958351ad9bcbdab0c57e7f649/lib/brandish/path_set.rb#L142-L153 | train |
rixth/tay | lib/tay/builder.rb | Tay.Builder.get_compiled_file_content | def get_compiled_file_content(path)
begin
Tilt.new(path.to_s).render({}, {
:spec => spec
})
rescue RuntimeError
File.read(path)
end
end | ruby | def get_compiled_file_content(path)
begin
Tilt.new(path.to_s).render({}, {
:spec => spec
})
rescue RuntimeError
File.read(path)
end
end | [
"def",
"get_compiled_file_content",
"(",
"path",
")",
"begin",
"Tilt",
".",
"new",
"(",
"path",
".",
"to_s",
")",
".",
"render",
"(",
"{",
"}",
",",
"{",
":spec",
"=>",
"spec",
"}",
")",
"rescue",
"RuntimeError",
"File",
".",
"read",
"(",
"path",
")"... | Given a path, run it through tilt and return the compiled version.
If there's no known engine for it, just return the content verbatim.
If we know the type buy are missing the gem, raise an exception. | [
"Given",
"a",
"path",
"run",
"it",
"through",
"tilt",
"and",
"return",
"the",
"compiled",
"version",
".",
"If",
"there",
"s",
"no",
"known",
"engine",
"for",
"it",
"just",
"return",
"the",
"content",
"verbatim",
".",
"If",
"we",
"know",
"the",
"type",
... | 60a5d64aa54e7ef13d10d9c8fb7825e2febea8e5 | https://github.com/rixth/tay/blob/60a5d64aa54e7ef13d10d9c8fb7825e2febea8e5/lib/tay/builder.rb#L56-L64 | train |
rixth/tay | lib/tay/builder.rb | Tay.Builder.simple_compile_directory | def simple_compile_directory(directory)
if directory.is_a?(String)
# If we just have a single dirname, assume it's under src
from_directory = (directory[/\//] ? '' : 'src/') + directory
directory = {
:from => from_directory,
:as => directory
}
end
... | ruby | def simple_compile_directory(directory)
if directory.is_a?(String)
# If we just have a single dirname, assume it's under src
from_directory = (directory[/\//] ? '' : 'src/') + directory
directory = {
:from => from_directory,
:as => directory
}
end
... | [
"def",
"simple_compile_directory",
"(",
"directory",
")",
"if",
"directory",
".",
"is_a?",
"(",
"String",
")",
"# If we just have a single dirname, assume it's under src",
"from_directory",
"=",
"(",
"directory",
"[",
"/",
"\\/",
"/",
"]",
"?",
"''",
":",
"'src/'",
... | Copy all the files from a directory to the output, compiling
them if they are familiar to us. Does not do any sprocketing. | [
"Copy",
"all",
"the",
"files",
"from",
"a",
"directory",
"to",
"the",
"output",
"compiling",
"them",
"if",
"they",
"are",
"familiar",
"to",
"us",
".",
"Does",
"not",
"do",
"any",
"sprocketing",
"."
] | 60a5d64aa54e7ef13d10d9c8fb7825e2febea8e5 | https://github.com/rixth/tay/blob/60a5d64aa54e7ef13d10d9c8fb7825e2febea8e5/lib/tay/builder.rb#L75-L107 | train |
rixth/tay | lib/tay/builder.rb | Tay.Builder.compile_files | def compile_files(files)
files.each do |base_path|
# We do this second glob in case the path provided in the tayfile
# references a compiled version
Dir[@base_dir.join('src', base_path + '*')].each do |path|
path = Pathname.new(path).relative_path_from(@base_dir.join('src'))
... | ruby | def compile_files(files)
files.each do |base_path|
# We do this second glob in case the path provided in the tayfile
# references a compiled version
Dir[@base_dir.join('src', base_path + '*')].each do |path|
path = Pathname.new(path).relative_path_from(@base_dir.join('src'))
... | [
"def",
"compile_files",
"(",
"files",
")",
"files",
".",
"each",
"do",
"|",
"base_path",
"|",
"# We do this second glob in case the path provided in the tayfile",
"# references a compiled version",
"Dir",
"[",
"@base_dir",
".",
"join",
"(",
"'src'",
",",
"base_path",
"+... | Process all the files in the directory through sprockets before writing
them to the output directory | [
"Process",
"all",
"the",
"files",
"in",
"the",
"directory",
"through",
"sprockets",
"before",
"writing",
"them",
"to",
"the",
"output",
"directory"
] | 60a5d64aa54e7ef13d10d9c8fb7825e2febea8e5 | https://github.com/rixth/tay/blob/60a5d64aa54e7ef13d10d9c8fb7825e2febea8e5/lib/tay/builder.rb#L112-L133 | train |
rixth/tay | lib/tay/builder.rb | Tay.Builder.write_manifest | def write_manifest
generator = ManifestGenerator.new(spec)
File.open(@output_dir.join('manifest.json'), 'w') do |f|
f.write JSON.pretty_generate(generator.spec_as_json)
end
end | ruby | def write_manifest
generator = ManifestGenerator.new(spec)
File.open(@output_dir.join('manifest.json'), 'w') do |f|
f.write JSON.pretty_generate(generator.spec_as_json)
end
end | [
"def",
"write_manifest",
"generator",
"=",
"ManifestGenerator",
".",
"new",
"(",
"spec",
")",
"File",
".",
"open",
"(",
"@output_dir",
".",
"join",
"(",
"'manifest.json'",
")",
",",
"'w'",
")",
"do",
"|",
"f",
"|",
"f",
".",
"write",
"JSON",
".",
"pret... | Generate the manifest from the spec and write it to disk | [
"Generate",
"the",
"manifest",
"from",
"the",
"spec",
"and",
"write",
"it",
"to",
"disk"
] | 60a5d64aa54e7ef13d10d9c8fb7825e2febea8e5 | https://github.com/rixth/tay/blob/60a5d64aa54e7ef13d10d9c8fb7825e2febea8e5/lib/tay/builder.rb#L137-L143 | train |
rixth/tay | lib/tay/builder.rb | Tay.Builder.create_sprockets_environment | def create_sprockets_environment
@sprockets = Sprockets::Environment.new
@sprockets.append_path(@base_dir.join('src/javascripts').to_s)
@sprockets.append_path(@base_dir.join('src/templates').to_s)
@sprockets.append_path(@base_dir.join('src/stylesheets').to_s)
@sprockets.append_path(@base_d... | ruby | def create_sprockets_environment
@sprockets = Sprockets::Environment.new
@sprockets.append_path(@base_dir.join('src/javascripts').to_s)
@sprockets.append_path(@base_dir.join('src/templates').to_s)
@sprockets.append_path(@base_dir.join('src/stylesheets').to_s)
@sprockets.append_path(@base_d... | [
"def",
"create_sprockets_environment",
"@sprockets",
"=",
"Sprockets",
"::",
"Environment",
".",
"new",
"@sprockets",
".",
"append_path",
"(",
"@base_dir",
".",
"join",
"(",
"'src/javascripts'",
")",
".",
"to_s",
")",
"@sprockets",
".",
"append_path",
"(",
"@base_... | Set up the sprockets environment for munging all the things | [
"Set",
"up",
"the",
"sprockets",
"environment",
"for",
"munging",
"all",
"the",
"things"
] | 60a5d64aa54e7ef13d10d9c8fb7825e2febea8e5 | https://github.com/rixth/tay/blob/60a5d64aa54e7ef13d10d9c8fb7825e2febea8e5/lib/tay/builder.rb#L147-L154 | train |
jrobertson/xmpp-agent | lib/xmpp4r-simple.rb | Jabber.Simple.deliver | def deliver(jid, message, type=:chat)
contacts(jid) do |friend|
unless subscribed_to? friend
add(friend.jid)
return deliver_deferred(friend.jid, message, type)
end
if message.kind_of?(Jabber::Message)
msg = message
msg.to = friend.jid
else
... | ruby | def deliver(jid, message, type=:chat)
contacts(jid) do |friend|
unless subscribed_to? friend
add(friend.jid)
return deliver_deferred(friend.jid, message, type)
end
if message.kind_of?(Jabber::Message)
msg = message
msg.to = friend.jid
else
... | [
"def",
"deliver",
"(",
"jid",
",",
"message",
",",
"type",
"=",
":chat",
")",
"contacts",
"(",
"jid",
")",
"do",
"|",
"friend",
"|",
"unless",
"subscribed_to?",
"friend",
"add",
"(",
"friend",
".",
"jid",
")",
"return",
"deliver_deferred",
"(",
"friend",... | Send a message to jabber user jid.
Valid message types are:
* :normal (default): a normal message.
* :chat: a one-to-one chat message.
* :groupchat: a group-chat message.
* :headline: a "headline" message.
* :error: an error message.
If the recipient is not in your contacts list, the message will be... | [
"Send",
"a",
"message",
"to",
"jabber",
"user",
"jid",
"."
] | 9078fa8e05d6c580d082a1cecb6f5ffd9157e12f | https://github.com/jrobertson/xmpp-agent/blob/9078fa8e05d6c580d082a1cecb6f5ffd9157e12f/lib/xmpp4r-simple.rb#L114-L130 | train |
jrobertson/xmpp-agent | lib/xmpp4r-simple.rb | Jabber.Simple.status | def status(presence, message)
@presence = presence
@status_message = message
stat_msg = Presence.new(@presence, @status_message)
send!(stat_msg)
end | ruby | def status(presence, message)
@presence = presence
@status_message = message
stat_msg = Presence.new(@presence, @status_message)
send!(stat_msg)
end | [
"def",
"status",
"(",
"presence",
",",
"message",
")",
"@presence",
"=",
"presence",
"@status_message",
"=",
"message",
"stat_msg",
"=",
"Presence",
".",
"new",
"(",
"@presence",
",",
"@status_message",
")",
"send!",
"(",
"stat_msg",
")",
"end"
] | Set your presence, with a message.
Available values for presence are:
* nil: online.
* :chat: free for chat.
* :away: away from the computer.
* :dnd: do not disturb.
* :xa: extended away.
It's not possible to set an offline status - to do that, disconnect! :-) | [
"Set",
"your",
"presence",
"with",
"a",
"message",
"."
] | 9078fa8e05d6c580d082a1cecb6f5ffd9157e12f | https://github.com/jrobertson/xmpp-agent/blob/9078fa8e05d6c580d082a1cecb6f5ffd9157e12f/lib/xmpp4r-simple.rb#L143-L148 | train |
jrobertson/xmpp-agent | lib/xmpp4r-simple.rb | Jabber.Simple.send! | def send!(msg)
attempts = 0
begin
attempts += 1
client.send(msg)
rescue Errno::EPIPE, IOError => e
sleep 1
disconnect
reconnect
retry unless attempts > 3
raise e
rescue Errno::ECONNRESET => e
sleep (attempts^2) * 60 + 60
dis... | ruby | def send!(msg)
attempts = 0
begin
attempts += 1
client.send(msg)
rescue Errno::EPIPE, IOError => e
sleep 1
disconnect
reconnect
retry unless attempts > 3
raise e
rescue Errno::ECONNRESET => e
sleep (attempts^2) * 60 + 60
dis... | [
"def",
"send!",
"(",
"msg",
")",
"attempts",
"=",
"0",
"begin",
"attempts",
"+=",
"1",
"client",
".",
"send",
"(",
"msg",
")",
"rescue",
"Errno",
"::",
"EPIPE",
",",
"IOError",
"=>",
"e",
"sleep",
"1",
"disconnect",
"reconnect",
"retry",
"unless",
"att... | Send a Jabber stanza over-the-wire. | [
"Send",
"a",
"Jabber",
"stanza",
"over",
"-",
"the",
"-",
"wire",
"."
] | 9078fa8e05d6c580d082a1cecb6f5ffd9157e12f | https://github.com/jrobertson/xmpp-agent/blob/9078fa8e05d6c580d082a1cecb6f5ffd9157e12f/lib/xmpp4r-simple.rb#L327-L345 | train |
jrobertson/xmpp-agent | lib/xmpp4r-simple.rb | Jabber.Simple.deliver_deferred | def deliver_deferred(jid, message, type)
msg = {:to => jid, :message => message, :type => type}
queue(:pending_messages) << [msg]
end | ruby | def deliver_deferred(jid, message, type)
msg = {:to => jid, :message => message, :type => type}
queue(:pending_messages) << [msg]
end | [
"def",
"deliver_deferred",
"(",
"jid",
",",
"message",
",",
"type",
")",
"msg",
"=",
"{",
":to",
"=>",
"jid",
",",
":message",
"=>",
"message",
",",
":type",
"=>",
"type",
"}",
"queue",
"(",
":pending_messages",
")",
"<<",
"[",
"msg",
"]",
"end"
] | Queue messages for delivery once a user has accepted our authorization
request. Works in conjunction with the deferred delivery thread.
You can use this method if you want to manually add friends and still
have the message queued for later delivery. | [
"Queue",
"messages",
"for",
"delivery",
"once",
"a",
"user",
"has",
"accepted",
"our",
"authorization",
"request",
".",
"Works",
"in",
"conjunction",
"with",
"the",
"deferred",
"delivery",
"thread",
"."
] | 9078fa8e05d6c580d082a1cecb6f5ffd9157e12f | https://github.com/jrobertson/xmpp-agent/blob/9078fa8e05d6c580d082a1cecb6f5ffd9157e12f/lib/xmpp4r-simple.rb#L364-L367 | train |
jrobertson/xmpp-agent | lib/xmpp4r-simple.rb | Jabber.Simple.start_deferred_delivery_thread | def start_deferred_delivery_thread #:nodoc:
Thread.new {
loop {
messages = [queue(:pending_messages).pop].flatten
messages.each do |message|
if subscribed_to?(message[:to])
deliver(message[:to], message[:message], message[:type])
else
... | ruby | def start_deferred_delivery_thread #:nodoc:
Thread.new {
loop {
messages = [queue(:pending_messages).pop].flatten
messages.each do |message|
if subscribed_to?(message[:to])
deliver(message[:to], message[:message], message[:type])
else
... | [
"def",
"start_deferred_delivery_thread",
"#:nodoc:",
"Thread",
".",
"new",
"{",
"loop",
"{",
"messages",
"=",
"[",
"queue",
"(",
":pending_messages",
")",
".",
"pop",
"]",
".",
"flatten",
"messages",
".",
"each",
"do",
"|",
"message",
"|",
"if",
"subscribed_... | This thread facilitates the delivery of messages to users who haven't yet
accepted an invitation from us. When we attempt to deliver a message, if
the user hasn't subscribed, we place the message in a queue for later
delivery. Once a user has accepted our authorization request, we deliver
any messages that have bee... | [
"This",
"thread",
"facilitates",
"the",
"delivery",
"of",
"messages",
"to",
"users",
"who",
"haven",
"t",
"yet",
"accepted",
"an",
"invitation",
"from",
"us",
".",
"When",
"we",
"attempt",
"to",
"deliver",
"a",
"message",
"if",
"the",
"user",
"hasn",
"t",
... | 9078fa8e05d6c580d082a1cecb6f5ffd9157e12f | https://github.com/jrobertson/xmpp-agent/blob/9078fa8e05d6c580d082a1cecb6f5ffd9157e12f/lib/xmpp4r-simple.rb#L461-L474 | train |
fenton-project/fenton_shell | lib/fenton_shell/key.rb | FentonShell.Key.create | def create(options)
status, body = key_create(options)
if status
save_message('Key': ['created!'])
true
else
save_message(body)
false
end
end | ruby | def create(options)
status, body = key_create(options)
if status
save_message('Key': ['created!'])
true
else
save_message(body)
false
end
end | [
"def",
"create",
"(",
"options",
")",
"status",
",",
"body",
"=",
"key_create",
"(",
"options",
")",
"if",
"status",
"save_message",
"(",
"'Key'",
":",
"[",
"'created!'",
"]",
")",
"true",
"else",
"save_message",
"(",
"body",
")",
"false",
"end",
"end"
] | Creates a new key on the local client
@param options [Hash] fields to send to ssh key pair generation
@return [String] success or failure message | [
"Creates",
"a",
"new",
"key",
"on",
"the",
"local",
"client"
] | 6e1d76186fa7ee7a3be141afad9361e3a3e0ec91 | https://github.com/fenton-project/fenton_shell/blob/6e1d76186fa7ee7a3be141afad9361e3a3e0ec91/lib/fenton_shell/key.rb#L13-L23 | train |
fenton-project/fenton_shell | lib/fenton_shell/key.rb | FentonShell.Key.key_create | def key_create(options)
ssh_key = key_generation(options)
ssh_private_key_file = options[:private_key]
ssh_public_key_file = "#{ssh_private_key_file}.pub"
# TODO: - add to .fenton/config file
File.write(ssh_private_key_file, ssh_key.private_key)
File.chmod(0o600, ssh_private_key_fil... | ruby | def key_create(options)
ssh_key = key_generation(options)
ssh_private_key_file = options[:private_key]
ssh_public_key_file = "#{ssh_private_key_file}.pub"
# TODO: - add to .fenton/config file
File.write(ssh_private_key_file, ssh_key.private_key)
File.chmod(0o600, ssh_private_key_fil... | [
"def",
"key_create",
"(",
"options",
")",
"ssh_key",
"=",
"key_generation",
"(",
"options",
")",
"ssh_private_key_file",
"=",
"options",
"[",
":private_key",
"]",
"ssh_public_key_file",
"=",
"\"#{ssh_private_key_file}.pub\"",
"# TODO: - add to .fenton/config file",
"File",
... | Sends a post request with json from the command line key
@param options [Hash] fields from fenton command line
@return [Object] true or false
@return [String] message on success or failure | [
"Sends",
"a",
"post",
"request",
"with",
"json",
"from",
"the",
"command",
"line",
"key"
] | 6e1d76186fa7ee7a3be141afad9361e3a3e0ec91 | https://github.com/fenton-project/fenton_shell/blob/6e1d76186fa7ee7a3be141afad9361e3a3e0ec91/lib/fenton_shell/key.rb#L32-L44 | train |
fenton-project/fenton_shell | lib/fenton_shell/key.rb | FentonShell.Key.key_generation | def key_generation(options)
SSHKey.generate(
type: options[:type],
bits: options[:bits],
comment: 'ssh@fenton_shell',
passphrase: options[:passphrase]
)
end | ruby | def key_generation(options)
SSHKey.generate(
type: options[:type],
bits: options[:bits],
comment: 'ssh@fenton_shell',
passphrase: options[:passphrase]
)
end | [
"def",
"key_generation",
"(",
"options",
")",
"SSHKey",
".",
"generate",
"(",
"type",
":",
"options",
"[",
":type",
"]",
",",
"bits",
":",
"options",
"[",
":bits",
"]",
",",
"comment",
":",
"'ssh@fenton_shell'",
",",
"passphrase",
":",
"options",
"[",
":... | Generates the SSH key pair
@param options [Hash] fields from fenton command line
@return [String] ssh key pair object created from the options hash | [
"Generates",
"the",
"SSH",
"key",
"pair"
] | 6e1d76186fa7ee7a3be141afad9361e3a3e0ec91 | https://github.com/fenton-project/fenton_shell/blob/6e1d76186fa7ee7a3be141afad9361e3a3e0ec91/lib/fenton_shell/key.rb#L50-L57 | train |
conversation/raca | lib/raca/containers.rb | Raca.Containers.metadata | def metadata
log "retrieving containers metadata from #{storage_path}"
response = storage_client.head(storage_path)
{
:containers => response["X-Account-Container-Count"].to_i,
:objects => response["X-Account-Object-Count"].to_i,
:bytes => response["X-Account-Bytes-U... | ruby | def metadata
log "retrieving containers metadata from #{storage_path}"
response = storage_client.head(storage_path)
{
:containers => response["X-Account-Container-Count"].to_i,
:objects => response["X-Account-Object-Count"].to_i,
:bytes => response["X-Account-Bytes-U... | [
"def",
"metadata",
"log",
"\"retrieving containers metadata from #{storage_path}\"",
"response",
"=",
"storage_client",
".",
"head",
"(",
"storage_path",
")",
"{",
":containers",
"=>",
"response",
"[",
"\"X-Account-Container-Count\"",
"]",
".",
"to_i",
",",
":objects",
... | Return metadata on all containers | [
"Return",
"metadata",
"on",
"all",
"containers"
] | fa69dfde22359cc0e06f655055be4eadcc7019c0 | https://github.com/conversation/raca/blob/fa69dfde22359cc0e06f655055be4eadcc7019c0/lib/raca/containers.rb#L24-L32 | train |
celldee/ffi-rxs | lib/ffi-rxs/context.rb | XS.Context.setctxopt | def setctxopt name, value
length = 4
pointer = LibC.malloc length
pointer.write_int value
rc = LibXS.xs_setctxopt @context, name, pointer, length
LibC.free(pointer) unless pointer.nil? || pointer.null?
rc
end | ruby | def setctxopt name, value
length = 4
pointer = LibC.malloc length
pointer.write_int value
rc = LibXS.xs_setctxopt @context, name, pointer, length
LibC.free(pointer) unless pointer.nil? || pointer.null?
rc
end | [
"def",
"setctxopt",
"name",
",",
"value",
"length",
"=",
"4",
"pointer",
"=",
"LibC",
".",
"malloc",
"length",
"pointer",
".",
"write_int",
"value",
"rc",
"=",
"LibXS",
".",
"xs_setctxopt",
"@context",
",",
"name",
",",
"pointer",
",",
"length",
"LibC",
... | Initialize context object
Sets options on a context.
It is recommended to use the default for +io_threads+
(which is 1) since most programs will not saturate I/O.
The rule of thumb is to make io_threads equal to the number
of gigabits per second that the application will produce.
The io_threads number specifie... | [
"Initialize",
"context",
"object",
"Sets",
"options",
"on",
"a",
"context",
"."
] | 95378f3a5e5b5b3f1f726a9a1620f41ab4ee7f0e | https://github.com/celldee/ffi-rxs/blob/95378f3a5e5b5b3f1f726a9a1620f41ab4ee7f0e/lib/ffi-rxs/context.rb#L79-L87 | train |
celldee/ffi-rxs | lib/ffi-rxs/context.rb | XS.Context.socket | def socket type
sock = nil
begin
sock = Socket.new @context, type
rescue ContextError => e
sock = nil
end
sock
end | ruby | def socket type
sock = nil
begin
sock = Socket.new @context, type
rescue ContextError => e
sock = nil
end
sock
end | [
"def",
"socket",
"type",
"sock",
"=",
"nil",
"begin",
"sock",
"=",
"Socket",
".",
"new",
"@context",
",",
"type",
"rescue",
"ContextError",
"=>",
"e",
"sock",
"=",
"nil",
"end",
"sock",
"end"
] | Allocates a socket for context
@param [Constant] type
One of @XS::REQ@, @XS::REP@, @XS::PUB@, @XS::SUB@, @XS::PAIR@,
@XS::PULL@, @XS::PUSH@, @XS::DEALER@, or @XS::ROUTER@
@return [Socket] when the allocation succeeds
@return nil when call fails | [
"Allocates",
"a",
"socket",
"for",
"context"
] | 95378f3a5e5b5b3f1f726a9a1620f41ab4ee7f0e | https://github.com/celldee/ffi-rxs/blob/95378f3a5e5b5b3f1f726a9a1620f41ab4ee7f0e/lib/ffi-rxs/context.rb#L116-L125 | train |
parrish/attention | lib/attention/instance.rb | Attention.Instance.publish | def publish
publisher.publish('instance', added: info) do |redis|
redis.setex "instance_#{ @id }", Attention.options[:ttl], JSON.dump(info)
end
heartbeat
end | ruby | def publish
publisher.publish('instance', added: info) do |redis|
redis.setex "instance_#{ @id }", Attention.options[:ttl], JSON.dump(info)
end
heartbeat
end | [
"def",
"publish",
"publisher",
".",
"publish",
"(",
"'instance'",
",",
"added",
":",
"info",
")",
"do",
"|",
"redis",
"|",
"redis",
".",
"setex",
"\"instance_#{ @id }\"",
",",
"Attention",
".",
"options",
"[",
":ttl",
"]",
",",
"JSON",
".",
"dump",
"(",
... | Creates an Instance
@param ip [String] Optionally override the IP of the server
@param port [Fixnum, Numeric] Optionally specify the port of the server
Publishes this server and starts the {#heartbeat} | [
"Creates",
"an",
"Instance"
] | ff5bd780b946636ba0e22f66bae3fb41b9c4353d | https://github.com/parrish/attention/blob/ff5bd780b946636ba0e22f66bae3fb41b9c4353d/lib/attention/instance.rb#L42-L47 | train |
elight/coulda_web_steps | lib/coulda_web_steps.rb | Coulda.WebSteps.given_a | def given_a(factory_name, args = {})
Given "a #{factory_name} #{humanize args}" do
args.each do |key, value|
if value.is_a? Symbol
instance_var_named_value = instance_variable_get("@#{value}")
args[key] = instance_var_named_value if instance_var_named_value
end
... | ruby | def given_a(factory_name, args = {})
Given "a #{factory_name} #{humanize args}" do
args.each do |key, value|
if value.is_a? Symbol
instance_var_named_value = instance_variable_get("@#{value}")
args[key] = instance_var_named_value if instance_var_named_value
end
... | [
"def",
"given_a",
"(",
"factory_name",
",",
"args",
"=",
"{",
"}",
")",
"Given",
"\"a #{factory_name} #{humanize args}\"",
"do",
"args",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"if",
"value",
".",
"is_a?",
"Symbol",
"instance_var_named_value",
"=",
... | Creates an object using a factory_girl factory and creates a Given step that reads like
"Given a gi_joe with a name of 'Blowtorch' and habit of 'swearing'"
@param factory_name A Symbol or String for the name of the factory_girl factory to use
@param args Arguments to supply to the *factory_name* factory_girl factory | [
"Creates",
"an",
"object",
"using",
"a",
"factory_girl",
"factory",
"and",
"creates",
"a",
"Given",
"step",
"that",
"reads",
"like",
"Given",
"a",
"gi_joe",
"with",
"a",
"name",
"of",
"Blowtorch",
"and",
"habit",
"of",
"swearing"
] | 0926325a105983351d8865fbb40751e5f3fa3431 | https://github.com/elight/coulda_web_steps/blob/0926325a105983351d8865fbb40751e5f3fa3431/lib/coulda_web_steps.rb#L10-L21 | train |
octoai/gem-octocore-mongo | lib/octocore-mongo/models/enterprise.rb | Octo.Enterprise.setup_notification_categories | def setup_notification_categories
templates = Octo.get_config(:push_templates)
if templates
templates.each do |t|
args = {
enterprise_id: self._id,
category_type: t[:name],
template_text: t[:text],
active: true
}
Octo::Tem... | ruby | def setup_notification_categories
templates = Octo.get_config(:push_templates)
if templates
templates.each do |t|
args = {
enterprise_id: self._id,
category_type: t[:name],
template_text: t[:text],
active: true
}
Octo::Tem... | [
"def",
"setup_notification_categories",
"templates",
"=",
"Octo",
".",
"get_config",
"(",
":push_templates",
")",
"if",
"templates",
"templates",
".",
"each",
"do",
"|",
"t",
"|",
"args",
"=",
"{",
"enterprise_id",
":",
"self",
".",
"_id",
",",
"category_type"... | Setup the notification categories for the enterprise | [
"Setup",
"the",
"notification",
"categories",
"for",
"the",
"enterprise"
] | bf7fa833fd7e08947697d0341ab5e80e89c8d05a | https://github.com/octoai/gem-octocore-mongo/blob/bf7fa833fd7e08947697d0341ab5e80e89c8d05a/lib/octocore-mongo/models/enterprise.rb#L36-L50 | train |
octoai/gem-octocore-mongo | lib/octocore-mongo/models/enterprise.rb | Octo.Enterprise.setup_intelligent_segments | def setup_intelligent_segments
segments = Octo.get_config(:intelligent_segments)
if segments
segments.each do |seg|
args = {
enterprise_id: self._id,
name: seg[:name],
type: seg[:type].constantize,
dimensions: seg[:dimensions].collect(&:const... | ruby | def setup_intelligent_segments
segments = Octo.get_config(:intelligent_segments)
if segments
segments.each do |seg|
args = {
enterprise_id: self._id,
name: seg[:name],
type: seg[:type].constantize,
dimensions: seg[:dimensions].collect(&:const... | [
"def",
"setup_intelligent_segments",
"segments",
"=",
"Octo",
".",
"get_config",
"(",
":intelligent_segments",
")",
"if",
"segments",
"segments",
".",
"each",
"do",
"|",
"seg",
"|",
"args",
"=",
"{",
"enterprise_id",
":",
"self",
".",
"_id",
",",
"name",
":"... | Setup the intelligent segments for the enterprise | [
"Setup",
"the",
"intelligent",
"segments",
"for",
"the",
"enterprise"
] | bf7fa833fd7e08947697d0341ab5e80e89c8d05a | https://github.com/octoai/gem-octocore-mongo/blob/bf7fa833fd7e08947697d0341ab5e80e89c8d05a/lib/octocore-mongo/models/enterprise.rb#L53-L71 | train |
songgz/fast_ext | app/controllers/fast_ext/sessions_controller.rb | FastExt.SessionsController.forgot_password | def forgot_password
klass = params[:type] || 'FastExt::MPerson'
@user = klass.constantize.where(username:params[:username])
random_password = Array.new(10).map { (65 + rand(58)).chr }.join
@user.password = random_password
@user.save!
#Mailer.create_and_deliver_password_change(@user, ... | ruby | def forgot_password
klass = params[:type] || 'FastExt::MPerson'
@user = klass.constantize.where(username:params[:username])
random_password = Array.new(10).map { (65 + rand(58)).chr }.join
@user.password = random_password
@user.save!
#Mailer.create_and_deliver_password_change(@user, ... | [
"def",
"forgot_password",
"klass",
"=",
"params",
"[",
":type",
"]",
"||",
"'FastExt::MPerson'",
"@user",
"=",
"klass",
".",
"constantize",
".",
"where",
"(",
"username",
":",
"params",
"[",
":username",
"]",
")",
"random_password",
"=",
"Array",
".",
"new",... | assign them a random one and mail it to them, asking them to change it | [
"assign",
"them",
"a",
"random",
"one",
"and",
"mail",
"it",
"to",
"them",
"asking",
"them",
"to",
"change",
"it"
] | 05c6bee1c4f7f841ecf16359af2765751a818c2a | https://github.com/songgz/fast_ext/blob/05c6bee1c4f7f841ecf16359af2765751a818c2a/app/controllers/fast_ext/sessions_controller.rb#L36-L43 | train |
26fe/sem4r | spec/helpers/rspec_hash.rb | Sem4rSpecHelper.Hash.except | def except(*keys)
self.reject { |k,v| keys.include?(k || k.to_sym) }
end | ruby | def except(*keys)
self.reject { |k,v| keys.include?(k || k.to_sym) }
end | [
"def",
"except",
"(",
"*",
"keys",
")",
"self",
".",
"reject",
"{",
"|",
"k",
",",
"v",
"|",
"keys",
".",
"include?",
"(",
"k",
"||",
"k",
".",
"to_sym",
")",
"}",
"end"
] | Filter keys out of a Hash.
{ :a => 1, :b => 2, :c => 3 }.except(:a)
=> { :b => 2, :c => 3 } | [
"Filter",
"keys",
"out",
"of",
"a",
"Hash",
"."
] | 2326404f98b9c2833549fcfda078d39c9954a0fa | https://github.com/26fe/sem4r/blob/2326404f98b9c2833549fcfda078d39c9954a0fa/spec/helpers/rspec_hash.rb#L42-L44 | train |
26fe/sem4r | spec/helpers/rspec_hash.rb | Sem4rSpecHelper.Hash.only | def only(*keys)
self.reject { |k,v| !keys.include?(k || k.to_sym) }
end | ruby | def only(*keys)
self.reject { |k,v| !keys.include?(k || k.to_sym) }
end | [
"def",
"only",
"(",
"*",
"keys",
")",
"self",
".",
"reject",
"{",
"|",
"k",
",",
"v",
"|",
"!",
"keys",
".",
"include?",
"(",
"k",
"||",
"k",
".",
"to_sym",
")",
"}",
"end"
] | Returns a Hash with only the pairs identified by +keys+.
{ :a => 1, :b => 2, :c => 3 }.only(:a)
=> { :a => 1 } | [
"Returns",
"a",
"Hash",
"with",
"only",
"the",
"pairs",
"identified",
"by",
"+",
"keys",
"+",
"."
] | 2326404f98b9c2833549fcfda078d39c9954a0fa | https://github.com/26fe/sem4r/blob/2326404f98b9c2833549fcfda078d39c9954a0fa/spec/helpers/rspec_hash.rb#L62-L64 | train |
medcat/brandish | lib/brandish/configure.rb | Brandish.Configure.build | def build(which = :all)
return to_enum(:build, which) unless block_given?
select_forms(which).each { |f| yield proc { f.build(self) } }
end | ruby | def build(which = :all)
return to_enum(:build, which) unless block_given?
select_forms(which).each { |f| yield proc { f.build(self) } }
end | [
"def",
"build",
"(",
"which",
"=",
":all",
")",
"return",
"to_enum",
"(",
":build",
",",
"which",
")",
"unless",
"block_given?",
"select_forms",
"(",
"which",
")",
".",
"each",
"{",
"|",
"f",
"|",
"yield",
"proc",
"{",
"f",
".",
"build",
"(",
"self",... | Given a set of forms to build, it yields blocks that can be called to
build a form.
@param which [::Symbol, <::Symbol>] If this is `:all`, all of the forms
available are built; otherwise, it only builds the forms whose names
are listed.
@yield [build] Yields for each form that can be built.
@yieldparam build... | [
"Given",
"a",
"set",
"of",
"forms",
"to",
"build",
"it",
"yields",
"blocks",
"that",
"can",
"be",
"called",
"to",
"build",
"a",
"form",
"."
] | c63f91dbb356aa0958351ad9bcbdab0c57e7f649 | https://github.com/medcat/brandish/blob/c63f91dbb356aa0958351ad9bcbdab0c57e7f649/lib/brandish/configure.rb#L133-L136 | train |
medcat/brandish | lib/brandish/configure.rb | Brandish.Configure.roots | def roots
@_roots ||= ::Hash.new do |h, k|
h[k] = nil
h[k] = parse_from(k)
end
end | ruby | def roots
@_roots ||= ::Hash.new do |h, k|
h[k] = nil
h[k] = parse_from(k)
end
end | [
"def",
"roots",
"@_roots",
"||=",
"::",
"Hash",
".",
"new",
"do",
"|",
"h",
",",
"k",
"|",
"h",
"[",
"k",
"]",
"=",
"nil",
"h",
"[",
"k",
"]",
"=",
"parse_from",
"(",
"k",
")",
"end",
"end"
] | A cache for all of the root nodes. This is a regular hash; however, upon
attempt to access an item that isn't already in the hash, it first
parses the file at that item, and stores the result in the hash, returning
the root node in the file. This is to cache files so that they do not
get reparsed multiple times.
... | [
"A",
"cache",
"for",
"all",
"of",
"the",
"root",
"nodes",
".",
"This",
"is",
"a",
"regular",
"hash",
";",
"however",
"upon",
"attempt",
"to",
"access",
"an",
"item",
"that",
"isn",
"t",
"already",
"in",
"the",
"hash",
"it",
"first",
"parses",
"the",
... | c63f91dbb356aa0958351ad9bcbdab0c57e7f649 | https://github.com/medcat/brandish/blob/c63f91dbb356aa0958351ad9bcbdab0c57e7f649/lib/brandish/configure.rb#L163-L168 | train |
medcat/brandish | lib/brandish/configure.rb | Brandish.Configure.parse_from | def parse_from(path, short = path.relative_path_from(root))
contents = path.read
digest = Digest::SHA2.digest(contents)
cache.fetch(digest) do
scanner = Scanner.new(contents, short, options)
parser = Parser.new(scanner.call)
parser.call.tap { |r| cache[digest] = r }
end
... | ruby | def parse_from(path, short = path.relative_path_from(root))
contents = path.read
digest = Digest::SHA2.digest(contents)
cache.fetch(digest) do
scanner = Scanner.new(contents, short, options)
parser = Parser.new(scanner.call)
parser.call.tap { |r| cache[digest] = r }
end
... | [
"def",
"parse_from",
"(",
"path",
",",
"short",
"=",
"path",
".",
"relative_path_from",
"(",
"root",
")",
")",
"contents",
"=",
"path",
".",
"read",
"digest",
"=",
"Digest",
"::",
"SHA2",
".",
"digest",
"(",
"contents",
")",
"cache",
".",
"fetch",
"(",... | Parses a file. This bypasses the filename cache.
@param path [::Pathname] The path to the actual file. This should
respond to `#read`. If this isn't a pathname, the short should be
provided.
@param short [::String] The short name of the file. This is used for
location information.
@return [Parser::Root... | [
"Parses",
"a",
"file",
".",
"This",
"bypasses",
"the",
"filename",
"cache",
"."
] | c63f91dbb356aa0958351ad9bcbdab0c57e7f649 | https://github.com/medcat/brandish/blob/c63f91dbb356aa0958351ad9bcbdab0c57e7f649/lib/brandish/configure.rb#L178-L187 | train |
d11wtq/rdo | lib/rdo/statement.rb | RDO.Statement.execute | def execute(*bind_values)
t = Time.now
@executor.execute(*bind_values).tap do |rs|
rs.info[:execution_time] ||= Time.now - t
if logger.debug?
logger.debug(
"(%.6f) %s %s" % [
rs.execution_time,
command,
("<Bind: #{bind_values.in... | ruby | def execute(*bind_values)
t = Time.now
@executor.execute(*bind_values).tap do |rs|
rs.info[:execution_time] ||= Time.now - t
if logger.debug?
logger.debug(
"(%.6f) %s %s" % [
rs.execution_time,
command,
("<Bind: #{bind_values.in... | [
"def",
"execute",
"(",
"*",
"bind_values",
")",
"t",
"=",
"Time",
".",
"now",
"@executor",
".",
"execute",
"(",
"bind_values",
")",
".",
"tap",
"do",
"|",
"rs",
"|",
"rs",
".",
"info",
"[",
":execution_time",
"]",
"||=",
"Time",
".",
"now",
"-",
"t... | Initialize a new Statement wrapping the given StatementExecutor.
@param [Object] executor
any object that responds to #execute, #connection and #command
Execute the command using the given bind values.
@param [Object...] args
bind parameters to use in place of '?' | [
"Initialize",
"a",
"new",
"Statement",
"wrapping",
"the",
"given",
"StatementExecutor",
"."
] | 91fe0c70cbce9947b879141c0f1001b8c4eeef19 | https://github.com/d11wtq/rdo/blob/91fe0c70cbce9947b879141c0f1001b8c4eeef19/lib/rdo/statement.rb#L33-L50 | train |
ktonon/code_node | spec/fixtures/activerecord/src/active_record/attribute_methods.rb | ActiveRecord.AttributeMethods.attributes | def attributes
attrs = {}
attribute_names.each { |name| attrs[name] = read_attribute(name) }
attrs
end | ruby | def attributes
attrs = {}
attribute_names.each { |name| attrs[name] = read_attribute(name) }
attrs
end | [
"def",
"attributes",
"attrs",
"=",
"{",
"}",
"attribute_names",
".",
"each",
"{",
"|",
"name",
"|",
"attrs",
"[",
"name",
"]",
"=",
"read_attribute",
"(",
"name",
")",
"}",
"attrs",
"end"
] | Returns a hash of all the attributes with their names as keys and the values of the attributes as values. | [
"Returns",
"a",
"hash",
"of",
"all",
"the",
"attributes",
"with",
"their",
"names",
"as",
"keys",
"and",
"the",
"values",
"of",
"the",
"attributes",
"as",
"values",
"."
] | 48d5d1a7442d9cade602be4fb782a1b56c7677f5 | https://github.com/ktonon/code_node/blob/48d5d1a7442d9cade602be4fb782a1b56c7677f5/spec/fixtures/activerecord/src/active_record/attribute_methods.rb#L183-L187 | train |
kachick/declare | lib/declare/assertions.rb | Declare.Assertions.EQL? | def EQL?(sample)
@it.eql?(sample) && sample.eql?(@it) && (@it.hash == sample.hash) &&
({@it => true}.has_key? sample)
end | ruby | def EQL?(sample)
@it.eql?(sample) && sample.eql?(@it) && (@it.hash == sample.hash) &&
({@it => true}.has_key? sample)
end | [
"def",
"EQL?",
"(",
"sample",
")",
"@it",
".",
"eql?",
"(",
"sample",
")",
"&&",
"sample",
".",
"eql?",
"(",
"@it",
")",
"&&",
"(",
"@it",
".",
"hash",
"==",
"sample",
".",
"hash",
")",
"&&",
"(",
"{",
"@it",
"=>",
"true",
"}",
".",
"has_key?",... | true if can use for hash-key | [
"true",
"if",
"can",
"use",
"for",
"hash",
"-",
"key"
] | ea871fd652a2b6664f0c3f49ed9e33b0bbaec2e3 | https://github.com/kachick/declare/blob/ea871fd652a2b6664f0c3f49ed9e33b0bbaec2e3/lib/declare/assertions.rb#L54-L57 | train |
kachick/declare | lib/declare/assertions.rb | Declare.Assertions.CATCH | def CATCH(exception_klass, &block)
block.call
rescue ::Exception
if $!.instance_of? exception_klass
pass
else
failure("Faced a exception, that instance of #{exception_klass}.",
"Faced a exception, that instance of #{$!.class}.", 2)
end
else
failure("... | ruby | def CATCH(exception_klass, &block)
block.call
rescue ::Exception
if $!.instance_of? exception_klass
pass
else
failure("Faced a exception, that instance of #{exception_klass}.",
"Faced a exception, that instance of #{$!.class}.", 2)
end
else
failure("... | [
"def",
"CATCH",
"(",
"exception_klass",
",",
"&",
"block",
")",
"block",
".",
"call",
"rescue",
"::",
"Exception",
"if",
"$!",
".",
"instance_of?",
"exception_klass",
"pass",
"else",
"failure",
"(",
"\"Faced a exception, that instance of #{exception_klass}.\"",
",",
... | pass if occured the error is just a own instance
@param [Class] exception_klass | [
"pass",
"if",
"occured",
"the",
"error",
"is",
"just",
"a",
"own",
"instance"
] | ea871fd652a2b6664f0c3f49ed9e33b0bbaec2e3 | https://github.com/kachick/declare/blob/ea871fd652a2b6664f0c3f49ed9e33b0bbaec2e3/lib/declare/assertions.rb#L238-L252 | train |
vojto/active_harmony | lib/active_harmony/queue_item.rb | ActiveHarmony.QueueItem.process_push | def process_push
factory = "::#{object_type}".constantize
local_object = factory.find(object_local_id)
syncer = factory.synchronizer
syncer.push_object(local_object)
self.state = 'done'
self.save
end | ruby | def process_push
factory = "::#{object_type}".constantize
local_object = factory.find(object_local_id)
syncer = factory.synchronizer
syncer.push_object(local_object)
self.state = 'done'
self.save
end | [
"def",
"process_push",
"factory",
"=",
"\"::#{object_type}\"",
".",
"constantize",
"local_object",
"=",
"factory",
".",
"find",
"(",
"object_local_id",
")",
"syncer",
"=",
"factory",
".",
"synchronizer",
"syncer",
".",
"push_object",
"(",
"local_object",
")",
"sel... | Processes queued item of type push | [
"Processes",
"queued",
"item",
"of",
"type",
"push"
] | 03e5c67ea7a1f986c729001c4fec944bf116640f | https://github.com/vojto/active_harmony/blob/03e5c67ea7a1f986c729001c4fec944bf116640f/lib/active_harmony/queue_item.rb#L27-L35 | train |
vojto/active_harmony | lib/active_harmony/queue_item.rb | ActiveHarmony.QueueItem.process_pull | def process_pull
factory = "::#{object_type}".constantize
syncer = factory.synchronizer
syncer.pull_object(self.object_remote_id)
self.state = 'done'
self.save
end | ruby | def process_pull
factory = "::#{object_type}".constantize
syncer = factory.synchronizer
syncer.pull_object(self.object_remote_id)
self.state = 'done'
self.save
end | [
"def",
"process_pull",
"factory",
"=",
"\"::#{object_type}\"",
".",
"constantize",
"syncer",
"=",
"factory",
".",
"synchronizer",
"syncer",
".",
"pull_object",
"(",
"self",
".",
"object_remote_id",
")",
"self",
".",
"state",
"=",
"'done'",
"self",
".",
"save",
... | Processes queued item of type pull | [
"Processes",
"queued",
"item",
"of",
"type",
"pull"
] | 03e5c67ea7a1f986c729001c4fec944bf116640f | https://github.com/vojto/active_harmony/blob/03e5c67ea7a1f986c729001c4fec944bf116640f/lib/active_harmony/queue_item.rb#L39-L46 | train |
elgalu/strongly_typed | lib/strongly_typed/attributes.rb | StronglyTyped.Attributes.attribute | def attribute(name, type=Object)
name = name.to_sym #normalize
raise NameError, "attribute `#{name}` already created" if members.include?(name)
raise TypeError, "second argument, type, must be a Class but got `#{type.inspect}` insted" unless type.is_a?(Class)
raise TypeError, "directly converti... | ruby | def attribute(name, type=Object)
name = name.to_sym #normalize
raise NameError, "attribute `#{name}` already created" if members.include?(name)
raise TypeError, "second argument, type, must be a Class but got `#{type.inspect}` insted" unless type.is_a?(Class)
raise TypeError, "directly converti... | [
"def",
"attribute",
"(",
"name",
",",
"type",
"=",
"Object",
")",
"name",
"=",
"name",
".",
"to_sym",
"#normalize",
"raise",
"NameError",
",",
"\"attribute `#{name}` already created\"",
"if",
"members",
".",
"include?",
"(",
"name",
")",
"raise",
"TypeError",
... | Create attribute accesors for the included class
Also validations and coercions for the type specified
@param [Symbol] name the accessor name
@param [Class] type the class type to use for validations and coercions
@example
class Person
include StronglyTyped::Model
attribute :id, Integer
attri... | [
"Create",
"attribute",
"accesors",
"for",
"the",
"included",
"class",
"Also",
"validations",
"and",
"coercions",
"for",
"the",
"type",
"specified"
] | b779ec9fe7bde28608a8a7022b28ef322fcdcebd | https://github.com/elgalu/strongly_typed/blob/b779ec9fe7bde28608a8a7022b28ef322fcdcebd/lib/strongly_typed/attributes.rb#L22-L30 | train |
elgalu/strongly_typed | lib/strongly_typed/attributes.rb | StronglyTyped.Attributes.new_attribute | def new_attribute(name, type)
attributes[name] = type
define_attr_reader(name)
define_attr_writer(name, type)
name
end | ruby | def new_attribute(name, type)
attributes[name] = type
define_attr_reader(name)
define_attr_writer(name, type)
name
end | [
"def",
"new_attribute",
"(",
"name",
",",
"type",
")",
"attributes",
"[",
"name",
"]",
"=",
"type",
"define_attr_reader",
"(",
"name",
")",
"define_attr_writer",
"(",
"name",
",",
"type",
")",
"name",
"end"
] | Add new attribute for the tiny object modeled
@param [Symbol] name the attribute name
@param [Class] type the class type
@private | [
"Add",
"new",
"attribute",
"for",
"the",
"tiny",
"object",
"modeled"
] | b779ec9fe7bde28608a8a7022b28ef322fcdcebd | https://github.com/elgalu/strongly_typed/blob/b779ec9fe7bde28608a8a7022b28ef322fcdcebd/lib/strongly_typed/attributes.rb#L54-L59 | train |
elgalu/strongly_typed | lib/strongly_typed/attributes.rb | StronglyTyped.Attributes.define_attr_writer | def define_attr_writer(name, type)
define_method("#{name}=") do |value|
unless value.kind_of?(type)
value = coerce(value, to: type)
unless value.kind_of?(type)
raise TypeError, "Attribute `#{name}` only accepts `#{type}` but got `#{value}`:`#{value.class}` instead"
... | ruby | def define_attr_writer(name, type)
define_method("#{name}=") do |value|
unless value.kind_of?(type)
value = coerce(value, to: type)
unless value.kind_of?(type)
raise TypeError, "Attribute `#{name}` only accepts `#{type}` but got `#{value}`:`#{value.class}` instead"
... | [
"def",
"define_attr_writer",
"(",
"name",
",",
"type",
")",
"define_method",
"(",
"\"#{name}=\"",
")",
"do",
"|",
"value",
"|",
"unless",
"value",
".",
"kind_of?",
"(",
"type",
")",
"value",
"=",
"coerce",
"(",
"value",
",",
"to",
":",
"type",
")",
"un... | Define attr_writer method for the new attribute
with the added feature of validations and coercions.
@param [Symbol] name the attribute name
@param [Class] type the class type
@raise [TypeError] if unable to coerce the value
@private | [
"Define",
"attr_writer",
"method",
"for",
"the",
"new",
"attribute",
"with",
"the",
"added",
"feature",
"of",
"validations",
"and",
"coercions",
"."
] | b779ec9fe7bde28608a8a7022b28ef322fcdcebd | https://github.com/elgalu/strongly_typed/blob/b779ec9fe7bde28608a8a7022b28ef322fcdcebd/lib/strongly_typed/attributes.rb#L81-L91 | train |
bradfeehan/derelict | lib/derelict/virtual_machine.rb | Derelict.VirtualMachine.validate! | def validate!
logger.debug "Starting validation for #{description}"
raise NotFound.new name, connection unless exists?
logger.info "Successfully validated #{description}"
self
end | ruby | def validate!
logger.debug "Starting validation for #{description}"
raise NotFound.new name, connection unless exists?
logger.info "Successfully validated #{description}"
self
end | [
"def",
"validate!",
"logger",
".",
"debug",
"\"Starting validation for #{description}\"",
"raise",
"NotFound",
".",
"new",
"name",
",",
"connection",
"unless",
"exists?",
"logger",
".",
"info",
"\"Successfully validated #{description}\"",
"self",
"end"
] | Initializes a new VirtualMachine for a connection and name
* connection: The +Derelict::Connection+ to use to manipulate
the VirtualMachine instance
* name: The name of the virtual machine, used when
communicating with the connection)
Validates the data used for this conn... | [
"Initializes",
"a",
"new",
"VirtualMachine",
"for",
"a",
"connection",
"and",
"name"
] | c9d70f04562280a34083dd060b0e4099e6f32d8d | https://github.com/bradfeehan/derelict/blob/c9d70f04562280a34083dd060b0e4099e6f32d8d/lib/derelict/virtual_machine.rb#L44-L49 | train |
bradfeehan/derelict | lib/derelict/virtual_machine.rb | Derelict.VirtualMachine.execute! | def execute!(command, options)
# Build up the arguments to pass to connection.execute!
arguments = [command, name, *arguments_for(command)]
arguments << "--color" if options[:color]
if options[:provider]
arguments << "--provider"
arguments << options[:provider]
... | ruby | def execute!(command, options)
# Build up the arguments to pass to connection.execute!
arguments = [command, name, *arguments_for(command)]
arguments << "--color" if options[:color]
if options[:provider]
arguments << "--provider"
arguments << options[:provider]
... | [
"def",
"execute!",
"(",
"command",
",",
"options",
")",
"# Build up the arguments to pass to connection.execute!",
"arguments",
"=",
"[",
"command",
",",
"name",
",",
"arguments_for",
"(",
"command",
")",
"]",
"arguments",
"<<",
"\"--color\"",
"if",
"options",
"[",
... | Executes a command on the connection for this VM
* command: The command to execute (as a symbol)
* options: A Hash of options, with the following optional keys:
* log: Logs the output of the command if true
(defaults to false)
* log_mode: Controls how commands are logged (on... | [
"Executes",
"a",
"command",
"on",
"the",
"connection",
"for",
"this",
"VM"
] | c9d70f04562280a34083dd060b0e4099e6f32d8d | https://github.com/bradfeehan/derelict/blob/c9d70f04562280a34083dd060b0e4099e6f32d8d/lib/derelict/virtual_machine.rb#L142-L161 | train |
hawx/duvet | lib/duvet/cov.rb | Duvet.Cov.total_coverage | def total_coverage
return 0.0 if lines.size.zero?
ran_lines.size.to_f / lines.size.to_f
end | ruby | def total_coverage
return 0.0 if lines.size.zero?
ran_lines.size.to_f / lines.size.to_f
end | [
"def",
"total_coverage",
"return",
"0.0",
"if",
"lines",
".",
"size",
".",
"zero?",
"ran_lines",
".",
"size",
".",
"to_f",
"/",
"lines",
".",
"size",
".",
"to_f",
"end"
] | Gives a real number between 0 and 1 indicating how many lines have been
executed.
@return [Float] lines executed as a fraction | [
"Gives",
"a",
"real",
"number",
"between",
"0",
"and",
"1",
"indicating",
"how",
"many",
"lines",
"have",
"been",
"executed",
"."
] | f1fdcb68742e0fd67e52afe3730b78d3b3a31cfd | https://github.com/hawx/duvet/blob/f1fdcb68742e0fd67e52afe3730b78d3b3a31cfd/lib/duvet/cov.rb#L35-L38 | train |
hawx/duvet | lib/duvet/cov.rb | Duvet.Cov.code_coverage | def code_coverage
return 0.0 if code_lines.size.zero?
ran_lines.size.to_f / code_lines.size.to_f
end | ruby | def code_coverage
return 0.0 if code_lines.size.zero?
ran_lines.size.to_f / code_lines.size.to_f
end | [
"def",
"code_coverage",
"return",
"0.0",
"if",
"code_lines",
".",
"size",
".",
"zero?",
"ran_lines",
".",
"size",
".",
"to_f",
"/",
"code_lines",
".",
"size",
".",
"to_f",
"end"
] | Gives a real number between 0 and 1 indicating how many lines of code have
been executed. It ignores all lines that can not be executed such as
comments.
@return [Float] lines of code executed as a fraction | [
"Gives",
"a",
"real",
"number",
"between",
"0",
"and",
"1",
"indicating",
"how",
"many",
"lines",
"of",
"code",
"have",
"been",
"executed",
".",
"It",
"ignores",
"all",
"lines",
"that",
"can",
"not",
"be",
"executed",
"such",
"as",
"comments",
"."
] | f1fdcb68742e0fd67e52afe3730b78d3b3a31cfd | https://github.com/hawx/duvet/blob/f1fdcb68742e0fd67e52afe3730b78d3b3a31cfd/lib/duvet/cov.rb#L45-L48 | train |
pboling/stackable_flash | lib/stackable_flash/stack_layer.rb | StackableFlash.StackLayer.[]= | def []=(key, value)
if StackableFlash.stacking
super(key,
StackableFlash::FlashStack.new.replace(
value.kind_of?(Array) ?
value :
# Preserves nil values in the result... I suppose that's OK, users can compact if needed :)
Array.new(1, value)
... | ruby | def []=(key, value)
if StackableFlash.stacking
super(key,
StackableFlash::FlashStack.new.replace(
value.kind_of?(Array) ?
value :
# Preserves nil values in the result... I suppose that's OK, users can compact if needed :)
Array.new(1, value)
... | [
"def",
"[]=",
"(",
"key",
",",
"value",
")",
"if",
"StackableFlash",
".",
"stacking",
"super",
"(",
"key",
",",
"StackableFlash",
"::",
"FlashStack",
".",
"new",
".",
"replace",
"(",
"value",
".",
"kind_of?",
"(",
"Array",
")",
"?",
"value",
":",
"# Pr... | Make an array at the key, while providing a seamless upgrade to existing flashes
Initial set to Array
Principle of least surprise
flash[:notice] = ['message1','message2']
flash[:notice] # => ['message1','message2']
Initial set to String
Principle of least surprise
flash[:notice] = 'original'
flash[:notice] ... | [
"Make",
"an",
"array",
"at",
"the",
"key",
"while",
"providing",
"a",
"seamless",
"upgrade",
"to",
"existing",
"flashes"
] | 9d52a7768c2261a88044bb26fec6defda8e100e7 | https://github.com/pboling/stackable_flash/blob/9d52a7768c2261a88044bb26fec6defda8e100e7/lib/stackable_flash/stack_layer.rb#L45-L59 | train |
rudionrails/little_log_friend | lib/little_log_friend.rb | ActiveSupport.BufferedLogger.add | def add(severity, message = nil, progname = nil, &block)
return if @level > severity
message = (message || (block && block.call) || progname).to_s
message = formatter.call(formatter.number_to_severity(severity), Time.now.utc, progname, message)
message = "#{message}\n" unless message[-1] == ?\n
... | ruby | def add(severity, message = nil, progname = nil, &block)
return if @level > severity
message = (message || (block && block.call) || progname).to_s
message = formatter.call(formatter.number_to_severity(severity), Time.now.utc, progname, message)
message = "#{message}\n" unless message[-1] == ?\n
... | [
"def",
"add",
"(",
"severity",
",",
"message",
"=",
"nil",
",",
"progname",
"=",
"nil",
",",
"&",
"block",
")",
"return",
"if",
"@level",
">",
"severity",
"message",
"=",
"(",
"message",
"||",
"(",
"block",
"&&",
"block",
".",
"call",
")",
"||",
"p... | We need to overload the add method. Basibally it is the same as the
original one, but we add our own log format to it. | [
"We",
"need",
"to",
"overload",
"the",
"add",
"method",
".",
"Basibally",
"it",
"is",
"the",
"same",
"as",
"the",
"original",
"one",
"but",
"we",
"add",
"our",
"own",
"log",
"format",
"to",
"it",
"."
] | eed4ecadbf4aeff0e7cd7cfb619e6a7695c6bfbd | https://github.com/rudionrails/little_log_friend/blob/eed4ecadbf4aeff0e7cd7cfb619e6a7695c6bfbd/lib/little_log_friend.rb#L49-L57 | train |
colbell/bitsa | lib/bitsa/gmail_contacts_loader.rb | Bitsa.GmailContactsLoader.load_chunk | def load_chunk(client, idx, cache, orig_last_modified)
# last_modified = nil
url = generate_loader_url(idx, orig_last_modified)
feed = client.get(url).to_xml
feed.elements.each('entry') do |entry|
process_entry(cache, entry)
# last_modified = entry.elements['updated'].text
... | ruby | def load_chunk(client, idx, cache, orig_last_modified)
# last_modified = nil
url = generate_loader_url(idx, orig_last_modified)
feed = client.get(url).to_xml
feed.elements.each('entry') do |entry|
process_entry(cache, entry)
# last_modified = entry.elements['updated'].text
... | [
"def",
"load_chunk",
"(",
"client",
",",
"idx",
",",
"cache",
",",
"orig_last_modified",
")",
"# last_modified = nil",
"url",
"=",
"generate_loader_url",
"(",
"idx",
",",
"orig_last_modified",
")",
"feed",
"=",
"client",
".",
"get",
"(",
"url",
")",
".",
"to... | Load the next chuck of data from GMail into the cache.
@param [GData::Client::Contacts] client Connection to GMail.
@param [Integer] idx Index of next piece of data to read from
<tt>client</tt>.
@param [Bitsa::ContacstCache] cache Cache to be updated from GMail.
@param [Datetime] orig_last_mo... | [
"Load",
"the",
"next",
"chuck",
"of",
"data",
"from",
"GMail",
"into",
"the",
"cache",
"."
] | 8b73c4988bde1bf8e64d9cb999164c3e5988dba5 | https://github.com/colbell/bitsa/blob/8b73c4988bde1bf8e64d9cb999164c3e5988dba5/lib/bitsa/gmail_contacts_loader.rb#L72-L82 | train |
colbell/bitsa | lib/bitsa/gmail_contacts_loader.rb | Bitsa.GmailContactsLoader.process_entry | def process_entry(cache, entry)
gmail_id = entry.elements['id'].text
if entry.elements['gd:deleted']
cache.delete(gmail_id)
else
addrs = []
entry.each_element('gd:email') { |a| addrs << a.attributes['address'] }
cache.update(gmail_id, entry.elements['title'].text || '',... | ruby | def process_entry(cache, entry)
gmail_id = entry.elements['id'].text
if entry.elements['gd:deleted']
cache.delete(gmail_id)
else
addrs = []
entry.each_element('gd:email') { |a| addrs << a.attributes['address'] }
cache.update(gmail_id, entry.elements['title'].text || '',... | [
"def",
"process_entry",
"(",
"cache",
",",
"entry",
")",
"gmail_id",
"=",
"entry",
".",
"elements",
"[",
"'id'",
"]",
".",
"text",
"if",
"entry",
".",
"elements",
"[",
"'gd:deleted'",
"]",
"cache",
".",
"delete",
"(",
"gmail_id",
")",
"else",
"addrs",
... | Process a Gmail contact, updating the cache appropriately.
@param [Bitsa::ContacstCache] cache Cache to be updated from GMail.
@param [REXML::Element] entry GMail data for a contact. | [
"Process",
"a",
"Gmail",
"contact",
"updating",
"the",
"cache",
"appropriately",
"."
] | 8b73c4988bde1bf8e64d9cb999164c3e5988dba5 | https://github.com/colbell/bitsa/blob/8b73c4988bde1bf8e64d9cb999164c3e5988dba5/lib/bitsa/gmail_contacts_loader.rb#L88-L97 | train |
colbell/bitsa | lib/bitsa/gmail_contacts_loader.rb | Bitsa.GmailContactsLoader.generate_loader_url | def generate_loader_url(idx, cache_last_modified)
# FIXME: Escape variables
url = "https://www.google.com/m8/feeds/contacts/#{@user}/thin"
url += '?orderby=lastmodified'
url += '&showdeleted=true'
url += "&max-results=#{@fetch_size}"
url += "&start-index=#{idx}"
if cache_last_m... | ruby | def generate_loader_url(idx, cache_last_modified)
# FIXME: Escape variables
url = "https://www.google.com/m8/feeds/contacts/#{@user}/thin"
url += '?orderby=lastmodified'
url += '&showdeleted=true'
url += "&max-results=#{@fetch_size}"
url += "&start-index=#{idx}"
if cache_last_m... | [
"def",
"generate_loader_url",
"(",
"idx",
",",
"cache_last_modified",
")",
"# FIXME: Escape variables",
"url",
"=",
"\"https://www.google.com/m8/feeds/contacts/#{@user}/thin\"",
"url",
"+=",
"'?orderby=lastmodified'",
"url",
"+=",
"'&showdeleted=true'",
"url",
"+=",
"\"&max-res... | Generate the URL to retrieve the next chunk of data from GMail.
@param [Integer] idx Index of next piece of data to read from
<tt>client</tt>.
@param [Datetime] cache_last_modified modification time of last contact
read from GMail | [
"Generate",
"the",
"URL",
"to",
"retrieve",
"the",
"next",
"chunk",
"of",
"data",
"from",
"GMail",
"."
] | 8b73c4988bde1bf8e64d9cb999164c3e5988dba5 | https://github.com/colbell/bitsa/blob/8b73c4988bde1bf8e64d9cb999164c3e5988dba5/lib/bitsa/gmail_contacts_loader.rb#L105-L116 | train |
hannesg/multi_git | lib/multi_git/walkable.rb | MultiGit.Walkable.walk | def walk( mode = :pre, &block )
raise ArgumentError, "Unknown walk mode #{mode.inspect}. Use either :pre, :post or :leaves" unless MODES.include? mode
return to_enum(:walk, mode) unless block
case(mode)
when :pre then walk_pre(&block)
when :post then walk_post(&block)
when :leaves... | ruby | def walk( mode = :pre, &block )
raise ArgumentError, "Unknown walk mode #{mode.inspect}. Use either :pre, :post or :leaves" unless MODES.include? mode
return to_enum(:walk, mode) unless block
case(mode)
when :pre then walk_pre(&block)
when :post then walk_post(&block)
when :leaves... | [
"def",
"walk",
"(",
"mode",
"=",
":pre",
",",
"&",
"block",
")",
"raise",
"ArgumentError",
",",
"\"Unknown walk mode #{mode.inspect}. Use either :pre, :post or :leaves\"",
"unless",
"MODES",
".",
"include?",
"mode",
"return",
"to_enum",
"(",
":walk",
",",
"mode",
")... | works like each, but recursive
@param mode [:pre, :post, :leaves] | [
"works",
"like",
"each",
"but",
"recursive"
] | cb82e66be7d27c3b630610ce3f1385b30811f139 | https://github.com/hannesg/multi_git/blob/cb82e66be7d27c3b630610ce3f1385b30811f139/lib/multi_git/walkable.rb#L12-L20 | train |
jD91mZM2/synacrb | lib/synacrb.rb | Synacrb.Session.verify_callback | def verify_callback(_, cert)
pem = cert.current_cert.public_key.to_pem
sha256 = OpenSSL::Digest::SHA256.new
hash = sha256.digest(pem).unpack("H*")
hash[0].casecmp(@hash).zero?
end | ruby | def verify_callback(_, cert)
pem = cert.current_cert.public_key.to_pem
sha256 = OpenSSL::Digest::SHA256.new
hash = sha256.digest(pem).unpack("H*")
hash[0].casecmp(@hash).zero?
end | [
"def",
"verify_callback",
"(",
"_",
",",
"cert",
")",
"pem",
"=",
"cert",
".",
"current_cert",
".",
"public_key",
".",
"to_pem",
"sha256",
"=",
"OpenSSL",
"::",
"Digest",
"::",
"SHA256",
".",
"new",
"hash",
"=",
"sha256",
".",
"digest",
"(",
"pem",
")"... | Connect to the server
OpenSSL verify callback used by initialize when optional callback argument isn't set. | [
"Connect",
"to",
"the",
"server",
"OpenSSL",
"verify",
"callback",
"used",
"by",
"initialize",
"when",
"optional",
"callback",
"argument",
"isn",
"t",
"set",
"."
] | c272c8a598f5d41f9185a5b5335213de91c944ab | https://github.com/jD91mZM2/synacrb/blob/c272c8a598f5d41f9185a5b5335213de91c944ab/lib/synacrb.rb#L39-L45 | train |
jD91mZM2/synacrb | lib/synacrb.rb | Synacrb.Session.login_with_token | def login_with_token(bot, name, token)
send Common::Login.new(bot, name, nil, token)
end | ruby | def login_with_token(bot, name, token)
send Common::Login.new(bot, name, nil, token)
end | [
"def",
"login_with_token",
"(",
"bot",
",",
"name",
",",
"token",
")",
"send",
"Common",
"::",
"Login",
".",
"new",
"(",
"bot",
",",
"name",
",",
"nil",
",",
"token",
")",
"end"
] | Sends the login packet with specific token.
Read the result with `read`. | [
"Sends",
"the",
"login",
"packet",
"with",
"specific",
"token",
".",
"Read",
"the",
"result",
"with",
"read",
"."
] | c272c8a598f5d41f9185a5b5335213de91c944ab | https://github.com/jD91mZM2/synacrb/blob/c272c8a598f5d41f9185a5b5335213de91c944ab/lib/synacrb.rb#L61-L63 | train |
jD91mZM2/synacrb | lib/synacrb.rb | Synacrb.Session.send | def send(packet)
id = Common.packet_to_id(packet)
data = [id, [packet.to_a]].to_msgpack
@stream.write Common.encode_u16(data.length)
@stream.write data
end | ruby | def send(packet)
id = Common.packet_to_id(packet)
data = [id, [packet.to_a]].to_msgpack
@stream.write Common.encode_u16(data.length)
@stream.write data
end | [
"def",
"send",
"(",
"packet",
")",
"id",
"=",
"Common",
".",
"packet_to_id",
"(",
"packet",
")",
"data",
"=",
"[",
"id",
",",
"[",
"packet",
".",
"to_a",
"]",
"]",
".",
"to_msgpack",
"@stream",
".",
"write",
"Common",
".",
"encode_u16",
"(",
"data",
... | Transmit a packet over the connection | [
"Transmit",
"a",
"packet",
"over",
"the",
"connection"
] | c272c8a598f5d41f9185a5b5335213de91c944ab | https://github.com/jD91mZM2/synacrb/blob/c272c8a598f5d41f9185a5b5335213de91c944ab/lib/synacrb.rb#L66-L72 | train |
jD91mZM2/synacrb | lib/synacrb.rb | Synacrb.Session.read | def read()
size_a = @stream.read 2
size = Common.decode_u16(size_a)
data = @stream.read size
data = MessagePack.unpack data
class_ = Common.packet_from_id data[0]
class_.new *data[1][0]
end | ruby | def read()
size_a = @stream.read 2
size = Common.decode_u16(size_a)
data = @stream.read size
data = MessagePack.unpack data
class_ = Common.packet_from_id data[0]
class_.new *data[1][0]
end | [
"def",
"read",
"(",
")",
"size_a",
"=",
"@stream",
".",
"read",
"2",
"size",
"=",
"Common",
".",
"decode_u16",
"(",
"size_a",
")",
"data",
"=",
"@stream",
".",
"read",
"size",
"data",
"=",
"MessagePack",
".",
"unpack",
"data",
"class_",
"=",
"Common",
... | Read a packet from the connection | [
"Read",
"a",
"packet",
"from",
"the",
"connection"
] | c272c8a598f5d41f9185a5b5335213de91c944ab | https://github.com/jD91mZM2/synacrb/blob/c272c8a598f5d41f9185a5b5335213de91c944ab/lib/synacrb.rb#L75-L83 | train |
brunofrank/trustvox | lib/trustvox/store.rb | Trustvox.Store.create | def create(store_data)
auth_by_platform_token!
response = self.class.post('/stores', { body: store_data.to_json })
data = JSON.parse(response.body) rescue nil
{
status: response.code,
data: data,
}
end | ruby | def create(store_data)
auth_by_platform_token!
response = self.class.post('/stores', { body: store_data.to_json })
data = JSON.parse(response.body) rescue nil
{
status: response.code,
data: data,
}
end | [
"def",
"create",
"(",
"store_data",
")",
"auth_by_platform_token!",
"response",
"=",
"self",
".",
"class",
".",
"post",
"(",
"'/stores'",
",",
"{",
"body",
":",
"store_data",
".",
"to_json",
"}",
")",
"data",
"=",
"JSON",
".",
"parse",
"(",
"response",
"... | Call create store api
@param store_data | [
"Call",
"create",
"store",
"api"
] | 1ceb4cfe0bf7c6fa51b951a02810f4e973d8ec23 | https://github.com/brunofrank/trustvox/blob/1ceb4cfe0bf7c6fa51b951a02810f4e973d8ec23/lib/trustvox/store.rb#L7-L16 | train |
brunofrank/trustvox | lib/trustvox/store.rb | Trustvox.Store.push_order | def push_order(order_data)
body = Utils.build_push_order_data(order_data)
auth_by_store_token!
response = self.class.post("/stores/#{Config.store_id}/orders", { body: body.to_json })
data = JSON.parse(response.body) rescue nil
{ status: response.code, data: data }
end | ruby | def push_order(order_data)
body = Utils.build_push_order_data(order_data)
auth_by_store_token!
response = self.class.post("/stores/#{Config.store_id}/orders", { body: body.to_json })
data = JSON.parse(response.body) rescue nil
{ status: response.code, data: data }
end | [
"def",
"push_order",
"(",
"order_data",
")",
"body",
"=",
"Utils",
".",
"build_push_order_data",
"(",
"order_data",
")",
"auth_by_store_token!",
"response",
"=",
"self",
".",
"class",
".",
"post",
"(",
"\"/stores/#{Config.store_id}/orders\"",
",",
"{",
"body",
":"... | Call order api
@param order_data | [
"Call",
"order",
"api"
] | 1ceb4cfe0bf7c6fa51b951a02810f4e973d8ec23 | https://github.com/brunofrank/trustvox/blob/1ceb4cfe0bf7c6fa51b951a02810f4e973d8ec23/lib/trustvox/store.rb#L20-L27 | train |
brunofrank/trustvox | lib/trustvox/store.rb | Trustvox.Store.load_store | def load_store(url)
auth_by_platform_token!
response = self.class.get("/stores", { query: { url: url} })
data = JSON.parse(response.body) rescue nil
{
status: response.code,
data: data,
}
end | ruby | def load_store(url)
auth_by_platform_token!
response = self.class.get("/stores", { query: { url: url} })
data = JSON.parse(response.body) rescue nil
{
status: response.code,
data: data,
}
end | [
"def",
"load_store",
"(",
"url",
")",
"auth_by_platform_token!",
"response",
"=",
"self",
".",
"class",
".",
"get",
"(",
"\"/stores\"",
",",
"{",
"query",
":",
"{",
"url",
":",
"url",
"}",
"}",
")",
"data",
"=",
"JSON",
".",
"parse",
"(",
"response",
... | Call store lookup api
@param url | [
"Call",
"store",
"lookup",
"api"
] | 1ceb4cfe0bf7c6fa51b951a02810f4e973d8ec23 | https://github.com/brunofrank/trustvox/blob/1ceb4cfe0bf7c6fa51b951a02810f4e973d8ec23/lib/trustvox/store.rb#L31-L40 | train |
irvingwashington/gem_footprint_analyzer | lib/gem_footprint_analyzer/average_runner.rb | GemFootprintAnalyzer.AverageRunner.calculate_averages | def calculate_averages(results)
Array.new(results.first.size) do |require_number|
samples = results.map { |r| r[require_number] }
first_sample = samples.first
average = initialize_average_with_copied_fields(first_sample)
AVERAGED_FIELDS.map do |field|
next unless first_s... | ruby | def calculate_averages(results)
Array.new(results.first.size) do |require_number|
samples = results.map { |r| r[require_number] }
first_sample = samples.first
average = initialize_average_with_copied_fields(first_sample)
AVERAGED_FIELDS.map do |field|
next unless first_s... | [
"def",
"calculate_averages",
"(",
"results",
")",
"Array",
".",
"new",
"(",
"results",
".",
"first",
".",
"size",
")",
"do",
"|",
"require_number",
"|",
"samples",
"=",
"results",
".",
"map",
"{",
"|",
"r",
"|",
"r",
"[",
"require_number",
"]",
"}",
... | Take corresponding results array values and compare them | [
"Take",
"corresponding",
"results",
"array",
"values",
"and",
"compare",
"them"
] | 19a8892f6baaeb16b1b166144c4f73852396220c | https://github.com/irvingwashington/gem_footprint_analyzer/blob/19a8892f6baaeb16b1b166144c4f73852396220c/lib/gem_footprint_analyzer/average_runner.rb#L30-L43 | train |
michaeledgar/amp-front | lib/amp-front/third_party/maruku/helpers.rb | MaRuKu.Helpers.md_el | def md_el(node_type, children=[], meta={}, al=nil)
if (e=children.first).kind_of?(MDElement) and
e.node_type == :ial then
if al
al += e.ial
else
al = e.ial
end
children.shift
end
e = MDElement.new(node_type, children, meta, al)
e.doc = @doc
return e
end | ruby | def md_el(node_type, children=[], meta={}, al=nil)
if (e=children.first).kind_of?(MDElement) and
e.node_type == :ial then
if al
al += e.ial
else
al = e.ial
end
children.shift
end
e = MDElement.new(node_type, children, meta, al)
e.doc = @doc
return e
end | [
"def",
"md_el",
"(",
"node_type",
",",
"children",
"=",
"[",
"]",
",",
"meta",
"=",
"{",
"}",
",",
"al",
"=",
"nil",
")",
"if",
"(",
"e",
"=",
"children",
".",
"first",
")",
".",
"kind_of?",
"(",
"MDElement",
")",
"and",
"e",
".",
"node_type",
... | if the first is a md_ial, it is used as such | [
"if",
"the",
"first",
"is",
"a",
"md_ial",
"it",
"is",
"used",
"as",
"such"
] | d939b7ed9a7b0e5a3d26e536b95149f88b64e3a9 | https://github.com/michaeledgar/amp-front/blob/d939b7ed9a7b0e5a3d26e536b95149f88b64e3a9/lib/amp-front/third_party/maruku/helpers.rb#L34-L47 | train |
hackberry-gh/actn-db | lib/actn/paths.rb | Actn.Paths.find_root_with_flag | def find_root_with_flag(flag, default=nil)
root_path = self.called_from[0]
while root_path && ::File.directory?(root_path) && !::File.exist?("#{root_path}/#{flag}")
parent = ::File.dirname(root_path)
root_path = parent != root_path && parent
end
root = ::File.exist?("#{root_pat... | ruby | def find_root_with_flag(flag, default=nil)
root_path = self.called_from[0]
while root_path && ::File.directory?(root_path) && !::File.exist?("#{root_path}/#{flag}")
parent = ::File.dirname(root_path)
root_path = parent != root_path && parent
end
root = ::File.exist?("#{root_pat... | [
"def",
"find_root_with_flag",
"(",
"flag",
",",
"default",
"=",
"nil",
")",
"root_path",
"=",
"self",
".",
"called_from",
"[",
"0",
"]",
"while",
"root_path",
"&&",
"::",
"File",
".",
"directory?",
"(",
"root_path",
")",
"&&",
"!",
"::",
"File",
".",
"... | i steal this from rails | [
"i",
"steal",
"this",
"from",
"rails"
] | 53b41773147507d5a7393f6a0b2b056f1e57f6ee | https://github.com/hackberry-gh/actn-db/blob/53b41773147507d5a7393f6a0b2b056f1e57f6ee/lib/actn/paths.rb#L21-L34 | train |
addagger/gaigo | lib/gaigo/helpers/form_helper_v3.rb | Gaigo.FormHelper.ilabel | def ilabel(object_name, method, content_or_options = nil, options = nil, &block)
options ||= {}
content_is_options = content_or_options.is_a?(Hash)
if content_is_options || block_given?
options.merge!(content_or_options) if content_is_options
text = nil
else
text = conte... | ruby | def ilabel(object_name, method, content_or_options = nil, options = nil, &block)
options ||= {}
content_is_options = content_or_options.is_a?(Hash)
if content_is_options || block_given?
options.merge!(content_or_options) if content_is_options
text = nil
else
text = conte... | [
"def",
"ilabel",
"(",
"object_name",
",",
"method",
",",
"content_or_options",
"=",
"nil",
",",
"options",
"=",
"nil",
",",
"&",
"block",
")",
"options",
"||=",
"{",
"}",
"content_is_options",
"=",
"content_or_options",
".",
"is_a?",
"(",
"Hash",
")",
"if"... | module_eval <<-EOV | [
"module_eval",
"<<",
"-",
"EOV"
] | b4dcc77052e859256defdca22d6bbbdfb07480c8 | https://github.com/addagger/gaigo/blob/b4dcc77052e859256defdca22d6bbbdfb07480c8/lib/gaigo/helpers/form_helper_v3.rb#L8-L20 | train |
jD91mZM2/synacrb | lib/synacrb/state.rb | Synacrb.State.get_private_channel | def get_private_channel(user)
@users.keys
.map { |channel| @channels[channel] }
.compact
.find { |channel| channel.private }
# the server doesn't send PMs you don't have access to
end | ruby | def get_private_channel(user)
@users.keys
.map { |channel| @channels[channel] }
.compact
.find { |channel| channel.private }
# the server doesn't send PMs you don't have access to
end | [
"def",
"get_private_channel",
"(",
"user",
")",
"@users",
".",
"keys",
".",
"map",
"{",
"|",
"channel",
"|",
"@channels",
"[",
"channel",
"]",
"}",
".",
"compact",
".",
"find",
"{",
"|",
"channel",
"|",
"channel",
".",
"private",
"}",
"# the server doesn... | Search for a private channel with user | [
"Search",
"for",
"a",
"private",
"channel",
"with",
"user"
] | c272c8a598f5d41f9185a5b5335213de91c944ab | https://github.com/jD91mZM2/synacrb/blob/c272c8a598f5d41f9185a5b5335213de91c944ab/lib/synacrb/state.rb#L33-L39 | train |
jD91mZM2/synacrb | lib/synacrb/state.rb | Synacrb.State.get_recipient_unchecked | def get_recipient_unchecked(channel_id)
@users.values
.find { |user| user.modes.keys
.any { |channel| channel == channel_id }}
end | ruby | def get_recipient_unchecked(channel_id)
@users.values
.find { |user| user.modes.keys
.any { |channel| channel == channel_id }}
end | [
"def",
"get_recipient_unchecked",
"(",
"channel_id",
")",
"@users",
".",
"values",
".",
"find",
"{",
"|",
"user",
"|",
"user",
".",
"modes",
".",
"keys",
".",
"any",
"{",
"|",
"channel",
"|",
"channel",
"==",
"channel_id",
"}",
"}",
"end"
] | Search for the recipient in a private channel.
If the channel isn't private, it returns the first user it can find
that has a special mode in that channel.
So you should probably make sure it's private first. | [
"Search",
"for",
"the",
"recipient",
"in",
"a",
"private",
"channel",
".",
"If",
"the",
"channel",
"isn",
"t",
"private",
"it",
"returns",
"the",
"first",
"user",
"it",
"can",
"find",
"that",
"has",
"a",
"special",
"mode",
"in",
"that",
"channel",
".",
... | c272c8a598f5d41f9185a5b5335213de91c944ab | https://github.com/jD91mZM2/synacrb/blob/c272c8a598f5d41f9185a5b5335213de91c944ab/lib/synacrb/state.rb#L53-L57 | train |
payout/rester | lib/rester/client.rb | Rester.Client._init_requester | def _init_requester
if circuit_breaker_enabled?
@_requester = Utils::CircuitBreaker.new(
threshold: error_threshold, retry_period: retry_period
) { |*args| _request(*args) }
@_requester.on_open do
logger.error("circuit opened for #{name}")
end
@_reques... | ruby | def _init_requester
if circuit_breaker_enabled?
@_requester = Utils::CircuitBreaker.new(
threshold: error_threshold, retry_period: retry_period
) { |*args| _request(*args) }
@_requester.on_open do
logger.error("circuit opened for #{name}")
end
@_reques... | [
"def",
"_init_requester",
"if",
"circuit_breaker_enabled?",
"@_requester",
"=",
"Utils",
"::",
"CircuitBreaker",
".",
"new",
"(",
"threshold",
":",
"error_threshold",
",",
"retry_period",
":",
"retry_period",
")",
"{",
"|",
"*",
"args",
"|",
"_request",
"(",
"ar... | Sets up the circuit breaker for making requests to the service.
Any exception raised by the `_request` method will count as a failure for
the circuit breaker. Once the threshold for errors has been reached, the
circuit opens and all subsequent requests will raise a CircuitOpenError.
When the circuit is opened or... | [
"Sets",
"up",
"the",
"circuit",
"breaker",
"for",
"making",
"requests",
"to",
"the",
"service",
"."
] | 404a45fa17e7f92e167a08c0bd90382dafd43cc5 | https://github.com/payout/rester/blob/404a45fa17e7f92e167a08c0bd90382dafd43cc5/lib/rester/client.rb#L105-L121 | train |
payout/rester | lib/rester/client.rb | Rester.Client._request | def _request(verb, path, params)
Rester.wrap_request do
Rester.request_info[:producer_name] = name
Rester.request_info[:path] = path
Rester.request_info[:verb] = verb
logger.info('sending request')
_set_default_headers
start_time = Time.now.to_f
begin
... | ruby | def _request(verb, path, params)
Rester.wrap_request do
Rester.request_info[:producer_name] = name
Rester.request_info[:path] = path
Rester.request_info[:verb] = verb
logger.info('sending request')
_set_default_headers
start_time = Time.now.to_f
begin
... | [
"def",
"_request",
"(",
"verb",
",",
"path",
",",
"params",
")",
"Rester",
".",
"wrap_request",
"do",
"Rester",
".",
"request_info",
"[",
":producer_name",
"]",
"=",
"name",
"Rester",
".",
"request_info",
"[",
":path",
"]",
"=",
"path",
"Rester",
".",
"r... | Add a correlation ID to the header and send the request to the adapter | [
"Add",
"a",
"correlation",
"ID",
"to",
"the",
"header",
"and",
"send",
"the",
"request",
"to",
"the",
"adapter"
] | 404a45fa17e7f92e167a08c0bd90382dafd43cc5 | https://github.com/payout/rester/blob/404a45fa17e7f92e167a08c0bd90382dafd43cc5/lib/rester/client.rb#L125-L143 | train |
valeriomazzeo/danger-junit_results | lib/junit_results/plugin.rb | Danger.DangerJunitResults.parse | def parse(file_path)
require 'nokogiri'
@doc = Nokogiri::XML(File.open(file_path))
@total_count = @doc.xpath('//testsuite').map { |x| x.attr('tests').to_i }.inject(0){ |sum, x| sum + x }
@skipped_count = @doc.xpath('//testsuite').map { |x| x.attr('skipped').to_i }.inject(0){ |sum, x| sum + x }... | ruby | def parse(file_path)
require 'nokogiri'
@doc = Nokogiri::XML(File.open(file_path))
@total_count = @doc.xpath('//testsuite').map { |x| x.attr('tests').to_i }.inject(0){ |sum, x| sum + x }
@skipped_count = @doc.xpath('//testsuite').map { |x| x.attr('skipped').to_i }.inject(0){ |sum, x| sum + x }... | [
"def",
"parse",
"(",
"file_path",
")",
"require",
"'nokogiri'",
"@doc",
"=",
"Nokogiri",
"::",
"XML",
"(",
"File",
".",
"open",
"(",
"file_path",
")",
")",
"@total_count",
"=",
"@doc",
".",
"xpath",
"(",
"'//testsuite'",
")",
".",
"map",
"{",
"|",
"x",... | Parses tests.
@return [success] | [
"Parses",
"tests",
"."
] | 6247fee99a3162e5a80002cd360ee47008ad6be3 | https://github.com/valeriomazzeo/danger-junit_results/blob/6247fee99a3162e5a80002cd360ee47008ad6be3/lib/junit_results/plugin.rb#L50-L63 | train |
casst01/easy-exist | lib/easy-exist/db.rb | EasyExist.DB.put | def put(document_uri, document)
validate_uri(document_uri)
res = put_document(document_uri, document, "application/xml")
res.success? ? res : handle_error(res)
end | ruby | def put(document_uri, document)
validate_uri(document_uri)
res = put_document(document_uri, document, "application/xml")
res.success? ? res : handle_error(res)
end | [
"def",
"put",
"(",
"document_uri",
",",
"document",
")",
"validate_uri",
"(",
"document_uri",
")",
"res",
"=",
"put_document",
"(",
"document_uri",
",",
"document",
",",
"\"application/xml\"",
")",
"res",
".",
"success?",
"?",
"res",
":",
"handle_error",
"(",
... | Puts the given document content at the specified URI
@param document_uri [String] the URI at wich to store the document.
relative to the collection specified on initialization otherwise '/db'.
@return [HTTParty::Response] the response object | [
"Puts",
"the",
"given",
"document",
"content",
"at",
"the",
"specified",
"URI"
] | 5f01d426456f88485783b6148274201908c5e2b7 | https://github.com/casst01/easy-exist/blob/5f01d426456f88485783b6148274201908c5e2b7/lib/easy-exist/db.rb#L38-L42 | train |
casst01/easy-exist | lib/easy-exist/db.rb | EasyExist.DB.delete | def delete(document_uri)
validate_uri(document_uri)
res = HTTParty.delete(document_uri, @default_opts)
res.success? ? res : handle_error(res)
end | ruby | def delete(document_uri)
validate_uri(document_uri)
res = HTTParty.delete(document_uri, @default_opts)
res.success? ? res : handle_error(res)
end | [
"def",
"delete",
"(",
"document_uri",
")",
"validate_uri",
"(",
"document_uri",
")",
"res",
"=",
"HTTParty",
".",
"delete",
"(",
"document_uri",
",",
"@default_opts",
")",
"res",
".",
"success?",
"?",
"res",
":",
"handle_error",
"(",
"res",
")",
"end"
] | Deletes the document at the specified URI from the store
@param document_uri [String] the URI of the document to delete.
relative to the collection specified on initialization otherwise '/db'.
@return [HTTParty::Response] the response object | [
"Deletes",
"the",
"document",
"at",
"the",
"specified",
"URI",
"from",
"the",
"store"
] | 5f01d426456f88485783b6148274201908c5e2b7 | https://github.com/casst01/easy-exist/blob/5f01d426456f88485783b6148274201908c5e2b7/lib/easy-exist/db.rb#L49-L53 | train |
casst01/easy-exist | lib/easy-exist/db.rb | EasyExist.DB.query | def query(query, opts = {})
body = EasyExist::QueryRequest.new(query, opts).body
res = HTTParty.post("", @default_opts.merge({
body: body,
headers: { 'Content-Type' => 'application/xml', 'Content-Length' => body.length.to_s }
}))
res.success? ? res.body : handle_error(res)
end | ruby | def query(query, opts = {})
body = EasyExist::QueryRequest.new(query, opts).body
res = HTTParty.post("", @default_opts.merge({
body: body,
headers: { 'Content-Type' => 'application/xml', 'Content-Length' => body.length.to_s }
}))
res.success? ? res.body : handle_error(res)
end | [
"def",
"query",
"(",
"query",
",",
"opts",
"=",
"{",
"}",
")",
"body",
"=",
"EasyExist",
"::",
"QueryRequest",
".",
"new",
"(",
"query",
",",
"opts",
")",
".",
"body",
"res",
"=",
"HTTParty",
".",
"post",
"(",
"\"\"",
",",
"@default_opts",
".",
"me... | Runs the given XQuery against the store and returns the results
@param query [String] XQuery to run against the store
@param opts [Hash] options for the query request.
@option opts :start [Integer] Index of first item to be returned.
@option opts :max [Integer] The maximum number of items to be returned.
@return ... | [
"Runs",
"the",
"given",
"XQuery",
"against",
"the",
"store",
"and",
"returns",
"the",
"results"
] | 5f01d426456f88485783b6148274201908c5e2b7 | https://github.com/casst01/easy-exist/blob/5f01d426456f88485783b6148274201908c5e2b7/lib/easy-exist/db.rb#L72-L79 | train |
casst01/easy-exist | lib/easy-exist/db.rb | EasyExist.DB.store_query | def store_query(query_uri, query)
validate_uri(query_uri)
res = put_document(query_uri, query, "application/xquery")
res.success? ? res : handle_error(res)
end | ruby | def store_query(query_uri, query)
validate_uri(query_uri)
res = put_document(query_uri, query, "application/xquery")
res.success? ? res : handle_error(res)
end | [
"def",
"store_query",
"(",
"query_uri",
",",
"query",
")",
"validate_uri",
"(",
"query_uri",
")",
"res",
"=",
"put_document",
"(",
"query_uri",
",",
"query",
",",
"\"application/xquery\"",
")",
"res",
".",
"success?",
"?",
"res",
":",
"handle_error",
"(",
"r... | Stores the given query at the specified URI
@param query_uri [String] the URI of the query to run
@param query [String] the query body
@return [HTTParty::Response] the response object | [
"Stores",
"the",
"given",
"query",
"at",
"the",
"specified",
"URI"
] | 5f01d426456f88485783b6148274201908c5e2b7 | https://github.com/casst01/easy-exist/blob/5f01d426456f88485783b6148274201908c5e2b7/lib/easy-exist/db.rb#L86-L90 | train |
casst01/easy-exist | lib/easy-exist/db.rb | EasyExist.DB.put_document | def put_document(uri, document, content_type)
HTTParty.put(uri, @default_opts.merge({
body: document,
headers: { "Content-Type" => content_type},
}))
end | ruby | def put_document(uri, document, content_type)
HTTParty.put(uri, @default_opts.merge({
body: document,
headers: { "Content-Type" => content_type},
}))
end | [
"def",
"put_document",
"(",
"uri",
",",
"document",
",",
"content_type",
")",
"HTTParty",
".",
"put",
"(",
"uri",
",",
"@default_opts",
".",
"merge",
"(",
"{",
"body",
":",
"document",
",",
"headers",
":",
"{",
"\"Content-Type\"",
"=>",
"content_type",
"}"... | Stores a document at the specified URI and with the specified content type
@param uri [String] the URI under which to store the document
@param document [String] the document body
@param content_type [String] the MIME Type of the document
@return [HTTParty::Response] the response object | [
"Stores",
"a",
"document",
"at",
"the",
"specified",
"URI",
"and",
"with",
"the",
"specified",
"content",
"type"
] | 5f01d426456f88485783b6148274201908c5e2b7 | https://github.com/casst01/easy-exist/blob/5f01d426456f88485783b6148274201908c5e2b7/lib/easy-exist/db.rb#L131-L136 | train |
scotdalton/institutions | lib/institutions/institution/core.rb | Institutions.Core.set_required_attributes | def set_required_attributes(code, name)
missing_arguments = []
missing_arguments << :code if code.nil?
missing_arguments << :name if name.nil?
raise ArgumentError.new("Cannot create the Institution based on the given arguments (:code => #{code.inspect}, :name => #{name.inspect}).\n"+
"Th... | ruby | def set_required_attributes(code, name)
missing_arguments = []
missing_arguments << :code if code.nil?
missing_arguments << :name if name.nil?
raise ArgumentError.new("Cannot create the Institution based on the given arguments (:code => #{code.inspect}, :name => #{name.inspect}).\n"+
"Th... | [
"def",
"set_required_attributes",
"(",
"code",
",",
"name",
")",
"missing_arguments",
"=",
"[",
"]",
"missing_arguments",
"<<",
":code",
"if",
"code",
".",
"nil?",
"missing_arguments",
"<<",
":name",
"if",
"name",
".",
"nil?",
"raise",
"ArgumentError",
".",
"n... | Creates a new Institution object from the given code, name and hash.
The optional +hash+, if given, will generate additional attributes and values.
For example:
require 'institutions'
hash = { "attribute1" => "My first attribute.", :array_attribute => [1, 2] }
institution = Institutions::Institution.new(... | [
"Creates",
"a",
"new",
"Institution",
"object",
"from",
"the",
"given",
"code",
"name",
"and",
"hash",
"."
] | e979f42d54abca3cc629b70eb3dd82aa84f19982 | https://github.com/scotdalton/institutions/blob/e979f42d54abca3cc629b70eb3dd82aa84f19982/lib/institutions/institution/core.rb#L41-L49 | train |
bleonard/daily | app/formatters/json_formatter.rb | Ruport.Formatter::JSON.build_table_body | def build_table_body
data.each_with_index do |row, i|
output << ",\n" if i > 0
build_row(row)
end
output << "\n"
end | ruby | def build_table_body
data.each_with_index do |row, i|
output << ",\n" if i > 0
build_row(row)
end
output << "\n"
end | [
"def",
"build_table_body",
"data",
".",
"each_with_index",
"do",
"|",
"row",
",",
"i",
"|",
"output",
"<<",
"\",\\n\"",
"if",
"i",
">",
"0",
"build_row",
"(",
"row",
")",
"end",
"output",
"<<",
"\"\\n\"",
"end"
] | Uses the Row controller to build up the table body. | [
"Uses",
"the",
"Row",
"controller",
"to",
"build",
"up",
"the",
"table",
"body",
"."
] | 0de33921da7ae678f09e782017eee33df69771e7 | https://github.com/bleonard/daily/blob/0de33921da7ae678f09e782017eee33df69771e7/app/formatters/json_formatter.rb#L21-L27 | train |
bleonard/daily | app/formatters/json_formatter.rb | Ruport.Formatter::JSON.build_row | def build_row(data = self.data)
values = data.to_a
keys = self.data.column_names.to_a
hash = {}
values.each_with_index do |val, i|
key = (keys[i] || i).to_s
hash[key] = val
end
line = hash.to_json.to_s
output << " #{line}"
end | ruby | def build_row(data = self.data)
values = data.to_a
keys = self.data.column_names.to_a
hash = {}
values.each_with_index do |val, i|
key = (keys[i] || i).to_s
hash[key] = val
end
line = hash.to_json.to_s
output << " #{line}"
end | [
"def",
"build_row",
"(",
"data",
"=",
"self",
".",
"data",
")",
"values",
"=",
"data",
".",
"to_a",
"keys",
"=",
"self",
".",
"data",
".",
"column_names",
".",
"to_a",
"hash",
"=",
"{",
"}",
"values",
".",
"each_with_index",
"do",
"|",
"val",
",",
... | Renders individual rows for the table. | [
"Renders",
"individual",
"rows",
"for",
"the",
"table",
"."
] | 0de33921da7ae678f09e782017eee33df69771e7 | https://github.com/bleonard/daily/blob/0de33921da7ae678f09e782017eee33df69771e7/app/formatters/json_formatter.rb#L36-L46 | train |
bleonard/daily | app/formatters/json_formatter.rb | Ruport.Formatter::JSON.build_grouping_body | def build_grouping_body
arr = []
data.each do |_,group|
arr << render_group(group, options)
end
output << arr.join(",\n")
end | ruby | def build_grouping_body
arr = []
data.each do |_,group|
arr << render_group(group, options)
end
output << arr.join(",\n")
end | [
"def",
"build_grouping_body",
"arr",
"=",
"[",
"]",
"data",
".",
"each",
"do",
"|",
"_",
",",
"group",
"|",
"arr",
"<<",
"render_group",
"(",
"group",
",",
"options",
")",
"end",
"output",
"<<",
"arr",
".",
"join",
"(",
"\",\\n\"",
")",
"end"
] | Generates the body for a grouping. Iterates through the groups and
renders them using the group controller. | [
"Generates",
"the",
"body",
"for",
"a",
"grouping",
".",
"Iterates",
"through",
"the",
"groups",
"and",
"renders",
"them",
"using",
"the",
"group",
"controller",
"."
] | 0de33921da7ae678f09e782017eee33df69771e7 | https://github.com/bleonard/daily/blob/0de33921da7ae678f09e782017eee33df69771e7/app/formatters/json_formatter.rb#L64-L70 | train |
checkdin/checkdin-ruby | lib/checkdin/users.rb | Checkdin.Users.users | def users(options={})
response = connection.get do |req|
req.url "users", options
end
return_error_or_body(response)
end | ruby | def users(options={})
response = connection.get do |req|
req.url "users", options
end
return_error_or_body(response)
end | [
"def",
"users",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"users\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
")",
"end"
] | Get a list of all users for the authenticating client.
@param [Hash] options
@option options Integer :limit - The maximum number of records to return. | [
"Get",
"a",
"list",
"of",
"all",
"users",
"for",
"the",
"authenticating",
"client",
"."
] | c3c4b38b0f8c710e1f805100dcf3a70649215b48 | https://github.com/checkdin/checkdin-ruby/blob/c3c4b38b0f8c710e1f805100dcf3a70649215b48/lib/checkdin/users.rb#L18-L23 | train |
checkdin/checkdin-ruby | lib/checkdin/users.rb | Checkdin.Users.create_user | def create_user(options={})
response = connection.post do |req|
req.url "users", options
end
return_error_or_body(response)
end | ruby | def create_user(options={})
response = connection.post do |req|
req.url "users", options
end
return_error_or_body(response)
end | [
"def",
"create_user",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"post",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"users\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
")",
"end"
] | Create a user in the checkd.in system tied to the authenticating client.
@param [Hash] options
@option options String :identifier - REQUIRED, The authenticating client's internal identifier for this user.
@option options String :email - REQUIRED, A valid email for the user
@option optio... | [
"Create",
"a",
"user",
"in",
"the",
"checkd",
".",
"in",
"system",
"tied",
"to",
"the",
"authenticating",
"client",
"."
] | c3c4b38b0f8c710e1f805100dcf3a70649215b48 | https://github.com/checkdin/checkdin-ruby/blob/c3c4b38b0f8c710e1f805100dcf3a70649215b48/lib/checkdin/users.rb#L52-L57 | train |
checkdin/checkdin-ruby | lib/checkdin/users.rb | Checkdin.Users.create_user_authentication | def create_user_authentication(id, options={})
response = connection.post do |req|
req.url "users/#{id}/authentications", options
end
return_error_or_body(response)
end | ruby | def create_user_authentication(id, options={})
response = connection.post do |req|
req.url "users/#{id}/authentications", options
end
return_error_or_body(response)
end | [
"def",
"create_user_authentication",
"(",
"id",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"post",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"users/#{id}/authentications\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"re... | Create an authentication for a user
param [Integer] id The ID of the user
@param [Hash] options
@option options String :provider - The name of the provider for the authentication (twitter, facebook, foursquare, linkedin, instagram)
@option options String :uid - The user's id for the provider (on the provider's se... | [
"Create",
"an",
"authentication",
"for",
"a",
"user"
] | c3c4b38b0f8c710e1f805100dcf3a70649215b48 | https://github.com/checkdin/checkdin-ruby/blob/c3c4b38b0f8c710e1f805100dcf3a70649215b48/lib/checkdin/users.rb#L88-L93 | train |
checkdin/checkdin-ruby | lib/checkdin/users.rb | Checkdin.Users.blacklisted | def blacklisted(options={})
response = connection.get do |req|
req.url "users/blacklisted", options
end
return_error_or_body(response)
end | ruby | def blacklisted(options={})
response = connection.get do |req|
req.url "users/blacklisted", options
end
return_error_or_body(response)
end | [
"def",
"blacklisted",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"users/blacklisted\"",
",",
"options",
"end",
"return_error_or_body",
"(",
"response",
")",
"end"
] | Get a list of all blacklisted users for the authenticating client.
@param [Hash] options
@option options Integer :limit - The maximum number of records to return. | [
"Get",
"a",
"list",
"of",
"all",
"blacklisted",
"users",
"for",
"the",
"authenticating",
"client",
"."
] | c3c4b38b0f8c710e1f805100dcf3a70649215b48 | https://github.com/checkdin/checkdin-ruby/blob/c3c4b38b0f8c710e1f805100dcf3a70649215b48/lib/checkdin/users.rb#L100-L105 | train |
checkdin/checkdin-ruby | lib/checkdin/users.rb | Checkdin.Users.view_user_full_description | def view_user_full_description(id)
response = connection.get do |req|
req.url "users/#{id}/full"
end
return_error_or_body(response)
end | ruby | def view_user_full_description(id)
response = connection.get do |req|
req.url "users/#{id}/full"
end
return_error_or_body(response)
end | [
"def",
"view_user_full_description",
"(",
"id",
")",
"response",
"=",
"connection",
".",
"get",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"\"users/#{id}/full\"",
"end",
"return_error_or_body",
"(",
"response",
")",
"end"
] | View a full user's description
param [Integer] id The ID of the user | [
"View",
"a",
"full",
"user",
"s",
"description"
] | c3c4b38b0f8c710e1f805100dcf3a70649215b48 | https://github.com/checkdin/checkdin-ruby/blob/c3c4b38b0f8c710e1f805100dcf3a70649215b48/lib/checkdin/users.rb#L142-L147 | train |
mezis/dragonfly-activerecord | lib/dragonfly-activerecord/store.rb | Dragonfly::ActiveRecord.Store.write | def write(temp_object, opts={})
temp_object.file do |fd|
File.new.tap do |file|
file.metadata = temp_object.meta
file.data = fd
file.save!
return file.id.to_s
end
end
end | ruby | def write(temp_object, opts={})
temp_object.file do |fd|
File.new.tap do |file|
file.metadata = temp_object.meta
file.data = fd
file.save!
return file.id.to_s
end
end
end | [
"def",
"write",
"(",
"temp_object",
",",
"opts",
"=",
"{",
"}",
")",
"temp_object",
".",
"file",
"do",
"|",
"fd",
"|",
"File",
".",
"new",
".",
"tap",
"do",
"|",
"file",
"|",
"file",
".",
"metadata",
"=",
"temp_object",
".",
"meta",
"file",
".",
... | +temp_object+ should respond to +data+ and +meta+ | [
"+",
"temp_object",
"+",
"should",
"respond",
"to",
"+",
"data",
"+",
"and",
"+",
"meta",
"+"
] | b14735fdded33c8ca41364407f546661df446e5d | https://github.com/mezis/dragonfly-activerecord/blob/b14735fdded33c8ca41364407f546661df446e5d/lib/dragonfly-activerecord/store.rb#L9-L18 | train |
ryanuber/ruby-aptly | lib/aptly/mirror.rb | Aptly.Mirror.update | def update kwargs={}
ignore_cksum = kwargs.arg :ignore_cksum, false
ignore_sigs = kwargs.arg :ignore_sigs, false
cmd = 'aptly mirror update'
cmd += ' -ignore-checksums' if ignore_cksum
cmd += ' -ignore-signatures' if ignore_sigs
cmd += " #{@name.quote}"
Aptly::runcmd cmd
... | ruby | def update kwargs={}
ignore_cksum = kwargs.arg :ignore_cksum, false
ignore_sigs = kwargs.arg :ignore_sigs, false
cmd = 'aptly mirror update'
cmd += ' -ignore-checksums' if ignore_cksum
cmd += ' -ignore-signatures' if ignore_sigs
cmd += " #{@name.quote}"
Aptly::runcmd cmd
... | [
"def",
"update",
"kwargs",
"=",
"{",
"}",
"ignore_cksum",
"=",
"kwargs",
".",
"arg",
":ignore_cksum",
",",
"false",
"ignore_sigs",
"=",
"kwargs",
".",
"arg",
":ignore_sigs",
",",
"false",
"cmd",
"=",
"'aptly mirror update'",
"cmd",
"+=",
"' -ignore-checksums'",
... | Updates a repository, syncing in all packages which have not already been
downloaded and caches them locally.
== Parameters:
ignore_cksum::
Ignore checksum mismatches
ignore_sigs::
Ignore author signature mismatches | [
"Updates",
"a",
"repository",
"syncing",
"in",
"all",
"packages",
"which",
"have",
"not",
"already",
"been",
"downloaded",
"and",
"caches",
"them",
"locally",
"."
] | 9581c38da30119d6a61b7ddac6334ab17fc67164 | https://github.com/ryanuber/ruby-aptly/blob/9581c38da30119d6a61b7ddac6334ab17fc67164/lib/aptly/mirror.rb#L138-L148 | train |
tomdionysus/stringtree-ruby | lib/stringtree/tree.rb | StringTree.Tree.delete | def delete(key)
node = find_node(key)
return false if node.nil?
node.value = nil
node.prune
true
end | ruby | def delete(key)
node = find_node(key)
return false if node.nil?
node.value = nil
node.prune
true
end | [
"def",
"delete",
"(",
"key",
")",
"node",
"=",
"find_node",
"(",
"key",
")",
"return",
"false",
"if",
"node",
".",
"nil?",
"node",
".",
"value",
"=",
"nil",
"node",
".",
"prune",
"true",
"end"
] | Delete a key | [
"Delete",
"a",
"key"
] | b5cf8a327e80855bf4b2bd6fe71950e0cbdff215 | https://github.com/tomdionysus/stringtree-ruby/blob/b5cf8a327e80855bf4b2bd6fe71950e0cbdff215/lib/stringtree/tree.rb#L41-L47 | train |
tomdionysus/stringtree-ruby | lib/stringtree/tree.rb | StringTree.Tree.match_count | def match_count(data, list = {})
return nil if @root == nil
i=0
while (i<data.length)
node = @root.find_forward(data, i, data.length-i)
if (node!=nil && node.value!=nil)
if (!list.has_key?(node))
list[node] = 1
else
list[node] += 1
... | ruby | def match_count(data, list = {})
return nil if @root == nil
i=0
while (i<data.length)
node = @root.find_forward(data, i, data.length-i)
if (node!=nil && node.value!=nil)
if (!list.has_key?(node))
list[node] = 1
else
list[node] += 1
... | [
"def",
"match_count",
"(",
"data",
",",
"list",
"=",
"{",
"}",
")",
"return",
"nil",
"if",
"@root",
"==",
"nil",
"i",
"=",
"0",
"while",
"(",
"i",
"<",
"data",
".",
"length",
")",
"node",
"=",
"@root",
".",
"find_forward",
"(",
"data",
",",
"i",
... | Return a Hash of terminating nodes to Integer counts for a given String data,
i.e. Find the count of instances of each String in the tree in the given data. | [
"Return",
"a",
"Hash",
"of",
"terminating",
"nodes",
"to",
"Integer",
"counts",
"for",
"a",
"given",
"String",
"data",
"i",
".",
"e",
".",
"Find",
"the",
"count",
"of",
"instances",
"of",
"each",
"String",
"in",
"the",
"tree",
"in",
"the",
"given",
"da... | b5cf8a327e80855bf4b2bd6fe71950e0cbdff215 | https://github.com/tomdionysus/stringtree-ruby/blob/b5cf8a327e80855bf4b2bd6fe71950e0cbdff215/lib/stringtree/tree.rb#L86-L103 | train |
tomdionysus/stringtree-ruby | lib/stringtree/tree.rb | StringTree.Tree.find_node | def find_node(key)
return nil if @root == nil
node = @root.find_vertical(key)
(node.nil? || node.value.nil? ? nil : node)
end | ruby | def find_node(key)
return nil if @root == nil
node = @root.find_vertical(key)
(node.nil? || node.value.nil? ? nil : node)
end | [
"def",
"find_node",
"(",
"key",
")",
"return",
"nil",
"if",
"@root",
"==",
"nil",
"node",
"=",
"@root",
".",
"find_vertical",
"(",
"key",
")",
"(",
"node",
".",
"nil?",
"||",
"node",
".",
"value",
".",
"nil?",
"?",
"nil",
":",
"node",
")",
"end"
] | Find a node by its key | [
"Find",
"a",
"node",
"by",
"its",
"key"
] | b5cf8a327e80855bf4b2bd6fe71950e0cbdff215 | https://github.com/tomdionysus/stringtree-ruby/blob/b5cf8a327e80855bf4b2bd6fe71950e0cbdff215/lib/stringtree/tree.rb#L108-L112 | train |
caruby/core | lib/caruby/migration/migrator.rb | CaRuby.Migrator.migrate_to_database | def migrate_to_database(&block)
# migrate with save
tm = Jinx::Stopwatch.measure { execute_save(&block) }.elapsed
logger.debug { format_migration_time_log_message(tm) }
end | ruby | def migrate_to_database(&block)
# migrate with save
tm = Jinx::Stopwatch.measure { execute_save(&block) }.elapsed
logger.debug { format_migration_time_log_message(tm) }
end | [
"def",
"migrate_to_database",
"(",
"&",
"block",
")",
"# migrate with save",
"tm",
"=",
"Jinx",
"::",
"Stopwatch",
".",
"measure",
"{",
"execute_save",
"(",
"block",
")",
"}",
".",
"elapsed",
"logger",
".",
"debug",
"{",
"format_migration_time_log_message",
"(",... | Creates a new Migrator with the given options.
The migration configuration must provide sufficient information to build a well-formed migration
target object. For example, if the target object is a new +CaTissue::SpecimenCollectionGroup+,
then the migrator must build that SCG's required +CollectionProtocolRegistrat... | [
"Creates",
"a",
"new",
"Migrator",
"with",
"the",
"given",
"options",
"."
] | a682dc57c6fa31aef765cdd206ed3d4b4c289c60 | https://github.com/caruby/core/blob/a682dc57c6fa31aef765cdd206ed3d4b4c289c60/lib/caruby/migration/migrator.rb#L47-L51 | train |
skift/estore_conventions | lib/estore_conventions/archived_attributes.rb | EstoreConventions.ArchivedAttributes.archive_attributes_utc | def archive_attributes_utc(attribute,start_time = DEFAULT_DAYS_START.ago, end_time = DEFAULT_DAYS_END.ago)
archived_attribute_base(attribute, start_time, end_time) do |hsh, obj|
hsh[obj.send(archived_time_attribute).to_i] = obj.send(attribute)
hsh
end
end | ruby | def archive_attributes_utc(attribute,start_time = DEFAULT_DAYS_START.ago, end_time = DEFAULT_DAYS_END.ago)
archived_attribute_base(attribute, start_time, end_time) do |hsh, obj|
hsh[obj.send(archived_time_attribute).to_i] = obj.send(attribute)
hsh
end
end | [
"def",
"archive_attributes_utc",
"(",
"attribute",
",",
"start_time",
"=",
"DEFAULT_DAYS_START",
".",
"ago",
",",
"end_time",
"=",
"DEFAULT_DAYS_END",
".",
"ago",
")",
"archived_attribute_base",
"(",
"attribute",
",",
"start_time",
",",
"end_time",
")",
"do",
"|",... | temp method, for prototyping | [
"temp",
"method",
"for",
"prototyping"
] | b9f1dfa45d476ecbadaa0a50729aeef064961183 | https://github.com/skift/estore_conventions/blob/b9f1dfa45d476ecbadaa0a50729aeef064961183/lib/estore_conventions/archived_attributes.rb#L101-L107 | train |
skift/estore_conventions | lib/estore_conventions/archived_attributes.rb | EstoreConventions.ArchivedAttributes.archive_attributes_by_time | def archive_attributes_by_time(attribute,start_time = DEFAULT_DAYS_START.ago, end_time = DEFAULT_DAYS_END.ago)
archived_attribute_base(attribute, start_time, end_time) do |hsh, obj|
hsh[obj.send(archived_time_attribute)] = obj.send(attribute)
hsh
end
end | ruby | def archive_attributes_by_time(attribute,start_time = DEFAULT_DAYS_START.ago, end_time = DEFAULT_DAYS_END.ago)
archived_attribute_base(attribute, start_time, end_time) do |hsh, obj|
hsh[obj.send(archived_time_attribute)] = obj.send(attribute)
hsh
end
end | [
"def",
"archive_attributes_by_time",
"(",
"attribute",
",",
"start_time",
"=",
"DEFAULT_DAYS_START",
".",
"ago",
",",
"end_time",
"=",
"DEFAULT_DAYS_END",
".",
"ago",
")",
"archived_attribute_base",
"(",
"attribute",
",",
"start_time",
",",
"end_time",
")",
"do",
... | temp method, for prototyping
save as above, except the keys are Time objects | [
"temp",
"method",
"for",
"prototyping",
"save",
"as",
"above",
"except",
"the",
"keys",
"are",
"Time",
"objects"
] | b9f1dfa45d476ecbadaa0a50729aeef064961183 | https://github.com/skift/estore_conventions/blob/b9f1dfa45d476ecbadaa0a50729aeef064961183/lib/estore_conventions/archived_attributes.rb#L111-L117 | train |
nicholas-johnson/content_driven | lib/content_driven/page.rb | ContentDriven.Page.add_child | def add_child key, page = nil
if key.is_a? Page
page, key = key, (self.keys.length + 1).to_sym
end
page.parent = self
page.url = key
self[key] = page
end | ruby | def add_child key, page = nil
if key.is_a? Page
page, key = key, (self.keys.length + 1).to_sym
end
page.parent = self
page.url = key
self[key] = page
end | [
"def",
"add_child",
"key",
",",
"page",
"=",
"nil",
"if",
"key",
".",
"is_a?",
"Page",
"page",
",",
"key",
"=",
"key",
",",
"(",
"self",
".",
"keys",
".",
"length",
"+",
"1",
")",
".",
"to_sym",
"end",
"page",
".",
"parent",
"=",
"self",
"page",
... | Add a child page. You will seldom need to call this directly.
Instead use add_blog or add_article | [
"Add",
"a",
"child",
"page",
".",
"You",
"will",
"seldom",
"need",
"to",
"call",
"this",
"directly",
".",
"Instead",
"use",
"add_blog",
"or",
"add_article"
] | ac362677810e45d95ce21975fed841d3d65f11d7 | https://github.com/nicholas-johnson/content_driven/blob/ac362677810e45d95ce21975fed841d3d65f11d7/lib/content_driven/page.rb#L33-L40 | train |
pwnall/authpwn_rails | app/models/credentials/password.rb | Credentials.Password.check_password | def check_password(password)
return false unless key
key == self.class.hash_password(password, key.split('|', 2).first)
end | ruby | def check_password(password)
return false unless key
key == self.class.hash_password(password, key.split('|', 2).first)
end | [
"def",
"check_password",
"(",
"password",
")",
"return",
"false",
"unless",
"key",
"key",
"==",
"self",
".",
"class",
".",
"hash_password",
"(",
"password",
",",
"key",
".",
"split",
"(",
"'|'",
",",
"2",
")",
".",
"first",
")",
"end"
] | Compares a plain-text password against the password hash in this credential.
Returns +true+ for a match, +false+ otherwise. | [
"Compares",
"a",
"plain",
"-",
"text",
"password",
"against",
"the",
"password",
"hash",
"in",
"this",
"credential",
"."
] | de3bd612a00025e8dc8296a73abe3acba948db17 | https://github.com/pwnall/authpwn_rails/blob/de3bd612a00025e8dc8296a73abe3acba948db17/app/models/credentials/password.rb#L37-L40 | train |
pwnall/authpwn_rails | app/models/credentials/password.rb | Credentials.Password.password= | def password=(new_password)
@password = new_password
salt = self.class.random_salt
self.key = new_password && self.class.hash_password(new_password, salt)
end | ruby | def password=(new_password)
@password = new_password
salt = self.class.random_salt
self.key = new_password && self.class.hash_password(new_password, salt)
end | [
"def",
"password",
"=",
"(",
"new_password",
")",
"@password",
"=",
"new_password",
"salt",
"=",
"self",
".",
"class",
".",
"random_salt",
"self",
".",
"key",
"=",
"new_password",
"&&",
"self",
".",
"class",
".",
"hash_password",
"(",
"new_password",
",",
... | Password virtual attribute. | [
"Password",
"virtual",
"attribute",
"."
] | de3bd612a00025e8dc8296a73abe3acba948db17 | https://github.com/pwnall/authpwn_rails/blob/de3bd612a00025e8dc8296a73abe3acba948db17/app/models/credentials/password.rb#L53-L57 | train |
technicalpickles/has_markup | shoulda_macros/has_markup.rb | HasMarkup.Shoulda.should_have_markup | def should_have_markup(column, options = {})
options = HasMarkup::default_has_markup_options.merge(options)
should_have_instance_methods "#{column}_html"
should_require_markup column if options[:required]
should_cache_markup column if options[:cache_html]
end | ruby | def should_have_markup(column, options = {})
options = HasMarkup::default_has_markup_options.merge(options)
should_have_instance_methods "#{column}_html"
should_require_markup column if options[:required]
should_cache_markup column if options[:cache_html]
end | [
"def",
"should_have_markup",
"(",
"column",
",",
"options",
"=",
"{",
"}",
")",
"options",
"=",
"HasMarkup",
"::",
"default_has_markup_options",
".",
"merge",
"(",
"options",
")",
"should_have_instance_methods",
"\"#{column}_html\"",
"should_require_markup",
"column",
... | Ensure that the model has markup. Accepts all the same options that has_markup does.
should_have_markup :content | [
"Ensure",
"that",
"the",
"model",
"has",
"markup",
".",
"Accepts",
"all",
"the",
"same",
"options",
"that",
"has_markup",
"does",
"."
] | d02df9da091e37b5198d41fb4e6cbd7d103fe32c | https://github.com/technicalpickles/has_markup/blob/d02df9da091e37b5198d41fb4e6cbd7d103fe32c/shoulda_macros/has_markup.rb#L23-L30 | train |
jimcar/orchestrate-api | lib/orchestrate/client.rb | Orchestrate.Client.send_request | def send_request(method, args)
request = API::Request.new(method, build_url(method, args), config.api_key) do |r|
r.data = args[:json] if args[:json]
r.ref = args[:ref] if args[:ref]
end
request.perform
end | ruby | def send_request(method, args)
request = API::Request.new(method, build_url(method, args), config.api_key) do |r|
r.data = args[:json] if args[:json]
r.ref = args[:ref] if args[:ref]
end
request.perform
end | [
"def",
"send_request",
"(",
"method",
",",
"args",
")",
"request",
"=",
"API",
"::",
"Request",
".",
"new",
"(",
"method",
",",
"build_url",
"(",
"method",
",",
"args",
")",
",",
"config",
".",
"api_key",
")",
"do",
"|",
"r",
"|",
"r",
".",
"data",... | Initialize and return a new Client instance. Optionally, configure
options for the instance by passing a Configuration object. If no
custom configuration is provided, the configuration options from
Orchestrate.config will be used.
Creates the Request object and sends it via the perform method,
which generates and... | [
"Initialize",
"and",
"return",
"a",
"new",
"Client",
"instance",
".",
"Optionally",
"configure",
"options",
"for",
"the",
"instance",
"by",
"passing",
"a",
"Configuration",
"object",
".",
"If",
"no",
"custom",
"configuration",
"is",
"provided",
"the",
"configura... | 8931c41d69b9e32096db7615d0b252b971a5857d | https://github.com/jimcar/orchestrate-api/blob/8931c41d69b9e32096db7615d0b252b971a5857d/lib/orchestrate/client.rb#L46-L52 | train |
jimcar/orchestrate-api | lib/orchestrate/client.rb | Orchestrate.Client.build_url | def build_url(method, args)
API::URL.new(method, config.base_url, args).path
end | ruby | def build_url(method, args)
API::URL.new(method, config.base_url, args).path
end | [
"def",
"build_url",
"(",
"method",
",",
"args",
")",
"API",
"::",
"URL",
".",
"new",
"(",
"method",
",",
"config",
".",
"base_url",
",",
"args",
")",
".",
"path",
"end"
] | Builds the URL for each HTTP request to the orchestrate.io api. | [
"Builds",
"the",
"URL",
"for",
"each",
"HTTP",
"request",
"to",
"the",
"orchestrate",
".",
"io",
"api",
"."
] | 8931c41d69b9e32096db7615d0b252b971a5857d | https://github.com/jimcar/orchestrate-api/blob/8931c41d69b9e32096db7615d0b252b971a5857d/lib/orchestrate/client.rb#L61-L63 | train |
jamiely/simulator | lib/simulator/variable_context.rb | Simulator.VariableContext.add_variables | def add_variables(*vars)
# create bound variables for each variable
bound_vars = vars.collect do |v|
BoundVariable.new v, self
end
# add all the bound variables to the variables hash
keys = vars.collect(&:name)
append_hash = Hash[ keys.zip(bound_vars) ]
@variables_hash... | ruby | def add_variables(*vars)
# create bound variables for each variable
bound_vars = vars.collect do |v|
BoundVariable.new v, self
end
# add all the bound variables to the variables hash
keys = vars.collect(&:name)
append_hash = Hash[ keys.zip(bound_vars) ]
@variables_hash... | [
"def",
"add_variables",
"(",
"*",
"vars",
")",
"# create bound variables for each variable",
"bound_vars",
"=",
"vars",
".",
"collect",
"do",
"|",
"v",
"|",
"BoundVariable",
".",
"new",
"v",
",",
"self",
"end",
"# add all the bound variables to the variables hash",
"k... | add variables. doesn't check for uniqueness, does not overwrite existing | [
"add",
"variables",
".",
"doesn",
"t",
"check",
"for",
"uniqueness",
"does",
"not",
"overwrite",
"existing"
] | 21395b72241d8f3ca93f90eecb5e1ad2870e9f69 | https://github.com/jamiely/simulator/blob/21395b72241d8f3ca93f90eecb5e1ad2870e9f69/lib/simulator/variable_context.rb#L16-L28 | train |
jamiely/simulator | lib/simulator/variable_context.rb | Simulator.VariableContext.set | def set(var_hash)
var_hash.each do |variable_name, value|
throw :MissingVariable unless @variables_hash.has_key? variable_name
bv = @variables_hash[variable_name]
bv.value = value
end
end | ruby | def set(var_hash)
var_hash.each do |variable_name, value|
throw :MissingVariable unless @variables_hash.has_key? variable_name
bv = @variables_hash[variable_name]
bv.value = value
end
end | [
"def",
"set",
"(",
"var_hash",
")",
"var_hash",
".",
"each",
"do",
"|",
"variable_name",
",",
"value",
"|",
"throw",
":MissingVariable",
"unless",
"@variables_hash",
".",
"has_key?",
"variable_name",
"bv",
"=",
"@variables_hash",
"[",
"variable_name",
"]",
"bv",... | Use to set the value for a variety of variables | [
"Use",
"to",
"set",
"the",
"value",
"for",
"a",
"variety",
"of",
"variables"
] | 21395b72241d8f3ca93f90eecb5e1ad2870e9f69 | https://github.com/jamiely/simulator/blob/21395b72241d8f3ca93f90eecb5e1ad2870e9f69/lib/simulator/variable_context.rb#L31-L38 | train |
akwiatkowski/simple_metar_parser | lib/simple_metar_parser/metar/metar_specials.rb | SimpleMetarParser.MetarSpecials.calculate_rain_and_snow | def calculate_rain_and_snow
@snow_metar = 0
@rain_metar = 0
self.specials.each do |s|
new_rain = 0
new_snow = 0
coefficient = 1
case s[:precipitation]
when 'drizzle' then
new_rain = 5
when 'rain' then
new_rain = 10
... | ruby | def calculate_rain_and_snow
@snow_metar = 0
@rain_metar = 0
self.specials.each do |s|
new_rain = 0
new_snow = 0
coefficient = 1
case s[:precipitation]
when 'drizzle' then
new_rain = 5
when 'rain' then
new_rain = 10
... | [
"def",
"calculate_rain_and_snow",
"@snow_metar",
"=",
"0",
"@rain_metar",
"=",
"0",
"self",
".",
"specials",
".",
"each",
"do",
"|",
"s",
"|",
"new_rain",
"=",
"0",
"new_snow",
"=",
"0",
"coefficient",
"=",
"1",
"case",
"s",
"[",
":precipitation",
"]",
"... | Calculate precipitation in self defined units and aproximated real world units | [
"Calculate",
"precipitation",
"in",
"self",
"defined",
"units",
"and",
"aproximated",
"real",
"world",
"units"
] | ff8ea6162c7be6137c8e56b768784e58d7c8ad01 | https://github.com/akwiatkowski/simple_metar_parser/blob/ff8ea6162c7be6137c8e56b768784e58d7c8ad01/lib/simple_metar_parser/metar/metar_specials.rb#L139-L207 | train |
Subsets and Splits
SQL Console for semeru/code-text-ruby
Retrieves 20,000 non-null code samples labeled as Ruby, providing a basic overview of the dataset but without deeper analysis.