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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
9,300 | sugaryourcoffee/syclink | lib/syclink/formatter.rb | SycLink.Formatter.print_horizontal_line | def print_horizontal_line(line, separator, widths)
puts widths.map { |width| line * width }.join(separator)
end | ruby | def print_horizontal_line(line, separator, widths)
puts widths.map { |width| line * width }.join(separator)
end | [
"def",
"print_horizontal_line",
"(",
"line",
",",
"separator",
",",
"widths",
")",
"puts",
"widths",
".",
"map",
"{",
"|",
"width",
"|",
"line",
"*",
"width",
"}",
".",
"join",
"(",
"separator",
")",
"end"
] | Prints a horizontal line below the header | [
"Prints",
"a",
"horizontal",
"line",
"below",
"the",
"header"
] | 941ee2045c946daa1e0db394eb643aa82c1254cc | https://github.com/sugaryourcoffee/syclink/blob/941ee2045c946daa1e0db394eb643aa82c1254cc/lib/syclink/formatter.rb#L100-L102 |
9,301 | sugaryourcoffee/syclink | lib/syclink/formatter.rb | SycLink.Formatter.print_table | def print_table(columns, formatter)
columns.transpose.each { |row| puts sprintf(formatter, *row) }
end | ruby | def print_table(columns, formatter)
columns.transpose.each { |row| puts sprintf(formatter, *row) }
end | [
"def",
"print_table",
"(",
"columns",
",",
"formatter",
")",
"columns",
".",
"transpose",
".",
"each",
"{",
"|",
"row",
"|",
"puts",
"sprintf",
"(",
"formatter",
",",
"row",
")",
"}",
"end"
] | Prints columns in a table format | [
"Prints",
"columns",
"in",
"a",
"table",
"format"
] | 941ee2045c946daa1e0db394eb643aa82c1254cc | https://github.com/sugaryourcoffee/syclink/blob/941ee2045c946daa1e0db394eb643aa82c1254cc/lib/syclink/formatter.rb#L105-L107 |
9,302 | lyrasis/collectionspace-client | lib/collectionspace/client/helpers.rb | CollectionSpace.Helpers.all | def all(path, options = {}, &block)
all = []
list_type, list_item = get_list_types(path)
result = request('GET', path, options)
raise RequestError.new result.status if result.status_code != 200 or result.parsed[list_type].nil?
total = result.parsed[list_type]['totalItems'].to_i
ite... | ruby | def all(path, options = {}, &block)
all = []
list_type, list_item = get_list_types(path)
result = request('GET', path, options)
raise RequestError.new result.status if result.status_code != 200 or result.parsed[list_type].nil?
total = result.parsed[list_type]['totalItems'].to_i
ite... | [
"def",
"all",
"(",
"path",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"all",
"=",
"[",
"]",
"list_type",
",",
"list_item",
"=",
"get_list_types",
"(",
"path",
")",
"result",
"=",
"request",
"(",
"'GET'",
",",
"path",
",",
"options",
")"... | get ALL records at path by paging through record set
can pass block to act on each page of results | [
"get",
"ALL",
"records",
"at",
"path",
"by",
"paging",
"through",
"record",
"set",
"can",
"pass",
"block",
"to",
"act",
"on",
"each",
"page",
"of",
"results"
] | 6db26dffb792bda2e8a5b46863a63dc1d56932a3 | https://github.com/lyrasis/collectionspace-client/blob/6db26dffb792bda2e8a5b46863a63dc1d56932a3/lib/collectionspace/client/helpers.rb#L23-L45 |
9,303 | lyrasis/collectionspace-client | lib/collectionspace/client/helpers.rb | CollectionSpace.Helpers.post_blob_url | def post_blob_url(url)
raise ArgumentError.new("Invalid blob URL #{url}") unless URI.parse(url).scheme =~ /^https?/
request 'POST', "blobs", {
query: { "blobUri" => url },
}
end | ruby | def post_blob_url(url)
raise ArgumentError.new("Invalid blob URL #{url}") unless URI.parse(url).scheme =~ /^https?/
request 'POST', "blobs", {
query: { "blobUri" => url },
}
end | [
"def",
"post_blob_url",
"(",
"url",
")",
"raise",
"ArgumentError",
".",
"new",
"(",
"\"Invalid blob URL #{url}\"",
")",
"unless",
"URI",
".",
"parse",
"(",
"url",
")",
".",
"scheme",
"=~",
"/",
"/",
"request",
"'POST'",
",",
"\"blobs\"",
",",
"{",
"query",... | create blob record by external url | [
"create",
"blob",
"record",
"by",
"external",
"url"
] | 6db26dffb792bda2e8a5b46863a63dc1d56932a3 | https://github.com/lyrasis/collectionspace-client/blob/6db26dffb792bda2e8a5b46863a63dc1d56932a3/lib/collectionspace/client/helpers.rb#L56-L61 |
9,304 | lyrasis/collectionspace-client | lib/collectionspace/client/helpers.rb | CollectionSpace.Helpers.to_object | def to_object(record, attribute_map, stringify_keys = false)
attributes = {}
attribute_map.each do |map|
map = map.inject({}) { |memo,(k,v)| memo[k.to_s] = v; memo} if stringify_keys
if map["with"]
as = deep_find(record, map["key"], map["nested_key"])
values = []
... | ruby | def to_object(record, attribute_map, stringify_keys = false)
attributes = {}
attribute_map.each do |map|
map = map.inject({}) { |memo,(k,v)| memo[k.to_s] = v; memo} if stringify_keys
if map["with"]
as = deep_find(record, map["key"], map["nested_key"])
values = []
... | [
"def",
"to_object",
"(",
"record",
",",
"attribute_map",
",",
"stringify_keys",
"=",
"false",
")",
"attributes",
"=",
"{",
"}",
"attribute_map",
".",
"each",
"do",
"|",
"map",
"|",
"map",
"=",
"map",
".",
"inject",
"(",
"{",
"}",
")",
"{",
"|",
"memo... | parsed record and map to get restructured object | [
"parsed",
"record",
"and",
"map",
"to",
"get",
"restructured",
"object"
] | 6db26dffb792bda2e8a5b46863a63dc1d56932a3 | https://github.com/lyrasis/collectionspace-client/blob/6db26dffb792bda2e8a5b46863a63dc1d56932a3/lib/collectionspace/client/helpers.rb#L86-L104 |
9,305 | tbuehlmann/ponder | lib/ponder/channel.rb | Ponder.Channel.topic | def topic
if @topic
@topic
else
connected do
fiber = Fiber.current
callbacks = {}
[331, 332, 403, 442].each do |numeric|
callbacks[numeric] = @thaum.on(numeric) do |event_data|
topic = event_data[:params].match(':(.*)').captures.first
... | ruby | def topic
if @topic
@topic
else
connected do
fiber = Fiber.current
callbacks = {}
[331, 332, 403, 442].each do |numeric|
callbacks[numeric] = @thaum.on(numeric) do |event_data|
topic = event_data[:params].match(':(.*)').captures.first
... | [
"def",
"topic",
"if",
"@topic",
"@topic",
"else",
"connected",
"do",
"fiber",
"=",
"Fiber",
".",
"current",
"callbacks",
"=",
"{",
"}",
"[",
"331",
",",
"332",
",",
"403",
",",
"442",
"]",
".",
"each",
"do",
"|",
"numeric",
"|",
"callbacks",
"[",
"... | Experimental, no tests so far. | [
"Experimental",
"no",
"tests",
"so",
"far",
"."
] | 930912e1b78b41afa1359121aca46197e9edff9c | https://github.com/tbuehlmann/ponder/blob/930912e1b78b41afa1359121aca46197e9edff9c/lib/ponder/channel.rb#L21-L44 |
9,306 | j-a-m-l/scrapula | lib/scrapula/page.rb | Scrapula.Page.search! | def search! query, operations = [], &block
result = @agent_page.search query
# FIXME on every object
result = operations.reduce(result) do |tmp, op|
tmp.__send__ op
end if result
yield result if block_given?
result
end | ruby | def search! query, operations = [], &block
result = @agent_page.search query
# FIXME on every object
result = operations.reduce(result) do |tmp, op|
tmp.__send__ op
end if result
yield result if block_given?
result
end | [
"def",
"search!",
"query",
",",
"operations",
"=",
"[",
"]",
",",
"&",
"block",
"result",
"=",
"@agent_page",
".",
"search",
"query",
"# FIXME on every object",
"result",
"=",
"operations",
".",
"reduce",
"(",
"result",
")",
"do",
"|",
"tmp",
",",
"op",
... | at returns the first one only, but search returns all | [
"at",
"returns",
"the",
"first",
"one",
"only",
"but",
"search",
"returns",
"all"
] | d5df8e1f05f0bd24e2f346ac2f2c3fc3b385b211 | https://github.com/j-a-m-l/scrapula/blob/d5df8e1f05f0bd24e2f346ac2f2c3fc3b385b211/lib/scrapula/page.rb#L24-L35 |
9,307 | ouvrages/guard-haml-coffee | lib/guard/haml-coffee.rb | Guard.HamlCoffee.get_output | def get_output(file)
file_dir = File.dirname(file)
file_name = File.basename(file).split('.')[0..-2].join('.')
file_name = "#{file_name}.js" if file_name.match("\.js").nil?
file_dir = file_dir.gsub(Regexp.new("#{@options[:input]}(\/){0,1}"), '') if @options[:input]
file_dir = File.join(@... | ruby | def get_output(file)
file_dir = File.dirname(file)
file_name = File.basename(file).split('.')[0..-2].join('.')
file_name = "#{file_name}.js" if file_name.match("\.js").nil?
file_dir = file_dir.gsub(Regexp.new("#{@options[:input]}(\/){0,1}"), '') if @options[:input]
file_dir = File.join(@... | [
"def",
"get_output",
"(",
"file",
")",
"file_dir",
"=",
"File",
".",
"dirname",
"(",
"file",
")",
"file_name",
"=",
"File",
".",
"basename",
"(",
"file",
")",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"..",
"-",
"2",
"]",
".",
"join",
"(",
"'.'",
... | Get the file path to output the html based on the file being
built. The output path is relative to where guard is being run.
@param file [String] path to file being built
@return [String] path to file where output should be written | [
"Get",
"the",
"file",
"path",
"to",
"output",
"the",
"html",
"based",
"on",
"the",
"file",
"being",
"built",
".",
"The",
"output",
"path",
"is",
"relative",
"to",
"where",
"guard",
"is",
"being",
"run",
"."
] | cfa5021cf8512c4f333c345f33f4c0199a5207ae | https://github.com/ouvrages/guard-haml-coffee/blob/cfa5021cf8512c4f333c345f33f4c0199a5207ae/lib/guard/haml-coffee.rb#L41-L55 |
9,308 | npepinpe/redstruct | lib/redstruct/sorted_set.rb | Redstruct.SortedSet.slice | def slice(**options)
defaults = {
lower: nil,
upper: nil,
exclusive: false,
lex: @lex
}
self.class::Slice.new(self, **defaults.merge(options))
end | ruby | def slice(**options)
defaults = {
lower: nil,
upper: nil,
exclusive: false,
lex: @lex
}
self.class::Slice.new(self, **defaults.merge(options))
end | [
"def",
"slice",
"(",
"**",
"options",
")",
"defaults",
"=",
"{",
"lower",
":",
"nil",
",",
"upper",
":",
"nil",
",",
"exclusive",
":",
"false",
",",
"lex",
":",
"@lex",
"}",
"self",
".",
"class",
"::",
"Slice",
".",
"new",
"(",
"self",
",",
"**",... | Returns a slice or partial selection of the set.
@see Redstruct::SortedSet::Slice#initialize
@return [Redstruct::SortedSet::Slice] a newly created slice for this set | [
"Returns",
"a",
"slice",
"or",
"partial",
"selection",
"of",
"the",
"set",
"."
] | c97b45e7227f8ed9029f0effff352fc4d82dc3cb | https://github.com/npepinpe/redstruct/blob/c97b45e7227f8ed9029f0effff352fc4d82dc3cb/lib/redstruct/sorted_set.rb#L72-L81 |
9,309 | npepinpe/redstruct | lib/redstruct/sorted_set.rb | Redstruct.SortedSet.to_enum | def to_enum(match: '*', count: 10, with_scores: false)
enumerator = self.connection.zscan_each(@key, match: match, count: count)
return enumerator if with_scores
return Enumerator.new do |yielder|
loop do
item, = enumerator.next
yielder << item
end
end
end | ruby | def to_enum(match: '*', count: 10, with_scores: false)
enumerator = self.connection.zscan_each(@key, match: match, count: count)
return enumerator if with_scores
return Enumerator.new do |yielder|
loop do
item, = enumerator.next
yielder << item
end
end
end | [
"def",
"to_enum",
"(",
"match",
":",
"'*'",
",",
"count",
":",
"10",
",",
"with_scores",
":",
"false",
")",
"enumerator",
"=",
"self",
".",
"connection",
".",
"zscan_each",
"(",
"@key",
",",
"match",
":",
"match",
",",
"count",
":",
"count",
")",
"re... | Use redis-rb zscan_each method to iterate over particular keys
@return [Enumerator] base enumerator to iterate of the namespaced keys | [
"Use",
"redis",
"-",
"rb",
"zscan_each",
"method",
"to",
"iterate",
"over",
"particular",
"keys"
] | c97b45e7227f8ed9029f0effff352fc4d82dc3cb | https://github.com/npepinpe/redstruct/blob/c97b45e7227f8ed9029f0effff352fc4d82dc3cb/lib/redstruct/sorted_set.rb#L142-L151 |
9,310 | teodor-pripoae/scalaroid | lib/scalaroid/replicated_dht.rb | Scalaroid.ReplicatedDHT.delete | def delete(key, timeout = 2000)
result_raw = @conn.call(:delete, [key, timeout])
result = @conn.class.process_result_delete(result_raw)
@lastDeleteResult = result[:results]
if result[:success] == true
return result[:ok]
elsif result[:success] == :timeout
raise TimeoutError.... | ruby | def delete(key, timeout = 2000)
result_raw = @conn.call(:delete, [key, timeout])
result = @conn.class.process_result_delete(result_raw)
@lastDeleteResult = result[:results]
if result[:success] == true
return result[:ok]
elsif result[:success] == :timeout
raise TimeoutError.... | [
"def",
"delete",
"(",
"key",
",",
"timeout",
"=",
"2000",
")",
"result_raw",
"=",
"@conn",
".",
"call",
"(",
":delete",
",",
"[",
"key",
",",
"timeout",
"]",
")",
"result",
"=",
"@conn",
".",
"class",
".",
"process_result_delete",
"(",
"result_raw",
")... | Create a new object using the given connection.
Tries to delete the value at the given key.
WARNING: This function can lead to inconsistent data (e.g. deleted items
can re-appear). Also when re-creating an item the version before the
delete can re-appear.
returns the number of successfully deleted items
use get... | [
"Create",
"a",
"new",
"object",
"using",
"the",
"given",
"connection",
".",
"Tries",
"to",
"delete",
"the",
"value",
"at",
"the",
"given",
"key",
"."
] | 4e9e90e71ce3008da79a72eae40fe2f187580be2 | https://github.com/teodor-pripoae/scalaroid/blob/4e9e90e71ce3008da79a72eae40fe2f187580be2/lib/scalaroid/replicated_dht.rb#L17-L28 |
9,311 | vast/rokko | lib/rokko.rb | Rokko.Rokko.prettify | def prettify(blocks)
docs_blocks, code_blocks = blocks
# Combine all docs blocks into a single big markdown document with section
# dividers and run through the Markdown processor. Then split it back out
# into separate sections
rendered_html = self.class.renderer.render(docs_blocks.join(... | ruby | def prettify(blocks)
docs_blocks, code_blocks = blocks
# Combine all docs blocks into a single big markdown document with section
# dividers and run through the Markdown processor. Then split it back out
# into separate sections
rendered_html = self.class.renderer.render(docs_blocks.join(... | [
"def",
"prettify",
"(",
"blocks",
")",
"docs_blocks",
",",
"code_blocks",
"=",
"blocks",
"# Combine all docs blocks into a single big markdown document with section",
"# dividers and run through the Markdown processor. Then split it back out",
"# into separate sections",
"rendered_html",
... | Take the result of `split` and apply Markdown formatting to comments | [
"Take",
"the",
"result",
"of",
"split",
"and",
"apply",
"Markdown",
"formatting",
"to",
"comments"
] | 37f451db3d0bd92151809fcaba5a88bb597bbcc0 | https://github.com/vast/rokko/blob/37f451db3d0bd92151809fcaba5a88bb597bbcc0/lib/rokko.rb#L150-L161 |
9,312 | daily-scrum/domain_neutral | lib/domain_neutral/symbolized_class.rb | DomainNeutral.SymbolizedClass.method_missing | def method_missing(method, *args)
if method.to_s =~ /^(\w+)\?$/
v = self.class.find_by_symbol($1)
raise NameError unless v
other = v.to_sym
self.class.class_eval { define_method(method) { self.to_sym == other }}
return self.to_sym == other
end
super
end | ruby | def method_missing(method, *args)
if method.to_s =~ /^(\w+)\?$/
v = self.class.find_by_symbol($1)
raise NameError unless v
other = v.to_sym
self.class.class_eval { define_method(method) { self.to_sym == other }}
return self.to_sym == other
end
super
end | [
"def",
"method_missing",
"(",
"method",
",",
"*",
"args",
")",
"if",
"method",
".",
"to_s",
"=~",
"/",
"\\w",
"\\?",
"/",
"v",
"=",
"self",
".",
"class",
".",
"find_by_symbol",
"(",
"$1",
")",
"raise",
"NameError",
"unless",
"v",
"other",
"=",
"v",
... | Allow to test for a specific role or similar like Role.accountant? | [
"Allow",
"to",
"test",
"for",
"a",
"specific",
"role",
"or",
"similar",
"like",
"Role",
".",
"accountant?"
] | 9176915226c00ef3eff782c216922ee4ab4f06c5 | https://github.com/daily-scrum/domain_neutral/blob/9176915226c00ef3eff782c216922ee4ab4f06c5/lib/domain_neutral/symbolized_class.rb#L154-L163 |
9,313 | daily-scrum/domain_neutral | lib/domain_neutral/symbolized_class.rb | DomainNeutral.SymbolizedClass.flush_cache | def flush_cache
Rails.cache.delete([self.class.name, symbol_was.to_s])
Rails.cache.delete([self.class.name, id])
end | ruby | def flush_cache
Rails.cache.delete([self.class.name, symbol_was.to_s])
Rails.cache.delete([self.class.name, id])
end | [
"def",
"flush_cache",
"Rails",
".",
"cache",
".",
"delete",
"(",
"[",
"self",
".",
"class",
".",
"name",
",",
"symbol_was",
".",
"to_s",
"]",
")",
"Rails",
".",
"cache",
".",
"delete",
"(",
"[",
"self",
".",
"class",
".",
"name",
",",
"id",
"]",
... | Flushes cache if record is saved | [
"Flushes",
"cache",
"if",
"record",
"is",
"saved"
] | 9176915226c00ef3eff782c216922ee4ab4f06c5 | https://github.com/daily-scrum/domain_neutral/blob/9176915226c00ef3eff782c216922ee4ab4f06c5/lib/domain_neutral/symbolized_class.rb#L173-L176 |
9,314 | koffeinfrei/technologist | lib/technologist/git_repository.rb | Technologist.GitRepository.find_blob | def find_blob(blob_name, current_tree = root_tree, &block)
blob = current_tree[blob_name]
if blob
blob = repository.lookup(blob[:oid])
if !block_given? || yield(blob)
return blob
end
end
# recurse
current_tree.each_tree do |sub_tree|
blob = find_... | ruby | def find_blob(blob_name, current_tree = root_tree, &block)
blob = current_tree[blob_name]
if blob
blob = repository.lookup(blob[:oid])
if !block_given? || yield(blob)
return blob
end
end
# recurse
current_tree.each_tree do |sub_tree|
blob = find_... | [
"def",
"find_blob",
"(",
"blob_name",
",",
"current_tree",
"=",
"root_tree",
",",
"&",
"block",
")",
"blob",
"=",
"current_tree",
"[",
"blob_name",
"]",
"if",
"blob",
"blob",
"=",
"repository",
".",
"lookup",
"(",
"blob",
"[",
":oid",
"]",
")",
"if",
"... | Recursively searches for the blob identified by `blob_name`
in all subdirectories in the repository. A blob is usually either
a file or a directory.
@param blob_name [String] the blob name
@param current_tree [Rugged::Tree] the git directory tree in which to look for the blob.
Defaults to the root tree (see `#r... | [
"Recursively",
"searches",
"for",
"the",
"blob",
"identified",
"by",
"blob_name",
"in",
"all",
"subdirectories",
"in",
"the",
"repository",
".",
"A",
"blob",
"is",
"usually",
"either",
"a",
"file",
"or",
"a",
"directory",
"."
] | 0fd1d5c07c6d73ac5a184b26ad6db40981388573 | https://github.com/koffeinfrei/technologist/blob/0fd1d5c07c6d73ac5a184b26ad6db40981388573/lib/technologist/git_repository.rb#L28-L43 |
9,315 | neiljohari/scram | app/models/scram/target.rb | Scram.Target.conditions_hash_validations | def conditions_hash_validations
conditions.each do |comparator, mappings|
errors.add(:conditions, "can't use undefined comparators") unless Scram::DSL::Definitions::COMPARATORS.keys.include? comparator.to_sym
errors.add(:conditions, "comparators must have values of type Hash") unless mappings.is_a... | ruby | def conditions_hash_validations
conditions.each do |comparator, mappings|
errors.add(:conditions, "can't use undefined comparators") unless Scram::DSL::Definitions::COMPARATORS.keys.include? comparator.to_sym
errors.add(:conditions, "comparators must have values of type Hash") unless mappings.is_a... | [
"def",
"conditions_hash_validations",
"conditions",
".",
"each",
"do",
"|",
"comparator",
",",
"mappings",
"|",
"errors",
".",
"add",
"(",
":conditions",
",",
"\"can't use undefined comparators\"",
")",
"unless",
"Scram",
"::",
"DSL",
"::",
"Definitions",
"::",
"C... | Validates that the conditions Hash follows an expected format | [
"Validates",
"that",
"the",
"conditions",
"Hash",
"follows",
"an",
"expected",
"format"
] | df3e48e9e9cab4b363b1370df5991319d21c256d | https://github.com/neiljohari/scram/blob/df3e48e9e9cab4b363b1370df5991319d21c256d/app/models/scram/target.rb#L75-L80 |
9,316 | postmodern/data_paths | lib/data_paths/methods.rb | DataPaths.Methods.register_data_path | def register_data_path(path)
path = File.expand_path(path)
DataPaths.register(path)
data_paths << path unless data_paths.include?(path)
return path
end | ruby | def register_data_path(path)
path = File.expand_path(path)
DataPaths.register(path)
data_paths << path unless data_paths.include?(path)
return path
end | [
"def",
"register_data_path",
"(",
"path",
")",
"path",
"=",
"File",
".",
"expand_path",
"(",
"path",
")",
"DataPaths",
".",
"register",
"(",
"path",
")",
"data_paths",
"<<",
"path",
"unless",
"data_paths",
".",
"include?",
"(",
"path",
")",
"return",
"path... | Registers a path as a data directory.
@param [String] path
The path to add to {DataPaths.paths}.
@return [String]
The fully qualified form of the specified path.
@example
register_data_dir File.join(File.dirname(__FILE__),'..','..','..','data')
@raise [RuntimeError]
The specified path is not a direc... | [
"Registers",
"a",
"path",
"as",
"a",
"data",
"directory",
"."
] | 17938884593b458b90b591a353686945884749d6 | https://github.com/postmodern/data_paths/blob/17938884593b458b90b591a353686945884749d6/lib/data_paths/methods.rb#L30-L37 |
9,317 | postmodern/data_paths | lib/data_paths/methods.rb | DataPaths.Methods.unregister_data_path | def unregister_data_path(path)
path = File.expand_path(path)
self.data_paths.delete(path)
return DataPaths.unregister!(path)
end | ruby | def unregister_data_path(path)
path = File.expand_path(path)
self.data_paths.delete(path)
return DataPaths.unregister!(path)
end | [
"def",
"unregister_data_path",
"(",
"path",
")",
"path",
"=",
"File",
".",
"expand_path",
"(",
"path",
")",
"self",
".",
"data_paths",
".",
"delete",
"(",
"path",
")",
"return",
"DataPaths",
".",
"unregister!",
"(",
"path",
")",
"end"
] | Unregisters any matching data directories.
@param [String] path
The path to unregister.
@return [String]
The unregistered data path.
@since 0.3.0 | [
"Unregisters",
"any",
"matching",
"data",
"directories",
"."
] | 17938884593b458b90b591a353686945884749d6 | https://github.com/postmodern/data_paths/blob/17938884593b458b90b591a353686945884749d6/lib/data_paths/methods.rb#L60-L65 |
9,318 | postmodern/data_paths | lib/data_paths/methods.rb | DataPaths.Methods.unregister_data_paths | def unregister_data_paths
data_paths.each { |path| DataPaths.unregister!(path) }
data_paths.clear
return true
end | ruby | def unregister_data_paths
data_paths.each { |path| DataPaths.unregister!(path) }
data_paths.clear
return true
end | [
"def",
"unregister_data_paths",
"data_paths",
".",
"each",
"{",
"|",
"path",
"|",
"DataPaths",
".",
"unregister!",
"(",
"path",
")",
"}",
"data_paths",
".",
"clear",
"return",
"true",
"end"
] | Unregisters all previously registered data directories.
@return [true]
Specifies all data paths were successfully unregistered.
@since 0.3.0 | [
"Unregisters",
"all",
"previously",
"registered",
"data",
"directories",
"."
] | 17938884593b458b90b591a353686945884749d6 | https://github.com/postmodern/data_paths/blob/17938884593b458b90b591a353686945884749d6/lib/data_paths/methods.rb#L85-L89 |
9,319 | ktonon/code_node | spec/fixtures/activerecord/src/active_record/identity_map.rb | ActiveRecord.IdentityMap.reinit_with | def reinit_with(coder)
@attributes_cache = {}
dirty = @changed_attributes.keys
attributes = self.class.initialize_attributes(coder['attributes'].except(*dirty))
@attributes.update(attributes)
@changed_attributes.update(coder['attributes'].slice(*dirty))
@changed_attributes.delet... | ruby | def reinit_with(coder)
@attributes_cache = {}
dirty = @changed_attributes.keys
attributes = self.class.initialize_attributes(coder['attributes'].except(*dirty))
@attributes.update(attributes)
@changed_attributes.update(coder['attributes'].slice(*dirty))
@changed_attributes.delet... | [
"def",
"reinit_with",
"(",
"coder",
")",
"@attributes_cache",
"=",
"{",
"}",
"dirty",
"=",
"@changed_attributes",
".",
"keys",
"attributes",
"=",
"self",
".",
"class",
".",
"initialize_attributes",
"(",
"coder",
"[",
"'attributes'",
"]",
".",
"except",
"(",
... | Reinitialize an Identity Map model object from +coder+.
+coder+ must contain the attributes necessary for initializing an empty
model object. | [
"Reinitialize",
"an",
"Identity",
"Map",
"model",
"object",
"from",
"+",
"coder",
"+",
".",
"+",
"coder",
"+",
"must",
"contain",
"the",
"attributes",
"necessary",
"for",
"initializing",
"an",
"empty",
"model",
"object",
"."
] | 48d5d1a7442d9cade602be4fb782a1b56c7677f5 | https://github.com/ktonon/code_node/blob/48d5d1a7442d9cade602be4fb782a1b56c7677f5/spec/fixtures/activerecord/src/active_record/identity_map.rb#L118-L129 |
9,320 | m-nasser/discourse_mountable_sso | app/controllers/discourse_mountable_sso/discourse_sso_controller.rb | DiscourseMountableSso.DiscourseSsoController.sso | def sso
require "discourse_mountable_sso/single_sign_on"
sso = DiscourseMountableSso::SingleSignOn.parse(
((session[:discourse_mountable_sso] || {}).delete(:query_string).presence || request.query_string),
@config.secret
)
discourse_data = send @config.discourse_data_meth... | ruby | def sso
require "discourse_mountable_sso/single_sign_on"
sso = DiscourseMountableSso::SingleSignOn.parse(
((session[:discourse_mountable_sso] || {}).delete(:query_string).presence || request.query_string),
@config.secret
)
discourse_data = send @config.discourse_data_meth... | [
"def",
"sso",
"require",
"\"discourse_mountable_sso/single_sign_on\"",
"sso",
"=",
"DiscourseMountableSso",
"::",
"SingleSignOn",
".",
"parse",
"(",
"(",
"(",
"session",
"[",
":discourse_mountable_sso",
"]",
"||",
"{",
"}",
")",
".",
"delete",
"(",
":query_string",
... | ensures user must login | [
"ensures",
"user",
"must",
"login"
] | 0adb568ea0ec4c06a4dc65abb95a9badce460bf1 | https://github.com/m-nasser/discourse_mountable_sso/blob/0adb568ea0ec4c06a4dc65abb95a9badce460bf1/app/controllers/discourse_mountable_sso/discourse_sso_controller.rb#L6-L20 |
9,321 | jtadeulopes/meme | lib/meme/info.rb | Meme.Info.followers | def followers(count=10)
count = 0 if count.is_a?(Symbol) && count == :all
query = "SELECT * FROM meme.followers(#{count}) WHERE owner_guid='#{self.guid}'"
parse = Request.parse(query)
if parse
results = parse['query']['results']
results.nil? ? nil : results['meme'].map {|m| Info.... | ruby | def followers(count=10)
count = 0 if count.is_a?(Symbol) && count == :all
query = "SELECT * FROM meme.followers(#{count}) WHERE owner_guid='#{self.guid}'"
parse = Request.parse(query)
if parse
results = parse['query']['results']
results.nil? ? nil : results['meme'].map {|m| Info.... | [
"def",
"followers",
"(",
"count",
"=",
"10",
")",
"count",
"=",
"0",
"if",
"count",
".",
"is_a?",
"(",
"Symbol",
")",
"&&",
"count",
"==",
":all",
"query",
"=",
"\"SELECT * FROM meme.followers(#{count}) WHERE owner_guid='#{self.guid}'\"",
"parse",
"=",
"Request",
... | Return user followers
Example:
# Search user
user = Meme::Info.find('jtadeulopes')
# Default
followers = user.followers
followers.count
=> 10
# Specify a count
followers = user.followers(100)
followers.count
=> 100
# All followers
followers = user.followers(:all)
followers... | [
"Return",
"user",
"followers"
] | dc3888c4af3c30d49053ec53f328187cb9255e88 | https://github.com/jtadeulopes/meme/blob/dc3888c4af3c30d49053ec53f328187cb9255e88/lib/meme/info.rb#L81-L91 |
9,322 | jtadeulopes/meme | lib/meme/info.rb | Meme.Info.posts | def posts(quantity=0)
query = "SELECT * FROM meme.posts(#{quantity}) WHERE owner_guid='#{self.guid}';"
parse = Request.parse(query)
if parse
results = parse['query']['results']
results.nil? ? nil : results['post'].map {|m| Post.new(m)}
else
parse.error!
end
end | ruby | def posts(quantity=0)
query = "SELECT * FROM meme.posts(#{quantity}) WHERE owner_guid='#{self.guid}';"
parse = Request.parse(query)
if parse
results = parse['query']['results']
results.nil? ? nil : results['post'].map {|m| Post.new(m)}
else
parse.error!
end
end | [
"def",
"posts",
"(",
"quantity",
"=",
"0",
")",
"query",
"=",
"\"SELECT * FROM meme.posts(#{quantity}) WHERE owner_guid='#{self.guid}';\"",
"parse",
"=",
"Request",
".",
"parse",
"(",
"query",
")",
"if",
"parse",
"results",
"=",
"parse",
"[",
"'query'",
"]",
"[",
... | Retrieves all posts of an user | [
"Retrieves",
"all",
"posts",
"of",
"an",
"user"
] | dc3888c4af3c30d49053ec53f328187cb9255e88 | https://github.com/jtadeulopes/meme/blob/dc3888c4af3c30d49053ec53f328187cb9255e88/lib/meme/info.rb#L128-L137 |
9,323 | sugaryourcoffee/syclink | lib/syclink/designer.rb | SycLink.Designer.add_links_from_file | def add_links_from_file(file)
File.foreach(file) do |line|
next if line.chomp.empty?
url, name, description, tag = line.chomp.split(';')
website.add_link(Link.new(url, { name: name,
description: description,
... | ruby | def add_links_from_file(file)
File.foreach(file) do |line|
next if line.chomp.empty?
url, name, description, tag = line.chomp.split(';')
website.add_link(Link.new(url, { name: name,
description: description,
... | [
"def",
"add_links_from_file",
"(",
"file",
")",
"File",
".",
"foreach",
"(",
"file",
")",
"do",
"|",
"line",
"|",
"next",
"if",
"line",
".",
"chomp",
".",
"empty?",
"url",
",",
"name",
",",
"description",
",",
"tag",
"=",
"line",
".",
"chomp",
".",
... | Reads arguments from a CSV file and creates links accordingly. The links
are added to the websie | [
"Reads",
"arguments",
"from",
"a",
"CSV",
"file",
"and",
"creates",
"links",
"accordingly",
".",
"The",
"links",
"are",
"added",
"to",
"the",
"websie"
] | 941ee2045c946daa1e0db394eb643aa82c1254cc | https://github.com/sugaryourcoffee/syclink/blob/941ee2045c946daa1e0db394eb643aa82c1254cc/lib/syclink/designer.rb#L33-L41 |
9,324 | sugaryourcoffee/syclink | lib/syclink/designer.rb | SycLink.Designer.export | def export(format)
message = "to_#{format.downcase}"
if website.respond_to? message
website.send(message)
else
raise "cannot export to #{format}"
end
end | ruby | def export(format)
message = "to_#{format.downcase}"
if website.respond_to? message
website.send(message)
else
raise "cannot export to #{format}"
end
end | [
"def",
"export",
"(",
"format",
")",
"message",
"=",
"\"to_#{format.downcase}\"",
"if",
"website",
".",
"respond_to?",
"message",
"website",
".",
"send",
"(",
"message",
")",
"else",
"raise",
"\"cannot export to #{format}\"",
"end",
"end"
] | Export links to specified format | [
"Export",
"links",
"to",
"specified",
"format"
] | 941ee2045c946daa1e0db394eb643aa82c1254cc | https://github.com/sugaryourcoffee/syclink/blob/941ee2045c946daa1e0db394eb643aa82c1254cc/lib/syclink/designer.rb#L51-L58 |
9,325 | sugaryourcoffee/syclink | lib/syclink/designer.rb | SycLink.Designer.update_links_from_file | def update_links_from_file(file)
File.foreach(file) do |line|
next if line.chomp.empty?
url, name, description, tag = line.chomp.split(';')
website.find_links(url).first.update({ name: name,
description: description,
... | ruby | def update_links_from_file(file)
File.foreach(file) do |line|
next if line.chomp.empty?
url, name, description, tag = line.chomp.split(';')
website.find_links(url).first.update({ name: name,
description: description,
... | [
"def",
"update_links_from_file",
"(",
"file",
")",
"File",
".",
"foreach",
"(",
"file",
")",
"do",
"|",
"line",
"|",
"next",
"if",
"line",
".",
"chomp",
".",
"empty?",
"url",
",",
"name",
",",
"description",
",",
"tag",
"=",
"line",
".",
"chomp",
"."... | Updates links read from a file | [
"Updates",
"links",
"read",
"from",
"a",
"file"
] | 941ee2045c946daa1e0db394eb643aa82c1254cc | https://github.com/sugaryourcoffee/syclink/blob/941ee2045c946daa1e0db394eb643aa82c1254cc/lib/syclink/designer.rb#L97-L105 |
9,326 | sugaryourcoffee/syclink | lib/syclink/designer.rb | SycLink.Designer.remove_links | def remove_links(urls)
urls.map { |url| list_links({ url: url }) }.flatten.compact.each do |link|
website.remove_link(link)
end
end | ruby | def remove_links(urls)
urls.map { |url| list_links({ url: url }) }.flatten.compact.each do |link|
website.remove_link(link)
end
end | [
"def",
"remove_links",
"(",
"urls",
")",
"urls",
".",
"map",
"{",
"|",
"url",
"|",
"list_links",
"(",
"{",
"url",
":",
"url",
"}",
")",
"}",
".",
"flatten",
".",
"compact",
".",
"each",
"do",
"|",
"link",
"|",
"website",
".",
"remove_link",
"(",
... | Deletes one or more links from the website. Returns the deleted links.
Expects the links provided in an array | [
"Deletes",
"one",
"or",
"more",
"links",
"from",
"the",
"website",
".",
"Returns",
"the",
"deleted",
"links",
".",
"Expects",
"the",
"links",
"provided",
"in",
"an",
"array"
] | 941ee2045c946daa1e0db394eb643aa82c1254cc | https://github.com/sugaryourcoffee/syclink/blob/941ee2045c946daa1e0db394eb643aa82c1254cc/lib/syclink/designer.rb#L114-L118 |
9,327 | sugaryourcoffee/syclink | lib/syclink/designer.rb | SycLink.Designer.remove_links_from_file | def remove_links_from_file(file)
urls = File.foreach(file).map { |url| url.chomp unless url.empty? }
remove_links(urls)
end | ruby | def remove_links_from_file(file)
urls = File.foreach(file).map { |url| url.chomp unless url.empty? }
remove_links(urls)
end | [
"def",
"remove_links_from_file",
"(",
"file",
")",
"urls",
"=",
"File",
".",
"foreach",
"(",
"file",
")",
".",
"map",
"{",
"|",
"url",
"|",
"url",
".",
"chomp",
"unless",
"url",
".",
"empty?",
"}",
"remove_links",
"(",
"urls",
")",
"end"
] | Deletes links based on URLs that are provided in a file. Each URL has to
be in one line | [
"Deletes",
"links",
"based",
"on",
"URLs",
"that",
"are",
"provided",
"in",
"a",
"file",
".",
"Each",
"URL",
"has",
"to",
"be",
"in",
"one",
"line"
] | 941ee2045c946daa1e0db394eb643aa82c1254cc | https://github.com/sugaryourcoffee/syclink/blob/941ee2045c946daa1e0db394eb643aa82c1254cc/lib/syclink/designer.rb#L122-L125 |
9,328 | sugaryourcoffee/syclink | lib/syclink/designer.rb | SycLink.Designer.save_website | def save_website(directory)
File.open(yaml_file(directory, website.title), 'w') do |f|
YAML.dump(website, f)
end
end | ruby | def save_website(directory)
File.open(yaml_file(directory, website.title), 'w') do |f|
YAML.dump(website, f)
end
end | [
"def",
"save_website",
"(",
"directory",
")",
"File",
".",
"open",
"(",
"yaml_file",
"(",
"directory",
",",
"website",
".",
"title",
")",
",",
"'w'",
")",
"do",
"|",
"f",
"|",
"YAML",
".",
"dump",
"(",
"website",
",",
"f",
")",
"end",
"end"
] | Saves the website to the specified directory with the downcased name of
the website and the extension 'website'. The website is save as YAML | [
"Saves",
"the",
"website",
"to",
"the",
"specified",
"directory",
"with",
"the",
"downcased",
"name",
"of",
"the",
"website",
"and",
"the",
"extension",
"website",
".",
"The",
"website",
"is",
"save",
"as",
"YAML"
] | 941ee2045c946daa1e0db394eb643aa82c1254cc | https://github.com/sugaryourcoffee/syclink/blob/941ee2045c946daa1e0db394eb643aa82c1254cc/lib/syclink/designer.rb#L129-L133 |
9,329 | sugaryourcoffee/syclink | lib/syclink/designer.rb | SycLink.Designer.delete_website | def delete_website(directory)
if File.exists? yaml_file(directory, website.title)
FileUtils.rm(yaml_file(directory, website.title))
end
end | ruby | def delete_website(directory)
if File.exists? yaml_file(directory, website.title)
FileUtils.rm(yaml_file(directory, website.title))
end
end | [
"def",
"delete_website",
"(",
"directory",
")",
"if",
"File",
".",
"exists?",
"yaml_file",
"(",
"directory",
",",
"website",
".",
"title",
")",
"FileUtils",
".",
"rm",
"(",
"yaml_file",
"(",
"directory",
",",
"website",
".",
"title",
")",
")",
"end",
"en... | Deletes the website if it already exists | [
"Deletes",
"the",
"website",
"if",
"it",
"already",
"exists"
] | 941ee2045c946daa1e0db394eb643aa82c1254cc | https://github.com/sugaryourcoffee/syclink/blob/941ee2045c946daa1e0db394eb643aa82c1254cc/lib/syclink/designer.rb#L142-L146 |
9,330 | cbrumelle/blueprintr | lib/blueprint-css/lib/blueprint/css_parser.rb | Blueprint.CSSParser.parse | def parse(data = nil)
data ||= @raw_data
# wrapper array holding hashes of css tags/rules
css_out = []
# clear initial spaces
data.strip_side_space!.strip_space!
# split on end of assignments
data.split('}').each_with_index do |assignments, index|
# split agai... | ruby | def parse(data = nil)
data ||= @raw_data
# wrapper array holding hashes of css tags/rules
css_out = []
# clear initial spaces
data.strip_side_space!.strip_space!
# split on end of assignments
data.split('}').each_with_index do |assignments, index|
# split agai... | [
"def",
"parse",
"(",
"data",
"=",
"nil",
")",
"data",
"||=",
"@raw_data",
"# wrapper array holding hashes of css tags/rules",
"css_out",
"=",
"[",
"]",
"# clear initial spaces",
"data",
".",
"strip_side_space!",
".",
"strip_space!",
"# split on end of assignments",
"data"... | returns a hash of all CSS data passed
==== Options
* <tt>data</tt> -- CSS string; defaults to string passed into the constructor | [
"returns",
"a",
"hash",
"of",
"all",
"CSS",
"data",
"passed"
] | b414436f614a8d97d77b47b588ddcf3f5e61b6bd | https://github.com/cbrumelle/blueprintr/blob/b414436f614a8d97d77b47b588ddcf3f5e61b6bd/lib/blueprint-css/lib/blueprint/css_parser.rb#L26-L58 |
9,331 | aleak/bender | lib/bender/cli.rb | Bender.CLI.load_enviroment | def load_enviroment(file = nil)
file ||= "."
if File.directory?(file) && File.exists?(File.expand_path("#{file}/config/environment.rb"))
require 'rails'
require File.expand_path("#{file}/config/environment.rb")
if defined?(::Rails) && ::Rails.respond_to?(:application)
... | ruby | def load_enviroment(file = nil)
file ||= "."
if File.directory?(file) && File.exists?(File.expand_path("#{file}/config/environment.rb"))
require 'rails'
require File.expand_path("#{file}/config/environment.rb")
if defined?(::Rails) && ::Rails.respond_to?(:application)
... | [
"def",
"load_enviroment",
"(",
"file",
"=",
"nil",
")",
"file",
"||=",
"\".\"",
"if",
"File",
".",
"directory?",
"(",
"file",
")",
"&&",
"File",
".",
"exists?",
"(",
"File",
".",
"expand_path",
"(",
"\"#{file}/config/environment.rb\"",
")",
")",
"require",
... | Loads the environment from the given configuration file.
@api private | [
"Loads",
"the",
"environment",
"from",
"the",
"given",
"configuration",
"file",
"."
] | 5892e6ffce84fc531d8cbf452b2676b4d012ab09 | https://github.com/aleak/bender/blob/5892e6ffce84fc531d8cbf452b2676b4d012ab09/lib/bender/cli.rb#L56-L73 |
9,332 | michaeledgar/amp-front | lib/amp-front/third_party/maruku/structures_iterators.rb | MaRuKu.MDElement.each_element | def each_element(e_node_type=nil, &block)
@children.each do |c|
if c.kind_of? MDElement
if (not e_node_type) || (e_node_type == c.node_type)
block.call c
end
c.each_element(e_node_type, &block)
end
end
end | ruby | def each_element(e_node_type=nil, &block)
@children.each do |c|
if c.kind_of? MDElement
if (not e_node_type) || (e_node_type == c.node_type)
block.call c
end
c.each_element(e_node_type, &block)
end
end
end | [
"def",
"each_element",
"(",
"e_node_type",
"=",
"nil",
",",
"&",
"block",
")",
"@children",
".",
"each",
"do",
"|",
"c",
"|",
"if",
"c",
".",
"kind_of?",
"MDElement",
"if",
"(",
"not",
"e_node_type",
")",
"||",
"(",
"e_node_type",
"==",
"c",
".",
"no... | Yields to each element of specified node_type
All elements if e_node_type is nil. | [
"Yields",
"to",
"each",
"element",
"of",
"specified",
"node_type",
"All",
"elements",
"if",
"e_node_type",
"is",
"nil",
"."
] | d939b7ed9a7b0e5a3d26e536b95149f88b64e3a9 | https://github.com/michaeledgar/amp-front/blob/d939b7ed9a7b0e5a3d26e536b95149f88b64e3a9/lib/amp-front/third_party/maruku/structures_iterators.rb#L28-L37 |
9,333 | michaeledgar/amp-front | lib/amp-front/third_party/maruku/structures_iterators.rb | MaRuKu.MDElement.replace_each_string | def replace_each_string(&block)
for c in @children
if c.kind_of? MDElement
c.replace_each_string(&block)
end
end
processed = []
until @children.empty?
c = @children.shift
if c.kind_of? String
result = block.call(c)
[*result].each do |e| processed << e end
else
processed << c
e... | ruby | def replace_each_string(&block)
for c in @children
if c.kind_of? MDElement
c.replace_each_string(&block)
end
end
processed = []
until @children.empty?
c = @children.shift
if c.kind_of? String
result = block.call(c)
[*result].each do |e| processed << e end
else
processed << c
e... | [
"def",
"replace_each_string",
"(",
"&",
"block",
")",
"for",
"c",
"in",
"@children",
"if",
"c",
".",
"kind_of?",
"MDElement",
"c",
".",
"replace_each_string",
"(",
"block",
")",
"end",
"end",
"processed",
"=",
"[",
"]",
"until",
"@children",
".",
"empty?",... | Apply passed block to each String in the hierarchy. | [
"Apply",
"passed",
"block",
"to",
"each",
"String",
"in",
"the",
"hierarchy",
"."
] | d939b7ed9a7b0e5a3d26e536b95149f88b64e3a9 | https://github.com/michaeledgar/amp-front/blob/d939b7ed9a7b0e5a3d26e536b95149f88b64e3a9/lib/amp-front/third_party/maruku/structures_iterators.rb#L40-L58 |
9,334 | philou/rspecproxies | lib/rspecproxies/proxies.rb | RSpecProxies.Proxies.and_before_calling_original | def and_before_calling_original
self.and_wrap_original do |m, *args, &block|
yield *args
m.call(*args, &block)
end
end | ruby | def and_before_calling_original
self.and_wrap_original do |m, *args, &block|
yield *args
m.call(*args, &block)
end
end | [
"def",
"and_before_calling_original",
"self",
".",
"and_wrap_original",
"do",
"|",
"m",
",",
"*",
"args",
",",
"&",
"block",
"|",
"yield",
"args",
"m",
".",
"call",
"(",
"args",
",",
"block",
")",
"end",
"end"
] | Will call the given block with all the actual arguments every time
the method is called | [
"Will",
"call",
"the",
"given",
"block",
"with",
"all",
"the",
"actual",
"arguments",
"every",
"time",
"the",
"method",
"is",
"called"
] | 7bb32654f1c4d0316e9f89161a95583333a3a66f | https://github.com/philou/rspecproxies/blob/7bb32654f1c4d0316e9f89161a95583333a3a66f/lib/rspecproxies/proxies.rb#L8-L13 |
9,335 | philou/rspecproxies | lib/rspecproxies/proxies.rb | RSpecProxies.Proxies.and_after_calling_original | def and_after_calling_original
self.and_wrap_original do |m, *args, &block|
result = m.call(*args, &block)
yield result
result
end
end | ruby | def and_after_calling_original
self.and_wrap_original do |m, *args, &block|
result = m.call(*args, &block)
yield result
result
end
end | [
"def",
"and_after_calling_original",
"self",
".",
"and_wrap_original",
"do",
"|",
"m",
",",
"*",
"args",
",",
"&",
"block",
"|",
"result",
"=",
"m",
".",
"call",
"(",
"args",
",",
"block",
")",
"yield",
"result",
"result",
"end",
"end"
] | Will call the given block with it's result every time the method
returns | [
"Will",
"call",
"the",
"given",
"block",
"with",
"it",
"s",
"result",
"every",
"time",
"the",
"method",
"returns"
] | 7bb32654f1c4d0316e9f89161a95583333a3a66f | https://github.com/philou/rspecproxies/blob/7bb32654f1c4d0316e9f89161a95583333a3a66f/lib/rspecproxies/proxies.rb#L17-L23 |
9,336 | pablogonzalezalba/acts_as_integer_infinitable | lib/acts_as_integer_infinitable.rb | ActsAsIntegerInfinitable.ClassMethods.acts_as_integer_infinitable | def acts_as_integer_infinitable(fields, options = {})
options[:infinity_value] = -1 unless options.key? :infinity_value
fields.each do |field|
define_method("#{field}=") do |value|
int_value = value == Float::INFINITY ? options[:infinity_value] : value
write_attribute(field, int... | ruby | def acts_as_integer_infinitable(fields, options = {})
options[:infinity_value] = -1 unless options.key? :infinity_value
fields.each do |field|
define_method("#{field}=") do |value|
int_value = value == Float::INFINITY ? options[:infinity_value] : value
write_attribute(field, int... | [
"def",
"acts_as_integer_infinitable",
"(",
"fields",
",",
"options",
"=",
"{",
"}",
")",
"options",
"[",
":infinity_value",
"]",
"=",
"-",
"1",
"unless",
"options",
".",
"key?",
":infinity_value",
"fields",
".",
"each",
"do",
"|",
"field",
"|",
"define_metho... | Allows the fields to store an Infinity value.
Overrides the setter and getter of those fields in order to capture
and return Infinity when appropiate.
Then you can use it as any other value and get the desired result, like
decrementing, incrementing, comparing with <, >, ==, etc.
Example:
class LibrarySubsc... | [
"Allows",
"the",
"fields",
"to",
"store",
"an",
"Infinity",
"value",
"."
] | 09dc8025a27524ce81fba2dca8a9263056e39cda | https://github.com/pablogonzalezalba/acts_as_integer_infinitable/blob/09dc8025a27524ce81fba2dca8a9263056e39cda/lib/acts_as_integer_infinitable.rb#L48-L62 |
9,337 | caruby/core | lib/caruby/database/persistence_service.rb | CaRuby.PersistenceService.query | def query(template_or_hql, *path)
String === template_or_hql ? query_hql(template_or_hql) : query_template(template_or_hql, path)
end | ruby | def query(template_or_hql, *path)
String === template_or_hql ? query_hql(template_or_hql) : query_template(template_or_hql, path)
end | [
"def",
"query",
"(",
"template_or_hql",
",",
"*",
"path",
")",
"String",
"===",
"template_or_hql",
"?",
"query_hql",
"(",
"template_or_hql",
")",
":",
"query_template",
"(",
"template_or_hql",
",",
"path",
")",
"end"
] | Creates a new PersistenceService with the specified application service name and options.
@param [String] the caBIG application service name
@param [{Symbol => Object}] opts the options
@option opts [String] :host the service host (default +localhost+)
@option opts [String] :version the caTissue version identifier... | [
"Creates",
"a",
"new",
"PersistenceService",
"with",
"the",
"specified",
"application",
"service",
"name",
"and",
"options",
"."
] | a682dc57c6fa31aef765cdd206ed3d4b4c289c60 | https://github.com/caruby/core/blob/a682dc57c6fa31aef765cdd206ed3d4b4c289c60/lib/caruby/database/persistence_service.rb#L44-L46 |
9,338 | caruby/core | lib/caruby/database/persistence_service.rb | CaRuby.PersistenceService.query_hql | def query_hql(hql)
logger.debug { "Building HQLCriteria..." }
criteria = HQLCriteria.new(hql)
target = hql[/from\s+(\S+)/i, 1]
raise DatabaseError.new("HQL does not contain a FROM clause: #{hql}") unless target
logger.debug { "Submitting search on target class #{target} with the following ... | ruby | def query_hql(hql)
logger.debug { "Building HQLCriteria..." }
criteria = HQLCriteria.new(hql)
target = hql[/from\s+(\S+)/i, 1]
raise DatabaseError.new("HQL does not contain a FROM clause: #{hql}") unless target
logger.debug { "Submitting search on target class #{target} with the following ... | [
"def",
"query_hql",
"(",
"hql",
")",
"logger",
".",
"debug",
"{",
"\"Building HQLCriteria...\"",
"}",
"criteria",
"=",
"HQLCriteria",
".",
"new",
"(",
"hql",
")",
"target",
"=",
"hql",
"[",
"/",
"\\s",
"\\S",
"/i",
",",
"1",
"]",
"raise",
"DatabaseError"... | Dispatches the given HQL to the application service.
@quirk caCORE query target parameter is necessary for caCORE 3.x but deprecated in caCORE 4+.
@param [String] hql the HQL to submit | [
"Dispatches",
"the",
"given",
"HQL",
"to",
"the",
"application",
"service",
"."
] | a682dc57c6fa31aef765cdd206ed3d4b4c289c60 | https://github.com/caruby/core/blob/a682dc57c6fa31aef765cdd206ed3d4b4c289c60/lib/caruby/database/persistence_service.rb#L105-L117 |
9,339 | caruby/core | lib/caruby/database/persistence_service.rb | CaRuby.PersistenceService.query_association_post_caCORE_v4 | def query_association_post_caCORE_v4(obj, attribute)
assn = obj.class.association(attribute)
begin
result = dispatch { |svc| svc.association(obj, assn) }
rescue Exception => e
logger.error("Error fetching association #{obj} - #{e}")
raise
end
end | ruby | def query_association_post_caCORE_v4(obj, attribute)
assn = obj.class.association(attribute)
begin
result = dispatch { |svc| svc.association(obj, assn) }
rescue Exception => e
logger.error("Error fetching association #{obj} - #{e}")
raise
end
end | [
"def",
"query_association_post_caCORE_v4",
"(",
"obj",
",",
"attribute",
")",
"assn",
"=",
"obj",
".",
"class",
".",
"association",
"(",
"attribute",
")",
"begin",
"result",
"=",
"dispatch",
"{",
"|",
"svc",
"|",
"svc",
".",
"association",
"(",
"obj",
",",... | Returns an array of domain objects associated with obj through the specified attribute.
This method uses the +caCORE+ v. 4+ getAssociation application service method.
*Note*: this method is only available for caBIG application services which implement +getAssociation+.
Currently, this includes +caCORE+ v. 4.0 and a... | [
"Returns",
"an",
"array",
"of",
"domain",
"objects",
"associated",
"with",
"obj",
"through",
"the",
"specified",
"attribute",
".",
"This",
"method",
"uses",
"the",
"+",
"caCORE",
"+",
"v",
".",
"4",
"+",
"getAssociation",
"application",
"service",
"method",
... | a682dc57c6fa31aef765cdd206ed3d4b4c289c60 | https://github.com/caruby/core/blob/a682dc57c6fa31aef765cdd206ed3d4b4c289c60/lib/caruby/database/persistence_service.rb#L152-L160 |
9,340 | X0nic/guard-yardstick | lib/guard/yardstick.rb | Guard.Yardstick.run_partially | def run_partially(paths)
return if paths.empty?
displayed_paths = paths.map { |path| smart_path(path) }
UI.info "Inspecting Yarddocs: #{displayed_paths.join(' ')}"
inspect_with_yardstick(path: paths)
end | ruby | def run_partially(paths)
return if paths.empty?
displayed_paths = paths.map { |path| smart_path(path) }
UI.info "Inspecting Yarddocs: #{displayed_paths.join(' ')}"
inspect_with_yardstick(path: paths)
end | [
"def",
"run_partially",
"(",
"paths",
")",
"return",
"if",
"paths",
".",
"empty?",
"displayed_paths",
"=",
"paths",
".",
"map",
"{",
"|",
"path",
"|",
"smart_path",
"(",
"path",
")",
"}",
"UI",
".",
"info",
"\"Inspecting Yarddocs: #{displayed_paths.join(' ')}\""... | Runs yardstick on a partial set of paths passed in by guard
@api private
@return [Void] | [
"Runs",
"yardstick",
"on",
"a",
"partial",
"set",
"of",
"paths",
"passed",
"in",
"by",
"guard"
] | 0a52568e1bf1458e611fad2367c41cd1728a9444 | https://github.com/X0nic/guard-yardstick/blob/0a52568e1bf1458e611fad2367c41cd1728a9444/lib/guard/yardstick.rb#L68-L75 |
9,341 | X0nic/guard-yardstick | lib/guard/yardstick.rb | Guard.Yardstick.inspect_with_yardstick | def inspect_with_yardstick(yardstick_options = {})
config = ::Yardstick::Config.coerce(yardstick_config(yardstick_options))
measurements = ::Yardstick.measure(config)
measurements.puts
rescue StandardError => error
UI.error 'The following exception occurred while running ' \
"... | ruby | def inspect_with_yardstick(yardstick_options = {})
config = ::Yardstick::Config.coerce(yardstick_config(yardstick_options))
measurements = ::Yardstick.measure(config)
measurements.puts
rescue StandardError => error
UI.error 'The following exception occurred while running ' \
"... | [
"def",
"inspect_with_yardstick",
"(",
"yardstick_options",
"=",
"{",
"}",
")",
"config",
"=",
"::",
"Yardstick",
"::",
"Config",
".",
"coerce",
"(",
"yardstick_config",
"(",
"yardstick_options",
")",
")",
"measurements",
"=",
"::",
"Yardstick",
".",
"measure",
... | Runs yardstick and outputs results to STDOUT
@api private
@return [Void] | [
"Runs",
"yardstick",
"and",
"outputs",
"results",
"to",
"STDOUT"
] | 0a52568e1bf1458e611fad2367c41cd1728a9444 | https://github.com/X0nic/guard-yardstick/blob/0a52568e1bf1458e611fad2367c41cd1728a9444/lib/guard/yardstick.rb#L81-L89 |
9,342 | X0nic/guard-yardstick | lib/guard/yardstick.rb | Guard.Yardstick.yardstick_config | def yardstick_config(extra_options = {})
return options unless options[:config]
yardstick_options = YAML.load_file(options[:config])
yardstick_options.merge(extra_options)
end | ruby | def yardstick_config(extra_options = {})
return options unless options[:config]
yardstick_options = YAML.load_file(options[:config])
yardstick_options.merge(extra_options)
end | [
"def",
"yardstick_config",
"(",
"extra_options",
"=",
"{",
"}",
")",
"return",
"options",
"unless",
"options",
"[",
":config",
"]",
"yardstick_options",
"=",
"YAML",
".",
"load_file",
"(",
"options",
"[",
":config",
"]",
")",
"yardstick_options",
".",
"merge",... | Merge further options with yardstick config file.
@api private
@return [Hash] Hash of options for yardstick measurement | [
"Merge",
"further",
"options",
"with",
"yardstick",
"config",
"file",
"."
] | 0a52568e1bf1458e611fad2367c41cd1728a9444 | https://github.com/X0nic/guard-yardstick/blob/0a52568e1bf1458e611fad2367c41cd1728a9444/lib/guard/yardstick.rb#L107-L112 |
9,343 | blambeau/domain | lib/domain/api.rb | Domain.API.domain_error! | def domain_error!(first, *args)
first = [first]+args unless args.empty?
raise TypeError, "Can't convert `#{first.inspect}` into #{self}", caller
end | ruby | def domain_error!(first, *args)
first = [first]+args unless args.empty?
raise TypeError, "Can't convert `#{first.inspect}` into #{self}", caller
end | [
"def",
"domain_error!",
"(",
"first",
",",
"*",
"args",
")",
"first",
"=",
"[",
"first",
"]",
"+",
"args",
"unless",
"args",
".",
"empty?",
"raise",
"TypeError",
",",
"\"Can't convert `#{first.inspect}` into #{self}\"",
",",
"caller",
"end"
] | Raises a type error for `args`.
@param [Array] args
arguments passed to `new` or another factory method
@raise TypeError
@api protected | [
"Raises",
"a",
"type",
"error",
"for",
"args",
"."
] | 3fd010cbf2e156013e0ea9afa608ba9b44e7bc75 | https://github.com/blambeau/domain/blob/3fd010cbf2e156013e0ea9afa608ba9b44e7bc75/lib/domain/api.rb#L11-L14 |
9,344 | checkdin/checkdin-ruby | lib/checkdin/user_bridge.rb | Checkdin.UserBridge.login_url | def login_url options
email = options.delete(:email) or raise ArgumentError.new("No :email passed for user")
user_identifier = options.delete(:user_identifier) or raise ArgumentError.new("No :user_identifier passed for user")
authenticated_parameters = build_authentica... | ruby | def login_url options
email = options.delete(:email) or raise ArgumentError.new("No :email passed for user")
user_identifier = options.delete(:user_identifier) or raise ArgumentError.new("No :user_identifier passed for user")
authenticated_parameters = build_authentica... | [
"def",
"login_url",
"options",
"email",
"=",
"options",
".",
"delete",
"(",
":email",
")",
"or",
"raise",
"ArgumentError",
".",
"new",
"(",
"\"No :email passed for user\"",
")",
"user_identifier",
"=",
"options",
".",
"delete",
"(",
":user_identifier",
")",
"or"... | Used to build the authenticated parameters for logging in an end-user on
checkd.in via a redirect.
options - a hash with a the following values defined:
:client_identifier - REQUIRED, the same client identifier used when accessing the regular
API methods.
:bridge_secret ... | [
"Used",
"to",
"build",
"the",
"authenticated",
"parameters",
"for",
"logging",
"in",
"an",
"end",
"-",
"user",
"on",
"checkd",
".",
"in",
"via",
"a",
"redirect",
"."
] | c3c4b38b0f8c710e1f805100dcf3a70649215b48 | https://github.com/checkdin/checkdin-ruby/blob/c3c4b38b0f8c710e1f805100dcf3a70649215b48/lib/checkdin/user_bridge.rb#L59-L66 |
9,345 | yogahp/meser_ongkir | lib/meser_ongkir/api.rb | MeserOngkir.Api.call | def call
url = URI(api_url)
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
url.query = URI.encode_www_form(@params) if @params
request = Net::HTTP::Get.new(url)
request['key'] = ENV['MESER_ONGKIR_API_KEY']
http.... | ruby | def call
url = URI(api_url)
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
url.query = URI.encode_www_form(@params) if @params
request = Net::HTTP::Get.new(url)
request['key'] = ENV['MESER_ONGKIR_API_KEY']
http.... | [
"def",
"call",
"url",
"=",
"URI",
"(",
"api_url",
")",
"http",
"=",
"Net",
"::",
"HTTP",
".",
"new",
"(",
"url",
".",
"host",
",",
"url",
".",
"port",
")",
"http",
".",
"use_ssl",
"=",
"true",
"http",
".",
"verify_mode",
"=",
"OpenSSL",
"::",
"SS... | Creating new object
@param
account_type [String] it could be :starter
main_path [String] it could be :city, :province
params [Hash] it could be { id: id city / id province, province: id province }
@example
MeserOngkir::Api.new(account_type, main_path, params) | [
"Creating",
"new",
"object"
] | b9fb3a925098c169793d1893ef00a0f2af222c16 | https://github.com/yogahp/meser_ongkir/blob/b9fb3a925098c169793d1893ef00a0f2af222c16/lib/meser_ongkir/api.rb#L24-L35 |
9,346 | tomas-stefano/rspec-i18n | lib/spec-i18n/matchers/method_missing.rb | Spec.Matchers.method_missing | def method_missing(sym, *args, &block) # :nodoc:\
matchers = natural_language.keywords['matchers']
be_word = matchers['be'] if matchers
sym = be_to_english(sym, be_word)
return Matchers::BePredicate.new(sym, *args, &block) if be_predicate?(sym)
return Matchers::Has.new(sym, *args, &block) ... | ruby | def method_missing(sym, *args, &block) # :nodoc:\
matchers = natural_language.keywords['matchers']
be_word = matchers['be'] if matchers
sym = be_to_english(sym, be_word)
return Matchers::BePredicate.new(sym, *args, &block) if be_predicate?(sym)
return Matchers::Has.new(sym, *args, &block) ... | [
"def",
"method_missing",
"(",
"sym",
",",
"*",
"args",
",",
"&",
"block",
")",
"# :nodoc:\\",
"matchers",
"=",
"natural_language",
".",
"keywords",
"[",
"'matchers'",
"]",
"be_word",
"=",
"matchers",
"[",
"'be'",
"]",
"if",
"matchers",
"sym",
"=",
"be_to_e... | Method Missing that returns Predicate for the respective sym word
Search the translate be word in the languages.yml for the rspec-i18n try
to comunicate with the Rspec | [
"Method",
"Missing",
"that",
"returns",
"Predicate",
"for",
"the",
"respective",
"sym",
"word",
"Search",
"the",
"translate",
"be",
"word",
"in",
"the",
"languages",
".",
"yml",
"for",
"the",
"rspec",
"-",
"i18n",
"try",
"to",
"comunicate",
"with",
"the",
... | 4383293c4c45ccbb02f42d79bf0fe208d1f913fb | https://github.com/tomas-stefano/rspec-i18n/blob/4383293c4c45ccbb02f42d79bf0fe208d1f913fb/lib/spec-i18n/matchers/method_missing.rb#L8-L14 |
9,347 | SpeciesFileGroup/taxonifi | lib/taxonifi/export/format/species_file.rb | Taxonifi::Export.SpeciesFile.tblRefs | def tblRefs
sql = []
@headers = %w{RefID ActualYear Title PubID Verbatim}
@name_collection.ref_collection.collection.each_with_index do |r,i|
# Assumes the 0 "null" pub id is there
pub_id = @pub_collection[r.publication] ? @pub_collection[r.publication] : 0
# Build a note base... | ruby | def tblRefs
sql = []
@headers = %w{RefID ActualYear Title PubID Verbatim}
@name_collection.ref_collection.collection.each_with_index do |r,i|
# Assumes the 0 "null" pub id is there
pub_id = @pub_collection[r.publication] ? @pub_collection[r.publication] : 0
# Build a note base... | [
"def",
"tblRefs",
"sql",
"=",
"[",
"]",
"@headers",
"=",
"%w{",
"RefID",
"ActualYear",
"Title",
"PubID",
"Verbatim",
"}",
"@name_collection",
".",
"ref_collection",
".",
"collection",
".",
"each_with_index",
"do",
"|",
"r",
",",
"i",
"|",
"# Assumes the 0 \"nu... | Generate a tblRefs string. | [
"Generate",
"a",
"tblRefs",
"string",
"."
] | 100dc94e7ffd378f6a81381c13768e35b2b65bf2 | https://github.com/SpeciesFileGroup/taxonifi/blob/100dc94e7ffd378f6a81381c13768e35b2b65bf2/lib/taxonifi/export/format/species_file.rb#L202-L242 |
9,348 | SpeciesFileGroup/taxonifi | lib/taxonifi/export/format/species_file.rb | Taxonifi::Export.SpeciesFile.tblPubs | def tblPubs
sql = []
@headers = %w{PubID PrefID PubType ShortName FullName Note LastUpdate ModifiedBy Publisher PlacePublished PubRegID Status StartYear EndYear BHL}
# Hackish should build this elsewhere, but degrades OK
pubs = @name_collection.ref_collection.collection.collect{|r| r.publicatio... | ruby | def tblPubs
sql = []
@headers = %w{PubID PrefID PubType ShortName FullName Note LastUpdate ModifiedBy Publisher PlacePublished PubRegID Status StartYear EndYear BHL}
# Hackish should build this elsewhere, but degrades OK
pubs = @name_collection.ref_collection.collection.collect{|r| r.publicatio... | [
"def",
"tblPubs",
"sql",
"=",
"[",
"]",
"@headers",
"=",
"%w{",
"PubID",
"PrefID",
"PubType",
"ShortName",
"FullName",
"Note",
"LastUpdate",
"ModifiedBy",
"Publisher",
"PlacePublished",
"PubRegID",
"Status",
"StartYear",
"EndYear",
"BHL",
"}",
"# Hackish should buil... | Generate tblPubs SQL | [
"Generate",
"tblPubs",
"SQL"
] | 100dc94e7ffd378f6a81381c13768e35b2b65bf2 | https://github.com/SpeciesFileGroup/taxonifi/blob/100dc94e7ffd378f6a81381c13768e35b2b65bf2/lib/taxonifi/export/format/species_file.rb#L245-L274 |
9,349 | SpeciesFileGroup/taxonifi | lib/taxonifi/export/format/species_file.rb | Taxonifi::Export.SpeciesFile.tblPeople | def tblPeople
@headers = %w{PersonID FamilyName GivenNames GivenInitials Suffix Role LastUpdate ModifiedBy}
sql = []
@name_collection.ref_collection.all_authors.each do |a|
cols = {
PersonID: a.id,
FamilyName: (a.last_name.length > 0 ? a.last_name : "Unknown"),
... | ruby | def tblPeople
@headers = %w{PersonID FamilyName GivenNames GivenInitials Suffix Role LastUpdate ModifiedBy}
sql = []
@name_collection.ref_collection.all_authors.each do |a|
cols = {
PersonID: a.id,
FamilyName: (a.last_name.length > 0 ? a.last_name : "Unknown"),
... | [
"def",
"tblPeople",
"@headers",
"=",
"%w{",
"PersonID",
"FamilyName",
"GivenNames",
"GivenInitials",
"Suffix",
"Role",
"LastUpdate",
"ModifiedBy",
"}",
"sql",
"=",
"[",
"]",
"@name_collection",
".",
"ref_collection",
".",
"all_authors",
".",
"each",
"do",
"|",
"... | Generate tblPeople string. | [
"Generate",
"tblPeople",
"string",
"."
] | 100dc94e7ffd378f6a81381c13768e35b2b65bf2 | https://github.com/SpeciesFileGroup/taxonifi/blob/100dc94e7ffd378f6a81381c13768e35b2b65bf2/lib/taxonifi/export/format/species_file.rb#L277-L294 |
9,350 | SpeciesFileGroup/taxonifi | lib/taxonifi/export/format/species_file.rb | Taxonifi::Export.SpeciesFile.tblRefAuthors | def tblRefAuthors
@headers = %w{RefID PersonID SeqNum AuthorCount LastUpdate ModifiedBy}
sql = []
@name_collection.ref_collection.collection.each do |r|
r.authors.each_with_index do |x, i|
cols = {
RefID: r.id,
PersonID: x.id,
SeqNum: i + 1,
... | ruby | def tblRefAuthors
@headers = %w{RefID PersonID SeqNum AuthorCount LastUpdate ModifiedBy}
sql = []
@name_collection.ref_collection.collection.each do |r|
r.authors.each_with_index do |x, i|
cols = {
RefID: r.id,
PersonID: x.id,
SeqNum: i + 1,
... | [
"def",
"tblRefAuthors",
"@headers",
"=",
"%w{",
"RefID",
"PersonID",
"SeqNum",
"AuthorCount",
"LastUpdate",
"ModifiedBy",
"}",
"sql",
"=",
"[",
"]",
"@name_collection",
".",
"ref_collection",
".",
"collection",
".",
"each",
"do",
"|",
"r",
"|",
"r",
".",
"au... | Generate tblRefAuthors string. | [
"Generate",
"tblRefAuthors",
"string",
"."
] | 100dc94e7ffd378f6a81381c13768e35b2b65bf2 | https://github.com/SpeciesFileGroup/taxonifi/blob/100dc94e7ffd378f6a81381c13768e35b2b65bf2/lib/taxonifi/export/format/species_file.rb#L297-L314 |
9,351 | SpeciesFileGroup/taxonifi | lib/taxonifi/export/format/species_file.rb | Taxonifi::Export.SpeciesFile.tblCites | def tblCites
@headers = %w{TaxonNameID SeqNum RefID NomenclatorID LastUpdate ModifiedBy NewNameStatus CitePages Note TypeClarification CurrentConcept ConceptChange InfoFlags InfoFlagStatus PolynomialStatus}
sql = []
@name_collection.citations.keys.each do |name_id|
seq_num = 1
@name_... | ruby | def tblCites
@headers = %w{TaxonNameID SeqNum RefID NomenclatorID LastUpdate ModifiedBy NewNameStatus CitePages Note TypeClarification CurrentConcept ConceptChange InfoFlags InfoFlagStatus PolynomialStatus}
sql = []
@name_collection.citations.keys.each do |name_id|
seq_num = 1
@name_... | [
"def",
"tblCites",
"@headers",
"=",
"%w{",
"TaxonNameID",
"SeqNum",
"RefID",
"NomenclatorID",
"LastUpdate",
"ModifiedBy",
"NewNameStatus",
"CitePages",
"Note",
"TypeClarification",
"CurrentConcept",
"ConceptChange",
"InfoFlags",
"InfoFlagStatus",
"PolynomialStatus",
"}",
"s... | Generate tblCites string. | [
"Generate",
"tblCites",
"string",
"."
] | 100dc94e7ffd378f6a81381c13768e35b2b65bf2 | https://github.com/SpeciesFileGroup/taxonifi/blob/100dc94e7ffd378f6a81381c13768e35b2b65bf2/lib/taxonifi/export/format/species_file.rb#L317-L346 |
9,352 | SpeciesFileGroup/taxonifi | lib/taxonifi/export/format/species_file.rb | Taxonifi::Export.SpeciesFile.tblTypeSpecies | def tblTypeSpecies
@headers = %w{GenusNameID SpeciesNameID Reason AuthorityRefID FirstFamGrpNameID LastUpdate ModifiedBy NewID}
sql = []
names = @name_collection.names_at_rank('genus') + @name_collection.names_at_rank('subgenus')
names.each do |n|
if n.properties[:type_species_id]
... | ruby | def tblTypeSpecies
@headers = %w{GenusNameID SpeciesNameID Reason AuthorityRefID FirstFamGrpNameID LastUpdate ModifiedBy NewID}
sql = []
names = @name_collection.names_at_rank('genus') + @name_collection.names_at_rank('subgenus')
names.each do |n|
if n.properties[:type_species_id]
... | [
"def",
"tblTypeSpecies",
"@headers",
"=",
"%w{",
"GenusNameID",
"SpeciesNameID",
"Reason",
"AuthorityRefID",
"FirstFamGrpNameID",
"LastUpdate",
"ModifiedBy",
"NewID",
"}",
"sql",
"=",
"[",
"]",
"names",
"=",
"@name_collection",
".",
"names_at_rank",
"(",
"'genus'",
... | Generate tblTypeSpecies string. | [
"Generate",
"tblTypeSpecies",
"string",
"."
] | 100dc94e7ffd378f6a81381c13768e35b2b65bf2 | https://github.com/SpeciesFileGroup/taxonifi/blob/100dc94e7ffd378f6a81381c13768e35b2b65bf2/lib/taxonifi/export/format/species_file.rb#L349-L374 |
9,353 | SpeciesFileGroup/taxonifi | lib/taxonifi/export/format/species_file.rb | Taxonifi::Export.SpeciesFile.tblNomenclator | def tblNomenclator
@headers = %w{NomenclatorID GenusNameID SubgenusNameID SpeciesNameID SubspeciesNameID LastUpdate ModifiedBy SuitableForGenus SuitableForSpecies InfrasubspeciesNameID InfrasubKind}
sql = []
i = 1
# Ugh, move build from here
@name_collection.nomenclators.keys.each do ... | ruby | def tblNomenclator
@headers = %w{NomenclatorID GenusNameID SubgenusNameID SpeciesNameID SubspeciesNameID LastUpdate ModifiedBy SuitableForGenus SuitableForSpecies InfrasubspeciesNameID InfrasubKind}
sql = []
i = 1
# Ugh, move build from here
@name_collection.nomenclators.keys.each do ... | [
"def",
"tblNomenclator",
"@headers",
"=",
"%w{",
"NomenclatorID",
"GenusNameID",
"SubgenusNameID",
"SpeciesNameID",
"SubspeciesNameID",
"LastUpdate",
"ModifiedBy",
"SuitableForGenus",
"SuitableForSpecies",
"InfrasubspeciesNameID",
"InfrasubKind",
"}",
"sql",
"=",
"[",
"]",
... | Must be called post tblGenusNames and tblSpeciesNames.
Some records are not used but can be cleaned by SF | [
"Must",
"be",
"called",
"post",
"tblGenusNames",
"and",
"tblSpeciesNames",
".",
"Some",
"records",
"are",
"not",
"used",
"but",
"can",
"be",
"cleaned",
"by",
"SF"
] | 100dc94e7ffd378f6a81381c13768e35b2b65bf2 | https://github.com/SpeciesFileGroup/taxonifi/blob/100dc94e7ffd378f6a81381c13768e35b2b65bf2/lib/taxonifi/export/format/species_file.rb#L411-L448 |
9,354 | jmcaffee/exceltocsv | lib/exceltocsv/excel_file.rb | ExcelToCsv.ExcelFile.empty_row? | def empty_row?(row)
is_empty = true
row.each do |item|
is_empty = false if item && !item.empty?
end
is_empty
end | ruby | def empty_row?(row)
is_empty = true
row.each do |item|
is_empty = false if item && !item.empty?
end
is_empty
end | [
"def",
"empty_row?",
"(",
"row",
")",
"is_empty",
"=",
"true",
"row",
".",
"each",
"do",
"|",
"item",
"|",
"is_empty",
"=",
"false",
"if",
"item",
"&&",
"!",
"item",
".",
"empty?",
"end",
"is_empty",
"end"
] | Return true if row contains no data | [
"Return",
"true",
"if",
"row",
"contains",
"no",
"data"
] | e93baed66baf4d7a0e341d8504bed3a9bf55ff55 | https://github.com/jmcaffee/exceltocsv/blob/e93baed66baf4d7a0e341d8504bed3a9bf55ff55/lib/exceltocsv/excel_file.rb#L176-L182 |
9,355 | jmcaffee/exceltocsv | lib/exceltocsv/excel_file.rb | ExcelToCsv.ExcelFile.truncate_decimal | def truncate_decimal(a_cell)
if(a_cell.is_a?(Numeric))
a_cell = truncate_decimal_to_string(a_cell, 3)
# Truncate zeros (unless there is only 1 decimal place)
# eg. 12.10 => 12.1
# 12.0 => 12.0
a_cell = BigDecimal.new(a_cell).to_s("F")
end
a_cell
end | ruby | def truncate_decimal(a_cell)
if(a_cell.is_a?(Numeric))
a_cell = truncate_decimal_to_string(a_cell, 3)
# Truncate zeros (unless there is only 1 decimal place)
# eg. 12.10 => 12.1
# 12.0 => 12.0
a_cell = BigDecimal.new(a_cell).to_s("F")
end
a_cell
end | [
"def",
"truncate_decimal",
"(",
"a_cell",
")",
"if",
"(",
"a_cell",
".",
"is_a?",
"(",
"Numeric",
")",
")",
"a_cell",
"=",
"truncate_decimal_to_string",
"(",
"a_cell",
",",
"3",
")",
"# Truncate zeros (unless there is only 1 decimal place)",
"# eg. 12.10 => 12.1",
"# ... | Truncates a decimal to 3 decimal places if numeric
and remove trailing zeros, if more than one decimal place.
returns a string | [
"Truncates",
"a",
"decimal",
"to",
"3",
"decimal",
"places",
"if",
"numeric",
"and",
"remove",
"trailing",
"zeros",
"if",
"more",
"than",
"one",
"decimal",
"place",
".",
"returns",
"a",
"string"
] | e93baed66baf4d7a0e341d8504bed3a9bf55ff55 | https://github.com/jmcaffee/exceltocsv/blob/e93baed66baf4d7a0e341d8504bed3a9bf55ff55/lib/exceltocsv/excel_file.rb#L206-L215 |
9,356 | jmcaffee/exceltocsv | lib/exceltocsv/excel_file.rb | ExcelToCsv.ExcelFile.clean_int_value | def clean_int_value(a_cell)
if(a_cell.match(/\.[0]+$/))
cary = a_cell.split(".")
a_cell = cary[0]
end
a_cell
end | ruby | def clean_int_value(a_cell)
if(a_cell.match(/\.[0]+$/))
cary = a_cell.split(".")
a_cell = cary[0]
end
a_cell
end | [
"def",
"clean_int_value",
"(",
"a_cell",
")",
"if",
"(",
"a_cell",
".",
"match",
"(",
"/",
"\\.",
"/",
")",
")",
"cary",
"=",
"a_cell",
".",
"split",
"(",
"\".\"",
")",
"a_cell",
"=",
"cary",
"[",
"0",
"]",
"end",
"a_cell",
"end"
] | If the result is n.000... Remove the unecessary zeros. | [
"If",
"the",
"result",
"is",
"n",
".",
"000",
"...",
"Remove",
"the",
"unecessary",
"zeros",
"."
] | e93baed66baf4d7a0e341d8504bed3a9bf55ff55 | https://github.com/jmcaffee/exceltocsv/blob/e93baed66baf4d7a0e341d8504bed3a9bf55ff55/lib/exceltocsv/excel_file.rb#L225-L231 |
9,357 | rsb/fuelcell | lib/fuelcell/cli.rb | Fuelcell.Cli.parse | def parse(raw_args)
cmd_args = cmd_args_extractor.call(raw_args)
cmd = root.locate(cmd_args, raw_args)
root.add_global_options(cmd)
begin
parser.call(cmd, cmd_args, raw_args)
rescue => e
shell.error e.message
shell.failure_exit
end
end | ruby | def parse(raw_args)
cmd_args = cmd_args_extractor.call(raw_args)
cmd = root.locate(cmd_args, raw_args)
root.add_global_options(cmd)
begin
parser.call(cmd, cmd_args, raw_args)
rescue => e
shell.error e.message
shell.failure_exit
end
end | [
"def",
"parse",
"(",
"raw_args",
")",
"cmd_args",
"=",
"cmd_args_extractor",
".",
"call",
"(",
"raw_args",
")",
"cmd",
"=",
"root",
".",
"locate",
"(",
"cmd_args",
",",
"raw_args",
")",
"root",
".",
"add_global_options",
"(",
"cmd",
")",
"begin",
"parser",... | Initializes with a root command object
When nothing is given we default to the script name otherwise you choose
the name of the root command or the command itself
Delegates all parsing responsiblities to a series of handlers, returning
a structured hash needed to execute a command. The command being executed
is ... | [
"Initializes",
"with",
"a",
"root",
"command",
"object"
] | 2eaa994170fa2b9243e7dee6d7c2b21e12274f6e | https://github.com/rsb/fuelcell/blob/2eaa994170fa2b9243e7dee6d7c2b21e12274f6e/lib/fuelcell/cli.rb#L38-L48 |
9,358 | rsb/fuelcell | lib/fuelcell/cli.rb | Fuelcell.Cli.execute | def execute(context)
cmd = context[:cmd]
opts = context[:opts] || {}
args = context[:args] || []
cmd_args = context[:cmd_args]
cli_shell = context[:shell] || shell
unless cmd.callable?
return root['help'].call(opts, cmd_args, shell)
end
cmd = ha... | ruby | def execute(context)
cmd = context[:cmd]
opts = context[:opts] || {}
args = context[:args] || []
cmd_args = context[:cmd_args]
cli_shell = context[:shell] || shell
unless cmd.callable?
return root['help'].call(opts, cmd_args, shell)
end
cmd = ha... | [
"def",
"execute",
"(",
"context",
")",
"cmd",
"=",
"context",
"[",
":cmd",
"]",
"opts",
"=",
"context",
"[",
":opts",
"]",
"||",
"{",
"}",
"args",
"=",
"context",
"[",
":args",
"]",
"||",
"[",
"]",
"cmd_args",
"=",
"context",
"[",
":cmd_args",
"]",... | Executes the callable object in a command. All command callable object
expect to be called the the options hash, arg hash and shell object.
@param context [Hash]
@return [Integer] | [
"Executes",
"the",
"callable",
"object",
"in",
"a",
"command",
".",
"All",
"command",
"callable",
"object",
"expect",
"to",
"be",
"called",
"the",
"the",
"options",
"hash",
"arg",
"hash",
"and",
"shell",
"object",
"."
] | 2eaa994170fa2b9243e7dee6d7c2b21e12274f6e | https://github.com/rsb/fuelcell/blob/2eaa994170fa2b9243e7dee6d7c2b21e12274f6e/lib/fuelcell/cli.rb#L55-L69 |
9,359 | gr4y/streambot | lib/streambot/oauth.rb | StreamBot.OAuth.get_access_token | def get_access_token
# get saved access token
if ::File.exists?(ACCESS_TOKEN)
@access_token = ::YAML.load_file(ACCESS_TOKEN)
end
# if access token is nil,
# then get a new initial token
if @access_token.nil?
get_initial_token
::File.open(ACCESS_TOKEN, 'w') do ... | ruby | def get_access_token
# get saved access token
if ::File.exists?(ACCESS_TOKEN)
@access_token = ::YAML.load_file(ACCESS_TOKEN)
end
# if access token is nil,
# then get a new initial token
if @access_token.nil?
get_initial_token
::File.open(ACCESS_TOKEN, 'w') do ... | [
"def",
"get_access_token",
"# get saved access token",
"if",
"::",
"File",
".",
"exists?",
"(",
"ACCESS_TOKEN",
")",
"@access_token",
"=",
"::",
"YAML",
".",
"load_file",
"(",
"ACCESS_TOKEN",
")",
"end",
"# if access token is nil,",
"# then get a new initial token",
"if... | get the access token | [
"get",
"the",
"access",
"token"
] | 3f454b62ea0c1e9eb29a3c7bf0d17f3caf14b375 | https://github.com/gr4y/streambot/blob/3f454b62ea0c1e9eb29a3c7bf0d17f3caf14b375/lib/streambot/oauth.rb#L52-L65 |
9,360 | gr4y/streambot | lib/streambot/oauth.rb | StreamBot.OAuth.get_initial_token | def get_initial_token
@request_token = get_request_token
puts "Place \"#{@request_token.authorize_url}\" in your browser"
print "Enter the number they give you: "
pin = STDIN.readline.chomp
@access_token = @request_token.get_access_token(:oauth_verifier => pin)
end | ruby | def get_initial_token
@request_token = get_request_token
puts "Place \"#{@request_token.authorize_url}\" in your browser"
print "Enter the number they give you: "
pin = STDIN.readline.chomp
@access_token = @request_token.get_access_token(:oauth_verifier => pin)
end | [
"def",
"get_initial_token",
"@request_token",
"=",
"get_request_token",
"puts",
"\"Place \\\"#{@request_token.authorize_url}\\\" in your browser\"",
"print",
"\"Enter the number they give you: \"",
"pin",
"=",
"STDIN",
".",
"readline",
".",
"chomp",
"@access_token",
"=",
"@reques... | get the initial access token | [
"get",
"the",
"initial",
"access",
"token"
] | 3f454b62ea0c1e9eb29a3c7bf0d17f3caf14b375 | https://github.com/gr4y/streambot/blob/3f454b62ea0c1e9eb29a3c7bf0d17f3caf14b375/lib/streambot/oauth.rb#L68-L74 |
9,361 | mccraigmccraig/rsxml | lib/rsxml/sexp.rb | Rsxml.Sexp.traverse | def traverse(sexp, visitor, context=Visitor::Context.new)
element_name, attrs, children = decompose_sexp(sexp)
non_ns_attrs, ns_bindings = Namespace::non_ns_attrs_ns_bindings(context.ns_stack, element_name, attrs)
context.ns_stack.push(ns_bindings)
eelement_name = Namespace::explode_qna... | ruby | def traverse(sexp, visitor, context=Visitor::Context.new)
element_name, attrs, children = decompose_sexp(sexp)
non_ns_attrs, ns_bindings = Namespace::non_ns_attrs_ns_bindings(context.ns_stack, element_name, attrs)
context.ns_stack.push(ns_bindings)
eelement_name = Namespace::explode_qna... | [
"def",
"traverse",
"(",
"sexp",
",",
"visitor",
",",
"context",
"=",
"Visitor",
"::",
"Context",
".",
"new",
")",
"element_name",
",",
"attrs",
",",
"children",
"=",
"decompose_sexp",
"(",
"sexp",
")",
"non_ns_attrs",
",",
"ns_bindings",
"=",
"Namespace",
... | pre-order traversal of the sexp, calling methods on
the visitor with each node | [
"pre",
"-",
"order",
"traversal",
"of",
"the",
"sexp",
"calling",
"methods",
"on",
"the",
"visitor",
"with",
"each",
"node"
] | 3699c186f01be476a5942d64cd5c39f4d6bbe175 | https://github.com/mccraigmccraig/rsxml/blob/3699c186f01be476a5942d64cd5c39f4d6bbe175/lib/rsxml/sexp.rb#L8-L33 |
9,362 | logankoester/errship | lib/errship.rb | Errship.Rescuers.errship_standard | def errship_standard(errship_scope = false)
flash[:error] ||= I18n.t('errship.standard')
render :template => '/errship/standard.html.erb',
:layout => 'application',
:locals => { :status_code => 500, :errship_scope => errship_scope },
:status => (Errship.status_co... | ruby | def errship_standard(errship_scope = false)
flash[:error] ||= I18n.t('errship.standard')
render :template => '/errship/standard.html.erb',
:layout => 'application',
:locals => { :status_code => 500, :errship_scope => errship_scope },
:status => (Errship.status_co... | [
"def",
"errship_standard",
"(",
"errship_scope",
"=",
"false",
")",
"flash",
"[",
":error",
"]",
"||=",
"I18n",
".",
"t",
"(",
"'errship.standard'",
")",
"render",
":template",
"=>",
"'/errship/standard.html.erb'",
",",
":layout",
"=>",
"'application'",
",",
":l... | A blank page with just the layout and flash message, which can be redirected to when
all else fails. | [
"A",
"blank",
"page",
"with",
"just",
"the",
"layout",
"and",
"flash",
"message",
"which",
"can",
"be",
"redirected",
"to",
"when",
"all",
"else",
"fails",
"."
] | 9e344c25a5c6b619af1b9b177ad4f40b415b2182 | https://github.com/logankoester/errship/blob/9e344c25a5c6b619af1b9b177ad4f40b415b2182/lib/errship.rb#L41-L47 |
9,363 | logankoester/errship | lib/errship.rb | Errship.Rescuers.flashback | def flashback(error_message, exception = nil)
airbrake_class.send(:notify, exception) if airbrake_class
flash[:error] = error_message
begin
redirect_to :back
rescue ActionController::RedirectBackError
redirect_to error_path
end
end | ruby | def flashback(error_message, exception = nil)
airbrake_class.send(:notify, exception) if airbrake_class
flash[:error] = error_message
begin
redirect_to :back
rescue ActionController::RedirectBackError
redirect_to error_path
end
end | [
"def",
"flashback",
"(",
"error_message",
",",
"exception",
"=",
"nil",
")",
"airbrake_class",
".",
"send",
"(",
":notify",
",",
"exception",
")",
"if",
"airbrake_class",
"flash",
"[",
":error",
"]",
"=",
"error_message",
"begin",
"redirect_to",
":back",
"resc... | Set the error flash and attempt to redirect back. If RedirectBackError is raised,
redirect to error_path instead. | [
"Set",
"the",
"error",
"flash",
"and",
"attempt",
"to",
"redirect",
"back",
".",
"If",
"RedirectBackError",
"is",
"raised",
"redirect",
"to",
"error_path",
"instead",
"."
] | 9e344c25a5c6b619af1b9b177ad4f40b415b2182 | https://github.com/logankoester/errship/blob/9e344c25a5c6b619af1b9b177ad4f40b415b2182/lib/errship.rb#L51-L59 |
9,364 | devver/sdbtools | lib/sdbtools/operation.rb | SDBTools.Operation.each | def each
Transaction.open(":#{method} operation") do |t|
next_token = starting_token
begin
args = @args.dup
args << next_token
results = @sdb.send(@method, *args)
yield(results, self)
next_token = results[:next_token]
end while next_token
... | ruby | def each
Transaction.open(":#{method} operation") do |t|
next_token = starting_token
begin
args = @args.dup
args << next_token
results = @sdb.send(@method, *args)
yield(results, self)
next_token = results[:next_token]
end while next_token
... | [
"def",
"each",
"Transaction",
".",
"open",
"(",
"\":#{method} operation\"",
")",
"do",
"|",
"t",
"|",
"next_token",
"=",
"starting_token",
"begin",
"args",
"=",
"@args",
".",
"dup",
"args",
"<<",
"next_token",
"results",
"=",
"@sdb",
".",
"send",
"(",
"@me... | Yields once for each result set, until there is no next token. | [
"Yields",
"once",
"for",
"each",
"result",
"set",
"until",
"there",
"is",
"no",
"next",
"token",
"."
] | 194c082bf3f67eac6d5eb40cbc392957db4da269 | https://github.com/devver/sdbtools/blob/194c082bf3f67eac6d5eb40cbc392957db4da269/lib/sdbtools/operation.rb#L20-L31 |
9,365 | populr/subdomainbox | lib/subdomainbox/secure_csrf_token.rb | ActionController.RequestForgeryProtection.form_authenticity_token | def form_authenticity_token
raise 'CSRF token secret must be defined' if CSRF_TOKEN_SECRET.nil? || CSRF_TOKEN_SECRET.empty?
if request.session_options[:id].nil? || request.session_options[:id].empty?
original_form_authenticity_token
else
Digest::SHA1.hexdigest("#{CSRF_TOKEN_S... | ruby | def form_authenticity_token
raise 'CSRF token secret must be defined' if CSRF_TOKEN_SECRET.nil? || CSRF_TOKEN_SECRET.empty?
if request.session_options[:id].nil? || request.session_options[:id].empty?
original_form_authenticity_token
else
Digest::SHA1.hexdigest("#{CSRF_TOKEN_S... | [
"def",
"form_authenticity_token",
"raise",
"'CSRF token secret must be defined'",
"if",
"CSRF_TOKEN_SECRET",
".",
"nil?",
"||",
"CSRF_TOKEN_SECRET",
".",
"empty?",
"if",
"request",
".",
"session_options",
"[",
":id",
"]",
".",
"nil?",
"||",
"request",
".",
"session_op... | Sets the token value for the current session. | [
"Sets",
"the",
"token",
"value",
"for",
"the",
"current",
"session",
"."
] | b29730ba14a2fa0b62759422d1cef78646d96a93 | https://github.com/populr/subdomainbox/blob/b29730ba14a2fa0b62759422d1cef78646d96a93/lib/subdomainbox/secure_csrf_token.rb#L11-L18 |
9,366 | hubb/putio.rb | lib/putio/configurable.rb | Putio.Configurable.reset! | def reset!
Putio::Configurable.keys.each do |key|
public_send("#{key}=".to_sym, Putio::Defaults.options[key])
end
self
end | ruby | def reset!
Putio::Configurable.keys.each do |key|
public_send("#{key}=".to_sym, Putio::Defaults.options[key])
end
self
end | [
"def",
"reset!",
"Putio",
"::",
"Configurable",
".",
"keys",
".",
"each",
"do",
"|",
"key",
"|",
"public_send",
"(",
"\"#{key}=\"",
".",
"to_sym",
",",
"Putio",
"::",
"Defaults",
".",
"options",
"[",
"key",
"]",
")",
"end",
"self",
"end"
] | Reset configuration options to default values | [
"Reset",
"configuration",
"options",
"to",
"default",
"values"
] | 83c12aa81cdb99aaeb767e9cd27bd92f14abffeb | https://github.com/hubb/putio.rb/blob/83c12aa81cdb99aaeb767e9cd27bd92f14abffeb/lib/putio/configurable.rb#L32-L37 |
9,367 | petebrowne/machined | lib/machined/context.rb | Machined.Context.add_machined_helpers | def add_machined_helpers # :nodoc:
machined.context_helpers.each do |helper|
case helper
when Proc
instance_eval &helper
when Module
extend helper
end
end
end | ruby | def add_machined_helpers # :nodoc:
machined.context_helpers.each do |helper|
case helper
when Proc
instance_eval &helper
when Module
extend helper
end
end
end | [
"def",
"add_machined_helpers",
"# :nodoc:",
"machined",
".",
"context_helpers",
".",
"each",
"do",
"|",
"helper",
"|",
"case",
"helper",
"when",
"Proc",
"instance_eval",
"helper",
"when",
"Module",
"extend",
"helper",
"end",
"end",
"end"
] | Loops through the helpers added to the Machined
environment and adds them to the Context. Supports
blocks and Modules. | [
"Loops",
"through",
"the",
"helpers",
"added",
"to",
"the",
"Machined",
"environment",
"and",
"adds",
"them",
"to",
"the",
"Context",
".",
"Supports",
"blocks",
"and",
"Modules",
"."
] | 4f3921bc5098104096474300e933f009f1b4f7dd | https://github.com/petebrowne/machined/blob/4f3921bc5098104096474300e933f009f1b4f7dd/lib/machined/context.rb#L43-L52 |
9,368 | mgsnova/crisp | lib/crisp/shell.rb | Crisp.Shell.run | def run
runtime = Runtime.new
buffer = ''
while (line = Readline.readline(buffer.empty? ? ">> " : "?> ", true))
begin
buffer << line
ast = Parser.new.parse(buffer)
puts "=> " + runtime.run(ast).to_s
buffer = ''
rescue Crisp::SyntaxError => e
... | ruby | def run
runtime = Runtime.new
buffer = ''
while (line = Readline.readline(buffer.empty? ? ">> " : "?> ", true))
begin
buffer << line
ast = Parser.new.parse(buffer)
puts "=> " + runtime.run(ast).to_s
buffer = ''
rescue Crisp::SyntaxError => e
... | [
"def",
"run",
"runtime",
"=",
"Runtime",
".",
"new",
"buffer",
"=",
"''",
"while",
"(",
"line",
"=",
"Readline",
".",
"readline",
"(",
"buffer",
".",
"empty?",
"?",
"\">> \"",
":",
"\"?> \"",
",",
"true",
")",
")",
"begin",
"buffer",
"<<",
"line",
"a... | start the shell | [
"start",
"the",
"shell"
] | 0b3695de59258971b8b39998602c5b6e9f10623b | https://github.com/mgsnova/crisp/blob/0b3695de59258971b8b39998602c5b6e9f10623b/lib/crisp/shell.rb#L9-L23 |
9,369 | mtnsat/zerg | zerg/lib/zerg/gem_plugin.rb | ZergGemPlugin.Manager.load | def load(needs = {})
needs = needs.merge({"zergrush" => INCLUDE})
Gem::Specification.each { |gem|
# don't load gems more than once
next if @gems.has_key? gem.name
check = needs.dup
# rolls through the depends and... | ruby | def load(needs = {})
needs = needs.merge({"zergrush" => INCLUDE})
Gem::Specification.each { |gem|
# don't load gems more than once
next if @gems.has_key? gem.name
check = needs.dup
# rolls through the depends and... | [
"def",
"load",
"(",
"needs",
"=",
"{",
"}",
")",
"needs",
"=",
"needs",
".",
"merge",
"(",
"{",
"\"zergrush\"",
"=>",
"INCLUDE",
"}",
")",
"Gem",
"::",
"Specification",
".",
"each",
"{",
"|",
"gem",
"|",
"# don't load gems more than once",
"next",
"if",
... | Responsible for going through the list of available gems and loading
any plugins requested. It keeps track of what it's loaded already
and won't load them again.
It accepts one parameter which is a hash of gem depends that should include
or exclude a gem from being loaded. A gem must depend on zergrush to be
co... | [
"Responsible",
"for",
"going",
"through",
"the",
"list",
"of",
"available",
"gems",
"and",
"loading",
"any",
"plugins",
"requested",
".",
"It",
"keeps",
"track",
"of",
"what",
"it",
"s",
"loaded",
"already",
"and",
"won",
"t",
"load",
"them",
"again",
"."
... | dd497665795c7b51a984ae050987a9c5421cd5eb | https://github.com/mtnsat/zerg/blob/dd497665795c7b51a984ae050987a9c5421cd5eb/zerg/lib/zerg/gem_plugin.rb#L161-L189 |
9,370 | jmettraux/rufus-cloche | lib/rufus/cloche.rb | Rufus.Cloche.put | def put(doc, opts={})
opts = opts.inject({}) { |h, (k, v)| h[k.to_s] = v; h }
doc = Rufus::Json.dup(doc) unless opts['update_rev']
# work with a copy, don't touch original
type, key = doc['type'], doc['_id']
raise(
ArgumentError.new("missing values for keys 'type' and/or '_id... | ruby | def put(doc, opts={})
opts = opts.inject({}) { |h, (k, v)| h[k.to_s] = v; h }
doc = Rufus::Json.dup(doc) unless opts['update_rev']
# work with a copy, don't touch original
type, key = doc['type'], doc['_id']
raise(
ArgumentError.new("missing values for keys 'type' and/or '_id... | [
"def",
"put",
"(",
"doc",
",",
"opts",
"=",
"{",
"}",
")",
"opts",
"=",
"opts",
".",
"inject",
"(",
"{",
"}",
")",
"{",
"|",
"h",
",",
"(",
"k",
",",
"v",
")",
"|",
"h",
"[",
"k",
".",
"to_s",
"]",
"=",
"v",
";",
"h",
"}",
"doc",
"=",... | Creates a new 'cloche'.
There are 2 options :
* :dir : to specify the directory into which the cloche data is store
* :nolock : when set to true, no flock is used
On the Windows platform, :nolock is set to true automatically.
Puts a document (Hash) under the cloche.
If the document is brand new, it will be g... | [
"Creates",
"a",
"new",
"cloche",
"."
] | e038fa69ded7d3de85f151d12d111466aef97aab | https://github.com/jmettraux/rufus-cloche/blob/e038fa69ded7d3de85f151d12d111466aef97aab/lib/rufus/cloche.rb#L75-L108 |
9,371 | jmettraux/rufus-cloche | lib/rufus/cloche.rb | Rufus.Cloche.get_many | def get_many(type, regex=nil, opts={})
opts = opts.inject({}) { |h, (k, v)| h[k.to_s] = v; h }
d = dir_for(type)
return (opts['count'] ? 0 : []) unless File.exist?(d)
regexes = regex ? Array(regex) : nil
docs = []
skipped = 0
limit = opts['limit']
skip = opts['skip'... | ruby | def get_many(type, regex=nil, opts={})
opts = opts.inject({}) { |h, (k, v)| h[k.to_s] = v; h }
d = dir_for(type)
return (opts['count'] ? 0 : []) unless File.exist?(d)
regexes = regex ? Array(regex) : nil
docs = []
skipped = 0
limit = opts['limit']
skip = opts['skip'... | [
"def",
"get_many",
"(",
"type",
",",
"regex",
"=",
"nil",
",",
"opts",
"=",
"{",
"}",
")",
"opts",
"=",
"opts",
".",
"inject",
"(",
"{",
"}",
")",
"{",
"|",
"h",
",",
"(",
"k",
",",
"v",
")",
"|",
"h",
"[",
"k",
".",
"to_s",
"]",
"=",
"... | Given a type, this method will return an array of all the documents for
that type.
A optional second parameter may be used to select, based on a regular
expression, which documents to include (match on the key '_id').
Will return an empty Hash if there is no documents for a given type.
== opts
:skip and :limi... | [
"Given",
"a",
"type",
"this",
"method",
"will",
"return",
"an",
"array",
"of",
"all",
"the",
"documents",
"for",
"that",
"type",
"."
] | e038fa69ded7d3de85f151d12d111466aef97aab | https://github.com/jmettraux/rufus-cloche/blob/e038fa69ded7d3de85f151d12d111466aef97aab/lib/rufus/cloche.rb#L174-L223 |
9,372 | Hermanverschooten/jquery_datepick | lib/jquery_datepick/form_helper.rb | JqueryDatepick.FormHelper.datepicker | def datepicker(object_name, method, options = {}, timepicker = false)
input_tag = JqueryDatepick::Tags.new(object_name, method, self, options)
dp_options, tf_options = input_tag.split_options(options)
tf_options[:value] = input_tag.format_date(tf_options[:value], String.new(dp_options[:dateFormat]))... | ruby | def datepicker(object_name, method, options = {}, timepicker = false)
input_tag = JqueryDatepick::Tags.new(object_name, method, self, options)
dp_options, tf_options = input_tag.split_options(options)
tf_options[:value] = input_tag.format_date(tf_options[:value], String.new(dp_options[:dateFormat]))... | [
"def",
"datepicker",
"(",
"object_name",
",",
"method",
",",
"options",
"=",
"{",
"}",
",",
"timepicker",
"=",
"false",
")",
"input_tag",
"=",
"JqueryDatepick",
"::",
"Tags",
".",
"new",
"(",
"object_name",
",",
"method",
",",
"self",
",",
"options",
")"... | Mehtod that generates datepicker input field inside a form | [
"Mehtod",
"that",
"generates",
"datepicker",
"input",
"field",
"inside",
"a",
"form"
] | 22fd5f4a1d5a95fb942427ae08e5078b293c969b | https://github.com/Hermanverschooten/jquery_datepick/blob/22fd5f4a1d5a95fb942427ae08e5078b293c969b/lib/jquery_datepick/form_helper.rb#L8-L16 |
9,373 | richo/twat | lib/twat/options.rb | Twat.Options.default= | def default=(value)
value = value.to_sym
unless config.accounts.include?(value)
raise NoSuchAccount
end
config[:default] = value
config.save!
end | ruby | def default=(value)
value = value.to_sym
unless config.accounts.include?(value)
raise NoSuchAccount
end
config[:default] = value
config.save!
end | [
"def",
"default",
"=",
"(",
"value",
")",
"value",
"=",
"value",
".",
"to_sym",
"unless",
"config",
".",
"accounts",
".",
"include?",
"(",
"value",
")",
"raise",
"NoSuchAccount",
"end",
"config",
"[",
":default",
"]",
"=",
"value",
"config",
".",
"save!"... | This is deliberately not abstracted (it could be easily accessed from
withing the method_missing method, but that will just lead to nastiness
later when I implement colors, for example. | [
"This",
"is",
"deliberately",
"not",
"abstracted",
"(",
"it",
"could",
"be",
"easily",
"accessed",
"from",
"withing",
"the",
"method_missing",
"method",
"but",
"that",
"will",
"just",
"lead",
"to",
"nastiness",
"later",
"when",
"I",
"implement",
"colors",
"for... | 0354059c2d9643a8c3b855dbb18105fa80bf651e | https://github.com/richo/twat/blob/0354059c2d9643a8c3b855dbb18105fa80bf651e/lib/twat/options.rb#L55-L63 |
9,374 | vojto/active_harmony | lib/active_harmony/queue.rb | ActiveHarmony.Queue.queue_push | def queue_push(object)
queue_item = QueueItem.new( :kind => "push",
:object_type => object.class.name,
:object_local_id => object.id,
:state => "new" )
queue_item.save
end | ruby | def queue_push(object)
queue_item = QueueItem.new( :kind => "push",
:object_type => object.class.name,
:object_local_id => object.id,
:state => "new" )
queue_item.save
end | [
"def",
"queue_push",
"(",
"object",
")",
"queue_item",
"=",
"QueueItem",
".",
"new",
"(",
":kind",
"=>",
"\"push\"",
",",
":object_type",
"=>",
"object",
".",
"class",
".",
"name",
",",
":object_local_id",
"=>",
"object",
".",
"id",
",",
":state",
"=>",
... | Queues object for push
@param [Object] Object | [
"Queues",
"object",
"for",
"push"
] | 03e5c67ea7a1f986c729001c4fec944bf116640f | https://github.com/vojto/active_harmony/blob/03e5c67ea7a1f986c729001c4fec944bf116640f/lib/active_harmony/queue.rb#L8-L14 |
9,375 | vojto/active_harmony | lib/active_harmony/queue.rb | ActiveHarmony.Queue.queue_pull | def queue_pull(object_class, remote_id)
queue_item = QueueItem.new( :kind => "pull",
:object_type => object_class.name,
:object_remote_id => remote_id,
:state => "new" )
queue_item.save
end | ruby | def queue_pull(object_class, remote_id)
queue_item = QueueItem.new( :kind => "pull",
:object_type => object_class.name,
:object_remote_id => remote_id,
:state => "new" )
queue_item.save
end | [
"def",
"queue_pull",
"(",
"object_class",
",",
"remote_id",
")",
"queue_item",
"=",
"QueueItem",
".",
"new",
"(",
":kind",
"=>",
"\"pull\"",
",",
":object_type",
"=>",
"object_class",
".",
"name",
",",
":object_remote_id",
"=>",
"remote_id",
",",
":state",
"=>... | Queues object for pull
@param [Class] Class of object
@param [String] Remote ID for object | [
"Queues",
"object",
"for",
"pull"
] | 03e5c67ea7a1f986c729001c4fec944bf116640f | https://github.com/vojto/active_harmony/blob/03e5c67ea7a1f986c729001c4fec944bf116640f/lib/active_harmony/queue.rb#L20-L26 |
9,376 | xufeisofly/organismo | lib/organismo/element_collection.rb | Organismo.ElementCollection.elements_by_source | def elements_by_source
source_items.map.with_index do |source_item, index|
Organismo::Element.new(source_item, index).create
end
end | ruby | def elements_by_source
source_items.map.with_index do |source_item, index|
Organismo::Element.new(source_item, index).create
end
end | [
"def",
"elements_by_source",
"source_items",
".",
"map",
".",
"with_index",
"do",
"|",
"source_item",
",",
"index",
"|",
"Organismo",
"::",
"Element",
".",
"new",
"(",
"source_item",
",",
"index",
")",
".",
"create",
"end",
"end"
] | initialize elements items | [
"initialize",
"elements",
"items"
] | cc133fc1c6206cb0efbff28daa7c9309481cd03e | https://github.com/xufeisofly/organismo/blob/cc133fc1c6206cb0efbff28daa7c9309481cd03e/lib/organismo/element_collection.rb#L16-L20 |
9,377 | mntnorv/puttext | lib/puttext/po_entry.rb | PutText.POEntry.to_s | def to_s
str = String.new('')
# Add comments
str = add_comment(str, ':', @references.join(' ')) if references?
str = add_comment(str, ',', @flags.join("\n")) if flags?
# Add id and context
str = add_string(str, 'msgctxt', @msgctxt) if @msgctxt
str = add_string(str, 'msgid', @... | ruby | def to_s
str = String.new('')
# Add comments
str = add_comment(str, ':', @references.join(' ')) if references?
str = add_comment(str, ',', @flags.join("\n")) if flags?
# Add id and context
str = add_string(str, 'msgctxt', @msgctxt) if @msgctxt
str = add_string(str, 'msgid', @... | [
"def",
"to_s",
"str",
"=",
"String",
".",
"new",
"(",
"''",
")",
"# Add comments",
"str",
"=",
"add_comment",
"(",
"str",
",",
"':'",
",",
"@references",
".",
"join",
"(",
"' '",
")",
")",
"if",
"references?",
"str",
"=",
"add_comment",
"(",
"str",
"... | Create a new POEntry
@param [Hash] attrs
@option attrs [String] :msgid the id of the string (the string that needs
to be translated). Can include a context, separated from the id by
{NS_SEPARATOR} or by the specified :separator.
@option attrs [String] :msgid_plural the pluralized id of the string (the
plur... | [
"Create",
"a",
"new",
"POEntry"
] | c5c210dff4e11f714418b6b426dc9e2739fe9876 | https://github.com/mntnorv/puttext/blob/c5c210dff4e11f714418b6b426dc9e2739fe9876/lib/puttext/po_entry.rb#L52-L66 |
9,378 | justinkim/tf2r | lib/tf2r/raffle.rb | TF2R.Raffle.info | def info
@info ||= {link_snippet: @link_snippet, title: title,
description: description, start_time: start_time,
end_time: end_time, win_chance: win_chance,
current_entries: current_entries, max_entries: max_entries,
is_done: is_done}
end | ruby | def info
@info ||= {link_snippet: @link_snippet, title: title,
description: description, start_time: start_time,
end_time: end_time, win_chance: win_chance,
current_entries: current_entries, max_entries: max_entries,
is_done: is_done}
end | [
"def",
"info",
"@info",
"||=",
"{",
"link_snippet",
":",
"@link_snippet",
",",
"title",
":",
"title",
",",
"description",
":",
"description",
",",
"start_time",
":",
"start_time",
",",
"end_time",
":",
"end_time",
",",
"win_chance",
":",
"win_chance",
",",
"... | Gives information about the raffle.
@example
r = Raffle.new('kstzcbd')
r.info #=>
{:link_snippet=>"kstzcbd",
:title=>"Just one refined [1 hour]",
:description=>"Plain and simple.",
:start_time=>2012-10-29 09:51:45 -0400,
:end_time=>2012-10-29 09:53:01 -0400,
:win_chance=>0.1,
:current... | [
"Gives",
"information",
"about",
"the",
"raffle",
"."
] | 20d9648fe1048d9b2a34064821d8c95aaff505da | https://github.com/justinkim/tf2r/blob/20d9648fe1048d9b2a34064821d8c95aaff505da/lib/tf2r/raffle.rb#L46-L52 |
9,379 | justinkim/tf2r | lib/tf2r/raffle.rb | TF2R.Raffle.populate_raffle_info | def populate_raffle_info
threads = []
threads << Thread.new do
@api_info = API.raffle_info(@link_snippet)
end
threads << Thread.new do
page = @scraper.fetch(raffle_link(@link_snippet))
@scraper_info = @scraper.scrape_raffle(page)
end
threads.each { |t| t.join... | ruby | def populate_raffle_info
threads = []
threads << Thread.new do
@api_info = API.raffle_info(@link_snippet)
end
threads << Thread.new do
page = @scraper.fetch(raffle_link(@link_snippet))
@scraper_info = @scraper.scrape_raffle(page)
end
threads.each { |t| t.join... | [
"def",
"populate_raffle_info",
"threads",
"=",
"[",
"]",
"threads",
"<<",
"Thread",
".",
"new",
"do",
"@api_info",
"=",
"API",
".",
"raffle_info",
"(",
"@link_snippet",
")",
"end",
"threads",
"<<",
"Thread",
".",
"new",
"do",
"page",
"=",
"@scraper",
".",
... | Asynchronously makes network connections to TF2R to query its API and
scrape the raffle page. | [
"Asynchronously",
"makes",
"network",
"connections",
"to",
"TF2R",
"to",
"query",
"its",
"API",
"and",
"scrape",
"the",
"raffle",
"page",
"."
] | 20d9648fe1048d9b2a34064821d8c95aaff505da | https://github.com/justinkim/tf2r/blob/20d9648fe1048d9b2a34064821d8c95aaff505da/lib/tf2r/raffle.rb#L76-L87 |
9,380 | justinkim/tf2r | lib/tf2r/raffle.rb | TF2R.Raffle.normalize_entries | def normalize_entries(entries)
entries.map do |entry|
entry[:steam_id] = extract_steam_id entry.delete('link')
entry[:username] = entry.delete('name')
entry[:color] = entry.delete('color').downcase.strip
entry[:avatar_link] = entry.delete('avatar')
end
entries
end | ruby | def normalize_entries(entries)
entries.map do |entry|
entry[:steam_id] = extract_steam_id entry.delete('link')
entry[:username] = entry.delete('name')
entry[:color] = entry.delete('color').downcase.strip
entry[:avatar_link] = entry.delete('avatar')
end
entries
end | [
"def",
"normalize_entries",
"(",
"entries",
")",
"entries",
".",
"map",
"do",
"|",
"entry",
"|",
"entry",
"[",
":steam_id",
"]",
"=",
"extract_steam_id",
"entry",
".",
"delete",
"(",
"'link'",
")",
"entry",
"[",
":username",
"]",
"=",
"entry",
".",
"dele... | Converts the representation of participants by TF2R's API into our own
standard representation. | [
"Converts",
"the",
"representation",
"of",
"participants",
"by",
"TF2R",
"s",
"API",
"into",
"our",
"own",
"standard",
"representation",
"."
] | 20d9648fe1048d9b2a34064821d8c95aaff505da | https://github.com/justinkim/tf2r/blob/20d9648fe1048d9b2a34064821d8c95aaff505da/lib/tf2r/raffle.rb#L96-L104 |
9,381 | moviepilot/andromeda | lib/andromeda/spot.rb | Andromeda.Spot.post_to | def post_to(track, data, tags_in = {})
tags_in = (here.tags.identical_copy.update(tags_in) rescue tags_in) if here
plan.post_data self, track, data, tags_in
self
end | ruby | def post_to(track, data, tags_in = {})
tags_in = (here.tags.identical_copy.update(tags_in) rescue tags_in) if here
plan.post_data self, track, data, tags_in
self
end | [
"def",
"post_to",
"(",
"track",
",",
"data",
",",
"tags_in",
"=",
"{",
"}",
")",
"tags_in",
"=",
"(",
"here",
".",
"tags",
".",
"identical_copy",
".",
"update",
"(",
"tags_in",
")",
"rescue",
"tags_in",
")",
"if",
"here",
"plan",
".",
"post_data",
"s... | Post data with the associated tags_in to this's spot's plan's method spot with name name
and hint that the caller requested the spot activation to be executed on track tack
@param [Track] track requested target track
@param [Any] data any data event
@param [Hash] tags to be passed along
@return [self] | [
"Post",
"data",
"with",
"the",
"associated",
"tags_in",
"to",
"this",
"s",
"spot",
"s",
"plan",
"s",
"method",
"spot",
"with",
"name",
"name",
"and",
"hint",
"that",
"the",
"caller",
"requested",
"the",
"spot",
"activation",
"to",
"be",
"executed",
"on",
... | 68e6bac3cdb798046dbfa0e08314e7a40c938927 | https://github.com/moviepilot/andromeda/blob/68e6bac3cdb798046dbfa0e08314e7a40c938927/lib/andromeda/spot.rb#L83-L87 |
9,382 | fenton-project/fenton_shell | lib/fenton_shell/organization.rb | FentonShell.Organization.organization_create | def organization_create(global_options, options)
result = Excon.post(
"#{global_options[:fenton_server_url]}/organizations.json",
body: organization_json(options),
headers: { 'Content-Type' => 'application/json' }
)
[result.status, JSON.parse(result.body)]
end | ruby | def organization_create(global_options, options)
result = Excon.post(
"#{global_options[:fenton_server_url]}/organizations.json",
body: organization_json(options),
headers: { 'Content-Type' => 'application/json' }
)
[result.status, JSON.parse(result.body)]
end | [
"def",
"organization_create",
"(",
"global_options",
",",
"options",
")",
"result",
"=",
"Excon",
".",
"post",
"(",
"\"#{global_options[:fenton_server_url]}/organizations.json\"",
",",
"body",
":",
"organization_json",
"(",
"options",
")",
",",
"headers",
":",
"{",
... | Sends a post request with json from the command line organization
@param global_options [Hash] global command line options
@param options [Hash] json fields to send to fenton server
@return [Fixnum] http status code
@return [String] message back from fenton server | [
"Sends",
"a",
"post",
"request",
"with",
"json",
"from",
"the",
"command",
"line",
"organization"
] | 6e1d76186fa7ee7a3be141afad9361e3a3e0ec91 | https://github.com/fenton-project/fenton_shell/blob/6e1d76186fa7ee7a3be141afad9361e3a3e0ec91/lib/fenton_shell/organization.rb#L35-L43 |
9,383 | futurechimp/drafter | lib/drafter/creation.rb | Drafter.Creation.save_draft | def save_draft(parent_draft=nil, parent_association_name=nil)
if valid?
do_create_draft(parent_draft, parent_association_name)
create_subdrafts
end
return self.draft.reload if self.draft
end | ruby | def save_draft(parent_draft=nil, parent_association_name=nil)
if valid?
do_create_draft(parent_draft, parent_association_name)
create_subdrafts
end
return self.draft.reload if self.draft
end | [
"def",
"save_draft",
"(",
"parent_draft",
"=",
"nil",
",",
"parent_association_name",
"=",
"nil",
")",
"if",
"valid?",
"do_create_draft",
"(",
"parent_draft",
",",
"parent_association_name",
")",
"create_subdrafts",
"end",
"return",
"self",
".",
"draft",
".",
"rel... | Build and save the draft when told to do so. | [
"Build",
"and",
"save",
"the",
"draft",
"when",
"told",
"to",
"do",
"so",
"."
] | 8308b922148a6a44280023b0ef33d48a41f2e83e | https://github.com/futurechimp/drafter/blob/8308b922148a6a44280023b0ef33d48a41f2e83e/lib/drafter/creation.rb#L14-L20 |
9,384 | futurechimp/drafter | lib/drafter/creation.rb | Drafter.Creation.build_draft_uploads | def build_draft_uploads
self.attributes.keys.each do |key|
if (self.respond_to?(key) &&
self.send(key).is_a?(CarrierWave::Uploader::Base) &&
self.send(key).file)
self.draft.draft_uploads << build_draft_upload(key)
end
end
end | ruby | def build_draft_uploads
self.attributes.keys.each do |key|
if (self.respond_to?(key) &&
self.send(key).is_a?(CarrierWave::Uploader::Base) &&
self.send(key).file)
self.draft.draft_uploads << build_draft_upload(key)
end
end
end | [
"def",
"build_draft_uploads",
"self",
".",
"attributes",
".",
"keys",
".",
"each",
"do",
"|",
"key",
"|",
"if",
"(",
"self",
".",
"respond_to?",
"(",
"key",
")",
"&&",
"self",
".",
"send",
"(",
"key",
")",
".",
"is_a?",
"(",
"CarrierWave",
"::",
"Upl... | Loop through and create DraftUpload objects for any Carrierwave
uploaders mounted on this draftable object.
@param [Hash] attrs the attributes to loop through
@return [Array<DraftUpload>] an array of unsaved DraftUpload objects. | [
"Loop",
"through",
"and",
"create",
"DraftUpload",
"objects",
"for",
"any",
"Carrierwave",
"uploaders",
"mounted",
"on",
"this",
"draftable",
"object",
"."
] | 8308b922148a6a44280023b0ef33d48a41f2e83e | https://github.com/futurechimp/drafter/blob/8308b922148a6a44280023b0ef33d48a41f2e83e/lib/drafter/creation.rb#L54-L62 |
9,385 | futurechimp/drafter | lib/drafter/creation.rb | Drafter.Creation.build_draft_upload | def build_draft_upload(key)
cw_uploader = self.send(key)
file = File.new(cw_uploader.file.path) if cw_uploader.file
existing_upload = self.draft.draft_uploads.where(:draftable_mount_column => key).first
draft_upload = existing_upload.nil? ? DraftUpload.new : existing_upload
draft... | ruby | def build_draft_upload(key)
cw_uploader = self.send(key)
file = File.new(cw_uploader.file.path) if cw_uploader.file
existing_upload = self.draft.draft_uploads.where(:draftable_mount_column => key).first
draft_upload = existing_upload.nil? ? DraftUpload.new : existing_upload
draft... | [
"def",
"build_draft_upload",
"(",
"key",
")",
"cw_uploader",
"=",
"self",
".",
"send",
"(",
"key",
")",
"file",
"=",
"File",
".",
"new",
"(",
"cw_uploader",
".",
"file",
".",
"path",
")",
"if",
"cw_uploader",
".",
"file",
"existing_upload",
"=",
"self",
... | Get a reference to the CarrierWave uploader mounted on the
current draftable object, grab the file in it, and shove
that file into a new DraftUpload.
@param [String] key the attribute where the CarrierWave uploader
is mounted.
@return [DraftUpload] containing the file in the uploader. | [
"Get",
"a",
"reference",
"to",
"the",
"CarrierWave",
"uploader",
"mounted",
"on",
"the",
"current",
"draftable",
"object",
"grab",
"the",
"file",
"in",
"it",
"and",
"shove",
"that",
"file",
"into",
"a",
"new",
"DraftUpload",
"."
] | 8308b922148a6a44280023b0ef33d48a41f2e83e | https://github.com/futurechimp/drafter/blob/8308b922148a6a44280023b0ef33d48a41f2e83e/lib/drafter/creation.rb#L71-L79 |
9,386 | jnicklas/eb_nested_set | lib/eb_nested_set.rb | EvenBetterNestedSet.NestedSet.root | def root(force_reload=nil)
@root = nil if force_reload
@root ||= transaction do
reload_boundaries
base_class.roots.find(:first, :conditions => ["#{nested_set_column(:left)} <= ? AND #{nested_set_column(:right)} >= ?", left, right])
end
end | ruby | def root(force_reload=nil)
@root = nil if force_reload
@root ||= transaction do
reload_boundaries
base_class.roots.find(:first, :conditions => ["#{nested_set_column(:left)} <= ? AND #{nested_set_column(:right)} >= ?", left, right])
end
end | [
"def",
"root",
"(",
"force_reload",
"=",
"nil",
")",
"@root",
"=",
"nil",
"if",
"force_reload",
"@root",
"||=",
"transaction",
"do",
"reload_boundaries",
"base_class",
".",
"roots",
".",
"find",
"(",
":first",
",",
":conditions",
"=>",
"[",
"\"#{nested_set_col... | Finds the root node that this node descends from
@param [Boolean] force_reload forces the root node to be reloaded
@return [ActiveRecord::Base] node the root node this descends from | [
"Finds",
"the",
"root",
"node",
"that",
"this",
"node",
"descends",
"from"
] | 71b7b71030116097e79a7bef02e77daedf9d3eae | https://github.com/jnicklas/eb_nested_set/blob/71b7b71030116097e79a7bef02e77daedf9d3eae/lib/eb_nested_set.rb#L206-L212 |
9,387 | jnicklas/eb_nested_set | lib/eb_nested_set.rb | EvenBetterNestedSet.NestedSet.family_ids | def family_ids(force_reload=false)
return @family_ids unless @family_ids.nil? or force_reload
transaction do
reload_boundaries
query = "SELECT id FROM #{self.class.quote_db_property(base_class.table_name)} " +
"WHERE #{nested_set_column(:left)} >= #{left} AND #{nested... | ruby | def family_ids(force_reload=false)
return @family_ids unless @family_ids.nil? or force_reload
transaction do
reload_boundaries
query = "SELECT id FROM #{self.class.quote_db_property(base_class.table_name)} " +
"WHERE #{nested_set_column(:left)} >= #{left} AND #{nested... | [
"def",
"family_ids",
"(",
"force_reload",
"=",
"false",
")",
"return",
"@family_ids",
"unless",
"@family_ids",
".",
"nil?",
"or",
"force_reload",
"transaction",
"do",
"reload_boundaries",
"query",
"=",
"\"SELECT id FROM #{self.class.quote_db_property(base_class.table_name)} \... | Returns the ids of the node and all nodes that descend from it.
@return [Array[Integer]] | [
"Returns",
"the",
"ids",
"of",
"the",
"node",
"and",
"all",
"nodes",
"that",
"descend",
"from",
"it",
"."
] | 71b7b71030116097e79a7bef02e77daedf9d3eae | https://github.com/jnicklas/eb_nested_set/blob/71b7b71030116097e79a7bef02e77daedf9d3eae/lib/eb_nested_set.rb#L279-L289 |
9,388 | jnicklas/eb_nested_set | lib/eb_nested_set.rb | EvenBetterNestedSet.NestedSet.recalculate_nested_set | def recalculate_nested_set(left) #:nodoc:
child_left = left + 1
children.each do |child|
child_left = child.recalculate_nested_set(child_left)
end
set_boundaries(left, child_left)
save_without_validation!
right + 1
end | ruby | def recalculate_nested_set(left) #:nodoc:
child_left = left + 1
children.each do |child|
child_left = child.recalculate_nested_set(child_left)
end
set_boundaries(left, child_left)
save_without_validation!
right + 1
end | [
"def",
"recalculate_nested_set",
"(",
"left",
")",
"#:nodoc:",
"child_left",
"=",
"left",
"+",
"1",
"children",
".",
"each",
"do",
"|",
"child",
"|",
"child_left",
"=",
"child",
".",
"recalculate_nested_set",
"(",
"child_left",
")",
"end",
"set_boundaries",
"(... | Rebuild this node's childrens boundaries | [
"Rebuild",
"this",
"node",
"s",
"childrens",
"boundaries"
] | 71b7b71030116097e79a7bef02e77daedf9d3eae | https://github.com/jnicklas/eb_nested_set/blob/71b7b71030116097e79a7bef02e77daedf9d3eae/lib/eb_nested_set.rb#L363-L372 |
9,389 | mabarroso/lleidasms | lib/lleidasms/client.rb | Lleidasms.Client.send_waplink | def send_waplink number, url, message
cmd_waplink number, url, message
if wait
wait_for last_label
return false if @response_cmd.eql? 'NOOK'
return "#{@response_args[0]}.#{@response_args[1]}".to_f
end
end | ruby | def send_waplink number, url, message
cmd_waplink number, url, message
if wait
wait_for last_label
return false if @response_cmd.eql? 'NOOK'
return "#{@response_args[0]}.#{@response_args[1]}".to_f
end
end | [
"def",
"send_waplink",
"number",
",",
"url",
",",
"message",
"cmd_waplink",
"number",
",",
"url",
",",
"message",
"if",
"wait",
"wait_for",
"last_label",
"return",
"false",
"if",
"@response_cmd",
".",
"eql?",
"'NOOK'",
"return",
"\"#{@response_args[0]}.#{@response_a... | number
The telephone number
url
The URL to content. Usually a image, tone or application
message
Information text before downloading content | [
"number",
"The",
"telephone",
"number",
"url",
"The",
"URL",
"to",
"content",
".",
"Usually",
"a",
"image",
"tone",
"or",
"application",
"message",
"Information",
"text",
"before",
"downloading",
"content"
] | 419d37d9a25cc73548e5d9e8ac86bc24f35793ee | https://github.com/mabarroso/lleidasms/blob/419d37d9a25cc73548e5d9e8ac86bc24f35793ee/lib/lleidasms/client.rb#L100-L108 |
9,390 | mabarroso/lleidasms | lib/lleidasms/client.rb | Lleidasms.Client.add_addressee | def add_addressee addressees, wait = true
@addressees_accepted = false
@addressees_rejected = false
if addressees.kind_of?(Array)
addressees = addressees.join ' '
end
cmd_dst addressees
while wait && !@addressees_accepted
wait_for last_label
retur... | ruby | def add_addressee addressees, wait = true
@addressees_accepted = false
@addressees_rejected = false
if addressees.kind_of?(Array)
addressees = addressees.join ' '
end
cmd_dst addressees
while wait && !@addressees_accepted
wait_for last_label
retur... | [
"def",
"add_addressee",
"addressees",
",",
"wait",
"=",
"true",
"@addressees_accepted",
"=",
"false",
"@addressees_rejected",
"=",
"false",
"if",
"addressees",
".",
"kind_of?",
"(",
"Array",
")",
"addressees",
"=",
"addressees",
".",
"join",
"' '",
"end",
"cmd_d... | Add telephone numbers into the massive send list.
It is recommended not to send more than 50 in each call
Return TRUE if ok
- see accepted in *last_addressees_accepted*
- see rejected in *last_addressees_rejected* | [
"Add",
"telephone",
"numbers",
"into",
"the",
"massive",
"send",
"list",
".",
"It",
"is",
"recommended",
"not",
"to",
"send",
"more",
"than",
"50",
"in",
"each",
"call"
] | 419d37d9a25cc73548e5d9e8ac86bc24f35793ee | https://github.com/mabarroso/lleidasms/blob/419d37d9a25cc73548e5d9e8ac86bc24f35793ee/lib/lleidasms/client.rb#L116-L129 |
9,391 | mabarroso/lleidasms | lib/lleidasms/client.rb | Lleidasms.Client.msg | def msg message, wait = true
cmd_msg message
return false unless wait_for(last_label) if wait
return @response_args
end | ruby | def msg message, wait = true
cmd_msg message
return false unless wait_for(last_label) if wait
return @response_args
end | [
"def",
"msg",
"message",
",",
"wait",
"=",
"true",
"cmd_msg",
"message",
"return",
"false",
"unless",
"wait_for",
"(",
"last_label",
")",
"if",
"wait",
"return",
"@response_args",
"end"
] | Set the message for the massive send list | [
"Set",
"the",
"message",
"for",
"the",
"massive",
"send",
"list"
] | 419d37d9a25cc73548e5d9e8ac86bc24f35793ee | https://github.com/mabarroso/lleidasms/blob/419d37d9a25cc73548e5d9e8ac86bc24f35793ee/lib/lleidasms/client.rb#L140-L144 |
9,392 | astjohn/cornerstone | app/mailers/cornerstone/cornerstone_mailer.rb | Cornerstone.CornerstoneMailer.new_post | def new_post(name, email, post, discussion)
@post = post
@discussion = discussion
@name = name
mail :to => email,
:subject => I18n.t('cornerstone.cornerstone_mailer.new_post.subject',
:topic => @discussion.subject)
end | ruby | def new_post(name, email, post, discussion)
@post = post
@discussion = discussion
@name = name
mail :to => email,
:subject => I18n.t('cornerstone.cornerstone_mailer.new_post.subject',
:topic => @discussion.subject)
end | [
"def",
"new_post",
"(",
"name",
",",
"email",
",",
"post",
",",
"discussion",
")",
"@post",
"=",
"post",
"@discussion",
"=",
"discussion",
"@name",
"=",
"name",
"mail",
":to",
"=>",
"email",
",",
":subject",
"=>",
"I18n",
".",
"t",
"(",
"'cornerstone.cor... | Email a single participant within a discussion - refer to post observer | [
"Email",
"a",
"single",
"participant",
"within",
"a",
"discussion",
"-",
"refer",
"to",
"post",
"observer"
] | d7af7c06288477c961f3e328b8640df4be337301 | https://github.com/astjohn/cornerstone/blob/d7af7c06288477c961f3e328b8640df4be337301/app/mailers/cornerstone/cornerstone_mailer.rb#L20-L28 |
9,393 | gouravtiwari/beam | lib/beam/upload.rb | Beam.Upload.validate_record | def validate_record(errors_count, row_hash, index)
record = new(row_hash)
unless record.valid?
errors_count += 1
[nil, errors_count, log_and_return_validation_error(record, row_hash, index)]
else
[record, errors_count, nil]
end
end | ruby | def validate_record(errors_count, row_hash, index)
record = new(row_hash)
unless record.valid?
errors_count += 1
[nil, errors_count, log_and_return_validation_error(record, row_hash, index)]
else
[record, errors_count, nil]
end
end | [
"def",
"validate_record",
"(",
"errors_count",
",",
"row_hash",
",",
"index",
")",
"record",
"=",
"new",
"(",
"row_hash",
")",
"unless",
"record",
".",
"valid?",
"errors_count",
"+=",
"1",
"[",
"nil",
",",
"errors_count",
",",
"log_and_return_validation_error",
... | Validates each record and returns error count if record is invalid | [
"Validates",
"each",
"record",
"and",
"returns",
"error",
"count",
"if",
"record",
"is",
"invalid"
] | 074f0d515b84cde319e95b18bd55e456400c3ab6 | https://github.com/gouravtiwari/beam/blob/074f0d515b84cde319e95b18bd55e456400c3ab6/lib/beam/upload.rb#L82-L90 |
9,394 | webco/tuiter | lib/tuiter/utils.rb | Tuiter.Request.create_http_request | def create_http_request(http_method, path, *arguments)
http_method = http_method.to_sym
if [:post, :put].include?(http_method)
data = arguments.shift
end
headers = arguments.first.is_a?(Hash) ? arguments.shift : {}
case http_method
when :post
reques... | ruby | def create_http_request(http_method, path, *arguments)
http_method = http_method.to_sym
if [:post, :put].include?(http_method)
data = arguments.shift
end
headers = arguments.first.is_a?(Hash) ? arguments.shift : {}
case http_method
when :post
reques... | [
"def",
"create_http_request",
"(",
"http_method",
",",
"path",
",",
"*",
"arguments",
")",
"http_method",
"=",
"http_method",
".",
"to_sym",
"if",
"[",
":post",
",",
":put",
"]",
".",
"include?",
"(",
"http_method",
")",
"data",
"=",
"arguments",
".",
"shi... | snippet based on oauth gem | [
"snippet",
"based",
"on",
"oauth",
"gem"
] | ace7b8f8fc973ec3dbb59e6f80cf98f9f705d777 | https://github.com/webco/tuiter/blob/ace7b8f8fc973ec3dbb59e6f80cf98f9f705d777/lib/tuiter/utils.rb#L95-L130 |
9,395 | fotonauts/activr | lib/activr/registry.rb | Activr.Registry.timeline_entries | def timeline_entries
@timeline_entries ||= begin
result = { }
self.timelines.each do |(timeline_kind, timeline_class)|
dir_name = Activr::Utils.kind_for_class(timeline_class)
dir_path = File.join(Activr.timelines_path, dir_name)
if !File.directory?(dir_path)
... | ruby | def timeline_entries
@timeline_entries ||= begin
result = { }
self.timelines.each do |(timeline_kind, timeline_class)|
dir_name = Activr::Utils.kind_for_class(timeline_class)
dir_path = File.join(Activr.timelines_path, dir_name)
if !File.directory?(dir_path)
... | [
"def",
"timeline_entries",
"@timeline_entries",
"||=",
"begin",
"result",
"=",
"{",
"}",
"self",
".",
"timelines",
".",
"each",
"do",
"|",
"(",
"timeline_kind",
",",
"timeline_class",
")",
"|",
"dir_name",
"=",
"Activr",
"::",
"Utils",
".",
"kind_for_class",
... | Get all registered timeline entries
@return [Hash{String=>Hash{String=>Class}}] A hash of `<timeline kind> => { <route kind> => <timeline entry class>, ... }` | [
"Get",
"all",
"registered",
"timeline",
"entries"
] | 92c071ad18a76d4130661da3ce47c1f0fb8ae913 | https://github.com/fotonauts/activr/blob/92c071ad18a76d4130661da3ce47c1f0fb8ae913/lib/activr/registry.rb#L70-L114 |
9,396 | fotonauts/activr | lib/activr/registry.rb | Activr.Registry.class_for_timeline_entry | def class_for_timeline_entry(timeline_kind, route_kind)
(self.timeline_entries[timeline_kind] && self.timeline_entries[timeline_kind][route_kind]) || Activr::Timeline::Entry
end | ruby | def class_for_timeline_entry(timeline_kind, route_kind)
(self.timeline_entries[timeline_kind] && self.timeline_entries[timeline_kind][route_kind]) || Activr::Timeline::Entry
end | [
"def",
"class_for_timeline_entry",
"(",
"timeline_kind",
",",
"route_kind",
")",
"(",
"self",
".",
"timeline_entries",
"[",
"timeline_kind",
"]",
"&&",
"self",
".",
"timeline_entries",
"[",
"timeline_kind",
"]",
"[",
"route_kind",
"]",
")",
"||",
"Activr",
"::",... | Get class for timeline entry corresponding to given route in given timeline
@param timeline_kind [String] Timeline kind
@param route_kind [String] Route kind
@return [Class] Timeline entry class | [
"Get",
"class",
"for",
"timeline",
"entry",
"corresponding",
"to",
"given",
"route",
"in",
"given",
"timeline"
] | 92c071ad18a76d4130661da3ce47c1f0fb8ae913 | https://github.com/fotonauts/activr/blob/92c071ad18a76d4130661da3ce47c1f0fb8ae913/lib/activr/registry.rb#L121-L123 |
9,397 | fotonauts/activr | lib/activr/registry.rb | Activr.Registry.add_entity | def add_entity(entity_name, entity_options, activity_klass)
entity_name = entity_name.to_sym
if @entity_classes[entity_name] && (@entity_classes[entity_name].name != entity_options[:class].name)
# otherwise this would break timeline entries deletion mecanism
raise "Entity name #{entity_name... | ruby | def add_entity(entity_name, entity_options, activity_klass)
entity_name = entity_name.to_sym
if @entity_classes[entity_name] && (@entity_classes[entity_name].name != entity_options[:class].name)
# otherwise this would break timeline entries deletion mecanism
raise "Entity name #{entity_name... | [
"def",
"add_entity",
"(",
"entity_name",
",",
"entity_options",
",",
"activity_klass",
")",
"entity_name",
"=",
"entity_name",
".",
"to_sym",
"if",
"@entity_classes",
"[",
"entity_name",
"]",
"&&",
"(",
"@entity_classes",
"[",
"entity_name",
"]",
".",
"name",
"!... | Register an entity
@param entity_name [Symbol] Entity name
@param entity_options [Hash] Entity options
@param activity_klass [Class] Activity class that uses that entity | [
"Register",
"an",
"entity"
] | 92c071ad18a76d4130661da3ce47c1f0fb8ae913 | https://github.com/fotonauts/activr/blob/92c071ad18a76d4130661da3ce47c1f0fb8ae913/lib/activr/registry.rb#L164-L188 |
9,398 | fotonauts/activr | lib/activr/registry.rb | Activr.Registry.activity_entities_for_model | def activity_entities_for_model(model_class)
@activity_entities_for_model[model_class] ||= begin
result = [ ]
@entity_classes.each do |entity_name, entity_class|
result << entity_name if (entity_class == model_class)
end
result
end
end | ruby | def activity_entities_for_model(model_class)
@activity_entities_for_model[model_class] ||= begin
result = [ ]
@entity_classes.each do |entity_name, entity_class|
result << entity_name if (entity_class == model_class)
end
result
end
end | [
"def",
"activity_entities_for_model",
"(",
"model_class",
")",
"@activity_entities_for_model",
"[",
"model_class",
"]",
"||=",
"begin",
"result",
"=",
"[",
"]",
"@entity_classes",
".",
"each",
"do",
"|",
"entity_name",
",",
"entity_class",
"|",
"result",
"<<",
"en... | Get all entities names for given model class | [
"Get",
"all",
"entities",
"names",
"for",
"given",
"model",
"class"
] | 92c071ad18a76d4130661da3ce47c1f0fb8ae913 | https://github.com/fotonauts/activr/blob/92c071ad18a76d4130661da3ce47c1f0fb8ae913/lib/activr/registry.rb#L209-L219 |
9,399 | fotonauts/activr | lib/activr/registry.rb | Activr.Registry.timeline_entities_for_model | def timeline_entities_for_model(model_class)
@timeline_entities_for_model[model_class] ||= begin
result = { }
self.timelines.each do |timeline_kind, timeline_class|
result[timeline_class] = [ ]
timeline_class.routes.each do |route|
entities_ary = @activity_entitie... | ruby | def timeline_entities_for_model(model_class)
@timeline_entities_for_model[model_class] ||= begin
result = { }
self.timelines.each do |timeline_kind, timeline_class|
result[timeline_class] = [ ]
timeline_class.routes.each do |route|
entities_ary = @activity_entitie... | [
"def",
"timeline_entities_for_model",
"(",
"model_class",
")",
"@timeline_entities_for_model",
"[",
"model_class",
"]",
"||=",
"begin",
"result",
"=",
"{",
"}",
"self",
".",
"timelines",
".",
"each",
"do",
"|",
"timeline_kind",
",",
"timeline_class",
"|",
"result"... | Get all entities names by timelines that can have a reference to given model class
@param model_class [Class] Model class
@return [Hash{Class=>Array<Symbol>}] Lists of entities names indexed by timeline class | [
"Get",
"all",
"entities",
"names",
"by",
"timelines",
"that",
"can",
"have",
"a",
"reference",
"to",
"given",
"model",
"class"
] | 92c071ad18a76d4130661da3ce47c1f0fb8ae913 | https://github.com/fotonauts/activr/blob/92c071ad18a76d4130661da3ce47c1f0fb8ae913/lib/activr/registry.rb#L225-L244 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.