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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8,000 | m-31/puppetdb_query | lib/puppetdb_query/mongodb.rb | PuppetDBQuery.MongoDB.node_properties_update | def node_properties_update(new_node_properties)
collection = connection[node_properties_collection]
old_names = collection.find.batch_size(999).projection(_id: 1).map { |k| k[:_id] }
delete = old_names - new_node_properties.keys
data = new_node_properties.map do |k, v|
{
replac... | ruby | def node_properties_update(new_node_properties)
collection = connection[node_properties_collection]
old_names = collection.find.batch_size(999).projection(_id: 1).map { |k| k[:_id] }
delete = old_names - new_node_properties.keys
data = new_node_properties.map do |k, v|
{
replac... | [
"def",
"node_properties_update",
"(",
"new_node_properties",
")",
"collection",
"=",
"connection",
"[",
"node_properties_collection",
"]",
"old_names",
"=",
"collection",
".",
"find",
".",
"batch_size",
"(",
"999",
")",
".",
"projection",
"(",
"_id",
":",
"1",
"... | update node properties | [
"update",
"node",
"properties"
] | 58103c91f291de8ce28d679256e50ae391b93ecb | https://github.com/m-31/puppetdb_query/blob/58103c91f291de8ce28d679256e50ae391b93ecb/lib/puppetdb_query/mongodb.rb#L206-L222 |
8,001 | m-31/puppetdb_query | lib/puppetdb_query/mongodb.rb | PuppetDBQuery.MongoDB.meta_fact_update | def meta_fact_update(method, ts_begin, ts_end)
connection[meta_collection].find_one_and_update(
{},
{
'$set' => {
last_fact_update: {
ts_begin: ts_begin.iso8601,
ts_end: ts_end.iso8601,
method: method
},
me... | ruby | def meta_fact_update(method, ts_begin, ts_end)
connection[meta_collection].find_one_and_update(
{},
{
'$set' => {
last_fact_update: {
ts_begin: ts_begin.iso8601,
ts_end: ts_end.iso8601,
method: method
},
me... | [
"def",
"meta_fact_update",
"(",
"method",
",",
"ts_begin",
",",
"ts_end",
")",
"connection",
"[",
"meta_collection",
"]",
".",
"find_one_and_update",
"(",
"{",
"}",
",",
"{",
"'$set'",
"=>",
"{",
"last_fact_update",
":",
"{",
"ts_begin",
":",
"ts_begin",
"."... | update or insert timestamps for given fact update method | [
"update",
"or",
"insert",
"timestamps",
"for",
"given",
"fact",
"update",
"method"
] | 58103c91f291de8ce28d679256e50ae391b93ecb | https://github.com/m-31/puppetdb_query/blob/58103c91f291de8ce28d679256e50ae391b93ecb/lib/puppetdb_query/mongodb.rb#L225-L243 |
8,002 | m-31/puppetdb_query | lib/puppetdb_query/mongodb.rb | PuppetDBQuery.MongoDB.meta_node_properties_update | def meta_node_properties_update(ts_begin, ts_end)
connection[meta_collection].find_one_and_update(
{},
{
'$set' => {
last_node_properties_update: {
ts_begin: ts_begin.iso8601,
ts_end: ts_end.iso8601
}
}
},
{ ... | ruby | def meta_node_properties_update(ts_begin, ts_end)
connection[meta_collection].find_one_and_update(
{},
{
'$set' => {
last_node_properties_update: {
ts_begin: ts_begin.iso8601,
ts_end: ts_end.iso8601
}
}
},
{ ... | [
"def",
"meta_node_properties_update",
"(",
"ts_begin",
",",
"ts_end",
")",
"connection",
"[",
"meta_collection",
"]",
".",
"find_one_and_update",
"(",
"{",
"}",
",",
"{",
"'$set'",
"=>",
"{",
"last_node_properties_update",
":",
"{",
"ts_begin",
":",
"ts_begin",
... | update or insert timestamps for node_properties_update | [
"update",
"or",
"insert",
"timestamps",
"for",
"node_properties_update"
] | 58103c91f291de8ce28d679256e50ae391b93ecb | https://github.com/m-31/puppetdb_query/blob/58103c91f291de8ce28d679256e50ae391b93ecb/lib/puppetdb_query/mongodb.rb#L246-L260 |
8,003 | minhnghivn/idata | lib/idata/detector.rb | Idata.Detector.find_same_occurence | def find_same_occurence
selected = @candidates.select { |delim, count|
begin
CSV.parse(@sample, col_sep: delim).select{|e| !e.empty? }.map{|e| e.count}.uniq.count == 1
rescue Exception => ex
false
end
}.keys
return selected.first if selected.count == 1
... | ruby | def find_same_occurence
selected = @candidates.select { |delim, count|
begin
CSV.parse(@sample, col_sep: delim).select{|e| !e.empty? }.map{|e| e.count}.uniq.count == 1
rescue Exception => ex
false
end
}.keys
return selected.first if selected.count == 1
... | [
"def",
"find_same_occurence",
"selected",
"=",
"@candidates",
".",
"select",
"{",
"|",
"delim",
",",
"count",
"|",
"begin",
"CSV",
".",
"parse",
"(",
"@sample",
",",
"col_sep",
":",
"delim",
")",
".",
"select",
"{",
"|",
"e",
"|",
"!",
"e",
".",
"emp... | high confident level | [
"high",
"confident",
"level"
] | 266bff364e8c98dd12eb4256dc7a3ee10a142fb3 | https://github.com/minhnghivn/idata/blob/266bff364e8c98dd12eb4256dc7a3ee10a142fb3/lib/idata/detector.rb#L53-L64 |
8,004 | jduckett/duck_map | lib/duck_map/route.rb | DuckMap.Route.keys_required? | def keys_required?
keys = self.segment_keys.dup
keys.delete(:format)
return keys.length > 0 ? true : false
end | ruby | def keys_required?
keys = self.segment_keys.dup
keys.delete(:format)
return keys.length > 0 ? true : false
end | [
"def",
"keys_required?",
"keys",
"=",
"self",
".",
"segment_keys",
".",
"dup",
"keys",
".",
"delete",
"(",
":format",
")",
"return",
"keys",
".",
"length",
">",
"0",
"?",
"true",
":",
"false",
"end"
] | Indicates if the current route requirements segments keys to generate a url.
@return [Boolean] True if keys are required to generate a url, otherwise, false. | [
"Indicates",
"if",
"the",
"current",
"route",
"requirements",
"segments",
"keys",
"to",
"generate",
"a",
"url",
"."
] | c510acfa95e8ad4afb1501366058ae88a73704df | https://github.com/jduckett/duck_map/blob/c510acfa95e8ad4afb1501366058ae88a73704df/lib/duck_map/route.rb#L261-L265 |
8,005 | emancu/ork | lib/ork/result_set.rb | Ork.ResultSet.next_page | def next_page
raise Ork::NoNextPage.new 'There is no next page' unless has_next_page?
self.class.new(@model,
@index,
@query,
@options.merge(continuation: keys.continuation))
end | ruby | def next_page
raise Ork::NoNextPage.new 'There is no next page' unless has_next_page?
self.class.new(@model,
@index,
@query,
@options.merge(continuation: keys.continuation))
end | [
"def",
"next_page",
"raise",
"Ork",
"::",
"NoNextPage",
".",
"new",
"'There is no next page'",
"unless",
"has_next_page?",
"self",
".",
"class",
".",
"new",
"(",
"@model",
",",
"@index",
",",
"@query",
",",
"@options",
".",
"merge",
"(",
"continuation",
":",
... | Get a new ResultSet fetch for the next page | [
"Get",
"a",
"new",
"ResultSet",
"fetch",
"for",
"the",
"next",
"page"
] | 83b2deaef0e790d90f98c031f254b5f438b19edf | https://github.com/emancu/ork/blob/83b2deaef0e790d90f98c031f254b5f438b19edf/lib/ork/result_set.rb#L55-L62 |
8,006 | rlafranchi/statixite | lib/statixite/cloud_sync.rb | Statixite.CloudSync.threaded_run! | def threaded_run!(files, change)
return if files.empty?
file_number = 0
total_files = files.length
mutex = Mutex.new
threads = []
5.times do |i|
threads[i] = Thread.new {
until files.empty?
mutex.synchronize do
file_number += 1
... | ruby | def threaded_run!(files, change)
return if files.empty?
file_number = 0
total_files = files.length
mutex = Mutex.new
threads = []
5.times do |i|
threads[i] = Thread.new {
until files.empty?
mutex.synchronize do
file_number += 1
... | [
"def",
"threaded_run!",
"(",
"files",
",",
"change",
")",
"return",
"if",
"files",
".",
"empty?",
"file_number",
"=",
"0",
"total_files",
"=",
"files",
".",
"length",
"mutex",
"=",
"Mutex",
".",
"new",
"threads",
"=",
"[",
"]",
"5",
".",
"times",
"do",... | todo improve speed | [
"todo",
"improve",
"speed"
] | 5322d40d4086edb89c8aa3b7cb563a35ffac0140 | https://github.com/rlafranchi/statixite/blob/5322d40d4086edb89c8aa3b7cb563a35ffac0140/lib/statixite/cloud_sync.rb#L93-L119 |
8,007 | jarhart/rattler | lib/rattler/compiler/ruby_generator.rb | Rattler::Compiler.RubyGenerator.intersperse | def intersperse(enum, opts={})
sep = opts[:sep]
newlines = opts[:newlines] || (opts[:newline] ? 1 : 0)
enum.each_with_index do |_, i|
if i > 0
self << sep if sep
newlines.times { newline }
end
yield _
end
self
end | ruby | def intersperse(enum, opts={})
sep = opts[:sep]
newlines = opts[:newlines] || (opts[:newline] ? 1 : 0)
enum.each_with_index do |_, i|
if i > 0
self << sep if sep
newlines.times { newline }
end
yield _
end
self
end | [
"def",
"intersperse",
"(",
"enum",
",",
"opts",
"=",
"{",
"}",
")",
"sep",
"=",
"opts",
"[",
":sep",
"]",
"newlines",
"=",
"opts",
"[",
":newlines",
"]",
"||",
"(",
"opts",
"[",
":newline",
"]",
"?",
"1",
":",
"0",
")",
"enum",
".",
"each_with_in... | Add a separator or newlines or both in between code generated in the
given block for each element in +enum+. Newlines, are always added
after the separator.
@param [Enumerable] enum an enumerable sequence of objects
@option opts [String] :sep (nil) optional separator to use between
elements
@option opts [true... | [
"Add",
"a",
"separator",
"or",
"newlines",
"or",
"both",
"in",
"between",
"code",
"generated",
"in",
"the",
"given",
"block",
"for",
"each",
"element",
"in",
"+",
"enum",
"+",
".",
"Newlines",
"are",
"always",
"added",
"after",
"the",
"separator",
"."
] | 8b4efde2a05e9e790955bb635d4a1a9615893719 | https://github.com/jarhart/rattler/blob/8b4efde2a05e9e790955bb635d4a1a9615893719/lib/rattler/compiler/ruby_generator.rb#L124-L135 |
8,008 | rubyrider/clomp | lib/clomp/operation.rb | Clomp.Operation.get_status | def get_status
@result['tracks'].collect {|track| track.name if track.failure?}.compact.count.zero? ? 'Success' : 'Failure'
end | ruby | def get_status
@result['tracks'].collect {|track| track.name if track.failure?}.compact.count.zero? ? 'Success' : 'Failure'
end | [
"def",
"get_status",
"@result",
"[",
"'tracks'",
"]",
".",
"collect",
"{",
"|",
"track",
"|",
"track",
".",
"name",
"if",
"track",
".",
"failure?",
"}",
".",
"compact",
".",
"count",
".",
"zero?",
"?",
"'Success'",
":",
"'Failure'",
"end"
] | collect track status | [
"collect",
"track",
"status"
] | da3cfa9c86773aad93c2bf7e59c51795f1d51c4d | https://github.com/rubyrider/clomp/blob/da3cfa9c86773aad93c2bf7e59c51795f1d51c4d/lib/clomp/operation.rb#L52-L54 |
8,009 | sloppycoder/fixed_width_file_validator | lib/fixed_width_file_validator/record_formatter.rb | FixedWidthFileValidator.RecordFormatter.formatted_value | def formatted_value(value, format, width)
value_str = value ? format(format, value) : ' ' * width # all space for nil value
length = value_str.length
if length > width
value_str.slice(0..width - 1)
elsif length < width
' ' * (width - length) + value_str
else
value_s... | ruby | def formatted_value(value, format, width)
value_str = value ? format(format, value) : ' ' * width # all space for nil value
length = value_str.length
if length > width
value_str.slice(0..width - 1)
elsif length < width
' ' * (width - length) + value_str
else
value_s... | [
"def",
"formatted_value",
"(",
"value",
",",
"format",
",",
"width",
")",
"value_str",
"=",
"value",
"?",
"format",
"(",
"format",
",",
"value",
")",
":",
"' '",
"*",
"width",
"# all space for nil value",
"length",
"=",
"value_str",
".",
"length",
"if",
"l... | format the string using given format
if the result is shorter than width, pad space to the left
if the result is longer than width, truncate the last characters | [
"format",
"the",
"string",
"using",
"given",
"format",
"if",
"the",
"result",
"is",
"shorter",
"than",
"width",
"pad",
"space",
"to",
"the",
"left",
"if",
"the",
"result",
"is",
"longer",
"than",
"width",
"truncate",
"the",
"last",
"characters"
] | 0dce83b0b73f65bc80c7fc61d5117a6a3acc1828 | https://github.com/sloppycoder/fixed_width_file_validator/blob/0dce83b0b73f65bc80c7fc61d5117a6a3acc1828/lib/fixed_width_file_validator/record_formatter.rb#L32-L42 |
8,010 | mikiobraun/jblas-ruby | lib/jblas/mixin_enum.rb | JBLAS.MatrixEnumMixin.map! | def map!(&block)
(0...length).each do |i|
put(i, block.call(get(i)))
end
self
end | ruby | def map!(&block)
(0...length).each do |i|
put(i, block.call(get(i)))
end
self
end | [
"def",
"map!",
"(",
"&",
"block",
")",
"(",
"0",
"...",
"length",
")",
".",
"each",
"do",
"|",
"i",
"|",
"put",
"(",
"i",
",",
"block",
".",
"call",
"(",
"get",
"(",
"i",
")",
")",
")",
"end",
"self",
"end"
] | Map each element and store the result in the matrix.
Note that the result must be again something
which can be stored in the matrix. Otherwise you should do an
to_a first. | [
"Map",
"each",
"element",
"and",
"store",
"the",
"result",
"in",
"the",
"matrix",
"."
] | 7233976c9e3b210e30bc36ead2b1e05ab3383fec | https://github.com/mikiobraun/jblas-ruby/blob/7233976c9e3b210e30bc36ead2b1e05ab3383fec/lib/jblas/mixin_enum.rb#L76-L81 |
8,011 | stomar/lanyon | lib/lanyon/router.rb | Lanyon.Router.endpoint | def endpoint(path)
normalized = normalize_path_info(path)
fullpath = File.join(@root, normalized)
endpoint = if FileTest.file?(fullpath)
fullpath
elsif needs_redirect_to_dir?(fullpath)
:must_redirect
elsif FileTest.file?(fullpath... | ruby | def endpoint(path)
normalized = normalize_path_info(path)
fullpath = File.join(@root, normalized)
endpoint = if FileTest.file?(fullpath)
fullpath
elsif needs_redirect_to_dir?(fullpath)
:must_redirect
elsif FileTest.file?(fullpath... | [
"def",
"endpoint",
"(",
"path",
")",
"normalized",
"=",
"normalize_path_info",
"(",
"path",
")",
"fullpath",
"=",
"File",
".",
"join",
"(",
"@root",
",",
"normalized",
")",
"endpoint",
"=",
"if",
"FileTest",
".",
"file?",
"(",
"fullpath",
")",
"fullpath",
... | Creates a Router for the given root directory.
Returns the full file system path of the file corresponding to
the given URL +path+, or
- +:must_redirect+ if the request must be redirected to +path/+,
- +:not_found+ if no corresponding file exists.
The return value is found as follows:
1. a +path/+ with a trail... | [
"Creates",
"a",
"Router",
"for",
"the",
"given",
"root",
"directory",
".",
"Returns",
"the",
"full",
"file",
"system",
"path",
"of",
"the",
"file",
"corresponding",
"to",
"the",
"given",
"URL",
"+",
"path",
"+",
"or"
] | 2b32ab991c45fdc68c4b0ac86297e6ceb528ba08 | https://github.com/stomar/lanyon/blob/2b32ab991c45fdc68c4b0ac86297e6ceb528ba08/lib/lanyon/router.rb#L30-L45 |
8,012 | stomar/lanyon | lib/lanyon/router.rb | Lanyon.Router.custom_404_body | def custom_404_body
filename = File.join(root, "404.html")
File.exist?(filename) ? File.binread(filename) : nil
end | ruby | def custom_404_body
filename = File.join(root, "404.html")
File.exist?(filename) ? File.binread(filename) : nil
end | [
"def",
"custom_404_body",
"filename",
"=",
"File",
".",
"join",
"(",
"root",
",",
"\"404.html\"",
")",
"File",
".",
"exist?",
"(",
"filename",
")",
"?",
"File",
".",
"binread",
"(",
"filename",
")",
":",
"nil",
"end"
] | Returns the body of the custom 404 page or +nil+ if none exists. | [
"Returns",
"the",
"body",
"of",
"the",
"custom",
"404",
"page",
"or",
"+",
"nil",
"+",
"if",
"none",
"exists",
"."
] | 2b32ab991c45fdc68c4b0ac86297e6ceb528ba08 | https://github.com/stomar/lanyon/blob/2b32ab991c45fdc68c4b0ac86297e6ceb528ba08/lib/lanyon/router.rb#L48-L52 |
8,013 | games-directory/api-giantbomb | lib/giantbomb/search.rb | GiantBomb.Search.filter | def filter(conditions)
if conditions
conditions.each do |key, value|
if self.respond_to?(key)
self.send(key, value)
end
end
end
end | ruby | def filter(conditions)
if conditions
conditions.each do |key, value|
if self.respond_to?(key)
self.send(key, value)
end
end
end
end | [
"def",
"filter",
"(",
"conditions",
")",
"if",
"conditions",
"conditions",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"if",
"self",
".",
"respond_to?",
"(",
"key",
")",
"self",
".",
"send",
"(",
"key",
",",
"value",
")",
"end",
"end",
"end",
... | A convenience method that takes a hash where each key is
the symbol of a method, and each value is the parameters
passed to that method. | [
"A",
"convenience",
"method",
"that",
"takes",
"a",
"hash",
"where",
"each",
"key",
"is",
"the",
"symbol",
"of",
"a",
"method",
"and",
"each",
"value",
"is",
"the",
"parameters",
"passed",
"to",
"that",
"method",
"."
] | 5dded4d69f8fd746e44a509bc66a67d963c54ad4 | https://github.com/games-directory/api-giantbomb/blob/5dded4d69f8fd746e44a509bc66a67d963c54ad4/lib/giantbomb/search.rb#L72-L80 |
8,014 | gjtorikian/nanoc-conref-fs | lib/nanoc-conref-fs/ancestry.rb | NanocConrefFS.Ancestry.find_array_parents | def find_array_parents(toc, title)
parents = ''
toc.each do |item|
if item.is_a?(Hash)
parents = find_hash_parents(item, title)
break unless parents.empty?
end
end
parents
end | ruby | def find_array_parents(toc, title)
parents = ''
toc.each do |item|
if item.is_a?(Hash)
parents = find_hash_parents(item, title)
break unless parents.empty?
end
end
parents
end | [
"def",
"find_array_parents",
"(",
"toc",
",",
"title",
")",
"parents",
"=",
"''",
"toc",
".",
"each",
"do",
"|",
"item",
"|",
"if",
"item",
".",
"is_a?",
"(",
"Hash",
")",
"parents",
"=",
"find_hash_parents",
"(",
"item",
",",
"title",
")",
"break",
... | Given a category file that's an array, this method finds
the parent of an item | [
"Given",
"a",
"category",
"file",
"that",
"s",
"an",
"array",
"this",
"method",
"finds",
"the",
"parent",
"of",
"an",
"item"
] | d1b423daadf8921bc27da553b299f7b7ff9bffa9 | https://github.com/gjtorikian/nanoc-conref-fs/blob/d1b423daadf8921bc27da553b299f7b7ff9bffa9/lib/nanoc-conref-fs/ancestry.rb#L23-L32 |
8,015 | gjtorikian/nanoc-conref-fs | lib/nanoc-conref-fs/ancestry.rb | NanocConrefFS.Ancestry.find_hash_parents | def find_hash_parents(toc, title)
parents = ''
toc.each_key do |key|
next if toc[key].nil?
toc[key].each do |item|
if item.is_a?(Hash)
if item.keys.include?(title)
parents = key
break
else
if item[item.keys.first].in... | ruby | def find_hash_parents(toc, title)
parents = ''
toc.each_key do |key|
next if toc[key].nil?
toc[key].each do |item|
if item.is_a?(Hash)
if item.keys.include?(title)
parents = key
break
else
if item[item.keys.first].in... | [
"def",
"find_hash_parents",
"(",
"toc",
",",
"title",
")",
"parents",
"=",
"''",
"toc",
".",
"each_key",
"do",
"|",
"key",
"|",
"next",
"if",
"toc",
"[",
"key",
"]",
".",
"nil?",
"toc",
"[",
"key",
"]",
".",
"each",
"do",
"|",
"item",
"|",
"if",
... | Given a category file that's a hash, this method finds
the parent of an item | [
"Given",
"a",
"category",
"file",
"that",
"s",
"a",
"hash",
"this",
"method",
"finds",
"the",
"parent",
"of",
"an",
"item"
] | d1b423daadf8921bc27da553b299f7b7ff9bffa9 | https://github.com/gjtorikian/nanoc-conref-fs/blob/d1b423daadf8921bc27da553b299f7b7ff9bffa9/lib/nanoc-conref-fs/ancestry.rb#L37-L60 |
8,016 | gjtorikian/nanoc-conref-fs | lib/nanoc-conref-fs/ancestry.rb | NanocConrefFS.Ancestry.find_array_children | def find_array_children(toc, title)
toc.each do |item|
next unless item.is_a?(Hash)
item.each_pair do |key, values|
if key == title
children = values.flatten
return children
end
end
end
# Found no children
Array.new
end | ruby | def find_array_children(toc, title)
toc.each do |item|
next unless item.is_a?(Hash)
item.each_pair do |key, values|
if key == title
children = values.flatten
return children
end
end
end
# Found no children
Array.new
end | [
"def",
"find_array_children",
"(",
"toc",
",",
"title",
")",
"toc",
".",
"each",
"do",
"|",
"item",
"|",
"next",
"unless",
"item",
".",
"is_a?",
"(",
"Hash",
")",
"item",
".",
"each_pair",
"do",
"|",
"key",
",",
"values",
"|",
"if",
"key",
"==",
"t... | Given a category file that's an array, this method finds
the children of an item, probably a map topic
toc - the array containing the table of contents
title - the text title to return the children of
Returns a flattened array of all descendants which could be empty. | [
"Given",
"a",
"category",
"file",
"that",
"s",
"an",
"array",
"this",
"method",
"finds",
"the",
"children",
"of",
"an",
"item",
"probably",
"a",
"map",
"topic"
] | d1b423daadf8921bc27da553b299f7b7ff9bffa9 | https://github.com/gjtorikian/nanoc-conref-fs/blob/d1b423daadf8921bc27da553b299f7b7ff9bffa9/lib/nanoc-conref-fs/ancestry.rb#L70-L82 |
8,017 | gjtorikian/nanoc-conref-fs | lib/nanoc-conref-fs/ancestry.rb | NanocConrefFS.Ancestry.find_hash_children | def find_hash_children(toc, title)
toc.each_key do |key|
next if toc[key].nil?
toc[key].each do |item|
next unless item.is_a?(Hash)
if item[title]
children = item.values.flatten
return children
end
end
end
# Found no childre... | ruby | def find_hash_children(toc, title)
toc.each_key do |key|
next if toc[key].nil?
toc[key].each do |item|
next unless item.is_a?(Hash)
if item[title]
children = item.values.flatten
return children
end
end
end
# Found no childre... | [
"def",
"find_hash_children",
"(",
"toc",
",",
"title",
")",
"toc",
".",
"each_key",
"do",
"|",
"key",
"|",
"next",
"if",
"toc",
"[",
"key",
"]",
".",
"nil?",
"toc",
"[",
"key",
"]",
".",
"each",
"do",
"|",
"item",
"|",
"next",
"unless",
"item",
"... | Given a category file that's a hash, this method finds
the children of an item, probably a map topic
toc - the hash containing the table of contents
title - the text title to return the children of
Returns a flattened array of all descendants which could be empty. | [
"Given",
"a",
"category",
"file",
"that",
"s",
"a",
"hash",
"this",
"method",
"finds",
"the",
"children",
"of",
"an",
"item",
"probably",
"a",
"map",
"topic"
] | d1b423daadf8921bc27da553b299f7b7ff9bffa9 | https://github.com/gjtorikian/nanoc-conref-fs/blob/d1b423daadf8921bc27da553b299f7b7ff9bffa9/lib/nanoc-conref-fs/ancestry.rb#L92-L105 |
8,018 | rschultheis/hatt | lib/hatt/api_clients.rb | Hatt.ApiClients.hatt_add_service | def hatt_add_service(name, url_or_svc_cfg_hash)
svc_cfg = case url_or_svc_cfg_hash
when String
{ 'url' => url_or_svc_cfg_hash }
when Hash
url_or_svc_cfg_hash
else
raise ArgumentError, "'#{url_or_svc_cfg_hash}' is... | ruby | def hatt_add_service(name, url_or_svc_cfg_hash)
svc_cfg = case url_or_svc_cfg_hash
when String
{ 'url' => url_or_svc_cfg_hash }
when Hash
url_or_svc_cfg_hash
else
raise ArgumentError, "'#{url_or_svc_cfg_hash}' is... | [
"def",
"hatt_add_service",
"(",
"name",
",",
"url_or_svc_cfg_hash",
")",
"svc_cfg",
"=",
"case",
"url_or_svc_cfg_hash",
"when",
"String",
"{",
"'url'",
"=>",
"url_or_svc_cfg_hash",
"}",
"when",
"Hash",
"url_or_svc_cfg_hash",
"else",
"raise",
"ArgumentError",
",",
"\... | add a service to hatt
@param name [String] the name of the service
@param url [String] an absolute url to the api | [
"add",
"a",
"service",
"to",
"hatt"
] | b1b5cddf2b52d8952e5607a2987d2efb648babaf | https://github.com/rschultheis/hatt/blob/b1b5cddf2b52d8952e5607a2987d2efb648babaf/lib/hatt/api_clients.rb#L18-L38 |
8,019 | etailer/parcel_api | lib/parcel_api/address.rb | ParcelApi.Address.details | def details(address_id)
details_url = File.join(DOMESTIC_URL, address_id.to_s)
response = @connection.get details_url
OpenStruct.new(response.parsed['address'])
end | ruby | def details(address_id)
details_url = File.join(DOMESTIC_URL, address_id.to_s)
response = @connection.get details_url
OpenStruct.new(response.parsed['address'])
end | [
"def",
"details",
"(",
"address_id",
")",
"details_url",
"=",
"File",
".",
"join",
"(",
"DOMESTIC_URL",
",",
"address_id",
".",
"to_s",
")",
"response",
"=",
"@connection",
".",
"get",
"details_url",
"OpenStruct",
".",
"new",
"(",
"response",
".",
"parsed",
... | Return domestic address details for a domestic address id
@param address_id [String]
@return address detail object | [
"Return",
"domestic",
"address",
"details",
"for",
"a",
"domestic",
"address",
"id"
] | fcb8d64e45f7ba72bab48f143ac5115b0441aced | https://github.com/etailer/parcel_api/blob/fcb8d64e45f7ba72bab48f143ac5115b0441aced/lib/parcel_api/address.rb#L36-L40 |
8,020 | etailer/parcel_api | lib/parcel_api/address.rb | ParcelApi.Address.australian_details | def australian_details(address_id)
details_url = File.join(AUSTRALIAN_URL, address_id.to_s)
response = @connection.get details_url
RecursiveOpenStruct.new(response.parsed['address'], recurse_over_arrays: true)
end | ruby | def australian_details(address_id)
details_url = File.join(AUSTRALIAN_URL, address_id.to_s)
response = @connection.get details_url
RecursiveOpenStruct.new(response.parsed['address'], recurse_over_arrays: true)
end | [
"def",
"australian_details",
"(",
"address_id",
")",
"details_url",
"=",
"File",
".",
"join",
"(",
"AUSTRALIAN_URL",
",",
"address_id",
".",
"to_s",
")",
"response",
"=",
"@connection",
".",
"get",
"details_url",
"RecursiveOpenStruct",
".",
"new",
"(",
"response... | Return australian address details for a specific international address id
@param address_id [String]
@return australian address detail | [
"Return",
"australian",
"address",
"details",
"for",
"a",
"specific",
"international",
"address",
"id"
] | fcb8d64e45f7ba72bab48f143ac5115b0441aced | https://github.com/etailer/parcel_api/blob/fcb8d64e45f7ba72bab48f143ac5115b0441aced/lib/parcel_api/address.rb#L55-L59 |
8,021 | etailer/parcel_api | lib/parcel_api/address.rb | ParcelApi.Address.international_search | def international_search(query, count=5, country_code=nil)
return [] if query.length < 4
response = @connection.get INTERNATIONAL_URL, params: { q: query.to_ascii, count: count, country_code: country_code }
response.parsed['addresses'].map {|address| OpenStruct.new(address)}
end | ruby | def international_search(query, count=5, country_code=nil)
return [] if query.length < 4
response = @connection.get INTERNATIONAL_URL, params: { q: query.to_ascii, count: count, country_code: country_code }
response.parsed['addresses'].map {|address| OpenStruct.new(address)}
end | [
"def",
"international_search",
"(",
"query",
",",
"count",
"=",
"5",
",",
"country_code",
"=",
"nil",
")",
"return",
"[",
"]",
"if",
"query",
".",
"length",
"<",
"4",
"response",
"=",
"@connection",
".",
"get",
"INTERNATIONAL_URL",
",",
"params",
":",
"{... | Search for an International Address
@param [String] characters to search for
@param [Integer] number of search results to return (max 10)
@param [String] country code for results - listed here: https://developers.google.com/public-data/docs/canonical/countries_csv/
@return [Array] array of international addresses | [
"Search",
"for",
"an",
"International",
"Address"
] | fcb8d64e45f7ba72bab48f143ac5115b0441aced | https://github.com/etailer/parcel_api/blob/fcb8d64e45f7ba72bab48f143ac5115b0441aced/lib/parcel_api/address.rb#L67-L72 |
8,022 | etailer/parcel_api | lib/parcel_api/address.rb | ParcelApi.Address.international_details | def international_details(address_id)
details_url = File.join(INTERNATIONAL_URL, address_id.to_s)
response = @connection.get details_url
RecursiveOpenStruct.new(response.parsed['result'], recurse_over_arrays: true)
end | ruby | def international_details(address_id)
details_url = File.join(INTERNATIONAL_URL, address_id.to_s)
response = @connection.get details_url
RecursiveOpenStruct.new(response.parsed['result'], recurse_over_arrays: true)
end | [
"def",
"international_details",
"(",
"address_id",
")",
"details_url",
"=",
"File",
".",
"join",
"(",
"INTERNATIONAL_URL",
",",
"address_id",
".",
"to_s",
")",
"response",
"=",
"@connection",
".",
"get",
"details_url",
"RecursiveOpenStruct",
".",
"new",
"(",
"re... | Return international address details for a specific international address id
@param address_id [String]
@return international address detail | [
"Return",
"international",
"address",
"details",
"for",
"a",
"specific",
"international",
"address",
"id"
] | fcb8d64e45f7ba72bab48f143ac5115b0441aced | https://github.com/etailer/parcel_api/blob/fcb8d64e45f7ba72bab48f143ac5115b0441aced/lib/parcel_api/address.rb#L78-L82 |
8,023 | EricBoersma/actionkit_connector | lib/actionkit_connector.rb | ActionKitConnector.Connector.find_petition_pages | def find_petition_pages(name, limit: 10, offset: 0)
target = "#{self.base_url}/petitionpage/"
options = {
basic_auth: self.auth,
query: {
_limit: limit,
_offset: offset,
name: name
}
}
self.class.get(target, options)
end | ruby | def find_petition_pages(name, limit: 10, offset: 0)
target = "#{self.base_url}/petitionpage/"
options = {
basic_auth: self.auth,
query: {
_limit: limit,
_offset: offset,
name: name
}
}
self.class.get(target, options)
end | [
"def",
"find_petition_pages",
"(",
"name",
",",
"limit",
":",
"10",
",",
"offset",
":",
"0",
")",
"target",
"=",
"\"#{self.base_url}/petitionpage/\"",
"options",
"=",
"{",
"basic_auth",
":",
"self",
".",
"auth",
",",
"query",
":",
"{",
"_limit",
":",
"limi... | Find petition pages matching a given name.
@param [Int] offset The number of records to skip.
@param [Int] limit The maximum number of results to return.
@param [String] name The string to match against name. | [
"Find",
"petition",
"pages",
"matching",
"a",
"given",
"name",
"."
] | 909b3a0feba9da3205473e676e66a2eb7294dc9e | https://github.com/EricBoersma/actionkit_connector/blob/909b3a0feba9da3205473e676e66a2eb7294dc9e/lib/actionkit_connector.rb#L50-L63 |
8,024 | EricBoersma/actionkit_connector | lib/actionkit_connector.rb | ActionKitConnector.Connector.create_petition_page | def create_petition_page(name, title, lang, canonical_url)
target = "#{self.base_url}/petitionpage/"
options = {
basic_auth: self.auth,
headers: {
'Content-type' => 'application/json; charset=UTF-8'
},
:body => {
:type => 'petitionpage',
... | ruby | def create_petition_page(name, title, lang, canonical_url)
target = "#{self.base_url}/petitionpage/"
options = {
basic_auth: self.auth,
headers: {
'Content-type' => 'application/json; charset=UTF-8'
},
:body => {
:type => 'petitionpage',
... | [
"def",
"create_petition_page",
"(",
"name",
",",
"title",
",",
"lang",
",",
"canonical_url",
")",
"target",
"=",
"\"#{self.base_url}/petitionpage/\"",
"options",
"=",
"{",
"basic_auth",
":",
"self",
".",
"auth",
",",
"headers",
":",
"{",
"'Content-type'",
"=>",
... | Create a petition page in your ActionKit instance.
@param [String] name The name of the page.
@param [String] title The title of the page.
@param [URI] lang The URI string for the language of this page in the form of /rest/v1/language/{id}
@param [URL] canonical_url The canonical UR... | [
"Create",
"a",
"petition",
"page",
"in",
"your",
"ActionKit",
"instance",
"."
] | 909b3a0feba9da3205473e676e66a2eb7294dc9e | https://github.com/EricBoersma/actionkit_connector/blob/909b3a0feba9da3205473e676e66a2eb7294dc9e/lib/actionkit_connector.rb#L79-L97 |
8,025 | EricBoersma/actionkit_connector | lib/actionkit_connector.rb | ActionKitConnector.Connector.create_action | def create_action(page_name, email, options={})
target = "#{self.base_url}/action/"
body = { page: page_name, email: email }.merge self.parse_action_options(options)
options = {
basic_auth: self.auth,
body: body.to_json,
format: :json,
headers: {'Content-Type' =... | ruby | def create_action(page_name, email, options={})
target = "#{self.base_url}/action/"
body = { page: page_name, email: email }.merge self.parse_action_options(options)
options = {
basic_auth: self.auth,
body: body.to_json,
format: :json,
headers: {'Content-Type' =... | [
"def",
"create_action",
"(",
"page_name",
",",
"email",
",",
"options",
"=",
"{",
"}",
")",
"target",
"=",
"\"#{self.base_url}/action/\"",
"body",
"=",
"{",
"page",
":",
"page_name",
",",
"email",
":",
"email",
"}",
".",
"merge",
"self",
".",
"parse_action... | Creates an action which associates a user with a page.
@param [String] page_name The ActionKit name of the page on which the action is being taken.
@param [String] email The email address of the person taking action. | [
"Creates",
"an",
"action",
"which",
"associates",
"a",
"user",
"with",
"a",
"page",
"."
] | 909b3a0feba9da3205473e676e66a2eb7294dc9e | https://github.com/EricBoersma/actionkit_connector/blob/909b3a0feba9da3205473e676e66a2eb7294dc9e/lib/actionkit_connector.rb#L129-L139 |
8,026 | EricBoersma/actionkit_connector | lib/actionkit_connector.rb | ActionKitConnector.Connector.create_donation_action | def create_donation_action(options={})
target = "#{self.base_url}/donationpush/"
options = self.validate_donation_options(options)
page_opts = {
basic_auth: self.auth,
body: options.to_json,
headers: {
'Content-Type' => 'application/json; charset=UTF-8'
... | ruby | def create_donation_action(options={})
target = "#{self.base_url}/donationpush/"
options = self.validate_donation_options(options)
page_opts = {
basic_auth: self.auth,
body: options.to_json,
headers: {
'Content-Type' => 'application/json; charset=UTF-8'
... | [
"def",
"create_donation_action",
"(",
"options",
"=",
"{",
"}",
")",
"target",
"=",
"\"#{self.base_url}/donationpush/\"",
"options",
"=",
"self",
".",
"validate_donation_options",
"(",
"options",
")",
"page_opts",
"=",
"{",
"basic_auth",
":",
"self",
".",
"auth",
... | Creates an action which registers a donation with a user account.
@param [Hash] options The hash of values sent to ActionKit which contain information about this transaction. | [
"Creates",
"an",
"action",
"which",
"registers",
"a",
"donation",
"with",
"a",
"user",
"account",
"."
] | 909b3a0feba9da3205473e676e66a2eb7294dc9e | https://github.com/EricBoersma/actionkit_connector/blob/909b3a0feba9da3205473e676e66a2eb7294dc9e/lib/actionkit_connector.rb#L144-L155 |
8,027 | EricBoersma/actionkit_connector | lib/actionkit_connector.rb | ActionKitConnector.Connector.list_users | def list_users(offset=0, limit=20)
target = "#{self.base_url}/user/"
options = {
basic_auth: self.auth,
query: {
_limit: limit,
_offset: offset
}
}
self.class.get(target, options)
end | ruby | def list_users(offset=0, limit=20)
target = "#{self.base_url}/user/"
options = {
basic_auth: self.auth,
query: {
_limit: limit,
_offset: offset
}
}
self.class.get(target, options)
end | [
"def",
"list_users",
"(",
"offset",
"=",
"0",
",",
"limit",
"=",
"20",
")",
"target",
"=",
"\"#{self.base_url}/user/\"",
"options",
"=",
"{",
"basic_auth",
":",
"self",
".",
"auth",
",",
"query",
":",
"{",
"_limit",
":",
"limit",
",",
"_offset",
":",
"... | Lists users in your instance.
@param [Int] offset The number of records to skip.
@param [Int] limit The maximum number of results to return. | [
"Lists",
"users",
"in",
"your",
"instance",
"."
] | 909b3a0feba9da3205473e676e66a2eb7294dc9e | https://github.com/EricBoersma/actionkit_connector/blob/909b3a0feba9da3205473e676e66a2eb7294dc9e/lib/actionkit_connector.rb#L169-L179 |
8,028 | nwops/retrospec | lib/retrospec/config.rb | Retrospec.Config.setup_config_file | def setup_config_file(file=nil)
if file.nil? or ! File.exists?(file)
# config does not exist
setup_config_dir
dst_file = File.join(default_retrospec_dir, 'config.yaml')
src_file = File.join(gem_dir,'config.yaml.sample')
safe_copy_file(src_file, dst_file)
file = dst_... | ruby | def setup_config_file(file=nil)
if file.nil? or ! File.exists?(file)
# config does not exist
setup_config_dir
dst_file = File.join(default_retrospec_dir, 'config.yaml')
src_file = File.join(gem_dir,'config.yaml.sample')
safe_copy_file(src_file, dst_file)
file = dst_... | [
"def",
"setup_config_file",
"(",
"file",
"=",
"nil",
")",
"if",
"file",
".",
"nil?",
"or",
"!",
"File",
".",
"exists?",
"(",
"file",
")",
"# config does not exist",
"setup_config_dir",
"dst_file",
"=",
"File",
".",
"join",
"(",
"default_retrospec_dir",
",",
... | we should be able to lookup where the user stores the config map
so the user doesn't have to pass this info each time
create a blank yaml config file it file does not exist | [
"we",
"should",
"be",
"able",
"to",
"lookup",
"where",
"the",
"user",
"stores",
"the",
"config",
"map",
"so",
"the",
"user",
"doesn",
"t",
"have",
"to",
"pass",
"this",
"info",
"each",
"time",
"create",
"a",
"blank",
"yaml",
"config",
"file",
"it",
"fi... | e61a8e8b86384c64a3ce9340d1342fa416740522 | https://github.com/nwops/retrospec/blob/e61a8e8b86384c64a3ce9340d1342fa416740522/lib/retrospec/config.rb#L18-L28 |
8,029 | ajh/speaky_csv | lib/speaky_csv/config_builder.rb | SpeakyCsv.ConfigBuilder.field | def field(*fields, export_only: false)
@config.fields += fields.map(&:to_sym)
@config.fields.uniq!
if export_only
@config.export_only_fields += fields.map(&:to_sym)
@config.export_only_fields.uniq!
end
nil
end | ruby | def field(*fields, export_only: false)
@config.fields += fields.map(&:to_sym)
@config.fields.uniq!
if export_only
@config.export_only_fields += fields.map(&:to_sym)
@config.export_only_fields.uniq!
end
nil
end | [
"def",
"field",
"(",
"*",
"fields",
",",
"export_only",
":",
"false",
")",
"@config",
".",
"fields",
"+=",
"fields",
".",
"map",
"(",
":to_sym",
")",
"@config",
".",
"fields",
".",
"uniq!",
"if",
"export_only",
"@config",
".",
"export_only_fields",
"+=",
... | Add one or many fields to the csv format.
If options are passed, they apply to all given fields. | [
"Add",
"one",
"or",
"many",
"fields",
"to",
"the",
"csv",
"format",
"."
] | aa16dd8e7dbe2202523b1a7d35a610c174c3fc21 | https://github.com/ajh/speaky_csv/blob/aa16dd8e7dbe2202523b1a7d35a610c174c3fc21/lib/speaky_csv/config_builder.rb#L15-L25 |
8,030 | ajh/speaky_csv | lib/speaky_csv/config_builder.rb | SpeakyCsv.ConfigBuilder.has_one | def has_one(name)
@config.root or raise NotImplementedError, "nested associations are not supported"
@config.has_ones[name.to_sym] ||= Config.new
yield self.class.new config: @config.has_ones[name.to_sym], root: false
nil
end | ruby | def has_one(name)
@config.root or raise NotImplementedError, "nested associations are not supported"
@config.has_ones[name.to_sym] ||= Config.new
yield self.class.new config: @config.has_ones[name.to_sym], root: false
nil
end | [
"def",
"has_one",
"(",
"name",
")",
"@config",
".",
"root",
"or",
"raise",
"NotImplementedError",
",",
"\"nested associations are not supported\"",
"@config",
".",
"has_ones",
"[",
"name",
".",
"to_sym",
"]",
"||=",
"Config",
".",
"new",
"yield",
"self",
".",
... | Define a one to one association. This is also aliased as `belongs_to`. Expects a name and a block to
define the fields on associated record.
For example:
define_csv_fields do |c|
has_many 'publisher' do |p|
p.field :id, :name, :_destroy
end
end | [
"Define",
"a",
"one",
"to",
"one",
"association",
".",
"This",
"is",
"also",
"aliased",
"as",
"belongs_to",
".",
"Expects",
"a",
"name",
"and",
"a",
"block",
"to",
"define",
"the",
"fields",
"on",
"associated",
"record",
"."
] | aa16dd8e7dbe2202523b1a7d35a610c174c3fc21 | https://github.com/ajh/speaky_csv/blob/aa16dd8e7dbe2202523b1a7d35a610c174c3fc21/lib/speaky_csv/config_builder.rb#L46-L52 |
8,031 | ajh/speaky_csv | lib/speaky_csv/config_builder.rb | SpeakyCsv.ConfigBuilder.has_many | def has_many(name)
@config.root or raise NotImplementedError, "nested associations are not supported"
@config.has_manys[name.to_sym] ||= Config.new
yield self.class.new config: @config.has_manys[name.to_sym], root: false
nil
end | ruby | def has_many(name)
@config.root or raise NotImplementedError, "nested associations are not supported"
@config.has_manys[name.to_sym] ||= Config.new
yield self.class.new config: @config.has_manys[name.to_sym], root: false
nil
end | [
"def",
"has_many",
"(",
"name",
")",
"@config",
".",
"root",
"or",
"raise",
"NotImplementedError",
",",
"\"nested associations are not supported\"",
"@config",
".",
"has_manys",
"[",
"name",
".",
"to_sym",
"]",
"||=",
"Config",
".",
"new",
"yield",
"self",
".",
... | Define a one to many association. Expect a name and a block to
define the fields on associated records.
For example:
define_csv_fields do |c|
has_many 'reviews' do |r|
r.field :id, :name, :_destroy
end
end | [
"Define",
"a",
"one",
"to",
"many",
"association",
".",
"Expect",
"a",
"name",
"and",
"a",
"block",
"to",
"define",
"the",
"fields",
"on",
"associated",
"records",
"."
] | aa16dd8e7dbe2202523b1a7d35a610c174c3fc21 | https://github.com/ajh/speaky_csv/blob/aa16dd8e7dbe2202523b1a7d35a610c174c3fc21/lib/speaky_csv/config_builder.rb#L66-L72 |
8,032 | mattnichols/ice_cube_cron | lib/ice_cube_cron/rule_builder.rb | IceCubeCron.RuleBuilder.build_rule | def build_rule(expression)
rule = build_root_recurrence_rule(expression)
rule = build_year_rules(rule, expression)
rule = build_weekday_rule(rule, expression)
rule = build_day_rules(rule, expression)
rule = build_time_rules(rule, expression)
rule = rule.until(expression.until) unless... | ruby | def build_rule(expression)
rule = build_root_recurrence_rule(expression)
rule = build_year_rules(rule, expression)
rule = build_weekday_rule(rule, expression)
rule = build_day_rules(rule, expression)
rule = build_time_rules(rule, expression)
rule = rule.until(expression.until) unless... | [
"def",
"build_rule",
"(",
"expression",
")",
"rule",
"=",
"build_root_recurrence_rule",
"(",
"expression",
")",
"rule",
"=",
"build_year_rules",
"(",
"rule",
",",
"expression",
")",
"rule",
"=",
"build_weekday_rule",
"(",
"rule",
",",
"expression",
")",
"rule",
... | Generates a rule based on a parsed expression | [
"Generates",
"a",
"rule",
"based",
"on",
"a",
"parsed",
"expression"
] | 9b406a40b5d15b03a3e58cb0ec64ca4a85a85cd0 | https://github.com/mattnichols/ice_cube_cron/blob/9b406a40b5d15b03a3e58cb0ec64ca4a85a85cd0/lib/ice_cube_cron/rule_builder.rb#L9-L18 |
8,033 | rschultheis/hatt | lib/hatt/json_helpers.rb | Hatt.JsonHelpers.jsonify | def jsonify(obj)
case obj
when String
JSON.pretty_generate(JSON.parse(obj))
when Hash, Array
JSON.pretty_generate(obj)
else
obj.to_s
end
rescue Exception
obj.to_s
end | ruby | def jsonify(obj)
case obj
when String
JSON.pretty_generate(JSON.parse(obj))
when Hash, Array
JSON.pretty_generate(obj)
else
obj.to_s
end
rescue Exception
obj.to_s
end | [
"def",
"jsonify",
"(",
"obj",
")",
"case",
"obj",
"when",
"String",
"JSON",
".",
"pretty_generate",
"(",
"JSON",
".",
"parse",
"(",
"obj",
")",
")",
"when",
"Hash",
",",
"Array",
"JSON",
".",
"pretty_generate",
"(",
"obj",
")",
"else",
"obj",
".",
"t... | always returns a string, intended for request bodies
every attempt is made to ensure string is valid json
but if that is not possible, then its returned as is | [
"always",
"returns",
"a",
"string",
"intended",
"for",
"request",
"bodies",
"every",
"attempt",
"is",
"made",
"to",
"ensure",
"string",
"is",
"valid",
"json",
"but",
"if",
"that",
"is",
"not",
"possible",
"then",
"its",
"returned",
"as",
"is"
] | b1b5cddf2b52d8952e5607a2987d2efb648babaf | https://github.com/rschultheis/hatt/blob/b1b5cddf2b52d8952e5607a2987d2efb648babaf/lib/hatt/json_helpers.rb#L8-L19 |
8,034 | rschultheis/hatt | lib/hatt/json_helpers.rb | Hatt.JsonHelpers.objectify | def objectify(json_string)
return nil if json_string.nil? || json_string == ''
case json_string
when Hash, Array
return json_string
else
JSON.parse(json_string.to_s)
end
rescue Exception
json_string
end | ruby | def objectify(json_string)
return nil if json_string.nil? || json_string == ''
case json_string
when Hash, Array
return json_string
else
JSON.parse(json_string.to_s)
end
rescue Exception
json_string
end | [
"def",
"objectify",
"(",
"json_string",
")",
"return",
"nil",
"if",
"json_string",
".",
"nil?",
"||",
"json_string",
"==",
"''",
"case",
"json_string",
"when",
"Hash",
",",
"Array",
"return",
"json_string",
"else",
"JSON",
".",
"parse",
"(",
"json_string",
"... | attempts to parse json strings into native ruby objects | [
"attempts",
"to",
"parse",
"json",
"strings",
"into",
"native",
"ruby",
"objects"
] | b1b5cddf2b52d8952e5607a2987d2efb648babaf | https://github.com/rschultheis/hatt/blob/b1b5cddf2b52d8952e5607a2987d2efb648babaf/lib/hatt/json_helpers.rb#L22-L32 |
8,035 | payout/podbay | lib/podbay/utils.rb | Podbay.Utils.count_values | def count_values(*values)
values.inject(Hash.new(0)) { |h, v| h[v] += 1; h }
end | ruby | def count_values(*values)
values.inject(Hash.new(0)) { |h, v| h[v] += 1; h }
end | [
"def",
"count_values",
"(",
"*",
"values",
")",
"values",
".",
"inject",
"(",
"Hash",
".",
"new",
"(",
"0",
")",
")",
"{",
"|",
"h",
",",
"v",
"|",
"h",
"[",
"v",
"]",
"+=",
"1",
";",
"h",
"}",
"end"
] | Returns a hash where the keys are the values in the passed array and the
values are the number of times that value appears in the list. | [
"Returns",
"a",
"hash",
"where",
"the",
"keys",
"are",
"the",
"values",
"in",
"the",
"passed",
"array",
"and",
"the",
"values",
"are",
"the",
"number",
"of",
"times",
"that",
"value",
"appears",
"in",
"the",
"list",
"."
] | a17cc1db6a1f032d9d7005136e4176dbe7f3a73d | https://github.com/payout/podbay/blob/a17cc1db6a1f032d9d7005136e4176dbe7f3a73d/lib/podbay/utils.rb#L124-L126 |
8,036 | payout/podbay | lib/podbay/utils.rb | Podbay.Utils.get_uid | def get_uid(username)
Etc.passwd { |u| return u.uid if u.name == username }
end | ruby | def get_uid(username)
Etc.passwd { |u| return u.uid if u.name == username }
end | [
"def",
"get_uid",
"(",
"username",
")",
"Etc",
".",
"passwd",
"{",
"|",
"u",
"|",
"return",
"u",
".",
"uid",
"if",
"u",
".",
"name",
"==",
"username",
"}",
"end"
] | Returns the UID for the username on the host. | [
"Returns",
"the",
"UID",
"for",
"the",
"username",
"on",
"the",
"host",
"."
] | a17cc1db6a1f032d9d7005136e4176dbe7f3a73d | https://github.com/payout/podbay/blob/a17cc1db6a1f032d9d7005136e4176dbe7f3a73d/lib/podbay/utils.rb#L130-L132 |
8,037 | payout/podbay | lib/podbay/utils.rb | Podbay.Utils.get_gid | def get_gid(group_name)
Etc.group { |g| return g.gid if g.name == group_name }
end | ruby | def get_gid(group_name)
Etc.group { |g| return g.gid if g.name == group_name }
end | [
"def",
"get_gid",
"(",
"group_name",
")",
"Etc",
".",
"group",
"{",
"|",
"g",
"|",
"return",
"g",
".",
"gid",
"if",
"g",
".",
"name",
"==",
"group_name",
"}",
"end"
] | Returns GID for the group on the host. | [
"Returns",
"GID",
"for",
"the",
"group",
"on",
"the",
"host",
"."
] | a17cc1db6a1f032d9d7005136e4176dbe7f3a73d | https://github.com/payout/podbay/blob/a17cc1db6a1f032d9d7005136e4176dbe7f3a73d/lib/podbay/utils.rb#L136-L138 |
8,038 | payout/podbay | lib/podbay/utils.rb | Podbay.Utils.podbay_info | def podbay_info(ip_address, path, timeout = 5)
JSON.parse(
get_request(
"http://#{ip_address}:#{Podbay::SERVER_INFO_PORT}/#{path}",
timeout: timeout
).body,
symbolize_names: true
)
end | ruby | def podbay_info(ip_address, path, timeout = 5)
JSON.parse(
get_request(
"http://#{ip_address}:#{Podbay::SERVER_INFO_PORT}/#{path}",
timeout: timeout
).body,
symbolize_names: true
)
end | [
"def",
"podbay_info",
"(",
"ip_address",
",",
"path",
",",
"timeout",
"=",
"5",
")",
"JSON",
".",
"parse",
"(",
"get_request",
"(",
"\"http://#{ip_address}:#{Podbay::SERVER_INFO_PORT}/#{path}\"",
",",
"timeout",
":",
"timeout",
")",
".",
"body",
",",
"symbolize_na... | Makes a GET request to the Podbay servers that are listening for Podbay
data requests | [
"Makes",
"a",
"GET",
"request",
"to",
"the",
"Podbay",
"servers",
"that",
"are",
"listening",
"for",
"Podbay",
"data",
"requests"
] | a17cc1db6a1f032d9d7005136e4176dbe7f3a73d | https://github.com/payout/podbay/blob/a17cc1db6a1f032d9d7005136e4176dbe7f3a73d/lib/podbay/utils.rb#L156-L164 |
8,039 | m-31/puppetdb_query | lib/puppetdb_query/updater.rb | PuppetDBQuery.Updater.update2 | def update2
update_node_properties
logger.info "update2 started (full update)"
tsb = Time.now
source_nodes = source_node_properties.keys
destination_nodes = destination.all_nodes
delete_missing(destination_nodes, source_nodes)
errors = false
complete = source.facts
... | ruby | def update2
update_node_properties
logger.info "update2 started (full update)"
tsb = Time.now
source_nodes = source_node_properties.keys
destination_nodes = destination.all_nodes
delete_missing(destination_nodes, source_nodes)
errors = false
complete = source.facts
... | [
"def",
"update2",
"update_node_properties",
"logger",
".",
"info",
"\"update2 started (full update)\"",
"tsb",
"=",
"Time",
".",
"now",
"source_nodes",
"=",
"source_node_properties",
".",
"keys",
"destination_nodes",
"=",
"destination",
".",
"all_nodes",
"delete_missing",... | update by deleting missing nodes and get a complete map of nodes with facts
and update or insert facts for each one
mongo: 1597 nodes in 35.31 seconds | [
"update",
"by",
"deleting",
"missing",
"nodes",
"and",
"get",
"a",
"complete",
"map",
"of",
"nodes",
"with",
"facts",
"and",
"update",
"or",
"insert",
"facts",
"for",
"each",
"one"
] | 58103c91f291de8ce28d679256e50ae391b93ecb | https://github.com/m-31/puppetdb_query/blob/58103c91f291de8ce28d679256e50ae391b93ecb/lib/puppetdb_query/updater.rb#L47-L67 |
8,040 | m-31/puppetdb_query | lib/puppetdb_query/updater.rb | PuppetDBQuery.Updater.update_node_properties | def update_node_properties
logger.info "update_node_properties started"
tsb = Time.now
@source_node_properties = source.node_properties
destination.node_properties_update(source_node_properties)
tse = Time.now
logger.info "update_node_properties got #{source_node_properties.size} nod... | ruby | def update_node_properties
logger.info "update_node_properties started"
tsb = Time.now
@source_node_properties = source.node_properties
destination.node_properties_update(source_node_properties)
tse = Time.now
logger.info "update_node_properties got #{source_node_properties.size} nod... | [
"def",
"update_node_properties",
"logger",
".",
"info",
"\"update_node_properties started\"",
"tsb",
"=",
"Time",
".",
"now",
"@source_node_properties",
"=",
"source",
".",
"node_properties",
"destination",
".",
"node_properties_update",
"(",
"source_node_properties",
")",
... | update node update information
mongo: 1602 nodes in 0.42 seconds | [
"update",
"node",
"update",
"information"
] | 58103c91f291de8ce28d679256e50ae391b93ecb | https://github.com/m-31/puppetdb_query/blob/58103c91f291de8ce28d679256e50ae391b93ecb/lib/puppetdb_query/updater.rb#L98-L107 |
8,041 | kamui/rack-accept_headers | lib/rack/accept_headers/encoding.rb | Rack::AcceptHeaders.Encoding.matches | def matches(encoding)
values.select {|v|
v == encoding || v == '*'
}.sort {|a, b|
# "*" gets least precedence, any others should be equal.
a == '*' ? 1 : (b == '*' ? -1 : 0)
}
end | ruby | def matches(encoding)
values.select {|v|
v == encoding || v == '*'
}.sort {|a, b|
# "*" gets least precedence, any others should be equal.
a == '*' ? 1 : (b == '*' ? -1 : 0)
}
end | [
"def",
"matches",
"(",
"encoding",
")",
"values",
".",
"select",
"{",
"|",
"v",
"|",
"v",
"==",
"encoding",
"||",
"v",
"==",
"'*'",
"}",
".",
"sort",
"{",
"|",
"a",
",",
"b",
"|",
"# \"*\" gets least precedence, any others should be equal.",
"a",
"==",
"... | Returns an array of encodings from this header that match the given
+encoding+, ordered by precedence. | [
"Returns",
"an",
"array",
"of",
"encodings",
"from",
"this",
"header",
"that",
"match",
"the",
"given",
"+",
"encoding",
"+",
"ordered",
"by",
"precedence",
"."
] | 099bfbb919de86b5842c8e14be42b8b784e53f03 | https://github.com/kamui/rack-accept_headers/blob/099bfbb919de86b5842c8e14be42b8b784e53f03/lib/rack/accept_headers/encoding.rb#L27-L34 |
8,042 | nigelr/selections | lib/selections/belongs_to_selection.rb | Selections.BelongsToSelection.belongs_to_selection | def belongs_to_selection(target, options={})
belongs_to target, options.merge(:class_name => "Selection")
# The "selections" table may not exist during certain rake scenarios such as db:migrate or db:reset.
if ActiveRecord::Base.connection.table_exists? Selection.table_name
prefix = self.name... | ruby | def belongs_to_selection(target, options={})
belongs_to target, options.merge(:class_name => "Selection")
# The "selections" table may not exist during certain rake scenarios such as db:migrate or db:reset.
if ActiveRecord::Base.connection.table_exists? Selection.table_name
prefix = self.name... | [
"def",
"belongs_to_selection",
"(",
"target",
",",
"options",
"=",
"{",
"}",
")",
"belongs_to",
"target",
",",
"options",
".",
"merge",
"(",
":class_name",
"=>",
"\"Selection\"",
")",
"# The \"selections\" table may not exist during certain rake scenarios such as db:migrate... | Helper for belongs_to and accepts all the standard rails options
Example
class Thing < ActiveRecord::Base
belongs_to_selection :priority
by default adds - class_name: "Selection"
This macro also adds a number of methods onto the class if there is a selection
named as the class underscore name (eg: "thing... | [
"Helper",
"for",
"belongs_to",
"and",
"accepts",
"all",
"the",
"standard",
"rails",
"options"
] | f4702869ffaf11fbcdc8fdad4c0e91b3d0a1ce45 | https://github.com/nigelr/selections/blob/f4702869ffaf11fbcdc8fdad4c0e91b3d0a1ce45/lib/selections/belongs_to_selection.rb#L26-L45 |
8,043 | zdavatz/htmlgrid | lib/htmlgrid/composite.rb | HtmlGrid.Composite.full_colspan | def full_colspan
raw_span = components.keys.collect{ |key|
key.at(0)
}.max.to_i
(raw_span > 0) ? raw_span + 1 : nil
end | ruby | def full_colspan
raw_span = components.keys.collect{ |key|
key.at(0)
}.max.to_i
(raw_span > 0) ? raw_span + 1 : nil
end | [
"def",
"full_colspan",
"raw_span",
"=",
"components",
".",
"keys",
".",
"collect",
"{",
"|",
"key",
"|",
"key",
".",
"at",
"(",
"0",
")",
"}",
".",
"max",
".",
"to_i",
"(",
"raw_span",
">",
"0",
")",
"?",
"raw_span",
"+",
"1",
":",
"nil",
"end"
] | =begin
def explode!
@grid.explode!
super
end
=end | [
"=",
"begin",
"def",
"explode!"
] | 88a0440466e422328b4553685d0efe7c9bbb4d72 | https://github.com/zdavatz/htmlgrid/blob/88a0440466e422328b4553685d0efe7c9bbb4d72/lib/htmlgrid/composite.rb#L254-L259 |
8,044 | crapooze/em-xmpp | lib/em-xmpp/entity.rb | EM::Xmpp.Entity.subscribe | def subscribe(&blk)
pres = connection.presence_stanza('to'=>jid.bare, 'type' => 'subscribe')
connection.send_stanza pres, &blk
end | ruby | def subscribe(&blk)
pres = connection.presence_stanza('to'=>jid.bare, 'type' => 'subscribe')
connection.send_stanza pres, &blk
end | [
"def",
"subscribe",
"(",
"&",
"blk",
")",
"pres",
"=",
"connection",
".",
"presence_stanza",
"(",
"'to'",
"=>",
"jid",
".",
"bare",
",",
"'type'",
"=>",
"'subscribe'",
")",
"connection",
".",
"send_stanza",
"pres",
",",
"blk",
"end"
] | sends a subscription request to the bare entity | [
"sends",
"a",
"subscription",
"request",
"to",
"the",
"bare",
"entity"
] | 804e139944c88bc317b359754d5ad69b75f42319 | https://github.com/crapooze/em-xmpp/blob/804e139944c88bc317b359754d5ad69b75f42319/lib/em-xmpp/entity.rb#L42-L45 |
8,045 | crapooze/em-xmpp | lib/em-xmpp/entity.rb | EM::Xmpp.Entity.accept_subscription | def accept_subscription(&blk)
pres = connection.presence_stanza('to'=>jid.bare, 'type' => 'subscribed')
connection.send_stanza pres, &blk
end | ruby | def accept_subscription(&blk)
pres = connection.presence_stanza('to'=>jid.bare, 'type' => 'subscribed')
connection.send_stanza pres, &blk
end | [
"def",
"accept_subscription",
"(",
"&",
"blk",
")",
"pres",
"=",
"connection",
".",
"presence_stanza",
"(",
"'to'",
"=>",
"jid",
".",
"bare",
",",
"'type'",
"=>",
"'subscribed'",
")",
"connection",
".",
"send_stanza",
"pres",
",",
"blk",
"end"
] | send a subscription stanza to accept an incoming subscription request | [
"send",
"a",
"subscription",
"stanza",
"to",
"accept",
"an",
"incoming",
"subscription",
"request"
] | 804e139944c88bc317b359754d5ad69b75f42319 | https://github.com/crapooze/em-xmpp/blob/804e139944c88bc317b359754d5ad69b75f42319/lib/em-xmpp/entity.rb#L48-L51 |
8,046 | crapooze/em-xmpp | lib/em-xmpp/entity.rb | EM::Xmpp.Entity.unsubscribe | def unsubscribe(&blk)
pres = connection.presence_stanza('to'=>jid.bare, 'type' => 'unsubscribe')
connection.send_stanza pres, &blk
end | ruby | def unsubscribe(&blk)
pres = connection.presence_stanza('to'=>jid.bare, 'type' => 'unsubscribe')
connection.send_stanza pres, &blk
end | [
"def",
"unsubscribe",
"(",
"&",
"blk",
")",
"pres",
"=",
"connection",
".",
"presence_stanza",
"(",
"'to'",
"=>",
"jid",
".",
"bare",
",",
"'type'",
"=>",
"'unsubscribe'",
")",
"connection",
".",
"send_stanza",
"pres",
",",
"blk",
"end"
] | unsubscribes from from the bare entity | [
"unsubscribes",
"from",
"from",
"the",
"bare",
"entity"
] | 804e139944c88bc317b359754d5ad69b75f42319 | https://github.com/crapooze/em-xmpp/blob/804e139944c88bc317b359754d5ad69b75f42319/lib/em-xmpp/entity.rb#L54-L57 |
8,047 | crapooze/em-xmpp | lib/em-xmpp/entity.rb | EM::Xmpp.Entity.pubsub | def pubsub(nid=nil)
node_jid = if nid
JID.new(jid.node, jid.domain, nid)
else
jid.to_s
end
PubSub.new(connection, node_jid)
end | ruby | def pubsub(nid=nil)
node_jid = if nid
JID.new(jid.node, jid.domain, nid)
else
jid.to_s
end
PubSub.new(connection, node_jid)
end | [
"def",
"pubsub",
"(",
"nid",
"=",
"nil",
")",
"node_jid",
"=",
"if",
"nid",
"JID",
".",
"new",
"(",
"jid",
".",
"node",
",",
"jid",
".",
"domain",
",",
"nid",
")",
"else",
"jid",
".",
"to_s",
"end",
"PubSub",
".",
"new",
"(",
"connection",
",",
... | returns a PubSub entity with same bare jid
accepts an optional node-id | [
"returns",
"a",
"PubSub",
"entity",
"with",
"same",
"bare",
"jid",
"accepts",
"an",
"optional",
"node",
"-",
"id"
] | 804e139944c88bc317b359754d5ad69b75f42319 | https://github.com/crapooze/em-xmpp/blob/804e139944c88bc317b359754d5ad69b75f42319/lib/em-xmpp/entity.rb#L130-L137 |
8,048 | crapooze/em-xmpp | lib/em-xmpp/entity.rb | EM::Xmpp.Entity.muc | def muc(nick=nil)
muc_jid = JID.new jid.node, jid.domain, nick
Muc.new(connection, muc_jid)
end | ruby | def muc(nick=nil)
muc_jid = JID.new jid.node, jid.domain, nick
Muc.new(connection, muc_jid)
end | [
"def",
"muc",
"(",
"nick",
"=",
"nil",
")",
"muc_jid",
"=",
"JID",
".",
"new",
"jid",
".",
"node",
",",
"jid",
".",
"domain",
",",
"nick",
"Muc",
".",
"new",
"(",
"connection",
",",
"muc_jid",
")",
"end"
] | Generates a MUC entity from this entity.
If the nick argument is null then the entity is the MUC itself.
If the nick argument is present, then the entity is the user with
the corresponding nickname. | [
"Generates",
"a",
"MUC",
"entity",
"from",
"this",
"entity",
".",
"If",
"the",
"nick",
"argument",
"is",
"null",
"then",
"the",
"entity",
"is",
"the",
"MUC",
"itself",
".",
"If",
"the",
"nick",
"argument",
"is",
"present",
"then",
"the",
"entity",
"is",
... | 804e139944c88bc317b359754d5ad69b75f42319 | https://github.com/crapooze/em-xmpp/blob/804e139944c88bc317b359754d5ad69b75f42319/lib/em-xmpp/entity.rb#L630-L633 |
8,049 | skift/estore_conventions | lib/estore_conventions/archived_outliers.rb | EstoreConventions.ArchivedOutliers.versions_average_for_attribute | def versions_average_for_attribute(att, opts={})
_use_delta = opts[:delta] || false
if _use_delta
return historical_rate_per_day(att, nil, nil)
else
data = versions_complete_data_for_attribute(att, opts)
return data.e_mean
end
end | ruby | def versions_average_for_attribute(att, opts={})
_use_delta = opts[:delta] || false
if _use_delta
return historical_rate_per_day(att, nil, nil)
else
data = versions_complete_data_for_attribute(att, opts)
return data.e_mean
end
end | [
"def",
"versions_average_for_attribute",
"(",
"att",
",",
"opts",
"=",
"{",
"}",
")",
"_use_delta",
"=",
"opts",
"[",
":delta",
"]",
"||",
"false",
"if",
"_use_delta",
"return",
"historical_rate_per_day",
"(",
"att",
",",
"nil",
",",
"nil",
")",
"else",
"d... | returns Float
this is wonky because of the wonky way we use historical_rate_by_day | [
"returns",
"Float",
"this",
"is",
"wonky",
"because",
"of",
"the",
"wonky",
"way",
"we",
"use",
"historical_rate_by_day"
] | b9f1dfa45d476ecbadaa0a50729aeef064961183 | https://github.com/skift/estore_conventions/blob/b9f1dfa45d476ecbadaa0a50729aeef064961183/lib/estore_conventions/archived_outliers.rb#L16-L25 |
8,050 | linjunpop/jia | lib/jia/user.rb | Jia.User.phone | def phone
@phone ||= -> {
mac = Jia::Utils.load_data('phone_mac').sample
area_code = rand(9999).to_s.center(4, rand(9).to_s)
user_identifier = rand(9999).to_s.center(4, rand(9).to_s)
"#{mac}#{area_code}#{user_identifier}"
}.call
end | ruby | def phone
@phone ||= -> {
mac = Jia::Utils.load_data('phone_mac').sample
area_code = rand(9999).to_s.center(4, rand(9).to_s)
user_identifier = rand(9999).to_s.center(4, rand(9).to_s)
"#{mac}#{area_code}#{user_identifier}"
}.call
end | [
"def",
"phone",
"@phone",
"||=",
"->",
"{",
"mac",
"=",
"Jia",
"::",
"Utils",
".",
"load_data",
"(",
"'phone_mac'",
")",
".",
"sample",
"area_code",
"=",
"rand",
"(",
"9999",
")",
".",
"to_s",
".",
"center",
"(",
"4",
",",
"rand",
"(",
"9",
")",
... | Get phone number
Jia::User.new.phone # => '18100000000' | [
"Get",
"phone",
"number"
] | 366da5916a4fca61198376d5bcae668a2841799e | https://github.com/linjunpop/jia/blob/366da5916a4fca61198376d5bcae668a2841799e/lib/jia/user.rb#L47-L54 |
8,051 | charypar/cyclical | lib/cyclical/rule.rb | Cyclical.Rule.match? | def match?(time, base)
aligned?(time, base) && @filters.all? { |f| f.match?(time) }
end | ruby | def match?(time, base)
aligned?(time, base) && @filters.all? { |f| f.match?(time) }
end | [
"def",
"match?",
"(",
"time",
",",
"base",
")",
"aligned?",
"(",
"time",
",",
"base",
")",
"&&",
"@filters",
".",
"all?",
"{",
"|",
"f",
"|",
"f",
".",
"match?",
"(",
"time",
")",
"}",
"end"
] | returns true if time is aligned to the recurrence pattern and matches all the filters | [
"returns",
"true",
"if",
"time",
"is",
"aligned",
"to",
"the",
"recurrence",
"pattern",
"and",
"matches",
"all",
"the",
"filters"
] | 8e45b8f83e2dd59fcad01e220412bb361867f5c6 | https://github.com/charypar/cyclical/blob/8e45b8f83e2dd59fcad01e220412bb361867f5c6/lib/cyclical/rule.rb#L101-L103 |
8,052 | charypar/cyclical | lib/cyclical/rule.rb | Cyclical.Rule.potential_previous | def potential_previous(current, base)
@filters.map { |f| f.previous(current) }.min || current
end | ruby | def potential_previous(current, base)
@filters.map { |f| f.previous(current) }.min || current
end | [
"def",
"potential_previous",
"(",
"current",
",",
"base",
")",
"@filters",
".",
"map",
"{",
"|",
"f",
"|",
"f",
".",
"previous",
"(",
"current",
")",
"}",
".",
"min",
"||",
"current",
"end"
] | Find a potential previous date matching the rule as a minimum of previous
valid dates from all the filters. Subclasses should add a check of
recurrence pattern match | [
"Find",
"a",
"potential",
"previous",
"date",
"matching",
"the",
"rule",
"as",
"a",
"minimum",
"of",
"previous",
"valid",
"dates",
"from",
"all",
"the",
"filters",
".",
"Subclasses",
"should",
"add",
"a",
"check",
"of",
"recurrence",
"pattern",
"match"
] | 8e45b8f83e2dd59fcad01e220412bb361867f5c6 | https://github.com/charypar/cyclical/blob/8e45b8f83e2dd59fcad01e220412bb361867f5c6/lib/cyclical/rule.rb#L216-L218 |
8,053 | chetan/bixby-common | lib/bixby-common/util/hashify.rb | Bixby.Hashify.to_hash | def to_hash
self.instance_variables.inject({}) { |m,v| m[v[1,v.length].to_sym] = instance_variable_get(v); m }
end | ruby | def to_hash
self.instance_variables.inject({}) { |m,v| m[v[1,v.length].to_sym] = instance_variable_get(v); m }
end | [
"def",
"to_hash",
"self",
".",
"instance_variables",
".",
"inject",
"(",
"{",
"}",
")",
"{",
"|",
"m",
",",
"v",
"|",
"m",
"[",
"v",
"[",
"1",
",",
"v",
".",
"length",
"]",
".",
"to_sym",
"]",
"=",
"instance_variable_get",
"(",
"v",
")",
";",
"... | Creates a Hash representation of self
@return [Hash] | [
"Creates",
"a",
"Hash",
"representation",
"of",
"self"
] | 3fb8829987b115fc53ec820d97a20b4a8c49b4a2 | https://github.com/chetan/bixby-common/blob/3fb8829987b115fc53ec820d97a20b4a8c49b4a2/lib/bixby-common/util/hashify.rb#L10-L12 |
8,054 | Timmehs/coals | lib/coals/task_tree.rb | Coals.TaskTree.build_tasks | def build_tasks
load_rakefile
Rake.application.tasks.reject { |t| t.comment.nil? }
end | ruby | def build_tasks
load_rakefile
Rake.application.tasks.reject { |t| t.comment.nil? }
end | [
"def",
"build_tasks",
"load_rakefile",
"Rake",
".",
"application",
".",
"tasks",
".",
"reject",
"{",
"|",
"t",
"|",
"t",
".",
"comment",
".",
"nil?",
"}",
"end"
] | Coals assumes that any task lacking a description
is not meant to be called directly, i.e. a 'subtask'
This is in line with the list rendered by `rake -T` | [
"Coals",
"assumes",
"that",
"any",
"task",
"lacking",
"a",
"description",
"is",
"not",
"meant",
"to",
"be",
"called",
"directly",
"i",
".",
"e",
".",
"a",
"subtask",
"This",
"is",
"in",
"line",
"with",
"the",
"list",
"rendered",
"by",
"rake",
"-",
"T"
... | 0b4b416386ab8775ecbc0965470ae1b7747ab884 | https://github.com/Timmehs/coals/blob/0b4b416386ab8775ecbc0965470ae1b7747ab884/lib/coals/task_tree.rb#L23-L26 |
8,055 | ideonetwork/lato-blog | app/models/lato_blog/post.rb | LatoBlog.Post.check_lato_blog_post_parent | def check_lato_blog_post_parent
post_parent = LatoBlog::PostParent.find_by(id: lato_blog_post_parent_id)
if !post_parent
errors.add('Post parent', 'not exist for the post')
throw :abort
return
end
same_language_post = post_parent.posts.find_by(meta_language: meta_languag... | ruby | def check_lato_blog_post_parent
post_parent = LatoBlog::PostParent.find_by(id: lato_blog_post_parent_id)
if !post_parent
errors.add('Post parent', 'not exist for the post')
throw :abort
return
end
same_language_post = post_parent.posts.find_by(meta_language: meta_languag... | [
"def",
"check_lato_blog_post_parent",
"post_parent",
"=",
"LatoBlog",
"::",
"PostParent",
".",
"find_by",
"(",
"id",
":",
"lato_blog_post_parent_id",
")",
"if",
"!",
"post_parent",
"errors",
".",
"add",
"(",
"'Post parent'",
",",
"'not exist for the post'",
")",
"th... | This function check that the post parent exist and has not others post for the same language. | [
"This",
"function",
"check",
"that",
"the",
"post",
"parent",
"exist",
"and",
"has",
"not",
"others",
"post",
"for",
"the",
"same",
"language",
"."
] | a0d92de299a0e285851743b9d4a902f611187cba | https://github.com/ideonetwork/lato-blog/blob/a0d92de299a0e285851743b9d4a902f611187cba/app/models/lato_blog/post.rb#L89-L103 |
8,056 | ideonetwork/lato-blog | app/models/lato_blog/post.rb | LatoBlog.Post.add_to_default_category | def add_to_default_category
default_category_parent = LatoBlog::CategoryParent.find_by(meta_default: true)
return unless default_category_parent
category = default_category_parent.categories.find_by(meta_language: meta_language)
return unless category
LatoBlog::CategoryPost.create(lato_b... | ruby | def add_to_default_category
default_category_parent = LatoBlog::CategoryParent.find_by(meta_default: true)
return unless default_category_parent
category = default_category_parent.categories.find_by(meta_language: meta_language)
return unless category
LatoBlog::CategoryPost.create(lato_b... | [
"def",
"add_to_default_category",
"default_category_parent",
"=",
"LatoBlog",
"::",
"CategoryParent",
".",
"find_by",
"(",
"meta_default",
":",
"true",
")",
"return",
"unless",
"default_category_parent",
"category",
"=",
"default_category_parent",
".",
"categories",
".",
... | This function add the post to the default category. | [
"This",
"function",
"add",
"the",
"post",
"to",
"the",
"default",
"category",
"."
] | a0d92de299a0e285851743b9d4a902f611187cba | https://github.com/ideonetwork/lato-blog/blob/a0d92de299a0e285851743b9d4a902f611187cba/app/models/lato_blog/post.rb#L106-L114 |
8,057 | teodor-pripoae/scalaroid | lib/scalaroid/json_connection.rb | Scalaroid.JSONConnection.call | def call(function, params)
start
req = Net::HTTP::Post.new(DEFAULT_PATH)
req.add_field('Content-Type', 'application/json; charset=utf-8')
req.body = URI::encode({
:jsonrpc => :'2.0',
:method => function,
:params => params,
:id => 0 }.to_json({:ascii_only => true})... | ruby | def call(function, params)
start
req = Net::HTTP::Post.new(DEFAULT_PATH)
req.add_field('Content-Type', 'application/json; charset=utf-8')
req.body = URI::encode({
:jsonrpc => :'2.0',
:method => function,
:params => params,
:id => 0 }.to_json({:ascii_only => true})... | [
"def",
"call",
"(",
"function",
",",
"params",
")",
"start",
"req",
"=",
"Net",
"::",
"HTTP",
"::",
"Post",
".",
"new",
"(",
"DEFAULT_PATH",
")",
"req",
".",
"add_field",
"(",
"'Content-Type'",
",",
"'application/json; charset=utf-8'",
")",
"req",
".",
"bo... | Calls the given function with the given parameters via the JSON
interface of Scalaris. | [
"Calls",
"the",
"given",
"function",
"with",
"the",
"given",
"parameters",
"via",
"the",
"JSON",
"interface",
"of",
"Scalaris",
"."
] | 4e9e90e71ce3008da79a72eae40fe2f187580be2 | https://github.com/teodor-pripoae/scalaroid/blob/4e9e90e71ce3008da79a72eae40fe2f187580be2/lib/scalaroid/json_connection.rb#L27-L49 |
8,058 | LRDesign/Caliph | lib/caliph/command-line.rb | Caliph.CommandLine.string_format | def string_format
(command_environment.map do |key, value|
[key, value].join("=")
end + [command]).join(" ")
end | ruby | def string_format
(command_environment.map do |key, value|
[key, value].join("=")
end + [command]).join(" ")
end | [
"def",
"string_format",
"(",
"command_environment",
".",
"map",
"do",
"|",
"key",
",",
"value",
"|",
"[",
"key",
",",
"value",
"]",
".",
"join",
"(",
"\"=\"",
")",
"end",
"+",
"[",
"command",
"]",
")",
".",
"join",
"(",
"\" \"",
")",
"end"
] | The command as a string, including arguments and options, plus prefixed
environment variables. | [
"The",
"command",
"as",
"a",
"string",
"including",
"arguments",
"and",
"options",
"plus",
"prefixed",
"environment",
"variables",
"."
] | 9ad99fb72f75b87fa76eb28d4fc3ab811b29bb99 | https://github.com/LRDesign/Caliph/blob/9ad99fb72f75b87fa76eb28d4fc3ab811b29bb99/lib/caliph/command-line.rb#L52-L56 |
8,059 | rudionrails/little_log_friend | lib/little_log_friend/formatter.rb | LittleLogFriend.Formatter.call | def call ( severity, time, progname, msg )
msg = Format % [format_datetime(time), severity, $$, progname, msg2str(msg)]
msg = @@colors[severity] + msg + @@colors['DEFAULT'] if @@colorize
msg << "\n"
end | ruby | def call ( severity, time, progname, msg )
msg = Format % [format_datetime(time), severity, $$, progname, msg2str(msg)]
msg = @@colors[severity] + msg + @@colors['DEFAULT'] if @@colorize
msg << "\n"
end | [
"def",
"call",
"(",
"severity",
",",
"time",
",",
"progname",
",",
"msg",
")",
"msg",
"=",
"Format",
"%",
"[",
"format_datetime",
"(",
"time",
")",
",",
"severity",
",",
"$$",
",",
"progname",
",",
"msg2str",
"(",
"msg",
")",
"]",
"msg",
"=",
"@@co... | This method is invoked when a log event occurs | [
"This",
"method",
"is",
"invoked",
"when",
"a",
"log",
"event",
"occurs"
] | eed4ecadbf4aeff0e7cd7cfb619e6a7695c6bfbd | https://github.com/rudionrails/little_log_friend/blob/eed4ecadbf4aeff0e7cd7cfb619e6a7695c6bfbd/lib/little_log_friend/formatter.rb#L30-L34 |
8,060 | Gr3atWh173/hail_hydra | lib/client.rb | HailHydra.TPB.search | def search(query, pages=1, orderby=99)
get = make_search_request(query, pages, orderby)
raise "Invalid response: #{get.response.code}" unless get.response.code == "200"
return parse_search_results(get.response.body)
end | ruby | def search(query, pages=1, orderby=99)
get = make_search_request(query, pages, orderby)
raise "Invalid response: #{get.response.code}" unless get.response.code == "200"
return parse_search_results(get.response.body)
end | [
"def",
"search",
"(",
"query",
",",
"pages",
"=",
"1",
",",
"orderby",
"=",
"99",
")",
"get",
"=",
"make_search_request",
"(",
"query",
",",
"pages",
",",
"orderby",
")",
"raise",
"\"Invalid response: #{get.response.code}\"",
"unless",
"get",
".",
"response",
... | remember the domain name and get the cookie to use from the TPB server
search torrents | [
"remember",
"the",
"domain",
"name",
"and",
"get",
"the",
"cookie",
"to",
"use",
"from",
"the",
"TPB",
"server",
"search",
"torrents"
] | 2ff9cd69b138182911c19f81905970979b2873a8 | https://github.com/Gr3atWh173/hail_hydra/blob/2ff9cd69b138182911c19f81905970979b2873a8/lib/client.rb#L16-L20 |
8,061 | anthonator/skittles | lib/skittles/request.rb | Skittles.Request.post | def post(path, options = {}, headers = {}, raw = false)
request(:post, path, options, headers, raw)
end | ruby | def post(path, options = {}, headers = {}, raw = false)
request(:post, path, options, headers, raw)
end | [
"def",
"post",
"(",
"path",
",",
"options",
"=",
"{",
"}",
",",
"headers",
"=",
"{",
"}",
",",
"raw",
"=",
"false",
")",
"request",
"(",
":post",
",",
"path",
",",
"options",
",",
"headers",
",",
"raw",
")",
"end"
] | Performs an HTTP POST request | [
"Performs",
"an",
"HTTP",
"POST",
"request"
] | 1d7744a53089ef70f4a9c77a8e876d51d4c5bafc | https://github.com/anthonator/skittles/blob/1d7744a53089ef70f4a9c77a8e876d51d4c5bafc/lib/skittles/request.rb#L9-L11 |
8,062 | anthonator/skittles | lib/skittles/request.rb | Skittles.Request.put | def put(path, options = {}, headers = {}, raw = false)
request(:put, path, options, headers, raw)
end | ruby | def put(path, options = {}, headers = {}, raw = false)
request(:put, path, options, headers, raw)
end | [
"def",
"put",
"(",
"path",
",",
"options",
"=",
"{",
"}",
",",
"headers",
"=",
"{",
"}",
",",
"raw",
"=",
"false",
")",
"request",
"(",
":put",
",",
"path",
",",
"options",
",",
"headers",
",",
"raw",
")",
"end"
] | Performs an HTTP PUT request | [
"Performs",
"an",
"HTTP",
"PUT",
"request"
] | 1d7744a53089ef70f4a9c77a8e876d51d4c5bafc | https://github.com/anthonator/skittles/blob/1d7744a53089ef70f4a9c77a8e876d51d4c5bafc/lib/skittles/request.rb#L14-L16 |
8,063 | anthonator/skittles | lib/skittles/request.rb | Skittles.Request.delete | def delete(path, options = {}, headers = {}, raw = false)
request(:delete, path, options, headers, raw)
end | ruby | def delete(path, options = {}, headers = {}, raw = false)
request(:delete, path, options, headers, raw)
end | [
"def",
"delete",
"(",
"path",
",",
"options",
"=",
"{",
"}",
",",
"headers",
"=",
"{",
"}",
",",
"raw",
"=",
"false",
")",
"request",
"(",
":delete",
",",
"path",
",",
"options",
",",
"headers",
",",
"raw",
")",
"end"
] | Performs an HTTP DELETE request | [
"Performs",
"an",
"HTTP",
"DELETE",
"request"
] | 1d7744a53089ef70f4a9c77a8e876d51d4c5bafc | https://github.com/anthonator/skittles/blob/1d7744a53089ef70f4a9c77a8e876d51d4c5bafc/lib/skittles/request.rb#L19-L21 |
8,064 | theablefew/ablerc | lib/ablerc/option.rb | Ablerc.Option.to_stub | def to_stub
stub = "## #{name}\n"
stub << "# #{description}\n" unless description.nil?
stub << "#{entry_for_refuse_allow_behavior}\n" unless refuses.nil? and allows.nil?
stub << "#{entry_for_key_value}\n"
stub << "\n"
end | ruby | def to_stub
stub = "## #{name}\n"
stub << "# #{description}\n" unless description.nil?
stub << "#{entry_for_refuse_allow_behavior}\n" unless refuses.nil? and allows.nil?
stub << "#{entry_for_key_value}\n"
stub << "\n"
end | [
"def",
"to_stub",
"stub",
"=",
"\"## #{name}\\n\"",
"stub",
"<<",
"\"# #{description}\\n\"",
"unless",
"description",
".",
"nil?",
"stub",
"<<",
"\"#{entry_for_refuse_allow_behavior}\\n\"",
"unless",
"refuses",
".",
"nil?",
"and",
"allows",
".",
"nil?",
"stub",
"<<",
... | Initialize the option
==== Parameters
* <tt>name</tt> - A valid name for the option
* <tt>behaviors</tt> - Behaviors used to for this option
* <tt>block</tt> - A proc that should be run against the option value.
==== Options
* <tt>allow</tt> - The option value must be in this list
* <tt>boolean</tt> - The... | [
"Initialize",
"the",
"option"
] | 21ef74d92ef584c82a65b50cf9c908c13864b9e1 | https://github.com/theablefew/ablerc/blob/21ef74d92ef584c82a65b50cf9c908c13864b9e1/lib/ablerc/option.rb#L32-L38 |
8,065 | aapis/notifaction | lib/notifaction/style.rb | Notifaction.Style.format | def format(message, colour = nil, style = nil)
c = @map[:colour][colour.to_sym] unless colour.nil?
if style.nil?
t = 0
else
t = @map[:style][style.to_sym]
end
"\e[#{t};#{c}m#{message}\e[0m"
end | ruby | def format(message, colour = nil, style = nil)
c = @map[:colour][colour.to_sym] unless colour.nil?
if style.nil?
t = 0
else
t = @map[:style][style.to_sym]
end
"\e[#{t};#{c}m#{message}\e[0m"
end | [
"def",
"format",
"(",
"message",
",",
"colour",
"=",
"nil",
",",
"style",
"=",
"nil",
")",
"c",
"=",
"@map",
"[",
":colour",
"]",
"[",
"colour",
".",
"to_sym",
"]",
"unless",
"colour",
".",
"nil?",
"if",
"style",
".",
"nil?",
"t",
"=",
"0",
"else... | Create the map hash
@since 0.4.1
Return an ASCII-formatted string for display in common command line
terminals
@since 0.0.1 | [
"Create",
"the",
"map",
"hash"
] | dbad4c2888a1a59f2a3745d1c1e55c923e0d2039 | https://github.com/aapis/notifaction/blob/dbad4c2888a1a59f2a3745d1c1e55c923e0d2039/lib/notifaction/style.rb#L29-L39 |
8,066 | jtzero/vigilem-support | lib/vigilem/ffi/array_pointer_sync.rb | Vigilem::FFI.ArrayPointerSync.update | def update
if (results = what_changed?)[:ary]
update_ptr
update_ary_cache
true
elsif results[:ptr]
update_ary
update_ptr_cache
true
else
false
end
end | ruby | def update
if (results = what_changed?)[:ary]
update_ptr
update_ary_cache
true
elsif results[:ptr]
update_ary
update_ptr_cache
true
else
false
end
end | [
"def",
"update",
"if",
"(",
"results",
"=",
"what_changed?",
")",
"[",
":ary",
"]",
"update_ptr",
"update_ary_cache",
"true",
"elsif",
"results",
"[",
":ptr",
"]",
"update_ary",
"update_ptr_cache",
"true",
"else",
"false",
"end",
"end"
] | detects what changed and updates as needed
@return [TrueClass || FalseClass] updated? | [
"detects",
"what",
"changed",
"and",
"updates",
"as",
"needed"
] | 4ce72bd01980ed9049e8c03c3d1437f1d4d0de7a | https://github.com/jtzero/vigilem-support/blob/4ce72bd01980ed9049e8c03c3d1437f1d4d0de7a/lib/vigilem/ffi/array_pointer_sync.rb#L305-L317 |
8,067 | jtzero/vigilem-support | lib/vigilem/ffi/array_pointer_sync.rb | Vigilem::FFI.ArrayPointerSync.update_ptr | def update_ptr
ptr.clear
if (not (arry_type = self.class.ary_type).is_a?(Symbol))
if arry_type.respond_to? :to_native
ary.each {|item| ptr.write_pointer(arry_type.to_native(item, nil)) }
elsif arry_type.method_defined? :bytes
ptr.write_bytes(ary.map {|item| item.respond.... | ruby | def update_ptr
ptr.clear
if (not (arry_type = self.class.ary_type).is_a?(Symbol))
if arry_type.respond_to? :to_native
ary.each {|item| ptr.write_pointer(arry_type.to_native(item, nil)) }
elsif arry_type.method_defined? :bytes
ptr.write_bytes(ary.map {|item| item.respond.... | [
"def",
"update_ptr",
"ptr",
".",
"clear",
"if",
"(",
"not",
"(",
"arry_type",
"=",
"self",
".",
"class",
".",
"ary_type",
")",
".",
"is_a?",
"(",
"Symbol",
")",
")",
"if",
"arry_type",
".",
"respond_to?",
":to_native",
"ary",
".",
"each",
"{",
"|",
"... | this is slightly dangerous, if anything was still pointing to old pointer location
now its being reclaimed, this will change it
@return [Integer] hash | [
"this",
"is",
"slightly",
"dangerous",
"if",
"anything",
"was",
"still",
"pointing",
"to",
"old",
"pointer",
"location",
"now",
"its",
"being",
"reclaimed",
"this",
"will",
"change",
"it"
] | 4ce72bd01980ed9049e8c03c3d1437f1d4d0de7a | https://github.com/jtzero/vigilem-support/blob/4ce72bd01980ed9049e8c03c3d1437f1d4d0de7a/lib/vigilem/ffi/array_pointer_sync.rb#L323-L346 |
8,068 | essfeed/ruby-ess | lib/ess/element.rb | ESS.Element.method_missing | def method_missing m, *args, &block
if method_name_is_tag_name? m
return assign_tag(m, args, &block)
elsif method_name_is_tag_adder_method? m
return extend_tag_list(m, args, &block)
elsif method_name_is_tag_list_method? m
return child_tags[m[0..-6].to_sym] ||= []
elsif m... | ruby | def method_missing m, *args, &block
if method_name_is_tag_name? m
return assign_tag(m, args, &block)
elsif method_name_is_tag_adder_method? m
return extend_tag_list(m, args, &block)
elsif method_name_is_tag_list_method? m
return child_tags[m[0..-6].to_sym] ||= []
elsif m... | [
"def",
"method_missing",
"m",
",",
"*",
"args",
",",
"&",
"block",
"if",
"method_name_is_tag_name?",
"m",
"return",
"assign_tag",
"(",
"m",
",",
"args",
",",
"block",
")",
"elsif",
"method_name_is_tag_adder_method?",
"m",
"return",
"extend_tag_list",
"(",
"m",
... | Handles methods corresponding to a tag name, ending with either
_list or _attr, or starting with add_ . | [
"Handles",
"methods",
"corresponding",
"to",
"a",
"tag",
"name",
"ending",
"with",
"either",
"_list",
"or",
"_attr",
"or",
"starting",
"with",
"add_",
"."
] | 25708228acd64e4abd0557e323f6e6adabf6e930 | https://github.com/essfeed/ruby-ess/blob/25708228acd64e4abd0557e323f6e6adabf6e930/lib/ess/element.rb#L149-L160 |
8,069 | mkulumadzi/mediawiki-keiki | lib/mediawiki-keiki/page.rb | MediaWiki.Page.summary | def summary
text_array = to_text.split("\n")
text = text_array[0]
i = 1
while text.length <= 140 && i < text_array.length
text << "\n" + text_array[i]
i += 1
end
text
end | ruby | def summary
text_array = to_text.split("\n")
text = text_array[0]
i = 1
while text.length <= 140 && i < text_array.length
text << "\n" + text_array[i]
i += 1
end
text
end | [
"def",
"summary",
"text_array",
"=",
"to_text",
".",
"split",
"(",
"\"\\n\"",
")",
"text",
"=",
"text_array",
"[",
"0",
"]",
"i",
"=",
"1",
"while",
"text",
".",
"length",
"<=",
"140",
"&&",
"i",
"<",
"text_array",
".",
"length",
"text",
"<<",
"\"\\n... | Returns a short summary that is at least 140 characters long | [
"Returns",
"a",
"short",
"summary",
"that",
"is",
"at",
"least",
"140",
"characters",
"long"
] | 849338f643543f3a432d209f0413346d513c1e81 | https://github.com/mkulumadzi/mediawiki-keiki/blob/849338f643543f3a432d209f0413346d513c1e81/lib/mediawiki-keiki/page.rb#L36-L48 |
8,070 | chingor13/oauth_provider_engine | app/models/oauth_provider_engine/request_token.rb | OauthProviderEngine.RequestToken.upgrade! | def upgrade!
access_token = nil
transaction do
access_token = OauthProviderEngine::AccessToken.create!({
:application_id => self.application_id,
:user_id => self.user_id,
})
self.destroy || raise(ActiveRecord::Rollback)
end
return access_token
end | ruby | def upgrade!
access_token = nil
transaction do
access_token = OauthProviderEngine::AccessToken.create!({
:application_id => self.application_id,
:user_id => self.user_id,
})
self.destroy || raise(ActiveRecord::Rollback)
end
return access_token
end | [
"def",
"upgrade!",
"access_token",
"=",
"nil",
"transaction",
"do",
"access_token",
"=",
"OauthProviderEngine",
"::",
"AccessToken",
".",
"create!",
"(",
"{",
":application_id",
"=>",
"self",
".",
"application_id",
",",
":user_id",
"=>",
"self",
".",
"user_id",
... | this method with upgrade the RequestToken to an AccessToken
note that this will destroy the current RequestToken | [
"this",
"method",
"with",
"upgrade",
"the",
"RequestToken",
"to",
"an",
"AccessToken",
"note",
"that",
"this",
"will",
"destroy",
"the",
"current",
"RequestToken"
] | 3e742fd15834fa209d7289637e993f4061aa406e | https://github.com/chingor13/oauth_provider_engine/blob/3e742fd15834fa209d7289637e993f4061aa406e/app/models/oauth_provider_engine/request_token.rb#L18-L28 |
8,071 | ddrscott/sort_index | lib/sort_index/file.rb | SortIndex.File.sorted_puts | def sorted_puts(line)
if line == nil || line.size == 0
raise ArgumentError, 'Line cannot be blank!'
end
if line.index($/)
raise ArgumentError, "Cannot `puts` a line with extra line endings. Make sure the line does not contain `#{$/.inspect}`"
end
matched, idx = binary_seek... | ruby | def sorted_puts(line)
if line == nil || line.size == 0
raise ArgumentError, 'Line cannot be blank!'
end
if line.index($/)
raise ArgumentError, "Cannot `puts` a line with extra line endings. Make sure the line does not contain `#{$/.inspect}`"
end
matched, idx = binary_seek... | [
"def",
"sorted_puts",
"(",
"line",
")",
"if",
"line",
"==",
"nil",
"||",
"line",
".",
"size",
"==",
"0",
"raise",
"ArgumentError",
",",
"'Line cannot be blank!'",
"end",
"if",
"line",
".",
"index",
"(",
"$/",
")",
"raise",
"ArgumentError",
",",
"\"Cannot `... | adds the line to the while maintaining the data's sort order
@param [String] line to add to the file, it should not have it's own line ending.
@return [Nil] always returns nil to match standard #puts method | [
"adds",
"the",
"line",
"to",
"the",
"while",
"maintaining",
"the",
"data",
"s",
"sort",
"order"
] | f414152668216f6d4371a9fee7da4b3600765346 | https://github.com/ddrscott/sort_index/blob/f414152668216f6d4371a9fee7da4b3600765346/lib/sort_index/file.rb#L8-L32 |
8,072 | ddrscott/sort_index | lib/sort_index/file.rb | SortIndex.File.index_each_line | def index_each_line
positions = []
size = 0
each_line do |line|
positions << [size, line.size]
size += line.size
end
rewind
positions
end | ruby | def index_each_line
positions = []
size = 0
each_line do |line|
positions << [size, line.size]
size += line.size
end
rewind
positions
end | [
"def",
"index_each_line",
"positions",
"=",
"[",
"]",
"size",
"=",
"0",
"each_line",
"do",
"|",
"line",
"|",
"positions",
"<<",
"[",
"size",
",",
"line",
".",
"size",
"]",
"size",
"+=",
"line",
".",
"size",
"end",
"rewind",
"positions",
"end"
] | Builds an Array of position and length of the current file.
@return [Array[Array[Fixnum,Fixnum]]] array of position, line length pairs | [
"Builds",
"an",
"Array",
"of",
"position",
"and",
"length",
"of",
"the",
"current",
"file",
"."
] | f414152668216f6d4371a9fee7da4b3600765346 | https://github.com/ddrscott/sort_index/blob/f414152668216f6d4371a9fee7da4b3600765346/lib/sort_index/file.rb#L38-L47 |
8,073 | ddrscott/sort_index | lib/sort_index/file.rb | SortIndex.File.do_at_current_position | def do_at_current_position(&block)
current_position = self.tell
huge_buffer = self.read
self.seek(current_position, IO::SEEK_SET)
block.call
ensure
self.write huge_buffer
end | ruby | def do_at_current_position(&block)
current_position = self.tell
huge_buffer = self.read
self.seek(current_position, IO::SEEK_SET)
block.call
ensure
self.write huge_buffer
end | [
"def",
"do_at_current_position",
"(",
"&",
"block",
")",
"current_position",
"=",
"self",
".",
"tell",
"huge_buffer",
"=",
"self",
".",
"read",
"self",
".",
"seek",
"(",
"current_position",
",",
"IO",
"::",
"SEEK_SET",
")",
"block",
".",
"call",
"ensure",
... | remembers current file position, reads everything at the position
execute the block, and put everything back.
This routine is really bad for huge files since it could run out of
memory. | [
"remembers",
"current",
"file",
"position",
"reads",
"everything",
"at",
"the",
"position",
"execute",
"the",
"block",
"and",
"put",
"everything",
"back",
".",
"This",
"routine",
"is",
"really",
"bad",
"for",
"huge",
"files",
"since",
"it",
"could",
"run",
"... | f414152668216f6d4371a9fee7da4b3600765346 | https://github.com/ddrscott/sort_index/blob/f414152668216f6d4371a9fee7da4b3600765346/lib/sort_index/file.rb#L53-L60 |
8,074 | thebigdb/thebigdb-ruby | lib/thebigdb/request.rb | TheBigDB.Request.prepare | def prepare(method, request_uri, params = {})
method = method.downcase.to_s
if TheBigDB.api_key.is_a?(String) and !TheBigDB.api_key.empty?
params.merge!("api_key" => TheBigDB.api_key)
end
# we add the API version to the URL, with a trailing slash and the rest of the request
reque... | ruby | def prepare(method, request_uri, params = {})
method = method.downcase.to_s
if TheBigDB.api_key.is_a?(String) and !TheBigDB.api_key.empty?
params.merge!("api_key" => TheBigDB.api_key)
end
# we add the API version to the URL, with a trailing slash and the rest of the request
reque... | [
"def",
"prepare",
"(",
"method",
",",
"request_uri",
",",
"params",
"=",
"{",
"}",
")",
"method",
"=",
"method",
".",
"downcase",
".",
"to_s",
"if",
"TheBigDB",
".",
"api_key",
".",
"is_a?",
"(",
"String",
")",
"and",
"!",
"TheBigDB",
".",
"api_key",
... | Prepares the basic @http object with the current values of the module (host, port, ...)
Prepares the @http_request object with the actual content of the request | [
"Prepares",
"the",
"basic"
] | 6c978e3b0712af43529f36c3324ff583bd133df8 | https://github.com/thebigdb/thebigdb-ruby/blob/6c978e3b0712af43529f36c3324ff583bd133df8/lib/thebigdb/request.rb#L22-L54 |
8,075 | thebigdb/thebigdb-ruby | lib/thebigdb/request.rb | TheBigDB.Request.execute | def execute
# Here is the order of operations:
# -> setting @data_sent
# -> executing before_request_execution callback
# -> executing the HTTP request
# -> setting @response
# -> setting @data_received
# -> executing after_request_execution callback
# Setting @data_sent... | ruby | def execute
# Here is the order of operations:
# -> setting @data_sent
# -> executing before_request_execution callback
# -> executing the HTTP request
# -> setting @response
# -> setting @data_received
# -> executing after_request_execution callback
# Setting @data_sent... | [
"def",
"execute",
"# Here is the order of operations:",
"# -> setting @data_sent",
"# -> executing before_request_execution callback",
"# -> executing the HTTP request",
"# -> setting @response",
"# -> setting @data_received",
"# -> executing after_request_execution callback",
"# Setting @data_sen... | Actually makes the request prepared in @http_request, and sets @http_response | [
"Actually",
"makes",
"the",
"request",
"prepared",
"in"
] | 6c978e3b0712af43529f36c3324ff583bd133df8 | https://github.com/thebigdb/thebigdb-ruby/blob/6c978e3b0712af43529f36c3324ff583bd133df8/lib/thebigdb/request.rb#L57-L116 |
8,076 | NUBIC/aker | lib/aker/group_membership.rb | Aker.GroupMemberships.find | def find(group, *affiliate_ids)
candidates = self.select { |gm| gm.group.include?(group) }
return candidates if affiliate_ids.empty?
candidates.select { |gm| affiliate_ids.detect { |id| gm.include_affiliate?(id) } }
end | ruby | def find(group, *affiliate_ids)
candidates = self.select { |gm| gm.group.include?(group) }
return candidates if affiliate_ids.empty?
candidates.select { |gm| affiliate_ids.detect { |id| gm.include_affiliate?(id) } }
end | [
"def",
"find",
"(",
"group",
",",
"*",
"affiliate_ids",
")",
"candidates",
"=",
"self",
".",
"select",
"{",
"|",
"gm",
"|",
"gm",
".",
"group",
".",
"include?",
"(",
"group",
")",
"}",
"return",
"candidates",
"if",
"affiliate_ids",
".",
"empty?",
"cand... | Finds the group memberships that match the given group, possibly
constrained by one or more affiliates.
(Note that this method hides the `Enumerable` method `find`.
You can still use it under its `detect` alias.)
@param [Group,#to_s] group the group in question or its name
@param [Array<Object>,nil] *affiliate_i... | [
"Finds",
"the",
"group",
"memberships",
"that",
"match",
"the",
"given",
"group",
"possibly",
"constrained",
"by",
"one",
"or",
"more",
"affiliates",
"."
] | ff43606a8812e38f96bbe71b46e7f631cbeacf1c | https://github.com/NUBIC/aker/blob/ff43606a8812e38f96bbe71b46e7f631cbeacf1c/lib/aker/group_membership.rb#L108-L112 |
8,077 | alfa-jpn/rails-kvs-driver | lib/rails_kvs_driver/session.rb | RailsKvsDriver.Session.session | def session(driver_config, &block)
driver_config = validate_driver_config!(driver_config)
driver_connection_pool(self, driver_config).with do |kvs_instance|
block.call(self.new(kvs_instance, driver_config))
end
end | ruby | def session(driver_config, &block)
driver_config = validate_driver_config!(driver_config)
driver_connection_pool(self, driver_config).with do |kvs_instance|
block.call(self.new(kvs_instance, driver_config))
end
end | [
"def",
"session",
"(",
"driver_config",
",",
"&",
"block",
")",
"driver_config",
"=",
"validate_driver_config!",
"(",
"driver_config",
")",
"driver_connection_pool",
"(",
"self",
",",
"driver_config",
")",
".",
"with",
"do",
"|",
"kvs_instance",
"|",
"block",
".... | connect kvs and exec block.
This function pools the connecting driver.
@example
config = {
:host => 'localhost', # host of KVS.
:port => 6379, # port of KVS.
:namespace => 'Example', # namespace of avoid a conflict with key
:timeout_sec => 5, # ti... | [
"connect",
"kvs",
"and",
"exec",
"block",
".",
"This",
"function",
"pools",
"the",
"connecting",
"driver",
"."
] | 0eaf5c649071f9d82dc5f2ff2f4d7efcf32d8982 | https://github.com/alfa-jpn/rails-kvs-driver/blob/0eaf5c649071f9d82dc5f2ff2f4d7efcf32d8982/lib/rails_kvs_driver/session.rb#L43-L48 |
8,078 | alfa-jpn/rails-kvs-driver | lib/rails_kvs_driver/session.rb | RailsKvsDriver.Session.driver_connection_pool | def driver_connection_pool(driver_class, driver_config)
pool = search_driver_connection_pool(driver_class, driver_config)
return (pool.nil?) ? set_driver_connection_pool(driver_class, driver_config) : pool
end | ruby | def driver_connection_pool(driver_class, driver_config)
pool = search_driver_connection_pool(driver_class, driver_config)
return (pool.nil?) ? set_driver_connection_pool(driver_class, driver_config) : pool
end | [
"def",
"driver_connection_pool",
"(",
"driver_class",
",",
"driver_config",
")",
"pool",
"=",
"search_driver_connection_pool",
"(",
"driver_class",
",",
"driver_config",
")",
"return",
"(",
"pool",
".",
"nil?",
")",
"?",
"set_driver_connection_pool",
"(",
"driver_clas... | get driver connection pool
if doesn't exist pool, it's made newly.
@param driver_class [RailsKvsDriver::Base] driver_class
@param driver_config [Hash] driver_config
@return [ConnectionPool] connection pool of driver | [
"get",
"driver",
"connection",
"pool",
"if",
"doesn",
"t",
"exist",
"pool",
"it",
"s",
"made",
"newly",
"."
] | 0eaf5c649071f9d82dc5f2ff2f4d7efcf32d8982 | https://github.com/alfa-jpn/rails-kvs-driver/blob/0eaf5c649071f9d82dc5f2ff2f4d7efcf32d8982/lib/rails_kvs_driver/session.rb#L58-L61 |
8,079 | alfa-jpn/rails-kvs-driver | lib/rails_kvs_driver/session.rb | RailsKvsDriver.Session.set_driver_connection_pool | def set_driver_connection_pool(driver_class, driver_config)
conf = {
size: driver_config[:pool_size],
timeout: driver_config[:timeout_sec]
}
pool = ConnectionPool.new(conf) { driver_class.connect(driver_config) }
RailsKvsDriver::KVS_CONNECTION_POOL[driver_class.name] ||... | ruby | def set_driver_connection_pool(driver_class, driver_config)
conf = {
size: driver_config[:pool_size],
timeout: driver_config[:timeout_sec]
}
pool = ConnectionPool.new(conf) { driver_class.connect(driver_config) }
RailsKvsDriver::KVS_CONNECTION_POOL[driver_class.name] ||... | [
"def",
"set_driver_connection_pool",
"(",
"driver_class",
",",
"driver_config",
")",
"conf",
"=",
"{",
"size",
":",
"driver_config",
"[",
":pool_size",
"]",
",",
"timeout",
":",
"driver_config",
"[",
":timeout_sec",
"]",
"}",
"pool",
"=",
"ConnectionPool",
".",
... | set driver connection pool
@param driver_class [RailsKvsDriver::Base] driver_class
@param driver_config [Hash] driver_config
@return [ConnectionPool] connection pool of driver | [
"set",
"driver",
"connection",
"pool"
] | 0eaf5c649071f9d82dc5f2ff2f4d7efcf32d8982 | https://github.com/alfa-jpn/rails-kvs-driver/blob/0eaf5c649071f9d82dc5f2ff2f4d7efcf32d8982/lib/rails_kvs_driver/session.rb#L68-L79 |
8,080 | alfa-jpn/rails-kvs-driver | lib/rails_kvs_driver/session.rb | RailsKvsDriver.Session.search_driver_connection_pool | def search_driver_connection_pool(driver_class, driver_config)
if RailsKvsDriver::KVS_CONNECTION_POOL.has_key?(driver_class.name)
RailsKvsDriver::KVS_CONNECTION_POOL[driver_class.name].each do |pool_set|
return pool_set[:pool] if equal_driver_config?(pool_set[:config], driver_config)
end... | ruby | def search_driver_connection_pool(driver_class, driver_config)
if RailsKvsDriver::KVS_CONNECTION_POOL.has_key?(driver_class.name)
RailsKvsDriver::KVS_CONNECTION_POOL[driver_class.name].each do |pool_set|
return pool_set[:pool] if equal_driver_config?(pool_set[:config], driver_config)
end... | [
"def",
"search_driver_connection_pool",
"(",
"driver_class",
",",
"driver_config",
")",
"if",
"RailsKvsDriver",
"::",
"KVS_CONNECTION_POOL",
".",
"has_key?",
"(",
"driver_class",
".",
"name",
")",
"RailsKvsDriver",
"::",
"KVS_CONNECTION_POOL",
"[",
"driver_class",
".",
... | search driver connection pool
@param driver_class [RailsKvsDriver::Base] driver_class
@param driver_config [Hash] driver_config
@return [ConnectionPool] connection pool of driver, or nil | [
"search",
"driver",
"connection",
"pool"
] | 0eaf5c649071f9d82dc5f2ff2f4d7efcf32d8982 | https://github.com/alfa-jpn/rails-kvs-driver/blob/0eaf5c649071f9d82dc5f2ff2f4d7efcf32d8982/lib/rails_kvs_driver/session.rb#L86-L94 |
8,081 | alfa-jpn/rails-kvs-driver | lib/rails_kvs_driver/session.rb | RailsKvsDriver.Session.equal_driver_config? | def equal_driver_config?(config1, config2)
return false unless config1[:host] == config2[:host]
return false unless config1[:port] == config2[:port]
return false unless config1[:timeout_sec] == config2[:timeout_sec]
return false unless config1[:pool_size] == config2[:pool_size]
... | ruby | def equal_driver_config?(config1, config2)
return false unless config1[:host] == config2[:host]
return false unless config1[:port] == config2[:port]
return false unless config1[:timeout_sec] == config2[:timeout_sec]
return false unless config1[:pool_size] == config2[:pool_size]
... | [
"def",
"equal_driver_config?",
"(",
"config1",
",",
"config2",
")",
"return",
"false",
"unless",
"config1",
"[",
":host",
"]",
"==",
"config2",
"[",
":host",
"]",
"return",
"false",
"unless",
"config1",
"[",
":port",
"]",
"==",
"config2",
"[",
":port",
"]"... | compare driver config.
@param config1 [Hash] driver config
@param config2 [Hash] driver config | [
"compare",
"driver",
"config",
"."
] | 0eaf5c649071f9d82dc5f2ff2f4d7efcf32d8982 | https://github.com/alfa-jpn/rails-kvs-driver/blob/0eaf5c649071f9d82dc5f2ff2f4d7efcf32d8982/lib/rails_kvs_driver/session.rb#L100-L107 |
8,082 | mgsnova/crisp | lib/crisp/function_runner.rb | Crisp.FunctionRunner.validate_args_count | def validate_args_count(expected, got)
if (expected.is_a?(Numeric) and expected != got) or
(expected.is_a?(Range) and !(expected === got))
raise ArgumentError, "wrong number of arguments for '#{name}' (#{got} for #{expected})"
end
end | ruby | def validate_args_count(expected, got)
if (expected.is_a?(Numeric) and expected != got) or
(expected.is_a?(Range) and !(expected === got))
raise ArgumentError, "wrong number of arguments for '#{name}' (#{got} for #{expected})"
end
end | [
"def",
"validate_args_count",
"(",
"expected",
",",
"got",
")",
"if",
"(",
"expected",
".",
"is_a?",
"(",
"Numeric",
")",
"and",
"expected",
"!=",
"got",
")",
"or",
"(",
"expected",
".",
"is_a?",
"(",
"Range",
")",
"and",
"!",
"(",
"expected",
"===",
... | following methods are used for calling from the function block
raise an error if argument count got does not match the expected | [
"following",
"methods",
"are",
"used",
"for",
"calling",
"from",
"the",
"function",
"block",
"raise",
"an",
"error",
"if",
"argument",
"count",
"got",
"does",
"not",
"match",
"the",
"expected"
] | 0b3695de59258971b8b39998602c5b6e9f10623b | https://github.com/mgsnova/crisp/blob/0b3695de59258971b8b39998602c5b6e9f10623b/lib/crisp/function_runner.rb#L23-L28 |
8,083 | FineLinePrototyping/irie | lib/irie/class_methods.rb | Irie.ClassMethods.extensions! | def extensions!(*extension_syms)
return extension_syms if extension_syms.length == 0
extension_syms = extension_syms.flatten.collect {|es| es.to_sym}.compact
if extension_syms.include?(:all)
ordered_extension_syms = self.extension_include_order.dup
else
extensions_without_defin... | ruby | def extensions!(*extension_syms)
return extension_syms if extension_syms.length == 0
extension_syms = extension_syms.flatten.collect {|es| es.to_sym}.compact
if extension_syms.include?(:all)
ordered_extension_syms = self.extension_include_order.dup
else
extensions_without_defin... | [
"def",
"extensions!",
"(",
"*",
"extension_syms",
")",
"return",
"extension_syms",
"if",
"extension_syms",
".",
"length",
"==",
"0",
"extension_syms",
"=",
"extension_syms",
".",
"flatten",
".",
"collect",
"{",
"|",
"es",
"|",
"es",
".",
"to_sym",
"}",
".",
... | Load specified extensions in the order defined by self.extension_include_order. | [
"Load",
"specified",
"extensions",
"in",
"the",
"order",
"defined",
"by",
"self",
".",
"extension_include_order",
"."
] | 522cd66bb41461d1b4a6512ad32b8bd2ab1edb0f | https://github.com/FineLinePrototyping/irie/blob/522cd66bb41461d1b4a6512ad32b8bd2ab1edb0f/lib/irie/class_methods.rb#L28-L59 |
8,084 | humpyard/humpyard | app/controllers/humpyard/elements_controller.rb | Humpyard.ElementsController.new | def new
@element = Humpyard::config.element_types[params[:type]].new(
:page_id => params[:page_id],
:container_id => params[:container_id].to_i > 0 ? params[:container_id].to_i : nil,
:page_yield_name => params[:yield_name].blank? ? 'main' : params[:yield_name],
:shared_state => 0... | ruby | def new
@element = Humpyard::config.element_types[params[:type]].new(
:page_id => params[:page_id],
:container_id => params[:container_id].to_i > 0 ? params[:container_id].to_i : nil,
:page_yield_name => params[:yield_name].blank? ? 'main' : params[:yield_name],
:shared_state => 0... | [
"def",
"new",
"@element",
"=",
"Humpyard",
"::",
"config",
".",
"element_types",
"[",
"params",
"[",
":type",
"]",
"]",
".",
"new",
"(",
":page_id",
"=>",
"params",
"[",
":page_id",
"]",
",",
":container_id",
"=>",
"params",
"[",
":container_id",
"]",
".... | Dialog content for a new element | [
"Dialog",
"content",
"for",
"a",
"new",
"element"
] | f344ab851f1dfd824c1e4cb4b92f7c62ac0acefd | https://github.com/humpyard/humpyard/blob/f344ab851f1dfd824c1e4cb4b92f7c62ac0acefd/app/controllers/humpyard/elements_controller.rb#L7-L21 |
8,085 | humpyard/humpyard | app/controllers/humpyard/elements_controller.rb | Humpyard.ElementsController.create | def create
@element = Humpyard::config.element_types[params[:type]].new params[:element]
unless can? :create, @element.element
render :json => {
:status => :failed
}, :status => 403
return
end
if @element.save
@prev = Hump... | ruby | def create
@element = Humpyard::config.element_types[params[:type]].new params[:element]
unless can? :create, @element.element
render :json => {
:status => :failed
}, :status => 403
return
end
if @element.save
@prev = Hump... | [
"def",
"create",
"@element",
"=",
"Humpyard",
"::",
"config",
".",
"element_types",
"[",
"params",
"[",
":type",
"]",
"]",
".",
"new",
"params",
"[",
":element",
"]",
"unless",
"can?",
":create",
",",
"@element",
".",
"element",
"render",
":json",
"=>",
... | Create a new element | [
"Create",
"a",
"new",
"element"
] | f344ab851f1dfd824c1e4cb4b92f7c62ac0acefd | https://github.com/humpyard/humpyard/blob/f344ab851f1dfd824c1e4cb4b92f7c62ac0acefd/app/controllers/humpyard/elements_controller.rb#L24-L60 |
8,086 | humpyard/humpyard | app/controllers/humpyard/elements_controller.rb | Humpyard.ElementsController.update | def update
@element = Humpyard::Element.find(params[:id])
if @element
unless can? :update, @element
render :json => {
:status => :failed
}, :status => 403
return
end
if @element.content_data.update_attributes params[:element]
... | ruby | def update
@element = Humpyard::Element.find(params[:id])
if @element
unless can? :update, @element
render :json => {
:status => :failed
}, :status => 403
return
end
if @element.content_data.update_attributes params[:element]
... | [
"def",
"update",
"@element",
"=",
"Humpyard",
"::",
"Element",
".",
"find",
"(",
"params",
"[",
":id",
"]",
")",
"if",
"@element",
"unless",
"can?",
":update",
",",
"@element",
"render",
":json",
"=>",
"{",
":status",
"=>",
":failed",
"}",
",",
":status"... | Update an existing element | [
"Update",
"an",
"existing",
"element"
] | f344ab851f1dfd824c1e4cb4b92f7c62ac0acefd | https://github.com/humpyard/humpyard/blob/f344ab851f1dfd824c1e4cb4b92f7c62ac0acefd/app/controllers/humpyard/elements_controller.rb#L81-L113 |
8,087 | humpyard/humpyard | app/controllers/humpyard/elements_controller.rb | Humpyard.ElementsController.move | def move
@element = Humpyard::Element.find(params[:id])
if @element
unless can? :update, @element
render :json => {
:status => :failed
}, :status => 403
return
end
@element.update_attributes(
:container => Humpyard::... | ruby | def move
@element = Humpyard::Element.find(params[:id])
if @element
unless can? :update, @element
render :json => {
:status => :failed
}, :status => 403
return
end
@element.update_attributes(
:container => Humpyard::... | [
"def",
"move",
"@element",
"=",
"Humpyard",
"::",
"Element",
".",
"find",
"(",
"params",
"[",
":id",
"]",
")",
"if",
"@element",
"unless",
"can?",
":update",
",",
"@element",
"render",
":json",
"=>",
"{",
":status",
"=>",
":failed",
"}",
",",
":status",
... | Move an element | [
"Move",
"an",
"element"
] | f344ab851f1dfd824c1e4cb4b92f7c62ac0acefd | https://github.com/humpyard/humpyard/blob/f344ab851f1dfd824c1e4cb4b92f7c62ac0acefd/app/controllers/humpyard/elements_controller.rb#L116-L144 |
8,088 | NUBIC/aker | lib/aker/configuration.rb | Aker.Configuration.api_modes= | def api_modes=(*new_modes)
new_modes = new_modes.first if new_modes.size == 1 && Array === new_modes.first
@api_modes = new_modes.compact.collect(&:to_sym)
end | ruby | def api_modes=(*new_modes)
new_modes = new_modes.first if new_modes.size == 1 && Array === new_modes.first
@api_modes = new_modes.compact.collect(&:to_sym)
end | [
"def",
"api_modes",
"=",
"(",
"*",
"new_modes",
")",
"new_modes",
"=",
"new_modes",
".",
"first",
"if",
"new_modes",
".",
"size",
"==",
"1",
"&&",
"Array",
"===",
"new_modes",
".",
"first",
"@api_modes",
"=",
"new_modes",
".",
"compact",
".",
"collect",
... | Replaces the non-interactive authentication modes.
@param [List<#to_sym>] new_modes the names of the desired modes
@return [void] | [
"Replaces",
"the",
"non",
"-",
"interactive",
"authentication",
"modes",
"."
] | ff43606a8812e38f96bbe71b46e7f631cbeacf1c | https://github.com/NUBIC/aker/blob/ff43606a8812e38f96bbe71b46e7f631cbeacf1c/lib/aker/configuration.rb#L110-L113 |
8,089 | NUBIC/aker | lib/aker/configuration.rb | Aker.Configuration.central | def central(filename)
params = ::Aker::CentralParameters.new(filename)
params.each { |k, v| add_parameters_for(k, v) }
end | ruby | def central(filename)
params = ::Aker::CentralParameters.new(filename)
params.each { |k, v| add_parameters_for(k, v) }
end | [
"def",
"central",
"(",
"filename",
")",
"params",
"=",
"::",
"Aker",
"::",
"CentralParameters",
".",
"new",
"(",
"filename",
")",
"params",
".",
"each",
"{",
"|",
"k",
",",
"v",
"|",
"add_parameters_for",
"(",
"k",
",",
"v",
")",
"}",
"end"
] | Loads parameters from the given aker central parameters
file.
@see Aker::CentralParameters
@param [String] filename the filename
@return [void] | [
"Loads",
"parameters",
"from",
"the",
"given",
"aker",
"central",
"parameters",
"file",
"."
] | ff43606a8812e38f96bbe71b46e7f631cbeacf1c | https://github.com/NUBIC/aker/blob/ff43606a8812e38f96bbe71b46e7f631cbeacf1c/lib/aker/configuration.rb#L224-L228 |
8,090 | ktemkin/ruby-adept | lib/adept/core.rb | Adept.Core.configure | def configure(elf_file, [email protected])
#Ensure the target is a string.
target = target.to_s
#Get the path to the bitfile and memory map which will be used to generate the new bitfile.
memory_map = "#@base_path/#{@targets[target]['memory_map']}"
bit_file = "#@base_path/... | ruby | def configure(elf_file, [email protected])
#Ensure the target is a string.
target = target.to_s
#Get the path to the bitfile and memory map which will be used to generate the new bitfile.
memory_map = "#@base_path/#{@targets[target]['memory_map']}"
bit_file = "#@base_path/... | [
"def",
"configure",
"(",
"elf_file",
",",
"target",
"=",
"@targets",
".",
"keys",
".",
"first",
")",
"#Ensure the target is a string.",
"target",
"=",
"target",
".",
"to_s",
"#Get the path to the bitfile and memory map which will be used to generate the new bitfile.",
"memory... | Initializes a new instance of a Core object.
Configures the given | [
"Initializes",
"a",
"new",
"instance",
"of",
"a",
"Core",
"object",
"."
] | c24eb7bb15162632a83dc2f389f60c98447c7d5c | https://github.com/ktemkin/ruby-adept/blob/c24eb7bb15162632a83dc2f389f60c98447c7d5c/lib/adept/core.rb#L71-L90 |
8,091 | ktemkin/ruby-adept | lib/adept/core.rb | Adept.Core.with_temporary_files | def with_temporary_files(file_contents='', dest_extension = '', source_extension = '', message=nil)
#File mode for all of the created temporary files.
#Create the files, and allow read/write, but do not lock for exclusive access.
file_mode = File::CREAT | File::RDWR
#Create a new file which co... | ruby | def with_temporary_files(file_contents='', dest_extension = '', source_extension = '', message=nil)
#File mode for all of the created temporary files.
#Create the files, and allow read/write, but do not lock for exclusive access.
file_mode = File::CREAT | File::RDWR
#Create a new file which co... | [
"def",
"with_temporary_files",
"(",
"file_contents",
"=",
"''",
",",
"dest_extension",
"=",
"''",
",",
"source_extension",
"=",
"''",
",",
"message",
"=",
"nil",
")",
"#File mode for all of the created temporary files.",
"#Create the files, and allow read/write, but do not lo... | Executes a given block with an "anonymous" temporary file.
The temporary file is deleted at the end of the block, and its contents
are returned. | [
"Executes",
"a",
"given",
"block",
"with",
"an",
"anonymous",
"temporary",
"file",
".",
"The",
"temporary",
"file",
"is",
"deleted",
"at",
"the",
"end",
"of",
"the",
"block",
"and",
"its",
"contents",
"are",
"returned",
"."
] | c24eb7bb15162632a83dc2f389f60c98447c7d5c | https://github.com/ktemkin/ruby-adept/blob/c24eb7bb15162632a83dc2f389f60c98447c7d5c/lib/adept/core.rb#L107-L133 |
8,092 | eet-nu/cheers | lib/cheers/color.rb | Cheers.Color.to_s | def to_s
return '#' + r.to_s(16).rjust(2, '0') +
g.to_s(16).rjust(2, '0') +
b.to_s(16).rjust(2, '0')
end | ruby | def to_s
return '#' + r.to_s(16).rjust(2, '0') +
g.to_s(16).rjust(2, '0') +
b.to_s(16).rjust(2, '0')
end | [
"def",
"to_s",
"return",
"'#'",
"+",
"r",
".",
"to_s",
"(",
"16",
")",
".",
"rjust",
"(",
"2",
",",
"'0'",
")",
"+",
"g",
".",
"to_s",
"(",
"16",
")",
".",
"rjust",
"(",
"2",
",",
"'0'",
")",
"+",
"b",
".",
"to_s",
"(",
"16",
")",
".",
... | Create new color from a hex value | [
"Create",
"new",
"color",
"from",
"a",
"hex",
"value"
] | 4b94bf8ce2a1ca929b9b56277e12f3e94e7a5399 | https://github.com/eet-nu/cheers/blob/4b94bf8ce2a1ca929b9b56277e12f3e94e7a5399/lib/cheers/color.rb#L16-L20 |
8,093 | plangrade/plangrade-ruby | lib/plangrade/client.rb | Plangrade.Client.request | def request(method, path, params={})
headers = @default_headers.merge({'Authorization' => "Bearer #{@access_token}"})
result = http_client.send_request(method, path, {
:params => params,
:headers => headers
})
result
end | ruby | def request(method, path, params={})
headers = @default_headers.merge({'Authorization' => "Bearer #{@access_token}"})
result = http_client.send_request(method, path, {
:params => params,
:headers => headers
})
result
end | [
"def",
"request",
"(",
"method",
",",
"path",
",",
"params",
"=",
"{",
"}",
")",
"headers",
"=",
"@default_headers",
".",
"merge",
"(",
"{",
"'Authorization'",
"=>",
"\"Bearer #{@access_token}\"",
"}",
")",
"result",
"=",
"http_client",
".",
"send_request",
... | Makes an HTTP request using the provided parameters
@raise [Plangrade::Error::Unauthorized]
@param method [string]
@param path [string]
@param params [Hash]
@return [Plangrade::ApiResponse]
@!visibility private | [
"Makes",
"an",
"HTTP",
"request",
"using",
"the",
"provided",
"parameters"
] | fe7240753825358c9b3c6887b51b5858a984c5f8 | https://github.com/plangrade/plangrade-ruby/blob/fe7240753825358c9b3c6887b51b5858a984c5f8/lib/plangrade/client.rb#L67-L74 |
8,094 | jeremyd/virtualmonkey | lib/virtualmonkey/application.rb | VirtualMonkey.Application.app_servers | def app_servers
ret = @servers.select { |s| s.nickname =~ /App Server/ }
raise "No app servers in deployment" unless ret.length > 0
ret
end | ruby | def app_servers
ret = @servers.select { |s| s.nickname =~ /App Server/ }
raise "No app servers in deployment" unless ret.length > 0
ret
end | [
"def",
"app_servers",
"ret",
"=",
"@servers",
".",
"select",
"{",
"|",
"s",
"|",
"s",
".",
"nickname",
"=~",
"/",
"/",
"}",
"raise",
"\"No app servers in deployment\"",
"unless",
"ret",
".",
"length",
">",
"0",
"ret",
"end"
] | returns an Array of the App Servers in the deployment | [
"returns",
"an",
"Array",
"of",
"the",
"App",
"Servers",
"in",
"the",
"deployment"
] | b2c7255f20ac5ec881eb90afbb5e712160db0dcb | https://github.com/jeremyd/virtualmonkey/blob/b2c7255f20ac5ec881eb90afbb5e712160db0dcb/lib/virtualmonkey/application.rb#L7-L11 |
8,095 | mhs/rvideo | lib/rvideo/inspector.rb | RVideo.Inspector.duration | def duration
return nil unless valid?
units = raw_duration.split(":")
(units[0].to_i * 60 * 60 * 1000) + (units[1].to_i * 60 * 1000) + (units[2].to_f * 1000).to_i
end | ruby | def duration
return nil unless valid?
units = raw_duration.split(":")
(units[0].to_i * 60 * 60 * 1000) + (units[1].to_i * 60 * 1000) + (units[2].to_f * 1000).to_i
end | [
"def",
"duration",
"return",
"nil",
"unless",
"valid?",
"units",
"=",
"raw_duration",
".",
"split",
"(",
"\":\"",
")",
"(",
"units",
"[",
"0",
"]",
".",
"to_i",
"*",
"60",
"*",
"60",
"*",
"1000",
")",
"+",
"(",
"units",
"[",
"1",
"]",
".",
"to_i"... | The duration of the movie in milliseconds, as an integer.
Example:
24400 # 24.4 seconds
Note that the precision of the duration is in tenths of a second, not
thousandths, but milliseconds are a more standard unit of time than
deciseconds. | [
"The",
"duration",
"of",
"the",
"movie",
"in",
"milliseconds",
"as",
"an",
"integer",
"."
] | 5d12bafc5b63888f01c42de272fddcef0ac528b1 | https://github.com/mhs/rvideo/blob/5d12bafc5b63888f01c42de272fddcef0ac528b1/lib/rvideo/inspector.rb#L304-L309 |
8,096 | genaromadrid/email_checker | lib/email_checker/domain.rb | EmailChecker.Domain.valid? | def valid?
return false unless @domain
Timeout.timeout(SERVER_TIMEOUT) do
return true if valid_mx_records?
return true if a_records?
end
rescue Timeout::Error, Errno::ECONNREFUSED
false
end | ruby | def valid?
return false unless @domain
Timeout.timeout(SERVER_TIMEOUT) do
return true if valid_mx_records?
return true if a_records?
end
rescue Timeout::Error, Errno::ECONNREFUSED
false
end | [
"def",
"valid?",
"return",
"false",
"unless",
"@domain",
"Timeout",
".",
"timeout",
"(",
"SERVER_TIMEOUT",
")",
"do",
"return",
"true",
"if",
"valid_mx_records?",
"return",
"true",
"if",
"a_records?",
"end",
"rescue",
"Timeout",
"::",
"Error",
",",
"Errno",
":... | Returns a new instance of Domain
@param domain [String] The domain name.
@example EmailChecker::Domain.new('google.com')
Checks if the domian exists and has valid MX and A records.
@return [Boolean] | [
"Returns",
"a",
"new",
"instance",
"of",
"Domain"
] | 34cae07ddf5bb86efff030d062e420d5aa15486a | https://github.com/genaromadrid/email_checker/blob/34cae07ddf5bb86efff030d062e420d5aa15486a/lib/email_checker/domain.rb#L20-L28 |
8,097 | genaromadrid/email_checker | lib/email_checker/domain.rb | EmailChecker.Domain.valid_mx_records? | def valid_mx_records?
mx_servers.each do |server|
exchange_a_records = dns.getresources(server[:address], Resolv::DNS::Resource::IN::A)
return true if exchange_a_records.any?
end
false
end | ruby | def valid_mx_records?
mx_servers.each do |server|
exchange_a_records = dns.getresources(server[:address], Resolv::DNS::Resource::IN::A)
return true if exchange_a_records.any?
end
false
end | [
"def",
"valid_mx_records?",
"mx_servers",
".",
"each",
"do",
"|",
"server",
"|",
"exchange_a_records",
"=",
"dns",
".",
"getresources",
"(",
"server",
"[",
":address",
"]",
",",
"Resolv",
"::",
"DNS",
"::",
"Resource",
"::",
"IN",
"::",
"A",
")",
"return",... | Check if the domian has valid MX records and it can receive emails.
The MX server exists and it has valid A records.
@return [Boolean] | [
"Check",
"if",
"the",
"domian",
"has",
"valid",
"MX",
"records",
"and",
"it",
"can",
"receive",
"emails",
".",
"The",
"MX",
"server",
"exists",
"and",
"it",
"has",
"valid",
"A",
"records",
"."
] | 34cae07ddf5bb86efff030d062e420d5aa15486a | https://github.com/genaromadrid/email_checker/blob/34cae07ddf5bb86efff030d062e420d5aa15486a/lib/email_checker/domain.rb#L34-L40 |
8,098 | genaromadrid/email_checker | lib/email_checker/domain.rb | EmailChecker.Domain.mx_servers | def mx_servers
return @mx_servers if @mx_servers
@mx_servers = []
mx_records.each do |mx|
@mx_servers.push(preference: mx.preference, address: mx.exchange.to_s)
end
@mx_servers
end | ruby | def mx_servers
return @mx_servers if @mx_servers
@mx_servers = []
mx_records.each do |mx|
@mx_servers.push(preference: mx.preference, address: mx.exchange.to_s)
end
@mx_servers
end | [
"def",
"mx_servers",
"return",
"@mx_servers",
"if",
"@mx_servers",
"@mx_servers",
"=",
"[",
"]",
"mx_records",
".",
"each",
"do",
"|",
"mx",
"|",
"@mx_servers",
".",
"push",
"(",
"preference",
":",
"mx",
".",
"preference",
",",
"address",
":",
"mx",
".",
... | The servers that this domian MX records point at.
@return [Array<Hash>] Array of type { preference: 1, address: '127.0.0.1' } | [
"The",
"servers",
"that",
"this",
"domian",
"MX",
"records",
"point",
"at",
"."
] | 34cae07ddf5bb86efff030d062e420d5aa15486a | https://github.com/genaromadrid/email_checker/blob/34cae07ddf5bb86efff030d062e420d5aa15486a/lib/email_checker/domain.rb#L67-L74 |
8,099 | userhello/bit_magic | lib/bit_magic/bits_generator.rb | BitMagic.BitsGenerator.bits_for | def bits_for(*field_names)
bits = []
field_names.flatten.each do |i|
if i.is_a?(Integer)
bits << i
next
end
if i.respond_to?(:to_sym) and @field_list[i.to_sym]
bits << @field_list[i.to_sym]
end
end
bits.flatten
... | ruby | def bits_for(*field_names)
bits = []
field_names.flatten.each do |i|
if i.is_a?(Integer)
bits << i
next
end
if i.respond_to?(:to_sym) and @field_list[i.to_sym]
bits << @field_list[i.to_sym]
end
end
bits.flatten
... | [
"def",
"bits_for",
"(",
"*",
"field_names",
")",
"bits",
"=",
"[",
"]",
"field_names",
".",
"flatten",
".",
"each",
"do",
"|",
"i",
"|",
"if",
"i",
".",
"is_a?",
"(",
"Integer",
")",
"bits",
"<<",
"i",
"next",
"end",
"if",
"i",
".",
"respond_to?",
... | Initialize the generator.
@param [BitMagic::Adapters::Magician, Hash] magician_or_field_list a Magician
object that contains field_list, bits, and options OR a Hash object of
:name => bit index or bit index array, key-value pairs
@param [Hash] options options and defaults, will override Magician action_options... | [
"Initialize",
"the",
"generator",
"."
] | 78b7fc28313af9c9506220812573576d229186bb | https://github.com/userhello/bit_magic/blob/78b7fc28313af9c9506220812573576d229186bb/lib/bit_magic/bits_generator.rb#L63-L78 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.