id int32 0 24.9k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
7,700 | Burgestrand/mellon | lib/mellon/keychain.rb | Mellon.Keychain.read | def read(key)
command "find-generic-password", "-g", "-l", key do |info, password_info|
[Utils.parse_info(info), Utils.parse_contents(password_info)]
end
rescue CommandError => e
raise unless e.message =~ ENTRY_MISSING
nil
end | ruby | def read(key)
command "find-generic-password", "-g", "-l", key do |info, password_info|
[Utils.parse_info(info), Utils.parse_contents(password_info)]
end
rescue CommandError => e
raise unless e.message =~ ENTRY_MISSING
nil
end | [
"def",
"read",
"(",
"key",
")",
"command",
"\"find-generic-password\"",
",",
"\"-g\"",
",",
"\"-l\"",
",",
"key",
"do",
"|",
"info",
",",
"password_info",
"|",
"[",
"Utils",
".",
"parse_info",
"(",
"info",
")",
",",
"Utils",
".",
"parse_contents",
"(",
"... | Read a key from the keychain.
@param [String] key
@return [Array<Hash, String>, nil] tuple of entry info, and text contents, or nil if key does not exist | [
"Read",
"a",
"key",
"from",
"the",
"keychain",
"."
] | 4ded7e28fee192a777605e5f9dcd3b1bd05770ef | https://github.com/Burgestrand/mellon/blob/4ded7e28fee192a777605e5f9dcd3b1bd05770ef/lib/mellon/keychain.rb#L142-L149 |
7,701 | Burgestrand/mellon | lib/mellon/keychain.rb | Mellon.Keychain.write | def write(key, data, options = {})
info = Utils.build_info(key, options)
command "add-generic-password",
"-a", info[:account_name],
"-s", info[:service_name],
"-l", info[:label],
"-D", info[:kind],
"-C", info[:type],
"-T", "", # which applications have access... | ruby | def write(key, data, options = {})
info = Utils.build_info(key, options)
command "add-generic-password",
"-a", info[:account_name],
"-s", info[:service_name],
"-l", info[:label],
"-D", info[:kind],
"-C", info[:type],
"-T", "", # which applications have access... | [
"def",
"write",
"(",
"key",
",",
"data",
",",
"options",
"=",
"{",
"}",
")",
"info",
"=",
"Utils",
".",
"build_info",
"(",
"key",
",",
"options",
")",
"command",
"\"add-generic-password\"",
",",
"\"-a\"",
",",
"info",
"[",
":account_name",
"]",
",",
"\... | Write data with given key to the keychain, or update existing key if it exists.
@note keychain entries are not unique by key, but also by the information
provided through options; two entries with same key but different
account name (for example), will become two different entries when
writing.
... | [
"Write",
"data",
"with",
"given",
"key",
"to",
"the",
"keychain",
"or",
"update",
"existing",
"key",
"if",
"it",
"exists",
"."
] | 4ded7e28fee192a777605e5f9dcd3b1bd05770ef | https://github.com/Burgestrand/mellon/blob/4ded7e28fee192a777605e5f9dcd3b1bd05770ef/lib/mellon/keychain.rb#L166-L178 |
7,702 | Burgestrand/mellon | lib/mellon/keychain.rb | Mellon.Keychain.delete | def delete(key, options = {})
info = Utils.build_info(key, options)
command "delete-generic-password",
"-a", info[:account_name],
"-s", info[:service_name],
"-l", info[:label],
"-D", info[:kind],
"-C", info[:type]
end | ruby | def delete(key, options = {})
info = Utils.build_info(key, options)
command "delete-generic-password",
"-a", info[:account_name],
"-s", info[:service_name],
"-l", info[:label],
"-D", info[:kind],
"-C", info[:type]
end | [
"def",
"delete",
"(",
"key",
",",
"options",
"=",
"{",
"}",
")",
"info",
"=",
"Utils",
".",
"build_info",
"(",
"key",
",",
"options",
")",
"command",
"\"delete-generic-password\"",
",",
"\"-a\"",
",",
"info",
"[",
":account_name",
"]",
",",
"\"-s\"",
","... | Delete the entry matching key and options.
@param [String] key
@param [Hash] options
@option (see #write) | [
"Delete",
"the",
"entry",
"matching",
"key",
"and",
"options",
"."
] | 4ded7e28fee192a777605e5f9dcd3b1bd05770ef | https://github.com/Burgestrand/mellon/blob/4ded7e28fee192a777605e5f9dcd3b1bd05770ef/lib/mellon/keychain.rb#L185-L194 |
7,703 | coreyward/typekit | lib/typekit/family.rb | Typekit.Family.variation | def variation(id)
variations.select { |v| v.id.split(':').last == id }.first
end | ruby | def variation(id)
variations.select { |v| v.id.split(':').last == id }.first
end | [
"def",
"variation",
"(",
"id",
")",
"variations",
".",
"select",
"{",
"|",
"v",
"|",
"v",
".",
"id",
".",
"split",
"(",
"':'",
")",
".",
"last",
"==",
"id",
"}",
".",
"first",
"end"
] | Find a variation in this Family by the Font Variation Description
@param id [String] Family/Font variation ID/Description (e.g. n4 or i7) | [
"Find",
"a",
"variation",
"in",
"this",
"Family",
"by",
"the",
"Font",
"Variation",
"Description"
] | 1e9f3749ad6066eec7fbdad50abe2ab5802e32d0 | https://github.com/coreyward/typekit/blob/1e9f3749ad6066eec7fbdad50abe2ab5802e32d0/lib/typekit/family.rb#L10-L12 |
7,704 | einzige/framework | lib/framework/application.rb | Framework.Application.load_application_files | def load_application_files
if %w(development test).include?(env.to_s)
config['autoload_paths'].each(&method(:autoreload_constants))
autoreload_yml
end
config['autoload_paths'].each(&method(:require_dependencies))
end | ruby | def load_application_files
if %w(development test).include?(env.to_s)
config['autoload_paths'].each(&method(:autoreload_constants))
autoreload_yml
end
config['autoload_paths'].each(&method(:require_dependencies))
end | [
"def",
"load_application_files",
"if",
"%w(",
"development",
"test",
")",
".",
"include?",
"(",
"env",
".",
"to_s",
")",
"config",
"[",
"'autoload_paths'",
"]",
".",
"each",
"(",
"method",
"(",
":autoreload_constants",
")",
")",
"autoreload_yml",
"end",
"confi... | Autoloads all app-specific files | [
"Autoloads",
"all",
"app",
"-",
"specific",
"files"
] | 5a8a2255265118aa244cdabac29fd1ce7f885118 | https://github.com/einzige/framework/blob/5a8a2255265118aa244cdabac29fd1ce7f885118/lib/framework/application.rb#L121-L127 |
7,705 | spoved/ruby-comicvine-api | lib/comicvine/resource.rb | ComicVine.Resource.fetch! | def fetch!
obj = ComicVine::API.get_details_by_url(self.api_detail_url)
self.methods.each do |m|
# Look for methods that can be set (i.e. ends with a =)
if m.to_s =~ /^(?!_)([\w\d\_]+)=$/
# Save our method symbols in a more readable fashion
get_m = $1.to_sym
set... | ruby | def fetch!
obj = ComicVine::API.get_details_by_url(self.api_detail_url)
self.methods.each do |m|
# Look for methods that can be set (i.e. ends with a =)
if m.to_s =~ /^(?!_)([\w\d\_]+)=$/
# Save our method symbols in a more readable fashion
get_m = $1.to_sym
set... | [
"def",
"fetch!",
"obj",
"=",
"ComicVine",
"::",
"API",
".",
"get_details_by_url",
"(",
"self",
".",
"api_detail_url",
")",
"self",
".",
"methods",
".",
"each",
"do",
"|",
"m",
"|",
"# Look for methods that can be set (i.e. ends with a =)",
"if",
"m",
".",
"to_s"... | Fetches data from ComicVine based on objects api_detail_url and updates self with new values
@return [ComicVine::Resource]
@since 0.1.2 | [
"Fetches",
"data",
"from",
"ComicVine",
"based",
"on",
"objects",
"api_detail_url",
"and",
"updates",
"self",
"with",
"new",
"values"
] | 08c993487ce4a513529d11a2e86f69e6f8d53bb3 | https://github.com/spoved/ruby-comicvine-api/blob/08c993487ce4a513529d11a2e86f69e6f8d53bb3/lib/comicvine/resource.rb#L41-L61 |
7,706 | simplelogica/pluckers | lib/pluckers/base.rb | Pluckers.Base.configure_query | def configure_query
@query_to_pluck = @records
@attributes_to_pluck = [{ name: @query_to_pluck.primary_key.to_sym, sql: "\"#{@query_to_pluck.table_name}\".#{@query_to_pluck.primary_key}" }]
@results = {}
@klass_reflections = @query_to_pluck.reflections.with_indifferent_access
pluck_reflec... | ruby | def configure_query
@query_to_pluck = @records
@attributes_to_pluck = [{ name: @query_to_pluck.primary_key.to_sym, sql: "\"#{@query_to_pluck.table_name}\".#{@query_to_pluck.primary_key}" }]
@results = {}
@klass_reflections = @query_to_pluck.reflections.with_indifferent_access
pluck_reflec... | [
"def",
"configure_query",
"@query_to_pluck",
"=",
"@records",
"@attributes_to_pluck",
"=",
"[",
"{",
"name",
":",
"@query_to_pluck",
".",
"primary_key",
".",
"to_sym",
",",
"sql",
":",
"\"\\\"#{@query_to_pluck.table_name}\\\".#{@query_to_pluck.primary_key}\"",
"}",
"]",
"... | In this base implementation we just reset all the query information.
Features and subclasses must redefine this method if they are interested
in adding some behaviour. | [
"In",
"this",
"base",
"implementation",
"we",
"just",
"reset",
"all",
"the",
"query",
"information",
".",
"Features",
"and",
"subclasses",
"must",
"redefine",
"this",
"method",
"if",
"they",
"are",
"interested",
"in",
"adding",
"some",
"behaviour",
"."
] | 73fabd5ba058722bac2950efa5549f417e435651 | https://github.com/simplelogica/pluckers/blob/73fabd5ba058722bac2950efa5549f417e435651/lib/pluckers/base.rb#L107-L119 |
7,707 | simplelogica/pluckers | lib/pluckers/base.rb | Pluckers.Base.build_results | def build_results
# Now we uinq the attributes
@attributes_to_pluck.uniq!{|f| f[:name] }
# Obtain both the names and SQL columns
names_to_pluck = @attributes_to_pluck.map{|f| f[:name] }
sql_to_pluck = @attributes_to_pluck.map{|f| f[:sql] }
# And perform the real ActiveRecord pluc... | ruby | def build_results
# Now we uinq the attributes
@attributes_to_pluck.uniq!{|f| f[:name] }
# Obtain both the names and SQL columns
names_to_pluck = @attributes_to_pluck.map{|f| f[:name] }
sql_to_pluck = @attributes_to_pluck.map{|f| f[:sql] }
# And perform the real ActiveRecord pluc... | [
"def",
"build_results",
"# Now we uinq the attributes",
"@attributes_to_pluck",
".",
"uniq!",
"{",
"|",
"f",
"|",
"f",
"[",
":name",
"]",
"}",
"# Obtain both the names and SQL columns",
"names_to_pluck",
"=",
"@attributes_to_pluck",
".",
"map",
"{",
"|",
"f",
"|",
"... | In this base implementation we perform the real pluck execution.
The method collects all the attributes and columns to pluck and add it
to the results array. | [
"In",
"this",
"base",
"implementation",
"we",
"perform",
"the",
"real",
"pluck",
"execution",
"."
] | 73fabd5ba058722bac2950efa5549f417e435651 | https://github.com/simplelogica/pluckers/blob/73fabd5ba058722bac2950efa5549f417e435651/lib/pluckers/base.rb#L126-L152 |
7,708 | jemmyw/bisques | lib/bisques/aws_request_authorization.rb | Bisques.AwsRequestAuthorization.signing_key | def signing_key
digest = "SHA256"
kDate = OpenSSL::HMAC.digest(digest, "AWS4" + credentials.aws_secret, request_datestamp)
kRegion = OpenSSL::HMAC.digest(digest, kDate, region)
kService = OpenSSL::HMAC.digest(digest, kRegion, service)
OpenSSL::HMAC.digest(digest, kService, "aws4_request")
... | ruby | def signing_key
digest = "SHA256"
kDate = OpenSSL::HMAC.digest(digest, "AWS4" + credentials.aws_secret, request_datestamp)
kRegion = OpenSSL::HMAC.digest(digest, kDate, region)
kService = OpenSSL::HMAC.digest(digest, kRegion, service)
OpenSSL::HMAC.digest(digest, kService, "aws4_request")
... | [
"def",
"signing_key",
"digest",
"=",
"\"SHA256\"",
"kDate",
"=",
"OpenSSL",
"::",
"HMAC",
".",
"digest",
"(",
"digest",
",",
"\"AWS4\"",
"+",
"credentials",
".",
"aws_secret",
",",
"request_datestamp",
")",
"kRegion",
"=",
"OpenSSL",
"::",
"HMAC",
".",
"dige... | Calculate the signing key for task 3. | [
"Calculate",
"the",
"signing",
"key",
"for",
"task",
"3",
"."
] | c48ab555f07664752bcbf9e8deb99bd75cbdc41b | https://github.com/jemmyw/bisques/blob/c48ab555f07664752bcbf9e8deb99bd75cbdc41b/lib/bisques/aws_request_authorization.rb#L103-L109 |
7,709 | jemmyw/bisques | lib/bisques/aws_request_authorization.rb | Bisques.AwsRequestAuthorization.canonical_headers | def canonical_headers
hash = headers.dup
hash["host"] ||= Addressable::URI.parse(url).host
hash = hash.map{|name,value| [name.downcase,value]}
hash.reject!{|name,value| name == "authorization"}
hash.sort
end | ruby | def canonical_headers
hash = headers.dup
hash["host"] ||= Addressable::URI.parse(url).host
hash = hash.map{|name,value| [name.downcase,value]}
hash.reject!{|name,value| name == "authorization"}
hash.sort
end | [
"def",
"canonical_headers",
"hash",
"=",
"headers",
".",
"dup",
"hash",
"[",
"\"host\"",
"]",
"||=",
"Addressable",
"::",
"URI",
".",
"parse",
"(",
"url",
")",
".",
"host",
"hash",
"=",
"hash",
".",
"map",
"{",
"|",
"name",
",",
"value",
"|",
"[",
... | The canonical headers, including the Host. | [
"The",
"canonical",
"headers",
"including",
"the",
"Host",
"."
] | c48ab555f07664752bcbf9e8deb99bd75cbdc41b | https://github.com/jemmyw/bisques/blob/c48ab555f07664752bcbf9e8deb99bd75cbdc41b/lib/bisques/aws_request_authorization.rb#L162-L168 |
7,710 | layerhq/migration_bundler | lib/migration_bundler/actions.rb | MigrationBundler.Actions.git | def git(commands={})
if commands.is_a?(Symbol)
run "git #{commands}"
else
commands.each do |cmd, options|
run "git #{cmd} #{options}"
end
end
end | ruby | def git(commands={})
if commands.is_a?(Symbol)
run "git #{commands}"
else
commands.each do |cmd, options|
run "git #{cmd} #{options}"
end
end
end | [
"def",
"git",
"(",
"commands",
"=",
"{",
"}",
")",
"if",
"commands",
".",
"is_a?",
"(",
"Symbol",
")",
"run",
"\"git #{commands}\"",
"else",
"commands",
".",
"each",
"do",
"|",
"cmd",
",",
"options",
"|",
"run",
"\"git #{cmd} #{options}\"",
"end",
"end",
... | Run a command in git.
git :init
git add: "this.file that.rb"
git add: "onefile.rb", rm: "badfile.cxx" | [
"Run",
"a",
"command",
"in",
"git",
"."
] | de7a3345daccd3a9fe47da818742812944c8daa4 | https://github.com/layerhq/migration_bundler/blob/de7a3345daccd3a9fe47da818742812944c8daa4/lib/migration_bundler/actions.rb#L8-L16 |
7,711 | m-31/puppetdb_query | lib/puppetdb_query/puppetdb.rb | PuppetDBQuery.PuppetDB.node_properties | def node_properties
result = {}
api_nodes.each do |data|
next if data['deactivated']
# in '/v3/nodes' we must take 'name'
name = data['certname']
values = data.dup
%w[deactivated certname].each { |key| values.delete(key) }
result[name] = values
end
... | ruby | def node_properties
result = {}
api_nodes.each do |data|
next if data['deactivated']
# in '/v3/nodes' we must take 'name'
name = data['certname']
values = data.dup
%w[deactivated certname].each { |key| values.delete(key) }
result[name] = values
end
... | [
"def",
"node_properties",
"result",
"=",
"{",
"}",
"api_nodes",
".",
"each",
"do",
"|",
"data",
"|",
"next",
"if",
"data",
"[",
"'deactivated'",
"]",
"# in '/v3/nodes' we must take 'name'",
"name",
"=",
"data",
"[",
"'certname'",
"]",
"values",
"=",
"data",
... | get hash of node update properties | [
"get",
"hash",
"of",
"node",
"update",
"properties"
] | 58103c91f291de8ce28d679256e50ae391b93ecb | https://github.com/m-31/puppetdb_query/blob/58103c91f291de8ce28d679256e50ae391b93ecb/lib/puppetdb_query/puppetdb.rb#L26-L37 |
7,712 | m-31/puppetdb_query | lib/puppetdb_query/puppetdb.rb | PuppetDBQuery.PuppetDB.nodes_update_facts_since | def nodes_update_facts_since(timestamp)
ts = (timestamp.is_a?(String) ? Time.iso8601(ts) : timestamp)
node_properties.delete_if do |_k, data|
# in '/v3/nodes' we must take 'facts-timestamp'
!data["facts_timestamp"] || Time.iso8601(data["facts_timestamp"]) < ts
end.keys
end | ruby | def nodes_update_facts_since(timestamp)
ts = (timestamp.is_a?(String) ? Time.iso8601(ts) : timestamp)
node_properties.delete_if do |_k, data|
# in '/v3/nodes' we must take 'facts-timestamp'
!data["facts_timestamp"] || Time.iso8601(data["facts_timestamp"]) < ts
end.keys
end | [
"def",
"nodes_update_facts_since",
"(",
"timestamp",
")",
"ts",
"=",
"(",
"timestamp",
".",
"is_a?",
"(",
"String",
")",
"?",
"Time",
".",
"iso8601",
"(",
"ts",
")",
":",
"timestamp",
")",
"node_properties",
".",
"delete_if",
"do",
"|",
"_k",
",",
"data"... | get all nodes that have updated facts | [
"get",
"all",
"nodes",
"that",
"have",
"updated",
"facts"
] | 58103c91f291de8ce28d679256e50ae391b93ecb | https://github.com/m-31/puppetdb_query/blob/58103c91f291de8ce28d679256e50ae391b93ecb/lib/puppetdb_query/puppetdb.rb#L40-L46 |
7,713 | m-31/puppetdb_query | lib/puppetdb_query/puppetdb.rb | PuppetDBQuery.PuppetDB.single_node_facts | def single_node_facts(node)
json = get_json("#{@nodes_url}/#{node}/facts", 10)
return nil if json.include?("error")
Hash[json.map { |data| [data["name"], data["value"]] }]
end | ruby | def single_node_facts(node)
json = get_json("#{@nodes_url}/#{node}/facts", 10)
return nil if json.include?("error")
Hash[json.map { |data| [data["name"], data["value"]] }]
end | [
"def",
"single_node_facts",
"(",
"node",
")",
"json",
"=",
"get_json",
"(",
"\"#{@nodes_url}/#{node}/facts\"",
",",
"10",
")",
"return",
"nil",
"if",
"json",
".",
"include?",
"(",
"\"error\"",
")",
"Hash",
"[",
"json",
".",
"map",
"{",
"|",
"data",
"|",
... | get hash of facts for given node name | [
"get",
"hash",
"of",
"facts",
"for",
"given",
"node",
"name"
] | 58103c91f291de8ce28d679256e50ae391b93ecb | https://github.com/m-31/puppetdb_query/blob/58103c91f291de8ce28d679256e50ae391b93ecb/lib/puppetdb_query/puppetdb.rb#L49-L53 |
7,714 | m-31/puppetdb_query | lib/puppetdb_query/puppetdb.rb | PuppetDBQuery.PuppetDB.facts | def facts
json = get_json(@facts_url, 60)
result = {}
json.each do |fact|
data = result[fact["certname"]]
result[fact["certname"]] = data = {} unless data
data[fact["name"]] = fact["value"]
end
result
end | ruby | def facts
json = get_json(@facts_url, 60)
result = {}
json.each do |fact|
data = result[fact["certname"]]
result[fact["certname"]] = data = {} unless data
data[fact["name"]] = fact["value"]
end
result
end | [
"def",
"facts",
"json",
"=",
"get_json",
"(",
"@facts_url",
",",
"60",
")",
"result",
"=",
"{",
"}",
"json",
".",
"each",
"do",
"|",
"fact",
"|",
"data",
"=",
"result",
"[",
"fact",
"[",
"\"certname\"",
"]",
"]",
"result",
"[",
"fact",
"[",
"\"cert... | get all nodes with all facts | [
"get",
"all",
"nodes",
"with",
"all",
"facts"
] | 58103c91f291de8ce28d679256e50ae391b93ecb | https://github.com/m-31/puppetdb_query/blob/58103c91f291de8ce28d679256e50ae391b93ecb/lib/puppetdb_query/puppetdb.rb#L56-L65 |
7,715 | bmizerany/swirl | lib/swirl/aws.rb | Swirl.AWS.call | def call(action, query={}, &blk)
call!(action, expand(query)) do |code, data|
case code
when 200
response = compact(data)
when 400...500
messages = if data["Response"]
Array(data["Response"]["Errors"]).map {|_, e| e["Message"] }
elsif data["ErrorRe... | ruby | def call(action, query={}, &blk)
call!(action, expand(query)) do |code, data|
case code
when 200
response = compact(data)
when 400...500
messages = if data["Response"]
Array(data["Response"]["Errors"]).map {|_, e| e["Message"] }
elsif data["ErrorRe... | [
"def",
"call",
"(",
"action",
",",
"query",
"=",
"{",
"}",
",",
"&",
"blk",
")",
"call!",
"(",
"action",
",",
"expand",
"(",
"query",
")",
")",
"do",
"|",
"code",
",",
"data",
"|",
"case",
"code",
"when",
"200",
"response",
"=",
"compact",
"(",
... | Execute an EC2 command, expand the input,
and compact the output
Examples:
ec2.call("DescribeInstances")
ec2.call("TerminateInstances", "InstanceId" => ["i-1234", "i-993j"] | [
"Execute",
"an",
"EC2",
"command",
"expand",
"the",
"input",
"and",
"compact",
"the",
"output"
] | e3fe63a7067329fb95752d96e50332af386c776b | https://github.com/bmizerany/swirl/blob/e3fe63a7067329fb95752d96e50332af386c776b/lib/swirl/aws.rb#L95-L118 |
7,716 | roja/words | lib/wordnet_connectors/pure_wordnet_connection.rb | Words.PureWordnetConnection.open! | def open!
raise BadWordnetDataset, "Failed to locate the wordnet database. Please ensure it is installed and that if it resides at a custom path that path is given as an argument when constructing the Words object." if @wordnet_path.nil?
@connected = true
# try and open evocations too
evocation_p... | ruby | def open!
raise BadWordnetDataset, "Failed to locate the wordnet database. Please ensure it is installed and that if it resides at a custom path that path is given as an argument when constructing the Words object." if @wordnet_path.nil?
@connected = true
# try and open evocations too
evocation_p... | [
"def",
"open!",
"raise",
"BadWordnetDataset",
",",
"\"Failed to locate the wordnet database. Please ensure it is installed and that if it resides at a custom path that path is given as an argument when constructing the Words object.\"",
"if",
"@wordnet_path",
".",
"nil?",
"@connected",
"=",
... | Constructs a new pure ruby connector for use with the words wordnet class.
@param [Pathname] data_path Specifies the directory within which constructed datasets can be found (evocations etc...)
@param [Pathname] wordnet_path Specifies the directory within which the wordnet dictionary can be found.
@return [PureWord... | [
"Constructs",
"a",
"new",
"pure",
"ruby",
"connector",
"for",
"use",
"with",
"the",
"words",
"wordnet",
"class",
"."
] | 4d6302e7218533fcc2afb4cd993686dd56fe2cde | https://github.com/roja/words/blob/4d6302e7218533fcc2afb4cd993686dd56fe2cde/lib/wordnet_connectors/pure_wordnet_connection.rb#L64-L77 |
7,717 | roja/words | lib/wordnet_connectors/pure_wordnet_connection.rb | Words.PureWordnetConnection.homographs | def homographs(term, use_cache = true)
raise NoWordnetConnection, "There is presently no connection to wordnet. To attempt to reistablish a connection you should use the 'open!' command on the Wordnet object." unless connected?
# Ensure that the term is either in the cache. If not, locate and add it if poss... | ruby | def homographs(term, use_cache = true)
raise NoWordnetConnection, "There is presently no connection to wordnet. To attempt to reistablish a connection you should use the 'open!' command on the Wordnet object." unless connected?
# Ensure that the term is either in the cache. If not, locate and add it if poss... | [
"def",
"homographs",
"(",
"term",
",",
"use_cache",
"=",
"true",
")",
"raise",
"NoWordnetConnection",
",",
"\"There is presently no connection to wordnet. To attempt to reistablish a connection you should use the 'open!' command on the Wordnet object.\"",
"unless",
"connected?",
"# Ens... | Locates from a term any relevent homographs and constructs a homographs hash.
@param [String] term The specific term that is desired from within wordnet.
@param [true, false] use_cache Specify whether to use caching when finding and retreving terms.
@result [Hash, nil] A hash in the format { 'lemma' => ..., 'tagsen... | [
"Locates",
"from",
"a",
"term",
"any",
"relevent",
"homographs",
"and",
"constructs",
"a",
"homographs",
"hash",
"."
] | 4d6302e7218533fcc2afb4cd993686dd56fe2cde | https://github.com/roja/words/blob/4d6302e7218533fcc2afb4cd993686dd56fe2cde/lib/wordnet_connectors/pure_wordnet_connection.rb#L94-L104 |
7,718 | roja/words | lib/wordnet_connectors/pure_wordnet_connection.rb | Words.PureWordnetConnection.synset | def synset(synset_id)
raise NoWordnetConnection, "There is presently no connection to wordnet. To attempt to reistablish a connection you should use the 'open!' command on the Wordnet object." unless connected?
pos = synset_id[0,1]
File.open(@wordnet_path + "data.#{SHORT_TO_POS_FILE_TYPE[pos]}","r") do... | ruby | def synset(synset_id)
raise NoWordnetConnection, "There is presently no connection to wordnet. To attempt to reistablish a connection you should use the 'open!' command on the Wordnet object." unless connected?
pos = synset_id[0,1]
File.open(@wordnet_path + "data.#{SHORT_TO_POS_FILE_TYPE[pos]}","r") do... | [
"def",
"synset",
"(",
"synset_id",
")",
"raise",
"NoWordnetConnection",
",",
"\"There is presently no connection to wordnet. To attempt to reistablish a connection you should use the 'open!' command on the Wordnet object.\"",
"unless",
"connected?",
"pos",
"=",
"synset_id",
"[",
"0",
... | Locates from a synset_id a specific synset and constructs a synset hash.
@param [String] synset_id The synset id to locate.
@result [Hash, nil] A hash in the format { "synset_id" => ..., "lexical_filenum" => ..., "synset_type" => ..., "words" => ..., "relations" => ..., "gloss" => ... }, or nil if no synset is avail... | [
"Locates",
"from",
"a",
"synset_id",
"a",
"specific",
"synset",
"and",
"constructs",
"a",
"synset",
"hash",
"."
] | 4d6302e7218533fcc2afb4cd993686dd56fe2cde | https://github.com/roja/words/blob/4d6302e7218533fcc2afb4cd993686dd56fe2cde/lib/wordnet_connectors/pure_wordnet_connection.rb#L111-L125 |
7,719 | roja/words | lib/wordnet_connectors/pure_wordnet_connection.rb | Words.PureWordnetConnection.evocations | def evocations(synset_id)
raise NoWordnetConnection, "There is presently no connection to wordnet. To attempt to reistablish a connection you should use the 'open!' command on the Wordnet object." unless connected?
if defined? @evocations
raw_evocations = @evocations[synset_id + "s"]
{ 'relations' => ra... | ruby | def evocations(synset_id)
raise NoWordnetConnection, "There is presently no connection to wordnet. To attempt to reistablish a connection you should use the 'open!' command on the Wordnet object." unless connected?
if defined? @evocations
raw_evocations = @evocations[synset_id + "s"]
{ 'relations' => ra... | [
"def",
"evocations",
"(",
"synset_id",
")",
"raise",
"NoWordnetConnection",
",",
"\"There is presently no connection to wordnet. To attempt to reistablish a connection you should use the 'open!' command on the Wordnet object.\"",
"unless",
"connected?",
"if",
"defined?",
"@evocations",
"... | Locates from a synset id any relevent evocations and constructs an evocations hash.
@see Synset
@param [String] senset_id The id number of a specific synset.
@result [Hash, nil] A hash in the format { 'relations' => ..., 'means' => ..., 'medians' => ... }, or nil if no evocations are available.
@raise [NoWordnetCo... | [
"Locates",
"from",
"a",
"synset",
"id",
"any",
"relevent",
"evocations",
"and",
"constructs",
"an",
"evocations",
"hash",
"."
] | 4d6302e7218533fcc2afb4cd993686dd56fe2cde | https://github.com/roja/words/blob/4d6302e7218533fcc2afb4cd993686dd56fe2cde/lib/wordnet_connectors/pure_wordnet_connection.rb#L142-L153 |
7,720 | jackjennings/hey | lib/hey/account.rb | Hey.Account.create | def create name, password, params = {}
params.merge!({
new_account_username: name,
new_account_passcode: password
})
post 'accounts', params
end | ruby | def create name, password, params = {}
params.merge!({
new_account_username: name,
new_account_passcode: password
})
post 'accounts', params
end | [
"def",
"create",
"name",
",",
"password",
",",
"params",
"=",
"{",
"}",
"params",
".",
"merge!",
"(",
"{",
"new_account_username",
":",
"name",
",",
"new_account_passcode",
":",
"password",
"}",
")",
"post",
"'accounts'",
",",
"params",
"end"
] | Sends a request to create an account using the +accounts+ endpoint.
Raises a +MissingAPITokenError+ error if an API token
hasn't been set on the Hey module or Yo instance.
Accepts an optional hash of additional parameters to
send with the request.
Hey::Account.new.create "worldcup", "somepass", email: "[email protected]... | [
"Sends",
"a",
"request",
"to",
"create",
"an",
"account",
"using",
"the",
"+",
"accounts",
"+",
"endpoint",
".",
"Raises",
"a",
"+",
"MissingAPITokenError",
"+",
"error",
"if",
"an",
"API",
"token",
"hasn",
"t",
"been",
"set",
"on",
"the",
"Hey",
"module... | 51eb3412f39f51d6f5e3bea5a0c1483766cf6139 | https://github.com/jackjennings/hey/blob/51eb3412f39f51d6f5e3bea5a0c1483766cf6139/lib/hey/account.rb#L14-L20 |
7,721 | nanodeath/threadz | lib/threadz/batch.rb | Threadz.Batch.when_done | def when_done(&block)
call_block = false
@job_lock.synchronize do
if completed?
call_block = true
else
@when_done_callbacks << block
end
end
yield if call_block
end | ruby | def when_done(&block)
call_block = false
@job_lock.synchronize do
if completed?
call_block = true
else
@when_done_callbacks << block
end
end
yield if call_block
end | [
"def",
"when_done",
"(",
"&",
"block",
")",
"call_block",
"=",
"false",
"@job_lock",
".",
"synchronize",
"do",
"if",
"completed?",
"call_block",
"=",
"true",
"else",
"@when_done_callbacks",
"<<",
"block",
"end",
"end",
"yield",
"if",
"call_block",
"end"
] | Execute a given block when the batch has finished processing. If the batch
has already finished executing, execute immediately. | [
"Execute",
"a",
"given",
"block",
"when",
"the",
"batch",
"has",
"finished",
"processing",
".",
"If",
"the",
"batch",
"has",
"already",
"finished",
"executing",
"execute",
"immediately",
"."
] | 5d96e052567076d5e86690f3d3703f1082330dd5 | https://github.com/nanodeath/threadz/blob/5d96e052567076d5e86690f3d3703f1082330dd5/lib/threadz/batch.rb#L118-L128 |
7,722 | rightscale/right_develop | lib/right_develop/commands/git.rb | RightDevelop::Commands.Git.prune | def prune(options={})
puts describe_prune(options)
puts "Fetching latest branches and tags from remotes"
@git.fetch_all(:prune => true)
branches = @git.branches(:all => true)
#Filter by name prefix
branches = branches.select { |x| x =~ options[:only] } if options[:only]
bran... | ruby | def prune(options={})
puts describe_prune(options)
puts "Fetching latest branches and tags from remotes"
@git.fetch_all(:prune => true)
branches = @git.branches(:all => true)
#Filter by name prefix
branches = branches.select { |x| x =~ options[:only] } if options[:only]
bran... | [
"def",
"prune",
"(",
"options",
"=",
"{",
"}",
")",
"puts",
"describe_prune",
"(",
"options",
")",
"puts",
"\"Fetching latest branches and tags from remotes\"",
"@git",
".",
"fetch_all",
"(",
":prune",
"=>",
"true",
")",
"branches",
"=",
"@git",
".",
"branches",... | Prune dead branches from the repository.
@option options [Time] :age Ignore branches whose HEAD commit is newer than this timestamp
@option options [Regexp] :except Ignore branches matching this pattern
@option options [Regexp] :only Consider only branches matching this pattern
@option options [Boolean] :local Con... | [
"Prune",
"dead",
"branches",
"from",
"the",
"repository",
"."
] | 52527b3c32200b542ed590f6f9a275c76758df0e | https://github.com/rightscale/right_develop/blob/52527b3c32200b542ed590f6f9a275c76758df0e/lib/right_develop/commands/git.rb#L165-L230 |
7,723 | rightscale/right_develop | lib/right_develop/commands/git.rb | RightDevelop::Commands.Git.describe_prune | def describe_prune(options)
statement = ['Pruning']
if options[:remote]
statement << 'remote'
elsif options[:local]
statement << 'local'
end
statement << 'branches'
if options[:age]
statement << "older than #{time_ago_in_words(options[:age])}"
end
... | ruby | def describe_prune(options)
statement = ['Pruning']
if options[:remote]
statement << 'remote'
elsif options[:local]
statement << 'local'
end
statement << 'branches'
if options[:age]
statement << "older than #{time_ago_in_words(options[:age])}"
end
... | [
"def",
"describe_prune",
"(",
"options",
")",
"statement",
"=",
"[",
"'Pruning'",
"]",
"if",
"options",
"[",
":remote",
"]",
"statement",
"<<",
"'remote'",
"elsif",
"options",
"[",
":local",
"]",
"statement",
"<<",
"'local'",
"end",
"statement",
"<<",
"'bran... | Build a plain-English description of a prune command based on the
options given.
@param [Hash] options | [
"Build",
"a",
"plain",
"-",
"English",
"description",
"of",
"a",
"prune",
"command",
"based",
"on",
"the",
"options",
"given",
"."
] | 52527b3c32200b542ed590f6f9a275c76758df0e | https://github.com/rightscale/right_develop/blob/52527b3c32200b542ed590f6f9a275c76758df0e/lib/right_develop/commands/git.rb#L288-L316 |
7,724 | rightscale/right_develop | lib/right_develop/commands/git.rb | RightDevelop::Commands.Git.prompt | def prompt(p, yes_no=false)
puts #newline for newline's sake!
loop do
print p, ' '
line = STDIN.readline.strip
if yes_no
return true if line =~ YES
return false if line =~ NO
else
return line
end
end
end | ruby | def prompt(p, yes_no=false)
puts #newline for newline's sake!
loop do
print p, ' '
line = STDIN.readline.strip
if yes_no
return true if line =~ YES
return false if line =~ NO
else
return line
end
end
end | [
"def",
"prompt",
"(",
"p",
",",
"yes_no",
"=",
"false",
")",
"puts",
"#newline for newline's sake!",
"loop",
"do",
"print",
"p",
",",
"' '",
"line",
"=",
"STDIN",
".",
"readline",
".",
"strip",
"if",
"yes_no",
"return",
"true",
"if",
"line",
"=~",
"YES",... | Ask the user a yes-or-no question | [
"Ask",
"the",
"user",
"a",
"yes",
"-",
"or",
"-",
"no",
"question"
] | 52527b3c32200b542ed590f6f9a275c76758df0e | https://github.com/rightscale/right_develop/blob/52527b3c32200b542ed590f6f9a275c76758df0e/lib/right_develop/commands/git.rb#L319-L332 |
7,725 | rightscale/right_develop | lib/right_develop/commands/git.rb | RightDevelop::Commands.Git.parse_age | def parse_age(str)
ord, word = str.split(/[. ]+/, 2)
ord = Integer(ord)
word.gsub!(/s$/, '')
ago = nil
TIME_INTERVALS.each do |pair|
mag, term = pair.first, pair.last
if term == word
ago = Time.at(Time.now.to_i - ord * mag)
break
end
... | ruby | def parse_age(str)
ord, word = str.split(/[. ]+/, 2)
ord = Integer(ord)
word.gsub!(/s$/, '')
ago = nil
TIME_INTERVALS.each do |pair|
mag, term = pair.first, pair.last
if term == word
ago = Time.at(Time.now.to_i - ord * mag)
break
end
... | [
"def",
"parse_age",
"(",
"str",
")",
"ord",
",",
"word",
"=",
"str",
".",
"split",
"(",
"/",
"/",
",",
"2",
")",
"ord",
"=",
"Integer",
"(",
"ord",
")",
"word",
".",
"gsub!",
"(",
"/",
"/",
",",
"''",
")",
"ago",
"=",
"nil",
"TIME_INTERVALS",
... | Given a natural-language English description of a time duration, return a Time in the past,
that is the same duration from Time.now that is expressed in the string.
@param [String] str an English time duration
@return [Time] a Time object in the past, as described relative to now by str | [
"Given",
"a",
"natural",
"-",
"language",
"English",
"description",
"of",
"a",
"time",
"duration",
"return",
"a",
"Time",
"in",
"the",
"past",
"that",
"is",
"the",
"same",
"duration",
"from",
"Time",
".",
"now",
"that",
"is",
"expressed",
"in",
"the",
"s... | 52527b3c32200b542ed590f6f9a275c76758df0e | https://github.com/rightscale/right_develop/blob/52527b3c32200b542ed590f6f9a275c76758df0e/lib/right_develop/commands/git.rb#L382-L403 |
7,726 | wilkosz/squash_matrix | lib/squash_matrix/client.rb | SquashMatrix.Client.get_save_params | def get_save_params
{
player: @player,
email: @email,
password: @password,
suppress_errors: @suppress_errors,
timeout: @timeout,
user_agent: @user_agent,
cookie: get_cookie_string,
expires: @expires.to_s,
proxy_addr: @proxy_addr,
prox... | ruby | def get_save_params
{
player: @player,
email: @email,
password: @password,
suppress_errors: @suppress_errors,
timeout: @timeout,
user_agent: @user_agent,
cookie: get_cookie_string,
expires: @expires.to_s,
proxy_addr: @proxy_addr,
prox... | [
"def",
"get_save_params",
"{",
"player",
":",
"@player",
",",
"email",
":",
"@email",
",",
"password",
":",
"@password",
",",
"suppress_errors",
":",
"@suppress_errors",
",",
"timeout",
":",
"@timeout",
",",
"user_agent",
":",
"@user_agent",
",",
"cookie",
":"... | Returns params to create existing authenticated client
@return [Hash] | [
"Returns",
"params",
"to",
"create",
"existing",
"authenticated",
"client"
] | ce3d3e191004905d31fdc96e4439c6290141d8da | https://github.com/wilkosz/squash_matrix/blob/ce3d3e191004905d31fdc96e4439c6290141d8da/lib/squash_matrix/client.rb#L22-L35 |
7,727 | wilkosz/squash_matrix | lib/squash_matrix/client.rb | SquashMatrix.Client.get_club_info | def get_club_info(id = nil)
return unless id.to_i.positive?
uri = URI::HTTP.build(
host: SquashMatrix::Constants::SQUASH_MATRIX_URL,
path: SquashMatrix::Constants::CLUB_PATH.gsub(':id', id.to_s)
)
success_proc = lambda do |res|
SquashMatrix::NokogiriParser.get_club_info(r... | ruby | def get_club_info(id = nil)
return unless id.to_i.positive?
uri = URI::HTTP.build(
host: SquashMatrix::Constants::SQUASH_MATRIX_URL,
path: SquashMatrix::Constants::CLUB_PATH.gsub(':id', id.to_s)
)
success_proc = lambda do |res|
SquashMatrix::NokogiriParser.get_club_info(r... | [
"def",
"get_club_info",
"(",
"id",
"=",
"nil",
")",
"return",
"unless",
"id",
".",
"to_i",
".",
"positive?",
"uri",
"=",
"URI",
"::",
"HTTP",
".",
"build",
"(",
"host",
":",
"SquashMatrix",
"::",
"Constants",
"::",
"SQUASH_MATRIX_URL",
",",
"path",
":",
... | Returns newly created Client
@note If suppress_errors == false SquashMatrix::Errors::AuthorizationError will be raised if specified credentials are incorrect and squash matrix authentication returns forbidden
@param [Hash] opts the options to create client
@return [Client]
Returns club info.
@note If suppress_erro... | [
"Returns",
"newly",
"created",
"Client"
] | ce3d3e191004905d31fdc96e4439c6290141d8da | https://github.com/wilkosz/squash_matrix/blob/ce3d3e191004905d31fdc96e4439c6290141d8da/lib/squash_matrix/client.rb#L85-L95 |
7,728 | wilkosz/squash_matrix | lib/squash_matrix/client.rb | SquashMatrix.Client.get_player_results | def get_player_results(id = nil)
return unless id.to_i.positive?
uri = URI::HTTP.build(
host: SquashMatrix::Constants::SQUASH_MATRIX_URL,
path: SquashMatrix::Constants::PLAYER_RESULTS_PATH.gsub(':id', id.to_s),
query: SquashMatrix::Constants::PLAYER_RSULTS_QUERY
)
success... | ruby | def get_player_results(id = nil)
return unless id.to_i.positive?
uri = URI::HTTP.build(
host: SquashMatrix::Constants::SQUASH_MATRIX_URL,
path: SquashMatrix::Constants::PLAYER_RESULTS_PATH.gsub(':id', id.to_s),
query: SquashMatrix::Constants::PLAYER_RSULTS_QUERY
)
success... | [
"def",
"get_player_results",
"(",
"id",
"=",
"nil",
")",
"return",
"unless",
"id",
".",
"to_i",
".",
"positive?",
"uri",
"=",
"URI",
"::",
"HTTP",
".",
"build",
"(",
"host",
":",
"SquashMatrix",
"::",
"Constants",
"::",
"SQUASH_MATRIX_URL",
",",
"path",
... | Returns player results.
@note If suppress_errors == false SquashMatrix Errors will be raised upon HttpNotFound, HttpConflict, Timeout::Error, etc...
@param id [Fixnum] played id found on squash matrix
@return [Array<Hash>] Array of player match results | [
"Returns",
"player",
"results",
"."
] | ce3d3e191004905d31fdc96e4439c6290141d8da | https://github.com/wilkosz/squash_matrix/blob/ce3d3e191004905d31fdc96e4439c6290141d8da/lib/squash_matrix/client.rb#L102-L113 |
7,729 | wilkosz/squash_matrix | lib/squash_matrix/client.rb | SquashMatrix.Client.get_search_results | def get_search_results(query = nil,
squash_only: false,
racquetball_only: false)
return if query.to_s.empty?
uri = URI::HTTP.build(
host: SquashMatrix::Constants::SQUASH_MATRIX_URL,
path: SquashMatrix::Constants::SEARCH_RESULTS_PATH
... | ruby | def get_search_results(query = nil,
squash_only: false,
racquetball_only: false)
return if query.to_s.empty?
uri = URI::HTTP.build(
host: SquashMatrix::Constants::SQUASH_MATRIX_URL,
path: SquashMatrix::Constants::SEARCH_RESULTS_PATH
... | [
"def",
"get_search_results",
"(",
"query",
"=",
"nil",
",",
"squash_only",
":",
"false",
",",
"racquetball_only",
":",
"false",
")",
"return",
"if",
"query",
".",
"to_s",
".",
"empty?",
"uri",
"=",
"URI",
"::",
"HTTP",
".",
"build",
"(",
"host",
":",
"... | Returns get_search_results results
@note If suppress_errors == false SquashMatrix Errors will be raised upon HttpNotFound, HttpConflict, Timeout::Error, etc...
@param query [String] get_search_results query
@return [Hash] hash object containing get_search_results results | [
"Returns",
"get_search_results",
"results"
] | ce3d3e191004905d31fdc96e4439c6290141d8da | https://github.com/wilkosz/squash_matrix/blob/ce3d3e191004905d31fdc96e4439c6290141d8da/lib/squash_matrix/client.rb#L137-L156 |
7,730 | atomicobject/hardmock | lib/hardmock/mock.rb | Hardmock.Mock.expects | def expects(*args, &block)
expector = Expector.new(self,@control,@expectation_builder)
# If there are no args, we return the Expector
return expector if args.empty?
# If there ARE args, we set up the expectation right here and return it
expector.send(args.shift.to_sym, *args, &block)
e... | ruby | def expects(*args, &block)
expector = Expector.new(self,@control,@expectation_builder)
# If there are no args, we return the Expector
return expector if args.empty?
# If there ARE args, we set up the expectation right here and return it
expector.send(args.shift.to_sym, *args, &block)
e... | [
"def",
"expects",
"(",
"*",
"args",
",",
"&",
"block",
")",
"expector",
"=",
"Expector",
".",
"new",
"(",
"self",
",",
"@control",
",",
"@expectation_builder",
")",
"# If there are no args, we return the Expector",
"return",
"expector",
"if",
"args",
".",
"empty... | Begin declaring an expectation for this Mock.
== Simple Examples
Expect the +customer+ to be queried for +account+, and return <tt>"The
Account"</tt>:
@customer.expects.account.returns "The Account"
Expect the +withdraw+ method to be called, and raise an exception when it
is (see Expectation#raises for more i... | [
"Begin",
"declaring",
"an",
"expectation",
"for",
"this",
"Mock",
"."
] | a2c01c2cbd28f56a71cc824f04b40ea1d14be367 | https://github.com/atomicobject/hardmock/blob/a2c01c2cbd28f56a71cc824f04b40ea1d14be367/lib/hardmock/mock.rb#L108-L114 |
7,731 | adamluzsi/download | lib/download.rb | Download.Object.file_path | def file_path
self.path= File.join(Dir.pwd, uri_file_name) unless path
if File.directory?(path)
self.path= File.join(self.path, uri_file_name)
end
self.path
end | ruby | def file_path
self.path= File.join(Dir.pwd, uri_file_name) unless path
if File.directory?(path)
self.path= File.join(self.path, uri_file_name)
end
self.path
end | [
"def",
"file_path",
"self",
".",
"path",
"=",
"File",
".",
"join",
"(",
"Dir",
".",
"pwd",
",",
"uri_file_name",
")",
"unless",
"path",
"if",
"File",
".",
"directory?",
"(",
"path",
")",
"self",
".",
"path",
"=",
"File",
".",
"join",
"(",
"self",
"... | return a string with a file path where the file will be saved | [
"return",
"a",
"string",
"with",
"a",
"file",
"path",
"where",
"the",
"file",
"will",
"be",
"saved"
] | 6de4193aeb6444e5fe2e0dbe7bd2da07c290baa3 | https://github.com/adamluzsi/download/blob/6de4193aeb6444e5fe2e0dbe7bd2da07c290baa3/lib/download.rb#L20-L29 |
7,732 | adamluzsi/download | lib/download.rb | Download.Object.start | def start(hash={})
set_multi(hash)
File.delete(file_path) if File.exist?(file_path)
File.open(file_path, 'wb') do |file_obj|
Kernel.open(*[url,options].compact) do |fin|
while (buf = fin.read(8192))
file_obj << buf
end
end
end
return file_... | ruby | def start(hash={})
set_multi(hash)
File.delete(file_path) if File.exist?(file_path)
File.open(file_path, 'wb') do |file_obj|
Kernel.open(*[url,options].compact) do |fin|
while (buf = fin.read(8192))
file_obj << buf
end
end
end
return file_... | [
"def",
"start",
"(",
"hash",
"=",
"{",
"}",
")",
"set_multi",
"(",
"hash",
")",
"File",
".",
"delete",
"(",
"file_path",
")",
"if",
"File",
".",
"exist?",
"(",
"file_path",
")",
"File",
".",
"open",
"(",
"file_path",
",",
"'wb'",
")",
"do",
"|",
... | start the downloading process | [
"start",
"the",
"downloading",
"process"
] | 6de4193aeb6444e5fe2e0dbe7bd2da07c290baa3 | https://github.com/adamluzsi/download/blob/6de4193aeb6444e5fe2e0dbe7bd2da07c290baa3/lib/download.rb#L32-L47 |
7,733 | sloppycoder/fixed_width_file_validator | lib/fixed_width_file_validator/validator.rb | FixedWidthFileValidator.FieldValidator.validate | def validate(record, field_name, bindings = {})
if validations
validations.collect do |validation|
unless valid_value?(validation, record, field_name, bindings)
FieldValidationError.new(validation, record, field_name, pos, width)
end
end.compact
elsif record &... | ruby | def validate(record, field_name, bindings = {})
if validations
validations.collect do |validation|
unless valid_value?(validation, record, field_name, bindings)
FieldValidationError.new(validation, record, field_name, pos, width)
end
end.compact
elsif record &... | [
"def",
"validate",
"(",
"record",
",",
"field_name",
",",
"bindings",
"=",
"{",
"}",
")",
"if",
"validations",
"validations",
".",
"collect",
"do",
"|",
"validation",
"|",
"unless",
"valid_value?",
"(",
"validation",
",",
"record",
",",
"field_name",
",",
... | return an array of error objects
empty array if all validation passes | [
"return",
"an",
"array",
"of",
"error",
"objects",
"empty",
"array",
"if",
"all",
"validation",
"passes"
] | 0dce83b0b73f65bc80c7fc61d5117a6a3acc1828 | https://github.com/sloppycoder/fixed_width_file_validator/blob/0dce83b0b73f65bc80c7fc61d5117a6a3acc1828/lib/fixed_width_file_validator/validator.rb#L35-L48 |
7,734 | etailer/parcel_api | lib/parcel_api/label.rb | ParcelApi.Label.details | def details(label_id)
details_url = File.join(LABEL_URL, "#{label_id}.json")
response = connection.get details_url
details = response.parsed.tap {|d| d.delete('success')}
OpenStruct.new(details)
end | ruby | def details(label_id)
details_url = File.join(LABEL_URL, "#{label_id}.json")
response = connection.get details_url
details = response.parsed.tap {|d| d.delete('success')}
OpenStruct.new(details)
end | [
"def",
"details",
"(",
"label_id",
")",
"details_url",
"=",
"File",
".",
"join",
"(",
"LABEL_URL",
",",
"\"#{label_id}.json\"",
")",
"response",
"=",
"connection",
".",
"get",
"details_url",
"details",
"=",
"response",
".",
"parsed",
".",
"tap",
"{",
"|",
... | Get label details
@param label_id [String]
@return Object of label details | [
"Get",
"label",
"details"
] | fcb8d64e45f7ba72bab48f143ac5115b0441aced | https://github.com/etailer/parcel_api/blob/fcb8d64e45f7ba72bab48f143ac5115b0441aced/lib/parcel_api/label.rb#L37-L42 |
7,735 | bilus/akasha | lib/akasha/event_router.rb | Akasha.EventRouter.connect! | def connect!(repository)
repository.subscribe do |aggregate_id, event|
route(event.name, aggregate_id, **event.data)
end
end | ruby | def connect!(repository)
repository.subscribe do |aggregate_id, event|
route(event.name, aggregate_id, **event.data)
end
end | [
"def",
"connect!",
"(",
"repository",
")",
"repository",
".",
"subscribe",
"do",
"|",
"aggregate_id",
",",
"event",
"|",
"route",
"(",
"event",
".",
"name",
",",
"aggregate_id",
",",
"**",
"event",
".",
"data",
")",
"end",
"end"
] | Connects to the repository. | [
"Connects",
"to",
"the",
"repository",
"."
] | 5fadefc249f520ae909b762956ac23a6f916b021 | https://github.com/bilus/akasha/blob/5fadefc249f520ae909b762956ac23a6f916b021/lib/akasha/event_router.rb#L9-L13 |
7,736 | jodigiordano/calendarize | app/helpers/calendarize_helper.rb | CalendarizeHelper.MonthlyCalendarBuilder.days_range | def days_range
ws = Date::DAYS_INTO_WEEK[@options[:week_start]]
(ws...ws+number_of_days_per_week).map{ |d| d % 7 }
end | ruby | def days_range
ws = Date::DAYS_INTO_WEEK[@options[:week_start]]
(ws...ws+number_of_days_per_week).map{ |d| d % 7 }
end | [
"def",
"days_range",
"ws",
"=",
"Date",
"::",
"DAYS_INTO_WEEK",
"[",
"@options",
"[",
":week_start",
"]",
"]",
"(",
"ws",
"...",
"ws",
"+",
"number_of_days_per_week",
")",
".",
"map",
"{",
"|",
"d",
"|",
"d",
"%",
"7",
"}",
"end"
] | Get the range of days to show | [
"Get",
"the",
"range",
"of",
"days",
"to",
"show"
] | 9131ead3434066367f5ccfce58eaaec9ba406678 | https://github.com/jodigiordano/calendarize/blob/9131ead3434066367f5ccfce58eaaec9ba406678/app/helpers/calendarize_helper.rb#L1008-L1011 |
7,737 | jodigiordano/calendarize | app/helpers/calendarize_helper.rb | CalendarizeHelper.MonthlyCalendarBuilder.row_to_day | def row_to_day(i, j)
starting_wday = @day_start.wday - 1
starting_wday = 6 if starting_wday < 0
# day without taking into account the :week_start so every 1st
# of the month is on a :monday on case [0, 0]
base = (i * 7) + j
# we add the :week_start
base += Date:... | ruby | def row_to_day(i, j)
starting_wday = @day_start.wday - 1
starting_wday = 6 if starting_wday < 0
# day without taking into account the :week_start so every 1st
# of the month is on a :monday on case [0, 0]
base = (i * 7) + j
# we add the :week_start
base += Date:... | [
"def",
"row_to_day",
"(",
"i",
",",
"j",
")",
"starting_wday",
"=",
"@day_start",
".",
"wday",
"-",
"1",
"starting_wday",
"=",
"6",
"if",
"starting_wday",
"<",
"0",
"# day without taking into account the :week_start so every 1st",
"# of the month is on a :monday on case [... | Get the month's day corresponding to a row. Nil is returned if none. | [
"Get",
"the",
"month",
"s",
"day",
"corresponding",
"to",
"a",
"row",
".",
"Nil",
"is",
"returned",
"if",
"none",
"."
] | 9131ead3434066367f5ccfce58eaaec9ba406678 | https://github.com/jodigiordano/calendarize/blob/9131ead3434066367f5ccfce58eaaec9ba406678/app/helpers/calendarize_helper.rb#L1031-L1049 |
7,738 | coreyward/typekit | lib/typekit/variation.rb | Typekit.Variation.fetch | def fetch(attribute)
family_id, variation_id = @id.split(':')
mass_assign Client.get("/families/#{family_id}/#{variation_id}")
attribute ? instance_variable_get("@#{attribute}") : self
end | ruby | def fetch(attribute)
family_id, variation_id = @id.split(':')
mass_assign Client.get("/families/#{family_id}/#{variation_id}")
attribute ? instance_variable_get("@#{attribute}") : self
end | [
"def",
"fetch",
"(",
"attribute",
")",
"family_id",
",",
"variation_id",
"=",
"@id",
".",
"split",
"(",
"':'",
")",
"mass_assign",
"Client",
".",
"get",
"(",
"\"/families/#{family_id}/#{variation_id}\"",
")",
"attribute",
"?",
"instance_variable_get",
"(",
"\"@#{a... | Get detailed information about this Family Variation from Typekit
@note This is called lazily when you access any non-loaded attribute
and doesn't need to be called manually unless you want to reload the
data. This means we can return an array of Variation objects for {Family#variations}
without making N+1 re... | [
"Get",
"detailed",
"information",
"about",
"this",
"Family",
"Variation",
"from",
"Typekit"
] | 1e9f3749ad6066eec7fbdad50abe2ab5802e32d0 | https://github.com/coreyward/typekit/blob/1e9f3749ad6066eec7fbdad50abe2ab5802e32d0/lib/typekit/variation.rb#L30-L34 |
7,739 | wikiti/scaleapi-ruby | lib/scale/api.rb | Scale.API.method_missing | def method_missing(m, *array)
endpoint = Scale.descendants(Scale::Endpoints::Endpoint).find { |e| e.match? m }
return endpoint.new(self, *array).process if endpoint
super
end | ruby | def method_missing(m, *array)
endpoint = Scale.descendants(Scale::Endpoints::Endpoint).find { |e| e.match? m }
return endpoint.new(self, *array).process if endpoint
super
end | [
"def",
"method_missing",
"(",
"m",
",",
"*",
"array",
")",
"endpoint",
"=",
"Scale",
".",
"descendants",
"(",
"Scale",
"::",
"Endpoints",
"::",
"Endpoint",
")",
".",
"find",
"{",
"|",
"e",
"|",
"e",
".",
"match?",
"m",
"}",
"return",
"endpoint",
".",... | Endpoint helper. If the method is not defined, then try looking into the available endpoints. | [
"Endpoint",
"helper",
".",
"If",
"the",
"method",
"is",
"not",
"defined",
"then",
"try",
"looking",
"into",
"the",
"available",
"endpoints",
"."
] | aece53c99e135bdf018f35f0c68aa673f3377258 | https://github.com/wikiti/scaleapi-ruby/blob/aece53c99e135bdf018f35f0c68aa673f3377258/lib/scale/api.rb#L50-L54 |
7,740 | mirego/bourgeois | lib/bourgeois/presenter.rb | Bourgeois.Presenter.execute_helper | def execute_helper(block, opts)
if_condition = execute_helper_condition(opts[:if])
unless_condition = !execute_helper_condition(opts[:unless], false)
block.call if if_condition && unless_condition
end | ruby | def execute_helper(block, opts)
if_condition = execute_helper_condition(opts[:if])
unless_condition = !execute_helper_condition(opts[:unless], false)
block.call if if_condition && unless_condition
end | [
"def",
"execute_helper",
"(",
"block",
",",
"opts",
")",
"if_condition",
"=",
"execute_helper_condition",
"(",
"opts",
"[",
":if",
"]",
")",
"unless_condition",
"=",
"!",
"execute_helper_condition",
"(",
"opts",
"[",
":unless",
"]",
",",
"false",
")",
"block",... | Execute a helper block if it matches conditions | [
"Execute",
"a",
"helper",
"block",
"if",
"it",
"matches",
"conditions"
] | 94618e0c442f8ac4c91ddc6623ee3e03c3665c4f | https://github.com/mirego/bourgeois/blob/94618e0c442f8ac4c91ddc6623ee3e03c3665c4f/lib/bourgeois/presenter.rb#L92-L97 |
7,741 | jarhart/rattler | lib/rattler/runtime/parse_node.rb | Rattler::Runtime.ParseNode.method_missing | def method_missing(symbol, *args)
(args.empty? and labeled.has_key?(symbol)) ? labeled[symbol] : super
end | ruby | def method_missing(symbol, *args)
(args.empty? and labeled.has_key?(symbol)) ? labeled[symbol] : super
end | [
"def",
"method_missing",
"(",
"symbol",
",",
"*",
"args",
")",
"(",
"args",
".",
"empty?",
"and",
"labeled",
".",
"has_key?",
"(",
"symbol",
")",
")",
"?",
"labeled",
"[",
"symbol",
"]",
":",
"super",
"end"
] | Return +true+ if the node has the same value as +other+, i.e. +other+
is an instance of the same class and has equal children and attributes
and the children are labeled the same.
@return [Boolean] +true+ the node has the same value as +other+
Allow labeled children to be accessed as methods. | [
"Return",
"+",
"true",
"+",
"if",
"the",
"node",
"has",
"the",
"same",
"value",
"as",
"+",
"other",
"+",
"i",
".",
"e",
".",
"+",
"other",
"+",
"is",
"an",
"instance",
"of",
"the",
"same",
"class",
"and",
"has",
"equal",
"children",
"and",
"attribu... | 8b4efde2a05e9e790955bb635d4a1a9615893719 | https://github.com/jarhart/rattler/blob/8b4efde2a05e9e790955bb635d4a1a9615893719/lib/rattler/runtime/parse_node.rb#L66-L68 |
7,742 | profitbricks/profitbricks-sdk-ruby | lib/profitbricks/volume.rb | ProfitBricks.Volume.create_snapshot | def create_snapshot(options = {})
response = ProfitBricks.request(
method: :post,
path: "/datacenters/#{datacenterId}/volumes/#{id}/create-snapshot",
headers: { 'Content-Type' => 'application/x-www-form-urlencoded' },
expects: 202,
body: URI.encode_www_form(options)
)... | ruby | def create_snapshot(options = {})
response = ProfitBricks.request(
method: :post,
path: "/datacenters/#{datacenterId}/volumes/#{id}/create-snapshot",
headers: { 'Content-Type' => 'application/x-www-form-urlencoded' },
expects: 202,
body: URI.encode_www_form(options)
)... | [
"def",
"create_snapshot",
"(",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"ProfitBricks",
".",
"request",
"(",
"method",
":",
":post",
",",
"path",
":",
"\"/datacenters/#{datacenterId}/volumes/#{id}/create-snapshot\"",
",",
"headers",
":",
"{",
"'Content-Type'"... | Create volume snapshot.
==== Parameters
* +options+<Hash>:
- +name+<String> - *Optional*, name of the snapshot
- +description+<String> - *Optional*, description of the snapshot
==== Returns
* +id+<String> - Universally unique identifer of resource
* +type+<String> - Resource type
* +href+<String> - Resour... | [
"Create",
"volume",
"snapshot",
"."
] | 03a379e412b0e6c0789ed14f2449f18bda622742 | https://github.com/profitbricks/profitbricks-sdk-ruby/blob/03a379e412b0e6c0789ed14f2449f18bda622742/lib/profitbricks/volume.rb#L84-L93 |
7,743 | kamui/rack-accept_headers | lib/rack/accept_headers/header.rb | Rack::AcceptHeaders.Header.parse_range_params | def parse_range_params(params)
params.split(';').inject({'q' => '1'}) do |m, p|
k, v = p.split('=', 2)
m[k.strip] = v.strip if v
m
end
end | ruby | def parse_range_params(params)
params.split(';').inject({'q' => '1'}) do |m, p|
k, v = p.split('=', 2)
m[k.strip] = v.strip if v
m
end
end | [
"def",
"parse_range_params",
"(",
"params",
")",
"params",
".",
"split",
"(",
"';'",
")",
".",
"inject",
"(",
"{",
"'q'",
"=>",
"'1'",
"}",
")",
"do",
"|",
"m",
",",
"p",
"|",
"k",
",",
"v",
"=",
"p",
".",
"split",
"(",
"'='",
",",
"2",
")",
... | Parses a string of media type range parameters into a hash of parameters
to their respective values. | [
"Parses",
"a",
"string",
"of",
"media",
"type",
"range",
"parameters",
"into",
"a",
"hash",
"of",
"parameters",
"to",
"their",
"respective",
"values",
"."
] | 099bfbb919de86b5842c8e14be42b8b784e53f03 | https://github.com/kamui/rack-accept_headers/blob/099bfbb919de86b5842c8e14be42b8b784e53f03/lib/rack/accept_headers/header.rb#L50-L56 |
7,744 | kamui/rack-accept_headers | lib/rack/accept_headers/header.rb | Rack::AcceptHeaders.Header.normalize_qvalue | def normalize_qvalue(q)
(q == 1 || q == 0) && q.is_a?(Float) ? q.to_i : q
end | ruby | def normalize_qvalue(q)
(q == 1 || q == 0) && q.is_a?(Float) ? q.to_i : q
end | [
"def",
"normalize_qvalue",
"(",
"q",
")",
"(",
"q",
"==",
"1",
"||",
"q",
"==",
"0",
")",
"&&",
"q",
".",
"is_a?",
"(",
"Float",
")",
"?",
"q",
".",
"to_i",
":",
"q",
"end"
] | Converts 1.0 and 0.0 qvalues to 1 and 0 respectively. Used to maintain
consistency across qvalue methods. | [
"Converts",
"1",
".",
"0",
"and",
"0",
".",
"0",
"qvalues",
"to",
"1",
"and",
"0",
"respectively",
".",
"Used",
"to",
"maintain",
"consistency",
"across",
"qvalue",
"methods",
"."
] | 099bfbb919de86b5842c8e14be42b8b784e53f03 | https://github.com/kamui/rack-accept_headers/blob/099bfbb919de86b5842c8e14be42b8b784e53f03/lib/rack/accept_headers/header.rb#L61-L63 |
7,745 | jduckett/duck_map | lib/duck_map/route_filter.rb | DuckMap.RouteFilter.match_any? | def match_any?(data = nil, values = [])
unless data.blank?
unless values.kind_of?(Array)
# wow, this worked!!??
# values was not an array, so, add values to a new array and assign back to values
values = [values]
end
values.each do |value|
if val... | ruby | def match_any?(data = nil, values = [])
unless data.blank?
unless values.kind_of?(Array)
# wow, this worked!!??
# values was not an array, so, add values to a new array and assign back to values
values = [values]
end
values.each do |value|
if val... | [
"def",
"match_any?",
"(",
"data",
"=",
"nil",
",",
"values",
"=",
"[",
"]",
")",
"unless",
"data",
".",
"blank?",
"unless",
"values",
".",
"kind_of?",
"(",
"Array",
")",
"# wow, this worked!!??",
"# values was not an array, so, add values to a new array and assign bac... | Matches a single value against an array of Strings, Symbols, and Regexp's.
@param [String] data Any value as a String to compare against any of the Strings, Symbols, or Regexp's in the values argument.
@param [Array] values An array of Strings, Symbols, or Regexp's to compare against the data argument. The arra... | [
"Matches",
"a",
"single",
"value",
"against",
"an",
"array",
"of",
"Strings",
"Symbols",
"and",
"Regexp",
"s",
"."
] | c510acfa95e8ad4afb1501366058ae88a73704df | https://github.com/jduckett/duck_map/blob/c510acfa95e8ad4afb1501366058ae88a73704df/lib/duck_map/route_filter.rb#L161-L188 |
7,746 | crowdint/cached_belongs_to | lib/cached_belongs_to.rb | CachedBelongsTo.ClassMethods.cached_belongs_to | def cached_belongs_to(*args)
caches = Array(args[1].delete(:caches))
association = belongs_to(*args)
create_cached_belongs_to_child_callbacks(caches, association)
create_cached_belongs_to_parent_callbacks(caches, association)
end | ruby | def cached_belongs_to(*args)
caches = Array(args[1].delete(:caches))
association = belongs_to(*args)
create_cached_belongs_to_child_callbacks(caches, association)
create_cached_belongs_to_parent_callbacks(caches, association)
end | [
"def",
"cached_belongs_to",
"(",
"*",
"args",
")",
"caches",
"=",
"Array",
"(",
"args",
"[",
"1",
"]",
".",
"delete",
"(",
":caches",
")",
")",
"association",
"=",
"belongs_to",
"(",
"args",
")",
"create_cached_belongs_to_child_callbacks",
"(",
"caches",
","... | Creates a many to one association between two models. Works
exactly as ActiveRecord's belongs_to, except that it adds
caching to it.
Usage:
class Book < ActiveRecord::Base
cached_belongs_to :author, :caches => :name
end | [
"Creates",
"a",
"many",
"to",
"one",
"association",
"between",
"two",
"models",
".",
"Works",
"exactly",
"as",
"ActiveRecord",
"s",
"belongs_to",
"except",
"that",
"it",
"adds",
"caching",
"to",
"it",
"."
] | 7dc5c07ff1a622286fdc739d0a98a7788bd2f13e | https://github.com/crowdint/cached_belongs_to/blob/7dc5c07ff1a622286fdc739d0a98a7788bd2f13e/lib/cached_belongs_to.rb#L17-L23 |
7,747 | bsm/pbio | lib/pbio/delimited.rb | PBIO.Delimited.read | def read(klass)
size = Delimited.read_uvarint(io)
klass.decode io.read(size) unless size.zero?
end | ruby | def read(klass)
size = Delimited.read_uvarint(io)
klass.decode io.read(size) unless size.zero?
end | [
"def",
"read",
"(",
"klass",
")",
"size",
"=",
"Delimited",
".",
"read_uvarint",
"(",
"io",
")",
"klass",
".",
"decode",
"io",
".",
"read",
"(",
"size",
")",
"unless",
"size",
".",
"zero?",
"end"
] | Reads the next message | [
"Reads",
"the",
"next",
"message"
] | 683e621b31080a415c0cdc9ca0d574a6b03b3f79 | https://github.com/bsm/pbio/blob/683e621b31080a415c0cdc9ca0d574a6b03b3f79/lib/pbio/delimited.rb#L50-L53 |
7,748 | synthesist/panoptimon | lib/panoptimon/monitor.rb | Panoptimon.Monitor._dirjson | def _dirjson (x)
x = Pathname.new(x)
x.entries.find_all {|f| f.to_s =~ /\.json$/i}.
map {|f| x + f}
end | ruby | def _dirjson (x)
x = Pathname.new(x)
x.entries.find_all {|f| f.to_s =~ /\.json$/i}.
map {|f| x + f}
end | [
"def",
"_dirjson",
"(",
"x",
")",
"x",
"=",
"Pathname",
".",
"new",
"(",
"x",
")",
"x",
".",
"entries",
".",
"find_all",
"{",
"|",
"f",
"|",
"f",
".",
"to_s",
"=~",
"/",
"\\.",
"/i",
"}",
".",
"map",
"{",
"|",
"f",
"|",
"x",
"+",
"f",
"}"... | Search directories for JSON files | [
"Search",
"directories",
"for",
"JSON",
"files"
] | 9346c221ae95aaa6528232a04a92478f7c9a5e15 | https://github.com/synthesist/panoptimon/blob/9346c221ae95aaa6528232a04a92478f7c9a5e15/lib/panoptimon/monitor.rb#L24-L28 |
7,749 | jarhart/rattler | lib/rattler.rb | Rattler.HelperMethods.compile_parser | def compile_parser(*args)
options = @@defaults.dup
grammar = nil
for arg in args
case arg
when Hash then options.merge!(arg)
when String then grammar = arg
end
end
base_class = options.delete(:class) ||
(Rattler::Runtime::const_get @@parser... | ruby | def compile_parser(*args)
options = @@defaults.dup
grammar = nil
for arg in args
case arg
when Hash then options.merge!(arg)
when String then grammar = arg
end
end
base_class = options.delete(:class) ||
(Rattler::Runtime::const_get @@parser... | [
"def",
"compile_parser",
"(",
"*",
"args",
")",
"options",
"=",
"@@defaults",
".",
"dup",
"grammar",
"=",
"nil",
"for",
"arg",
"in",
"args",
"case",
"arg",
"when",
"Hash",
"then",
"options",
".",
"merge!",
"(",
"arg",
")",
"when",
"String",
"then",
"gr... | Define a parser with the given grammar and compile it into a parser class
using the given options
@return [Class] a new parser class | [
"Define",
"a",
"parser",
"with",
"the",
"given",
"grammar",
"and",
"compile",
"it",
"into",
"a",
"parser",
"class",
"using",
"the",
"given",
"options"
] | 8b4efde2a05e9e790955bb635d4a1a9615893719 | https://github.com/jarhart/rattler/blob/8b4efde2a05e9e790955bb635d4a1a9615893719/lib/rattler.rb#L29-L41 |
7,750 | Fedcomp/any_sms | lib/any_sms/configuration.rb | AnySMS.Configuration.default_backend= | def default_backend=(value)
raise ArgumentError, "default_backend must be a symbol!" unless value.is_a? Symbol
unless @backends.keys.include? value
raise ArgumentError, "Unregistered backend cannot be set as default!"
end
@default_backend = value
end | ruby | def default_backend=(value)
raise ArgumentError, "default_backend must be a symbol!" unless value.is_a? Symbol
unless @backends.keys.include? value
raise ArgumentError, "Unregistered backend cannot be set as default!"
end
@default_backend = value
end | [
"def",
"default_backend",
"=",
"(",
"value",
")",
"raise",
"ArgumentError",
",",
"\"default_backend must be a symbol!\"",
"unless",
"value",
".",
"is_a?",
"Symbol",
"unless",
"@backends",
".",
"keys",
".",
"include?",
"value",
"raise",
"ArgumentError",
",",
"\"Unreg... | Specify default sms backend. It must be registered.
@param value [Symbol] Backend key which will be used as default | [
"Specify",
"default",
"sms",
"backend",
".",
"It",
"must",
"be",
"registered",
"."
] | c8a2483acc5b263b47a00b4d64d3114b43ff2342 | https://github.com/Fedcomp/any_sms/blob/c8a2483acc5b263b47a00b4d64d3114b43ff2342/lib/any_sms/configuration.rb#L34-L42 |
7,751 | Fedcomp/any_sms | lib/any_sms/configuration.rb | AnySMS.Configuration.register_backend | def register_backend(key, classname, params = {})
raise ArgumentError, "backend key must be a symbol!" unless key.is_a? Symbol
unless classname.class == Class
raise ArgumentError, "backend class must be class (not instance or string)"
end
unless classname.method_defined? :send_sms
... | ruby | def register_backend(key, classname, params = {})
raise ArgumentError, "backend key must be a symbol!" unless key.is_a? Symbol
unless classname.class == Class
raise ArgumentError, "backend class must be class (not instance or string)"
end
unless classname.method_defined? :send_sms
... | [
"def",
"register_backend",
"(",
"key",
",",
"classname",
",",
"params",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"\"backend key must be a symbol!\"",
"unless",
"key",
".",
"is_a?",
"Symbol",
"unless",
"classname",
".",
"class",
"==",
"Class",
"raise",
... | Register sms provider backend
@param key [Symbol] Key for acessing backend in any part of AnySMS
@param classname [Class] Real class implementation of sms backend
@param params [Hash]
Optional params for backend. Useful for passing tokens and options | [
"Register",
"sms",
"provider",
"backend"
] | c8a2483acc5b263b47a00b4d64d3114b43ff2342 | https://github.com/Fedcomp/any_sms/blob/c8a2483acc5b263b47a00b4d64d3114b43ff2342/lib/any_sms/configuration.rb#L50-L62 |
7,752 | mssola/cconfig | lib/cconfig/cconfig.rb | CConfig.Config.fetch | def fetch
cfg = File.file?(@default) ? YAML.load_file(@default) : {}
local = fetch_local
hsh = strict_merge_with_env(default: cfg, local: local, prefix: @prefix)
hsh.extend(::CConfig::HashUtils::Extensions)
hsh.defaults = cfg
hsh
end | ruby | def fetch
cfg = File.file?(@default) ? YAML.load_file(@default) : {}
local = fetch_local
hsh = strict_merge_with_env(default: cfg, local: local, prefix: @prefix)
hsh.extend(::CConfig::HashUtils::Extensions)
hsh.defaults = cfg
hsh
end | [
"def",
"fetch",
"cfg",
"=",
"File",
".",
"file?",
"(",
"@default",
")",
"?",
"YAML",
".",
"load_file",
"(",
"@default",
")",
":",
"{",
"}",
"local",
"=",
"fetch_local",
"hsh",
"=",
"strict_merge_with_env",
"(",
"default",
":",
"cfg",
",",
"local",
":",... | Instantiate an object with `default` as the path to the default
configuration, `local` as the alternate file, and `prefix` as the prefix
for environment variables. The `prefix` will take "cconfig" as the default.
Note: the `local` value will be discarded in favor of the
`#{prefix}_LOCAL_CONFIG_PATH` environment va... | [
"Instantiate",
"an",
"object",
"with",
"default",
"as",
"the",
"path",
"to",
"the",
"default",
"configuration",
"local",
"as",
"the",
"alternate",
"file",
"and",
"prefix",
"as",
"the",
"prefix",
"for",
"environment",
"variables",
".",
"The",
"prefix",
"will",
... | 793fb743cdcc064a96fb911bc17483fa0d343056 | https://github.com/mssola/cconfig/blob/793fb743cdcc064a96fb911bc17483fa0d343056/lib/cconfig/cconfig.rb#L45-L53 |
7,753 | mssola/cconfig | lib/cconfig/cconfig.rb | CConfig.Config.fetch_local | def fetch_local
if File.file?(@local)
# Check for bad user input in the local config.yml file.
local = YAML.load_file(@local)
raise FormatError unless local.is_a?(::Hash)
local
else
{}
end
end | ruby | def fetch_local
if File.file?(@local)
# Check for bad user input in the local config.yml file.
local = YAML.load_file(@local)
raise FormatError unless local.is_a?(::Hash)
local
else
{}
end
end | [
"def",
"fetch_local",
"if",
"File",
".",
"file?",
"(",
"@local",
")",
"# Check for bad user input in the local config.yml file.",
"local",
"=",
"YAML",
".",
"load_file",
"(",
"@local",
")",
"raise",
"FormatError",
"unless",
"local",
".",
"is_a?",
"(",
"::",
"Hash"... | Returns a hash with the alternate values that have to override the default
ones. | [
"Returns",
"a",
"hash",
"with",
"the",
"alternate",
"values",
"that",
"have",
"to",
"override",
"the",
"default",
"ones",
"."
] | 793fb743cdcc064a96fb911bc17483fa0d343056 | https://github.com/mssola/cconfig/blob/793fb743cdcc064a96fb911bc17483fa0d343056/lib/cconfig/cconfig.rb#L64-L74 |
7,754 | m4n/validates_captcha | lib/validates_captcha/form_helper.rb | ValidatesCaptcha.FormHelper.captcha_challenge | def captcha_challenge(object_name, options = {})
options.symbolize_keys!
object = options.delete(:object)
sanitized_object_name = object_name.to_s.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
ValidatesCaptcha.provider.render_challenge sanitized_object_name, object, options
end | ruby | def captcha_challenge(object_name, options = {})
options.symbolize_keys!
object = options.delete(:object)
sanitized_object_name = object_name.to_s.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
ValidatesCaptcha.provider.render_challenge sanitized_object_name, object, options
end | [
"def",
"captcha_challenge",
"(",
"object_name",
",",
"options",
"=",
"{",
"}",
")",
"options",
".",
"symbolize_keys!",
"object",
"=",
"options",
".",
"delete",
"(",
":object",
")",
"sanitized_object_name",
"=",
"object_name",
".",
"to_s",
".",
"gsub",
"(",
"... | Returns the captcha challenge.
Internally calls the +render_challenge+ method of ValidatesCaptcha#provider. | [
"Returns",
"the",
"captcha",
"challenge",
"."
] | 6537953bd81860ac07694b1a8e1cd32b2a24240c | https://github.com/m4n/validates_captcha/blob/6537953bd81860ac07694b1a8e1cd32b2a24240c/lib/validates_captcha/form_helper.rb#L6-L13 |
7,755 | m4n/validates_captcha | lib/validates_captcha/form_helper.rb | ValidatesCaptcha.FormHelper.captcha_field | def captcha_field(object_name, options = {})
options.delete(:id)
hidden_field(object_name, :captcha_challenge, options) + text_field(object_name, :captcha_solution, options)
end | ruby | def captcha_field(object_name, options = {})
options.delete(:id)
hidden_field(object_name, :captcha_challenge, options) + text_field(object_name, :captcha_solution, options)
end | [
"def",
"captcha_field",
"(",
"object_name",
",",
"options",
"=",
"{",
"}",
")",
"options",
".",
"delete",
"(",
":id",
")",
"hidden_field",
"(",
"object_name",
",",
":captcha_challenge",
",",
"options",
")",
"+",
"text_field",
"(",
"object_name",
",",
":captc... | Returns an input tag of the "text" type tailored for entering the captcha solution.
Internally calls Rails' #text_field helper method, passing the +object_name+ and
+options+ arguments. | [
"Returns",
"an",
"input",
"tag",
"of",
"the",
"text",
"type",
"tailored",
"for",
"entering",
"the",
"captcha",
"solution",
"."
] | 6537953bd81860ac07694b1a8e1cd32b2a24240c | https://github.com/m4n/validates_captcha/blob/6537953bd81860ac07694b1a8e1cd32b2a24240c/lib/validates_captcha/form_helper.rb#L19-L23 |
7,756 | m4n/validates_captcha | lib/validates_captcha/form_helper.rb | ValidatesCaptcha.FormHelper.regenerate_captcha_challenge_link | def regenerate_captcha_challenge_link(object_name, options = {}, html_options = {})
options.symbolize_keys!
object = options.delete(:object)
sanitized_object_name = object_name.to_s.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
ValidatesCaptcha.provider.render_regenerate_challenge_link sanit... | ruby | def regenerate_captcha_challenge_link(object_name, options = {}, html_options = {})
options.symbolize_keys!
object = options.delete(:object)
sanitized_object_name = object_name.to_s.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
ValidatesCaptcha.provider.render_regenerate_challenge_link sanit... | [
"def",
"regenerate_captcha_challenge_link",
"(",
"object_name",
",",
"options",
"=",
"{",
"}",
",",
"html_options",
"=",
"{",
"}",
")",
"options",
".",
"symbolize_keys!",
"object",
"=",
"options",
".",
"delete",
"(",
":object",
")",
"sanitized_object_name",
"=",... | By default, returns an anchor tag that makes an AJAX request to fetch a new captcha challenge and updates
the current challenge after the request is complete.
Internally calls +render_regenerate_challenge_link+ method of ValidatesCaptcha#provider. | [
"By",
"default",
"returns",
"an",
"anchor",
"tag",
"that",
"makes",
"an",
"AJAX",
"request",
"to",
"fetch",
"a",
"new",
"captcha",
"challenge",
"and",
"updates",
"the",
"current",
"challenge",
"after",
"the",
"request",
"is",
"complete",
"."
] | 6537953bd81860ac07694b1a8e1cd32b2a24240c | https://github.com/m4n/validates_captcha/blob/6537953bd81860ac07694b1a8e1cd32b2a24240c/lib/validates_captcha/form_helper.rb#L29-L36 |
7,757 | jduckett/duck_map | lib/duck_map/sitemap_object.rb | DuckMap.SitemapObject.sitemap_capture_segments | def sitemap_capture_segments(segment_mappings = {}, segments = [])
values = {}
# do nothing if there are no segments to work on
if segments.kind_of?(Array)
# first, look for mappings
unless segment_mappings.blank?
segments.each do |key|
attribute_name = segment... | ruby | def sitemap_capture_segments(segment_mappings = {}, segments = [])
values = {}
# do nothing if there are no segments to work on
if segments.kind_of?(Array)
# first, look for mappings
unless segment_mappings.blank?
segments.each do |key|
attribute_name = segment... | [
"def",
"sitemap_capture_segments",
"(",
"segment_mappings",
"=",
"{",
"}",
",",
"segments",
"=",
"[",
"]",
")",
"values",
"=",
"{",
"}",
"# do nothing if there are no segments to work on",
"if",
"segments",
".",
"kind_of?",
"(",
"Array",
")",
"# first, look for mapp... | Segment keys are placeholders for the values that are plugged into a named route when it is constructed.
The following Rails route has a two segment keys: :id and :format.
book GET /books/:id(.:format) books#show
:id is the row.id of a Book and :format is the extension to be used when constructing a path... | [
"Segment",
"keys",
"are",
"placeholders",
"for",
"the",
"values",
"that",
"are",
"plugged",
"into",
"a",
"named",
"route",
"when",
"it",
"is",
"constructed",
"."
] | c510acfa95e8ad4afb1501366058ae88a73704df | https://github.com/jduckett/duck_map/blob/c510acfa95e8ad4afb1501366058ae88a73704df/lib/duck_map/sitemap_object.rb#L424-L457 |
7,758 | OpenBEL/bel_parser | lib/bel_parser/ast_generator.rb | BELParser.ASTGenerator.each | def each # rubocop:disable MethodLength
if block_given?
line_number = 1
expanded_line = nil
map_lines(@io.each_line.lazy).each do |line|
if line.end_with?(LINE_CONTINUATOR)
expanded_line = "#{expanded_line}#{line.chomp(LINE_CONTINUATOR)}"
else
... | ruby | def each # rubocop:disable MethodLength
if block_given?
line_number = 1
expanded_line = nil
map_lines(@io.each_line.lazy).each do |line|
if line.end_with?(LINE_CONTINUATOR)
expanded_line = "#{expanded_line}#{line.chomp(LINE_CONTINUATOR)}"
else
... | [
"def",
"each",
"# rubocop:disable MethodLength",
"if",
"block_given?",
"line_number",
"=",
"1",
"expanded_line",
"=",
"nil",
"map_lines",
"(",
"@io",
".",
"each_line",
".",
"lazy",
")",
".",
"each",
"do",
"|",
"line",
"|",
"if",
"line",
".",
"end_with?",
"("... | Yields AST results for each line of the IO.
@example Receive AST results in given block.
# doctest setup require 'bel_parser' self.class.include AST::Sexp
# example usage line_io = StringIO.new("\"AKT1\"\n") line =
nil ast_res = nil ::BELParser::ASTGenerator.new.each(line_io)
{ |(line_number, line, re... | [
"Yields",
"AST",
"results",
"for",
"each",
"line",
"of",
"the",
"IO",
"."
] | f0a35de93c300abff76c22e54696a83d22a4fbc9 | https://github.com/OpenBEL/bel_parser/blob/f0a35de93c300abff76c22e54696a83d22a4fbc9/lib/bel_parser/ast_generator.rb#L48-L72 |
7,759 | pwnall/ether_ping | lib/ether_ping/client.rb | EtherPing.Client.ping | def ping(data, timeout = 1)
if data.kind_of? Numeric
data = "\0" * data
end
# Pad data to have at least 64 bytes.
data += "\0" * (64 - data.length) if data.length < 64
ping_packet = [@dest_mac, @source_mac, @ether_type, data].join
response = nil
receive_ts = nil
send_ts = nil
... | ruby | def ping(data, timeout = 1)
if data.kind_of? Numeric
data = "\0" * data
end
# Pad data to have at least 64 bytes.
data += "\0" * (64 - data.length) if data.length < 64
ping_packet = [@dest_mac, @source_mac, @ether_type, data].join
response = nil
receive_ts = nil
send_ts = nil
... | [
"def",
"ping",
"(",
"data",
",",
"timeout",
"=",
"1",
")",
"if",
"data",
".",
"kind_of?",
"Numeric",
"data",
"=",
"\"\\0\"",
"*",
"data",
"end",
"# Pad data to have at least 64 bytes.",
"data",
"+=",
"\"\\0\"",
"*",
"(",
"64",
"-",
"data",
".",
"length",
... | Pings over raw Ethernet sockets.
Returns a Number representing the ping latency (in seconds) if the ping
response matches, an array of [expected, received] strings if it doesn't
match, and false if the ping times out. | [
"Pings",
"over",
"raw",
"Ethernet",
"sockets",
"."
] | 3f61b40963adc74188ff9dbf7722850dadb32365 | https://github.com/pwnall/ether_ping/blob/3f61b40963adc74188ff9dbf7722850dadb32365/lib/ether_ping/client.rb#L24-L51 |
7,760 | kch/dominion | lib/dominion/domain_suffix_rule.rb | Dominion.DomainSuffixRule.=~ | def =~(domain)
labels.zip(domain.labels).all? { |r, d| ["*", d].include? r }
end | ruby | def =~(domain)
labels.zip(domain.labels).all? { |r, d| ["*", d].include? r }
end | [
"def",
"=~",
"(",
"domain",
")",
"labels",
".",
"zip",
"(",
"domain",
".",
"labels",
")",
".",
"all?",
"{",
"|",
"r",
",",
"d",
"|",
"[",
"\"*\"",
",",
"d",
"]",
".",
"include?",
"r",
"}",
"end"
] | match against a domain name. the domain must be an instance of DomainName | [
"match",
"against",
"a",
"domain",
"name",
".",
"the",
"domain",
"must",
"be",
"an",
"instance",
"of",
"DomainName"
] | ecdd6ff6edcf1c4658fa4e4736de32854ea492dd | https://github.com/kch/dominion/blob/ecdd6ff6edcf1c4658fa4e4736de32854ea492dd/lib/dominion/domain_suffix_rule.rb#L16-L18 |
7,761 | jimeh/time_ext | lib/time_ext/iterations.rb | TimeExt.Iterations.each | def each(unit, options = {}, &block)
iterate(unit, options.merge(:map_result => false), &block)
end | ruby | def each(unit, options = {}, &block)
iterate(unit, options.merge(:map_result => false), &block)
end | [
"def",
"each",
"(",
"unit",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"iterate",
"(",
"unit",
",",
"options",
".",
"merge",
"(",
":map_result",
"=>",
"false",
")",
",",
"block",
")",
"end"
] | Executes passed block for each "unit" of time specified, with a new time object for each interval passed to the block. | [
"Executes",
"passed",
"block",
"for",
"each",
"unit",
"of",
"time",
"specified",
"with",
"a",
"new",
"time",
"object",
"for",
"each",
"interval",
"passed",
"to",
"the",
"block",
"."
] | 53fed4fb33c4fe5948cbc609eaf2319a9b05b1db | https://github.com/jimeh/time_ext/blob/53fed4fb33c4fe5948cbc609eaf2319a9b05b1db/lib/time_ext/iterations.rb#L65-L67 |
7,762 | jimeh/time_ext | lib/time_ext/iterations.rb | TimeExt.Iterations.beginning_of_each | def beginning_of_each(unit, options = {}, &block)
iterate(unit, options.merge(:map_result => false, :beginning_of => true), &block)
end | ruby | def beginning_of_each(unit, options = {}, &block)
iterate(unit, options.merge(:map_result => false, :beginning_of => true), &block)
end | [
"def",
"beginning_of_each",
"(",
"unit",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"iterate",
"(",
"unit",
",",
"options",
".",
"merge",
"(",
":map_result",
"=>",
"false",
",",
":beginning_of",
"=>",
"true",
")",
",",
"block",
")",
"end"
] | Executes passed block for each "unit" of time specified, with a new time object set to the beginning of "unit" for each interval passed to the block. | [
"Executes",
"passed",
"block",
"for",
"each",
"unit",
"of",
"time",
"specified",
"with",
"a",
"new",
"time",
"object",
"set",
"to",
"the",
"beginning",
"of",
"unit",
"for",
"each",
"interval",
"passed",
"to",
"the",
"block",
"."
] | 53fed4fb33c4fe5948cbc609eaf2319a9b05b1db | https://github.com/jimeh/time_ext/blob/53fed4fb33c4fe5948cbc609eaf2319a9b05b1db/lib/time_ext/iterations.rb#L70-L72 |
7,763 | jimeh/time_ext | lib/time_ext/iterations.rb | TimeExt.Iterations.map_each | def map_each(unit, options = {}, &block)
iterate(unit, options.merge(:map_result => true), &block)
end | ruby | def map_each(unit, options = {}, &block)
iterate(unit, options.merge(:map_result => true), &block)
end | [
"def",
"map_each",
"(",
"unit",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"iterate",
"(",
"unit",
",",
"options",
".",
"merge",
"(",
":map_result",
"=>",
"true",
")",
",",
"block",
")",
"end"
] | Executes passed block for each "unit" of time specified, returning an array with the return values from the passed block. | [
"Executes",
"passed",
"block",
"for",
"each",
"unit",
"of",
"time",
"specified",
"returning",
"an",
"array",
"with",
"the",
"return",
"values",
"from",
"the",
"passed",
"block",
"."
] | 53fed4fb33c4fe5948cbc609eaf2319a9b05b1db | https://github.com/jimeh/time_ext/blob/53fed4fb33c4fe5948cbc609eaf2319a9b05b1db/lib/time_ext/iterations.rb#L75-L77 |
7,764 | jimeh/time_ext | lib/time_ext/iterations.rb | TimeExt.Iterations.map_beginning_of_each | def map_beginning_of_each(unit, options = {}, &block)
iterate(unit, options.merge(:map_result => true, :beginning_of => true), &block)
end | ruby | def map_beginning_of_each(unit, options = {}, &block)
iterate(unit, options.merge(:map_result => true, :beginning_of => true), &block)
end | [
"def",
"map_beginning_of_each",
"(",
"unit",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"iterate",
"(",
"unit",
",",
"options",
".",
"merge",
"(",
":map_result",
"=>",
"true",
",",
":beginning_of",
"=>",
"true",
")",
",",
"block",
")",
"end... | Executes passed block for each "unit" of time specified, returning an array with the return values from passed block. Additionally the time object passed into the block is set to the beginning of specified "unit". | [
"Executes",
"passed",
"block",
"for",
"each",
"unit",
"of",
"time",
"specified",
"returning",
"an",
"array",
"with",
"the",
"return",
"values",
"from",
"passed",
"block",
".",
"Additionally",
"the",
"time",
"object",
"passed",
"into",
"the",
"block",
"is",
"... | 53fed4fb33c4fe5948cbc609eaf2319a9b05b1db | https://github.com/jimeh/time_ext/blob/53fed4fb33c4fe5948cbc609eaf2319a9b05b1db/lib/time_ext/iterations.rb#L80-L82 |
7,765 | Burgestrand/mellon | lib/mellon/utils.rb | Mellon.Utils.build_info | def build_info(key, options = {})
options = DEFAULT_OPTIONS.merge(options)
note_type = TYPES.fetch(options.fetch(:type, :note).to_s)
account_name = options.fetch(:account_name, "")
service_name = options.fetch(:service_name, key)
label = options.fetch(:label, service_name)
{
... | ruby | def build_info(key, options = {})
options = DEFAULT_OPTIONS.merge(options)
note_type = TYPES.fetch(options.fetch(:type, :note).to_s)
account_name = options.fetch(:account_name, "")
service_name = options.fetch(:service_name, key)
label = options.fetch(:label, service_name)
{
... | [
"def",
"build_info",
"(",
"key",
",",
"options",
"=",
"{",
"}",
")",
"options",
"=",
"DEFAULT_OPTIONS",
".",
"merge",
"(",
"options",
")",
"note_type",
"=",
"TYPES",
".",
"fetch",
"(",
"options",
".",
"fetch",
"(",
":type",
",",
":note",
")",
".",
"t... | Build an entry info hash.
@param [String] key
@param [Hash] options
@return [Hash] | [
"Build",
"an",
"entry",
"info",
"hash",
"."
] | 4ded7e28fee192a777605e5f9dcd3b1bd05770ef | https://github.com/Burgestrand/mellon/blob/4ded7e28fee192a777605e5f9dcd3b1bd05770ef/lib/mellon/utils.rb#L14-L29 |
7,766 | Burgestrand/mellon | lib/mellon/utils.rb | Mellon.Utils.parse_contents | def parse_contents(password_string)
unpacked = password_string[/password: 0x([a-f0-9]+)/i, 1]
password = if unpacked
[unpacked].pack("H*")
else
password_string[/password: "(.+)"/m, 1]
end
password ||= ""
parsed = Plist.parse_xml(password.force_encoding("".encoding)... | ruby | def parse_contents(password_string)
unpacked = password_string[/password: 0x([a-f0-9]+)/i, 1]
password = if unpacked
[unpacked].pack("H*")
else
password_string[/password: "(.+)"/m, 1]
end
password ||= ""
parsed = Plist.parse_xml(password.force_encoding("".encoding)... | [
"def",
"parse_contents",
"(",
"password_string",
")",
"unpacked",
"=",
"password_string",
"[",
"/",
"/i",
",",
"1",
"]",
"password",
"=",
"if",
"unpacked",
"[",
"unpacked",
"]",
".",
"pack",
"(",
"\"H*\"",
")",
"else",
"password_string",
"[",
"/",
"/m",
... | Parse entry contents.
@param [String]
@return [String] | [
"Parse",
"entry",
"contents",
"."
] | 4ded7e28fee192a777605e5f9dcd3b1bd05770ef | https://github.com/Burgestrand/mellon/blob/4ded7e28fee192a777605e5f9dcd3b1bd05770ef/lib/mellon/utils.rb#L77-L94 |
7,767 | melborne/maliq | lib/maliq/file_utils.rb | Maliq.FileUtils.split | def split(path, marker=nil)
marker ||= SPLIT_MARKER
content = File.read(path)
filename = File.basename(path, '.*')
yfm, content = retrieveYFM(content)
contents = [filename] + content.split(marker)
prev_name = filename
contents.each_slice(2).with({}) do |(fname, text), h|
... | ruby | def split(path, marker=nil)
marker ||= SPLIT_MARKER
content = File.read(path)
filename = File.basename(path, '.*')
yfm, content = retrieveYFM(content)
contents = [filename] + content.split(marker)
prev_name = filename
contents.each_slice(2).with({}) do |(fname, text), h|
... | [
"def",
"split",
"(",
"path",
",",
"marker",
"=",
"nil",
")",
"marker",
"||=",
"SPLIT_MARKER",
"content",
"=",
"File",
".",
"read",
"(",
"path",
")",
"filename",
"=",
"File",
".",
"basename",
"(",
"path",
",",
"'.*'",
")",
"yfm",
",",
"content",
"=",
... | Split a file with SPLIT_MARKER.
Returns a Hash of filename key with its content. | [
"Split",
"a",
"file",
"with",
"SPLIT_MARKER",
".",
"Returns",
"a",
"Hash",
"of",
"filename",
"key",
"with",
"its",
"content",
"."
] | c53f020f5a71e60fcb6df60cef981691cb92428f | https://github.com/melborne/maliq/blob/c53f020f5a71e60fcb6df60cef981691cb92428f/lib/maliq/file_utils.rb#L20-L31 |
7,768 | bilus/akasha | lib/akasha/aggregate.rb | Akasha.Aggregate.apply_events | def apply_events(events)
events.each do |event|
method_name = event_handler(event)
public_send(method_name, event.data) if respond_to?(method_name)
end
@revision = events.last&.revision.to_i if events.last.respond_to?(:revision)
end | ruby | def apply_events(events)
events.each do |event|
method_name = event_handler(event)
public_send(method_name, event.data) if respond_to?(method_name)
end
@revision = events.last&.revision.to_i if events.last.respond_to?(:revision)
end | [
"def",
"apply_events",
"(",
"events",
")",
"events",
".",
"each",
"do",
"|",
"event",
"|",
"method_name",
"=",
"event_handler",
"(",
"event",
")",
"public_send",
"(",
"method_name",
",",
"event",
".",
"data",
")",
"if",
"respond_to?",
"(",
"method_name",
"... | Replay events, building up the state of the aggregate.
Used by Repository. | [
"Replay",
"events",
"building",
"up",
"the",
"state",
"of",
"the",
"aggregate",
".",
"Used",
"by",
"Repository",
"."
] | 5fadefc249f520ae909b762956ac23a6f916b021 | https://github.com/bilus/akasha/blob/5fadefc249f520ae909b762956ac23a6f916b021/lib/akasha/aggregate.rb#L32-L38 |
7,769 | dalehamel/ruby-pandoc | lib/ruby-pandoc/dependencies.rb | RubyPandoc.Dependencies.get_pandoc | def get_pandoc
return if has_pandoc
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
system("wget #{PANDOC_URL} -O pandoc.deb")
system("sudo dpkg -i pandoc.deb")
end
end
end | ruby | def get_pandoc
return if has_pandoc
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
system("wget #{PANDOC_URL} -O pandoc.deb")
system("sudo dpkg -i pandoc.deb")
end
end
end | [
"def",
"get_pandoc",
"return",
"if",
"has_pandoc",
"Dir",
".",
"mktmpdir",
"do",
"|",
"dir",
"|",
"Dir",
".",
"chdir",
"(",
"dir",
")",
"do",
"system",
"(",
"\"wget #{PANDOC_URL} -O pandoc.deb\"",
")",
"system",
"(",
"\"sudo dpkg -i pandoc.deb\"",
")",
"end",
... | FIXME make this conditional to different types of platforms | [
"FIXME",
"make",
"this",
"conditional",
"to",
"different",
"types",
"of",
"platforms"
] | 43a4081c137bc9b7308651dd616e571b63b5ad6a | https://github.com/dalehamel/ruby-pandoc/blob/43a4081c137bc9b7308651dd616e571b63b5ad6a/lib/ruby-pandoc/dependencies.rb#L46-L54 |
7,770 | olarivain/xcodebuilder | lib/xcode_builder.rb | XcodeBuilder.XcodeBuilder.build | def build
clean unless @configuration.skip_clean
# update the long version number with the date
@configuration.timestamp_plist if @configuration.timestamp_build
print "Building Project..."
success = xcodebuild @configuration.build_arguments, "build"
raise "** BUILD FAILED **" unles... | ruby | def build
clean unless @configuration.skip_clean
# update the long version number with the date
@configuration.timestamp_plist if @configuration.timestamp_build
print "Building Project..."
success = xcodebuild @configuration.build_arguments, "build"
raise "** BUILD FAILED **" unles... | [
"def",
"build",
"clean",
"unless",
"@configuration",
".",
"skip_clean",
"# update the long version number with the date",
"@configuration",
".",
"timestamp_plist",
"if",
"@configuration",
".",
"timestamp_build",
"print",
"\"Building Project...\"",
"success",
"=",
"xcodebuild",
... | desc "Build the beta release of the app" | [
"desc",
"Build",
"the",
"beta",
"release",
"of",
"the",
"app"
] | d6b1b7d589261dfd066e77906999ae7bf841d99f | https://github.com/olarivain/xcodebuilder/blob/d6b1b7d589261dfd066e77906999ae7bf841d99f/lib/xcode_builder.rb#L69-L79 |
7,771 | olarivain/xcodebuilder | lib/xcode_builder.rb | XcodeBuilder.XcodeBuilder.pod_dry_run | def pod_dry_run
print "Pod dry run..."
repos = resolved_repos.join ","
result = system "pod lib lint #{@configuration.podspec_file} --allow-warnings --sources=#{repos}"
raise "** Pod dry run failed **" if !result
puts "Done"
end | ruby | def pod_dry_run
print "Pod dry run..."
repos = resolved_repos.join ","
result = system "pod lib lint #{@configuration.podspec_file} --allow-warnings --sources=#{repos}"
raise "** Pod dry run failed **" if !result
puts "Done"
end | [
"def",
"pod_dry_run",
"print",
"\"Pod dry run...\"",
"repos",
"=",
"resolved_repos",
".",
"join",
"\",\"",
"result",
"=",
"system",
"\"pod lib lint #{@configuration.podspec_file} --allow-warnings --sources=#{repos}\"",
"raise",
"\"** Pod dry run failed **\"",
"if",
"!",
"result",... | runs a pod dry run before tagging | [
"runs",
"a",
"pod",
"dry",
"run",
"before",
"tagging"
] | d6b1b7d589261dfd066e77906999ae7bf841d99f | https://github.com/olarivain/xcodebuilder/blob/d6b1b7d589261dfd066e77906999ae7bf841d99f/lib/xcode_builder.rb#L199-L205 |
7,772 | nextmat/hetchy | lib/hetchy/dataset.rb | Hetchy.Dataset.percentile | def percentile(perc)
if perc > 100.0 || perc < 0.0
raise InvalidPercentile, "percentile must be between 0.0 and 100.0"
end
return 0.0 if data.empty?
rank = (perc / 100.0) * (size + 1)
return data[0] if rank < 1
return data[-1] if rank > size
return da... | ruby | def percentile(perc)
if perc > 100.0 || perc < 0.0
raise InvalidPercentile, "percentile must be between 0.0 and 100.0"
end
return 0.0 if data.empty?
rank = (perc / 100.0) * (size + 1)
return data[0] if rank < 1
return data[-1] if rank > size
return da... | [
"def",
"percentile",
"(",
"perc",
")",
"if",
"perc",
">",
"100.0",
"||",
"perc",
"<",
"0.0",
"raise",
"InvalidPercentile",
",",
"\"percentile must be between 0.0 and 100.0\"",
"end",
"return",
"0.0",
"if",
"data",
".",
"empty?",
"rank",
"=",
"(",
"perc",
"/",
... | Generate a percentile for the data set.
@example
snapshot.percentile(95)
snapshot.percentile(99.9) | [
"Generate",
"a",
"percentile",
"for",
"the",
"data",
"set",
"."
] | a06c0127351b5a94d71c8d9a8b7ed9c14bddf96f | https://github.com/nextmat/hetchy/blob/a06c0127351b5a94d71c8d9a8b7ed9c14bddf96f/lib/hetchy/dataset.rb#L26-L38 |
7,773 | nextmat/hetchy | lib/hetchy/dataset.rb | Hetchy.Dataset.weighted_average_for | def weighted_average_for(rank)
above = data[rank.to_i]
below = data[rank.to_i - 1]
fractional = rank - rank.floor
below + ((above - below) * fractional)
end | ruby | def weighted_average_for(rank)
above = data[rank.to_i]
below = data[rank.to_i - 1]
fractional = rank - rank.floor
below + ((above - below) * fractional)
end | [
"def",
"weighted_average_for",
"(",
"rank",
")",
"above",
"=",
"data",
"[",
"rank",
".",
"to_i",
"]",
"below",
"=",
"data",
"[",
"rank",
".",
"to_i",
"-",
"1",
"]",
"fractional",
"=",
"rank",
"-",
"rank",
".",
"floor",
"below",
"+",
"(",
"(",
"abov... | when rank lands between values, generated a weighted average
of adjacent values | [
"when",
"rank",
"lands",
"between",
"values",
"generated",
"a",
"weighted",
"average",
"of",
"adjacent",
"values"
] | a06c0127351b5a94d71c8d9a8b7ed9c14bddf96f | https://github.com/nextmat/hetchy/blob/a06c0127351b5a94d71c8d9a8b7ed9c14bddf96f/lib/hetchy/dataset.rb#L44-L49 |
7,774 | mikiobraun/jblas-ruby | lib/jblas/mixin_convert.rb | JBLAS.MatrixConvertMixin.to_s | def to_s(fmt=nil, coljoin=', ', rowjoin='; ')
if fmt
x = rows_to_a
'[' + x.map do |r|
if Enumerable === r
r.map {|e| sprintf(fmt, e)}.join(coljoin)
else
sprintf(fmt, r)
end
end.join(rowjoin) + ']'
else
toString
end
... | ruby | def to_s(fmt=nil, coljoin=', ', rowjoin='; ')
if fmt
x = rows_to_a
'[' + x.map do |r|
if Enumerable === r
r.map {|e| sprintf(fmt, e)}.join(coljoin)
else
sprintf(fmt, r)
end
end.join(rowjoin) + ']'
else
toString
end
... | [
"def",
"to_s",
"(",
"fmt",
"=",
"nil",
",",
"coljoin",
"=",
"', '",
",",
"rowjoin",
"=",
"'; '",
")",
"if",
"fmt",
"x",
"=",
"rows_to_a",
"'['",
"+",
"x",
".",
"map",
"do",
"|",
"r",
"|",
"if",
"Enumerable",
"===",
"r",
"r",
".",
"map",
"{",
... | Convert this matrix to a string.
This methods takes a few extra arguments to control how the result looks
like.
+fmt+ is a format as used by sprintf, +coljoin+ is the string used to
join column, +rowjoin+ is what is used to join rows. For example,
x.to_s('%.1f', ' ', "\n")
Returns a matrix where columns ar... | [
"Convert",
"this",
"matrix",
"to",
"a",
"string",
"."
] | 7233976c9e3b210e30bc36ead2b1e05ab3383fec | https://github.com/mikiobraun/jblas-ruby/blob/7233976c9e3b210e30bc36ead2b1e05ab3383fec/lib/jblas/mixin_convert.rb#L52-L65 |
7,775 | dimakura/cra.ge | lib/cra/services.rb | CRA.Services.by_name_and_dob | def by_name_and_dob(lname, fname, year, month, day)
body = self.gov_talk_request({
service: 'GetDataUsingCriteriaParameter',
message: 'CRAGetDataUsingCriteria',
class: 'CRAGetDataUsingCriteria',
params: {
LastName: lname,
FirstName: fname,
Year: year... | ruby | def by_name_and_dob(lname, fname, year, month, day)
body = self.gov_talk_request({
service: 'GetDataUsingCriteriaParameter',
message: 'CRAGetDataUsingCriteria',
class: 'CRAGetDataUsingCriteria',
params: {
LastName: lname,
FirstName: fname,
Year: year... | [
"def",
"by_name_and_dob",
"(",
"lname",
",",
"fname",
",",
"year",
",",
"month",
",",
"day",
")",
"body",
"=",
"self",
".",
"gov_talk_request",
"(",
"{",
"service",
":",
"'GetDataUsingCriteriaParameter'",
",",
"message",
":",
"'CRAGetDataUsingCriteria'",
",",
... | Returns array of passports. | [
"Returns",
"array",
"of",
"passports",
"."
] | 13a9c40b27cdad93ae9892eb25aaee2deae4f541 | https://github.com/dimakura/cra.ge/blob/13a9c40b27cdad93ae9892eb25aaee2deae4f541/lib/cra/services.rb#L17-L31 |
7,776 | dimakura/cra.ge | lib/cra/services.rb | CRA.Services.by_id_card | def by_id_card(private_number, id_card_serial, id_card_numb)
body = self.gov_talk_request({
service: 'GetDataUsingPrivateNumberAndIdCardParameter',
message: 'GetDataUsingPrivateNumberAndCard',
class: 'GetDataUsingPrivateNumberAndCard',
params: {
PrivateNumber: private_n... | ruby | def by_id_card(private_number, id_card_serial, id_card_numb)
body = self.gov_talk_request({
service: 'GetDataUsingPrivateNumberAndIdCardParameter',
message: 'GetDataUsingPrivateNumberAndCard',
class: 'GetDataUsingPrivateNumberAndCard',
params: {
PrivateNumber: private_n... | [
"def",
"by_id_card",
"(",
"private_number",
",",
"id_card_serial",
",",
"id_card_numb",
")",
"body",
"=",
"self",
".",
"gov_talk_request",
"(",
"{",
"service",
":",
"'GetDataUsingPrivateNumberAndIdCardParameter'",
",",
"message",
":",
"'GetDataUsingPrivateNumberAndCard'",... | Returns ID card information. | [
"Returns",
"ID",
"card",
"information",
"."
] | 13a9c40b27cdad93ae9892eb25aaee2deae4f541 | https://github.com/dimakura/cra.ge/blob/13a9c40b27cdad93ae9892eb25aaee2deae4f541/lib/cra/services.rb#L34-L46 |
7,777 | dimakura/cra.ge | lib/cra/services.rb | CRA.Services.by_passport | def by_passport(private_number, passport)
body = self.gov_talk_request({
service: 'FetchPersonInfoByPassportNumberUsingCriteriaParameter',
message: 'CRA_FetchInfoByPassportCriteria',
class: 'CRA_FetchInfoByPassportCriteria',
params: {
PrivateNumber: private_number,
... | ruby | def by_passport(private_number, passport)
body = self.gov_talk_request({
service: 'FetchPersonInfoByPassportNumberUsingCriteriaParameter',
message: 'CRA_FetchInfoByPassportCriteria',
class: 'CRA_FetchInfoByPassportCriteria',
params: {
PrivateNumber: private_number,
... | [
"def",
"by_passport",
"(",
"private_number",
",",
"passport",
")",
"body",
"=",
"self",
".",
"gov_talk_request",
"(",
"{",
"service",
":",
"'FetchPersonInfoByPassportNumberUsingCriteriaParameter'",
",",
"message",
":",
"'CRA_FetchInfoByPassportCriteria'",
",",
"class",
... | Returns passport information. | [
"Returns",
"passport",
"information",
"."
] | 13a9c40b27cdad93ae9892eb25aaee2deae4f541 | https://github.com/dimakura/cra.ge/blob/13a9c40b27cdad93ae9892eb25aaee2deae4f541/lib/cra/services.rb#L49-L60 |
7,778 | dimakura/cra.ge | lib/cra/services.rb | CRA.Services.address_by_name | def address_by_name(parent_id, name)
body = self.gov_talk_request({
service: 'AddrFindeAddressByNameParameter',
message: 'CRA_AddrFindeAddressByName',
class: 'CRA_AddrFindeAddressByName',
params: {
Id: parent_id,
Word: name,
}
})
CRA::Addre... | ruby | def address_by_name(parent_id, name)
body = self.gov_talk_request({
service: 'AddrFindeAddressByNameParameter',
message: 'CRA_AddrFindeAddressByName',
class: 'CRA_AddrFindeAddressByName',
params: {
Id: parent_id,
Word: name,
}
})
CRA::Addre... | [
"def",
"address_by_name",
"(",
"parent_id",
",",
"name",
")",
"body",
"=",
"self",
".",
"gov_talk_request",
"(",
"{",
"service",
":",
"'AddrFindeAddressByNameParameter'",
",",
"message",
":",
"'CRA_AddrFindeAddressByName'",
",",
"class",
":",
"'CRA_AddrFindeAddressByN... | Returns array of addresses. | [
"Returns",
"array",
"of",
"addresses",
"."
] | 13a9c40b27cdad93ae9892eb25aaee2deae4f541 | https://github.com/dimakura/cra.ge/blob/13a9c40b27cdad93ae9892eb25aaee2deae4f541/lib/cra/services.rb#L63-L74 |
7,779 | dimakura/cra.ge | lib/cra/services.rb | CRA.Services.address_by_parent | def address_by_parent(parent_id)
body = self.gov_talk_request({
message: 'CRA_AddrGetNodesByParentID',
class: 'CRA_AddrGetNodesByParentID',
params: {
long: parent_id,
}
})
CRA::AddressNode.list_from_hash(body['ArrayOfNodeInfo']['NodeInfo'])
end | ruby | def address_by_parent(parent_id)
body = self.gov_talk_request({
message: 'CRA_AddrGetNodesByParentID',
class: 'CRA_AddrGetNodesByParentID',
params: {
long: parent_id,
}
})
CRA::AddressNode.list_from_hash(body['ArrayOfNodeInfo']['NodeInfo'])
end | [
"def",
"address_by_parent",
"(",
"parent_id",
")",
"body",
"=",
"self",
".",
"gov_talk_request",
"(",
"{",
"message",
":",
"'CRA_AddrGetNodesByParentID'",
",",
"class",
":",
"'CRA_AddrGetNodesByParentID'",
",",
"params",
":",
"{",
"long",
":",
"parent_id",
",",
... | Returns array of address nodes. | [
"Returns",
"array",
"of",
"address",
"nodes",
"."
] | 13a9c40b27cdad93ae9892eb25aaee2deae4f541 | https://github.com/dimakura/cra.ge/blob/13a9c40b27cdad93ae9892eb25aaee2deae4f541/lib/cra/services.rb#L87-L96 |
7,780 | dimakura/cra.ge | lib/cra/services.rb | CRA.Services.address_info | def address_info(id)
body = self.gov_talk_request({
message: 'CRA_AddrGetAddressInfoByID',
class: 'CRA_AddrGetAddressInfoByID',
params: {
long: id,
}
})
# puts body.to_s
CRA::AddressInfo.init_from_hash(body['AddressInfo'])
end | ruby | def address_info(id)
body = self.gov_talk_request({
message: 'CRA_AddrGetAddressInfoByID',
class: 'CRA_AddrGetAddressInfoByID',
params: {
long: id,
}
})
# puts body.to_s
CRA::AddressInfo.init_from_hash(body['AddressInfo'])
end | [
"def",
"address_info",
"(",
"id",
")",
"body",
"=",
"self",
".",
"gov_talk_request",
"(",
"{",
"message",
":",
"'CRA_AddrGetAddressInfoByID'",
",",
"class",
":",
"'CRA_AddrGetAddressInfoByID'",
",",
"params",
":",
"{",
"long",
":",
"id",
",",
"}",
"}",
")",
... | Get address info by it's id. | [
"Get",
"address",
"info",
"by",
"it",
"s",
"id",
"."
] | 13a9c40b27cdad93ae9892eb25aaee2deae4f541 | https://github.com/dimakura/cra.ge/blob/13a9c40b27cdad93ae9892eb25aaee2deae4f541/lib/cra/services.rb#L99-L109 |
7,781 | dimakura/cra.ge | lib/cra/services.rb | CRA.Services.persons_at_address | def persons_at_address(address_id)
body = self.gov_talk_request({
message: 'CRA_GetPersonsAtAddress',
class: 'CRA_GetPersonsAtAddress',
params: {
long: address_id,
}
})
CRA::PersonAtAddress.list_from_hash(body['ArrayOfPersonsAtAddress'])
end | ruby | def persons_at_address(address_id)
body = self.gov_talk_request({
message: 'CRA_GetPersonsAtAddress',
class: 'CRA_GetPersonsAtAddress',
params: {
long: address_id,
}
})
CRA::PersonAtAddress.list_from_hash(body['ArrayOfPersonsAtAddress'])
end | [
"def",
"persons_at_address",
"(",
"address_id",
")",
"body",
"=",
"self",
".",
"gov_talk_request",
"(",
"{",
"message",
":",
"'CRA_GetPersonsAtAddress'",
",",
"class",
":",
"'CRA_GetPersonsAtAddress'",
",",
"params",
":",
"{",
"long",
":",
"address_id",
",",
"}"... | Get persons array at the given address. | [
"Get",
"persons",
"array",
"at",
"the",
"given",
"address",
"."
] | 13a9c40b27cdad93ae9892eb25aaee2deae4f541 | https://github.com/dimakura/cra.ge/blob/13a9c40b27cdad93ae9892eb25aaee2deae4f541/lib/cra/services.rb#L112-L121 |
7,782 | EmmanuelOga/firering | lib/firering/requests.rb | Firering.Requests.user | def user(id, &callback)
http(:get, "/users/#{id}.json") do |data, http|
Firering::User.instantiate(self, data, :user, &callback)
end
end | ruby | def user(id, &callback)
http(:get, "/users/#{id}.json") do |data, http|
Firering::User.instantiate(self, data, :user, &callback)
end
end | [
"def",
"user",
"(",
"id",
",",
"&",
"callback",
")",
"http",
"(",
":get",
",",
"\"/users/#{id}.json\"",
")",
"do",
"|",
"data",
",",
"http",
"|",
"Firering",
"::",
"User",
".",
"instantiate",
"(",
"self",
",",
"data",
",",
":user",
",",
"callback",
"... | returns a user by id | [
"returns",
"a",
"user",
"by",
"id"
] | 9e13dc3399f7429713b5213c5ee77bedf01def31 | https://github.com/EmmanuelOga/firering/blob/9e13dc3399f7429713b5213c5ee77bedf01def31/lib/firering/requests.rb#L13-L17 |
7,783 | EmmanuelOga/firering | lib/firering/requests.rb | Firering.Requests.room | def room(id, &callback)
http(:get, "/room/#{id}.json") do |data, http|
Firering::Room.instantiate(self, data, :room, &callback)
end
end | ruby | def room(id, &callback)
http(:get, "/room/#{id}.json") do |data, http|
Firering::Room.instantiate(self, data, :room, &callback)
end
end | [
"def",
"room",
"(",
"id",
",",
"&",
"callback",
")",
"http",
"(",
":get",
",",
"\"/room/#{id}.json\"",
")",
"do",
"|",
"data",
",",
"http",
"|",
"Firering",
"::",
"Room",
".",
"instantiate",
"(",
"self",
",",
"data",
",",
":room",
",",
"callback",
")... | returns a room by id | [
"returns",
"a",
"room",
"by",
"id"
] | 9e13dc3399f7429713b5213c5ee77bedf01def31 | https://github.com/EmmanuelOga/firering/blob/9e13dc3399f7429713b5213c5ee77bedf01def31/lib/firering/requests.rb#L20-L24 |
7,784 | EmmanuelOga/firering | lib/firering/requests.rb | Firering.Requests.search_messages | def search_messages(query, &callback)
http(:get, "/search/#{query}.json") do |data, http|
callback.call(data[:messages].map { |msg| Firering::Message.instantiate(self, msg) }) if callback
end
end | ruby | def search_messages(query, &callback)
http(:get, "/search/#{query}.json") do |data, http|
callback.call(data[:messages].map { |msg| Firering::Message.instantiate(self, msg) }) if callback
end
end | [
"def",
"search_messages",
"(",
"query",
",",
"&",
"callback",
")",
"http",
"(",
":get",
",",
"\"/search/#{query}.json\"",
")",
"do",
"|",
"data",
",",
"http",
"|",
"callback",
".",
"call",
"(",
"data",
"[",
":messages",
"]",
".",
"map",
"{",
"|",
"msg"... | Returns all the messages containing the supplied term. | [
"Returns",
"all",
"the",
"messages",
"containing",
"the",
"supplied",
"term",
"."
] | 9e13dc3399f7429713b5213c5ee77bedf01def31 | https://github.com/EmmanuelOga/firering/blob/9e13dc3399f7429713b5213c5ee77bedf01def31/lib/firering/requests.rb#L40-L44 |
7,785 | EmmanuelOga/firering | lib/firering/requests.rb | Firering.Requests.star_message | def star_message(id, yes_or_no = true, &callback)
http(yes_or_no ? :post : :delete, "/messages/#{id}/star.json") do |data, http|
callback.call(data) if callback
end
end | ruby | def star_message(id, yes_or_no = true, &callback)
http(yes_or_no ? :post : :delete, "/messages/#{id}/star.json") do |data, http|
callback.call(data) if callback
end
end | [
"def",
"star_message",
"(",
"id",
",",
"yes_or_no",
"=",
"true",
",",
"&",
"callback",
")",
"http",
"(",
"yes_or_no",
"?",
":post",
":",
":delete",
",",
"\"/messages/#{id}/star.json\"",
")",
"do",
"|",
"data",
",",
"http",
"|",
"callback",
".",
"call",
"... | Toggles the star next to a message | [
"Toggles",
"the",
"star",
"next",
"to",
"a",
"message"
] | 9e13dc3399f7429713b5213c5ee77bedf01def31 | https://github.com/EmmanuelOga/firering/blob/9e13dc3399f7429713b5213c5ee77bedf01def31/lib/firering/requests.rb#L47-L51 |
7,786 | Tapjoy/slugforge | lib/slugforge/configuration.rb | Slugforge.Configuration.defaults | def defaults
@values = Hash[self.class.options.select { |_, c| c.key?(:default) }.map { |n,c| [n, c[:default]] }].merge(@values)
end | ruby | def defaults
@values = Hash[self.class.options.select { |_, c| c.key?(:default) }.map { |n,c| [n, c[:default]] }].merge(@values)
end | [
"def",
"defaults",
"@values",
"=",
"Hash",
"[",
"self",
".",
"class",
".",
"options",
".",
"select",
"{",
"|",
"_",
",",
"c",
"|",
"c",
".",
"key?",
"(",
":default",
")",
"}",
".",
"map",
"{",
"|",
"n",
",",
"c",
"|",
"[",
"n",
",",
"c",
"[... | Get a hash of all options with default values. The list of values is initialized with the result. | [
"Get",
"a",
"hash",
"of",
"all",
"options",
"with",
"default",
"values",
".",
"The",
"list",
"of",
"values",
"is",
"initialized",
"with",
"the",
"result",
"."
] | 2e6b3d3022a1172dd7411e2d53b6218ad40d29c8 | https://github.com/Tapjoy/slugforge/blob/2e6b3d3022a1172dd7411e2d53b6218ad40d29c8/lib/slugforge/configuration.rb#L58-L60 |
7,787 | Tapjoy/slugforge | lib/slugforge/configuration.rb | Slugforge.Configuration.read_yaml | def read_yaml(path)
return unless File.exist?(path)
source = YAML.load_file(path)
return unless source.is_a?(Hash)
update_with { |config| read_yaml_key(source, config[:key]) }
end | ruby | def read_yaml(path)
return unless File.exist?(path)
source = YAML.load_file(path)
return unless source.is_a?(Hash)
update_with { |config| read_yaml_key(source, config[:key]) }
end | [
"def",
"read_yaml",
"(",
"path",
")",
"return",
"unless",
"File",
".",
"exist?",
"(",
"path",
")",
"source",
"=",
"YAML",
".",
"load_file",
"(",
"path",
")",
"return",
"unless",
"source",
".",
"is_a?",
"(",
"Hash",
")",
"update_with",
"{",
"|",
"config... | Attempt to read option keys from a YAML file | [
"Attempt",
"to",
"read",
"option",
"keys",
"from",
"a",
"YAML",
"file"
] | 2e6b3d3022a1172dd7411e2d53b6218ad40d29c8 | https://github.com/Tapjoy/slugforge/blob/2e6b3d3022a1172dd7411e2d53b6218ad40d29c8/lib/slugforge/configuration.rb#L88-L94 |
7,788 | Tapjoy/slugforge | lib/slugforge/configuration.rb | Slugforge.Configuration.update_with | def update_with(&blk)
self.class.options.each do |name, config|
value = yield(config)
@values[name] = value unless value.nil?
end
end | ruby | def update_with(&blk)
self.class.options.each do |name, config|
value = yield(config)
@values[name] = value unless value.nil?
end
end | [
"def",
"update_with",
"(",
"&",
"blk",
")",
"self",
".",
"class",
".",
"options",
".",
"each",
"do",
"|",
"name",
",",
"config",
"|",
"value",
"=",
"yield",
"(",
"config",
")",
"@values",
"[",
"name",
"]",
"=",
"value",
"unless",
"value",
".",
"nil... | For every option we yield the configuration and expect a value back. If the block returns a value we set the
option to it. | [
"For",
"every",
"option",
"we",
"yield",
"the",
"configuration",
"and",
"expect",
"a",
"value",
"back",
".",
"If",
"the",
"block",
"returns",
"a",
"value",
"we",
"set",
"the",
"option",
"to",
"it",
"."
] | 2e6b3d3022a1172dd7411e2d53b6218ad40d29c8 | https://github.com/Tapjoy/slugforge/blob/2e6b3d3022a1172dd7411e2d53b6218ad40d29c8/lib/slugforge/configuration.rb#L117-L122 |
7,789 | rack-webprofiler/rack-webprofiler | lib/rack/web_profiler/collectors.rb | Rack.WebProfiler::Collectors.add_collector | def add_collector(collector_class)
return collector_class.each { |c| add_collector(c) } if collector_class.is_a? Array
raise ArgumentError, "`collector_class' must be a class" unless collector_class.is_a? Class
unless collector_class.included_modules.include?(Rack::WebProfiler::Collector::DSL)
... | ruby | def add_collector(collector_class)
return collector_class.each { |c| add_collector(c) } if collector_class.is_a? Array
raise ArgumentError, "`collector_class' must be a class" unless collector_class.is_a? Class
unless collector_class.included_modules.include?(Rack::WebProfiler::Collector::DSL)
... | [
"def",
"add_collector",
"(",
"collector_class",
")",
"return",
"collector_class",
".",
"each",
"{",
"|",
"c",
"|",
"add_collector",
"(",
"c",
")",
"}",
"if",
"collector_class",
".",
"is_a?",
"Array",
"raise",
"ArgumentError",
",",
"\"`collector_class' must be a cl... | Add a collector.
@param collector_class [Array, Class]
@raise [ArgumentError] if `collector_class' is not a Class or is not an instance of Rack::WebProfiler::Collector::DSL
or a collector with this identifier is already registrered. | [
"Add",
"a",
"collector",
"."
] | bdb411fbb41eeddf612bbde91301ff94b3853a12 | https://github.com/rack-webprofiler/rack-webprofiler/blob/bdb411fbb41eeddf612bbde91301ff94b3853a12/lib/rack/web_profiler/collectors.rb#L40-L61 |
7,790 | rack-webprofiler/rack-webprofiler | lib/rack/web_profiler/collectors.rb | Rack.WebProfiler::Collectors.sort_collectors! | def sort_collectors!
@sorted_collectors = {}
tmp = @collectors.sort_by { |_klass, definition| definition.position }
tmp.each { |_k, v| @sorted_collectors[v.identifier.to_sym] = v }
end | ruby | def sort_collectors!
@sorted_collectors = {}
tmp = @collectors.sort_by { |_klass, definition| definition.position }
tmp.each { |_k, v| @sorted_collectors[v.identifier.to_sym] = v }
end | [
"def",
"sort_collectors!",
"@sorted_collectors",
"=",
"{",
"}",
"tmp",
"=",
"@collectors",
".",
"sort_by",
"{",
"|",
"_klass",
",",
"definition",
"|",
"definition",
".",
"position",
"}",
"tmp",
".",
"each",
"{",
"|",
"_k",
",",
"v",
"|",
"@sorted_collector... | Sort collectors by definition identifier. | [
"Sort",
"collectors",
"by",
"definition",
"identifier",
"."
] | bdb411fbb41eeddf612bbde91301ff94b3853a12 | https://github.com/rack-webprofiler/rack-webprofiler/blob/bdb411fbb41eeddf612bbde91301ff94b3853a12/lib/rack/web_profiler/collectors.rb#L88-L93 |
7,791 | bazaarlabs/tvdbr | lib/tvdbr/data_set.rb | Tvdbr.DataSet.normalize_value | def normalize_value(val)
if val.is_a?(Hash)
val = val["__content__"] if val.has_key?("__content__")
val = val.values.first if val.respond_to?(:values) && val.values.one?
val = val.join(" ") if val.respond_to?(:join)
val.to_s
else # any other value
val
... | ruby | def normalize_value(val)
if val.is_a?(Hash)
val = val["__content__"] if val.has_key?("__content__")
val = val.values.first if val.respond_to?(:values) && val.values.one?
val = val.join(" ") if val.respond_to?(:join)
val.to_s
else # any other value
val
... | [
"def",
"normalize_value",
"(",
"val",
")",
"if",
"val",
".",
"is_a?",
"(",
"Hash",
")",
"val",
"=",
"val",
"[",
"\"__content__\"",
"]",
"if",
"val",
".",
"has_key?",
"(",
"\"__content__\"",
")",
"val",
"=",
"val",
".",
"values",
".",
"first",
"if",
"... | Normalizes a value for the formatted hash values
TVDB hashes should not contain more hashes
Sometimes TVDB returns a hash with content inside which needs to be extracted | [
"Normalizes",
"a",
"value",
"for",
"the",
"formatted",
"hash",
"values",
"TVDB",
"hashes",
"should",
"not",
"contain",
"more",
"hashes",
"Sometimes",
"TVDB",
"returns",
"a",
"hash",
"with",
"content",
"inside",
"which",
"needs",
"to",
"be",
"extracted"
] | be9a1324c8d8051b7063bf7152aa1c53c25b0661 | https://github.com/bazaarlabs/tvdbr/blob/be9a1324c8d8051b7063bf7152aa1c53c25b0661/lib/tvdbr/data_set.rb#L76-L85 |
7,792 | Sology/syswatch | lib/syswatch/cli.rb | SysWatch.CLI.parse_options! | def parse_options!(args)
@options = {}
opts = ::OptionParser.new do |opts|
opts.banner = "Usage: syswatch [options]\n\n Options:"
opts.on("-f", "--foreground", "Do not daemonize, just run in foreground.") do |f|
@options[:foreground] = f
end
opts.on("-v", "--verbose", "Be verbose, print ou... | ruby | def parse_options!(args)
@options = {}
opts = ::OptionParser.new do |opts|
opts.banner = "Usage: syswatch [options]\n\n Options:"
opts.on("-f", "--foreground", "Do not daemonize, just run in foreground.") do |f|
@options[:foreground] = f
end
opts.on("-v", "--verbose", "Be verbose, print ou... | [
"def",
"parse_options!",
"(",
"args",
")",
"@options",
"=",
"{",
"}",
"opts",
"=",
"::",
"OptionParser",
".",
"new",
"do",
"|",
"opts",
"|",
"opts",
".",
"banner",
"=",
"\"Usage: syswatch [options]\\n\\n Options:\"",
"opts",
".",
"on",
"(",
"\"-f\"",
",",
... | Initialize a new system watcher
@param argv [Hash] the command line parameters hash (usually `ARGV`).
@param env [Hash] the environment variables hash (usually `ENV`).
Parse the command line options | [
"Initialize",
"a",
"new",
"system",
"watcher"
] | 75d64d3e93e7d4a506396bb7c0ce2169daca712e | https://github.com/Sology/syswatch/blob/75d64d3e93e7d4a506396bb7c0ce2169daca712e/lib/syswatch/cli.rb#L19-L41 |
7,793 | Tapjoy/slugforge | lib/slugforge/slugins.rb | Slugforge.SluginManager.locate_slugins | def locate_slugins
Gem.refresh
(Gem::Specification.respond_to?(:each) ? Gem::Specification : Gem.source_index.find_name('')).each do |gem|
next if gem.name !~ PREFIX
slugin_name = gem.name.split('-', 2).last
@slugins << Slugin.new(slugin_name, gem.name, gem, true) if !gem_located?(ge... | ruby | def locate_slugins
Gem.refresh
(Gem::Specification.respond_to?(:each) ? Gem::Specification : Gem.source_index.find_name('')).each do |gem|
next if gem.name !~ PREFIX
slugin_name = gem.name.split('-', 2).last
@slugins << Slugin.new(slugin_name, gem.name, gem, true) if !gem_located?(ge... | [
"def",
"locate_slugins",
"Gem",
".",
"refresh",
"(",
"Gem",
"::",
"Specification",
".",
"respond_to?",
"(",
":each",
")",
"?",
"Gem",
"::",
"Specification",
":",
"Gem",
".",
"source_index",
".",
"find_name",
"(",
"''",
")",
")",
".",
"each",
"do",
"|",
... | Find all installed Pry slugins and store them in an internal array. | [
"Find",
"all",
"installed",
"Pry",
"slugins",
"and",
"store",
"them",
"in",
"an",
"internal",
"array",
"."
] | 2e6b3d3022a1172dd7411e2d53b6218ad40d29c8 | https://github.com/Tapjoy/slugforge/blob/2e6b3d3022a1172dd7411e2d53b6218ad40d29c8/lib/slugforge/slugins.rb#L110-L118 |
7,794 | dlangevin/gxapi_rails | lib/gxapi/ostruct.rb | Gxapi.Ostruct.to_hash | def to_hash
ret = {}
@hash.dup.each_pair do |key, val|
ret[key] = self.convert_value_from_ostruct(val)
end
ret
end | ruby | def to_hash
ret = {}
@hash.dup.each_pair do |key, val|
ret[key] = self.convert_value_from_ostruct(val)
end
ret
end | [
"def",
"to_hash",
"ret",
"=",
"{",
"}",
"@hash",
".",
"dup",
".",
"each_pair",
"do",
"|",
"key",
",",
"val",
"|",
"ret",
"[",
"key",
"]",
"=",
"self",
".",
"convert_value_from_ostruct",
"(",
"val",
")",
"end",
"ret",
"end"
] | recursive open struct | [
"recursive",
"open",
"struct"
] | 21361227f0c70118b38f7fa372a18c0ae7aab810 | https://github.com/dlangevin/gxapi_rails/blob/21361227f0c70118b38f7fa372a18c0ae7aab810/lib/gxapi/ostruct.rb#L17-L23 |
7,795 | dlangevin/gxapi_rails | lib/gxapi/ostruct.rb | Gxapi.Ostruct.define_accessors | def define_accessors(field)
# add the generated method
self.generated_methods.module_eval do
define_method(field) do
@hash[field]
end
define_method("#{field}=") do |val|
@hash[field] = val
end
end
end | ruby | def define_accessors(field)
# add the generated method
self.generated_methods.module_eval do
define_method(field) do
@hash[field]
end
define_method("#{field}=") do |val|
@hash[field] = val
end
end
end | [
"def",
"define_accessors",
"(",
"field",
")",
"# add the generated method",
"self",
".",
"generated_methods",
".",
"module_eval",
"do",
"define_method",
"(",
"field",
")",
"do",
"@hash",
"[",
"field",
"]",
"end",
"define_method",
"(",
"\"#{field}=\"",
")",
"do",
... | define accessors for an attribute | [
"define",
"accessors",
"for",
"an",
"attribute"
] | 21361227f0c70118b38f7fa372a18c0ae7aab810 | https://github.com/dlangevin/gxapi_rails/blob/21361227f0c70118b38f7fa372a18c0ae7aab810/lib/gxapi/ostruct.rb#L51-L61 |
7,796 | dlangevin/gxapi_rails | lib/gxapi/ostruct.rb | Gxapi.Ostruct.method_missing | def method_missing(meth, *args, &block)
if meth.to_s =~ /=$/
self.define_accessors(meth.to_s.gsub(/=$/,''))
return self.send(meth, *args, &block)
end
super
end | ruby | def method_missing(meth, *args, &block)
if meth.to_s =~ /=$/
self.define_accessors(meth.to_s.gsub(/=$/,''))
return self.send(meth, *args, &block)
end
super
end | [
"def",
"method_missing",
"(",
"meth",
",",
"*",
"args",
",",
"&",
"block",
")",
"if",
"meth",
".",
"to_s",
"=~",
"/",
"/",
"self",
".",
"define_accessors",
"(",
"meth",
".",
"to_s",
".",
"gsub",
"(",
"/",
"/",
",",
"''",
")",
")",
"return",
"self... | dynamically define getter and setter when an unknown setter is called | [
"dynamically",
"define",
"getter",
"and",
"setter",
"when",
"an",
"unknown",
"setter",
"is",
"called"
] | 21361227f0c70118b38f7fa372a18c0ae7aab810 | https://github.com/dlangevin/gxapi_rails/blob/21361227f0c70118b38f7fa372a18c0ae7aab810/lib/gxapi/ostruct.rb#L69-L75 |
7,797 | dlangevin/gxapi_rails | lib/gxapi/ostruct.rb | Gxapi.Ostruct.underscore | def underscore(string)
string = string.to_s
string = string[0].downcase + string[1..-1].gsub(/([A-Z])/,'_\1')
string.downcase
end | ruby | def underscore(string)
string = string.to_s
string = string[0].downcase + string[1..-1].gsub(/([A-Z])/,'_\1')
string.downcase
end | [
"def",
"underscore",
"(",
"string",
")",
"string",
"=",
"string",
".",
"to_s",
"string",
"=",
"string",
"[",
"0",
"]",
".",
"downcase",
"+",
"string",
"[",
"1",
"..",
"-",
"1",
"]",
".",
"gsub",
"(",
"/",
"/",
",",
"'_\\1'",
")",
"string",
".",
... | take a string an convert it from
camelCase to under_scored | [
"take",
"a",
"string",
"an",
"convert",
"it",
"from",
"camelCase",
"to",
"under_scored"
] | 21361227f0c70118b38f7fa372a18c0ae7aab810 | https://github.com/dlangevin/gxapi_rails/blob/21361227f0c70118b38f7fa372a18c0ae7aab810/lib/gxapi/ostruct.rb#L79-L83 |
7,798 | jlinder/nitroapi | lib/nitro_api/batch_calls.rb | NitroApi.BatchCalls.handle_batch_multiple_actions | def handle_batch_multiple_actions
# TODO: improve handling of errors in the batch response
actions = []
@batch.each do |action|
actions << to_query(action[:params])
end
results = really_make_call({'method' => 'batch.run','methodFeed' => JSON.dump(actions)}, :post)
@batch = n... | ruby | def handle_batch_multiple_actions
# TODO: improve handling of errors in the batch response
actions = []
@batch.each do |action|
actions << to_query(action[:params])
end
results = really_make_call({'method' => 'batch.run','methodFeed' => JSON.dump(actions)}, :post)
@batch = n... | [
"def",
"handle_batch_multiple_actions",
"# TODO: improve handling of errors in the batch response",
"actions",
"=",
"[",
"]",
"@batch",
".",
"each",
"do",
"|",
"action",
"|",
"actions",
"<<",
"to_query",
"(",
"action",
"[",
":params",
"]",
")",
"end",
"results",
"="... | This function handles making the call when there is more than one call in
the batch. | [
"This",
"function",
"handles",
"making",
"the",
"call",
"when",
"there",
"is",
"more",
"than",
"one",
"call",
"in",
"the",
"batch",
"."
] | 9bf51a1988e213ce0020b783d7d375fe8d418638 | https://github.com/jlinder/nitroapi/blob/9bf51a1988e213ce0020b783d7d375fe8d418638/lib/nitro_api/batch_calls.rb#L35-L46 |
7,799 | marcmo/cxxproject | lib/cxxproject/buildingblocks/static_library.rb | Cxxproject.StaticLibrary.convert_to_rake | def convert_to_rake()
object_multitask = prepare_tasks_for_objects()
archiver = @tcs[:ARCHIVER]
res = typed_file_task Rake::Task::LIBRARY, get_task_name => object_multitask do
cmd = calc_command_line
aname = calc_archive_name
Dir.chdir(@project_dir) do
FileUtils.rm(a... | ruby | def convert_to_rake()
object_multitask = prepare_tasks_for_objects()
archiver = @tcs[:ARCHIVER]
res = typed_file_task Rake::Task::LIBRARY, get_task_name => object_multitask do
cmd = calc_command_line
aname = calc_archive_name
Dir.chdir(@project_dir) do
FileUtils.rm(a... | [
"def",
"convert_to_rake",
"(",
")",
"object_multitask",
"=",
"prepare_tasks_for_objects",
"(",
")",
"archiver",
"=",
"@tcs",
"[",
":ARCHIVER",
"]",
"res",
"=",
"typed_file_task",
"Rake",
"::",
"Task",
"::",
"LIBRARY",
",",
"get_task_name",
"=>",
"object_multitask"... | task that will link the given object files to a static lib | [
"task",
"that",
"will",
"link",
"the",
"given",
"object",
"files",
"to",
"a",
"static",
"lib"
] | 3740a09d6a143acd96bde3d2ff79055a6b810da4 | https://github.com/marcmo/cxxproject/blob/3740a09d6a143acd96bde3d2ff79055a6b810da4/lib/cxxproject/buildingblocks/static_library.rb#L86-L119 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.