id int32 0 24.9k | repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 |
|---|---|---|---|---|---|---|---|---|---|---|---|
7,200 | timotheeguerin/clin | lib/clin/command_mixin/options.rb | Clin::CommandMixin::Options.ClassMethods.list_option | def list_option(name, description, **config)
add_option Clin::OptionList.new(name, description, **config)
end | ruby | def list_option(name, description, **config)
add_option Clin::OptionList.new(name, description, **config)
end | [
"def",
"list_option",
"(",
"name",
",",
"description",
",",
"**",
"config",
")",
"add_option",
"Clin",
"::",
"OptionList",
".",
"new",
"(",
"name",
",",
"description",
",",
"**",
"config",
")",
"end"
] | Add a list option.
@see Clin::OptionList#initialize | [
"Add",
"a",
"list",
"option",
"."
] | 43d41c47f9c652065ab7ce636d48a9fe1754135e | https://github.com/timotheeguerin/clin/blob/43d41c47f9c652065ab7ce636d48a9fe1754135e/lib/clin/command_mixin/options.rb#L53-L55 |
7,201 | timotheeguerin/clin | lib/clin/command_mixin/options.rb | Clin::CommandMixin::Options.ClassMethods.list_flag_option | def list_flag_option(name, description, **config)
add_option Clin::OptionList.new(name, description, **config.merge(argument: false))
end | ruby | def list_flag_option(name, description, **config)
add_option Clin::OptionList.new(name, description, **config.merge(argument: false))
end | [
"def",
"list_flag_option",
"(",
"name",
",",
"description",
",",
"**",
"config",
")",
"add_option",
"Clin",
"::",
"OptionList",
".",
"new",
"(",
"name",
",",
"description",
",",
"**",
"config",
".",
"merge",
"(",
"argument",
":",
"false",
")",
")",
"end"... | Add a list options that don't take arguments
Same as .list_option but set +argument+ to false
@see Clin::OptionList#initialize | [
"Add",
"a",
"list",
"options",
"that",
"don",
"t",
"take",
"arguments",
"Same",
"as",
".",
"list_option",
"but",
"set",
"+",
"argument",
"+",
"to",
"false"
] | 43d41c47f9c652065ab7ce636d48a9fe1754135e | https://github.com/timotheeguerin/clin/blob/43d41c47f9c652065ab7ce636d48a9fe1754135e/lib/clin/command_mixin/options.rb#L60-L62 |
7,202 | timotheeguerin/clin | lib/clin/command_mixin/options.rb | Clin::CommandMixin::Options.ClassMethods.general_option | def general_option(option_cls, config = {})
option_cls = option_cls.constantize if option_cls.is_a? String
@general_options[option_cls] = option_cls.new(config)
end | ruby | def general_option(option_cls, config = {})
option_cls = option_cls.constantize if option_cls.is_a? String
@general_options[option_cls] = option_cls.new(config)
end | [
"def",
"general_option",
"(",
"option_cls",
",",
"config",
"=",
"{",
"}",
")",
"option_cls",
"=",
"option_cls",
".",
"constantize",
"if",
"option_cls",
".",
"is_a?",
"String",
"@general_options",
"[",
"option_cls",
"]",
"=",
"option_cls",
".",
"new",
"(",
"c... | Add a general option
@param option_cls [Class<GeneralOption>] Class inherited from GeneralOption
@param config [Hash] General option config. Check the general option config. | [
"Add",
"a",
"general",
"option"
] | 43d41c47f9c652065ab7ce636d48a9fe1754135e | https://github.com/timotheeguerin/clin/blob/43d41c47f9c652065ab7ce636d48a9fe1754135e/lib/clin/command_mixin/options.rb#L78-L81 |
7,203 | timotheeguerin/clin | lib/clin/command_mixin/options.rb | Clin::CommandMixin::Options.ClassMethods.remove_general_option | def remove_general_option(option_cls)
option_cls = option_cls.constantize if option_cls.is_a? String
@general_options.delete(option_cls)
end | ruby | def remove_general_option(option_cls)
option_cls = option_cls.constantize if option_cls.is_a? String
@general_options.delete(option_cls)
end | [
"def",
"remove_general_option",
"(",
"option_cls",
")",
"option_cls",
"=",
"option_cls",
".",
"constantize",
"if",
"option_cls",
".",
"is_a?",
"String",
"@general_options",
".",
"delete",
"(",
"option_cls",
")",
"end"
] | Remove a general option
Might be useful if a parent added the option but is not needed in this child. | [
"Remove",
"a",
"general",
"option",
"Might",
"be",
"useful",
"if",
"a",
"parent",
"added",
"the",
"option",
"but",
"is",
"not",
"needed",
"in",
"this",
"child",
"."
] | 43d41c47f9c652065ab7ce636d48a9fe1754135e | https://github.com/timotheeguerin/clin/blob/43d41c47f9c652065ab7ce636d48a9fe1754135e/lib/clin/command_mixin/options.rb#L85-L88 |
7,204 | timotheeguerin/clin | lib/clin/command_mixin/options.rb | Clin::CommandMixin::Options.ClassMethods.option_defaults | def option_defaults
out = {}
@specific_options.each do |option|
option.load_default(out)
end
@general_options.each do |_cls, option|
out.merge! option.class.option_defaults
end
out
end | ruby | def option_defaults
out = {}
@specific_options.each do |option|
option.load_default(out)
end
@general_options.each do |_cls, option|
out.merge! option.class.option_defaults
end
out
end | [
"def",
"option_defaults",
"out",
"=",
"{",
"}",
"@specific_options",
".",
"each",
"do",
"|",
"option",
"|",
"option",
".",
"load_default",
"(",
"out",
")",
"end",
"@general_options",
".",
"each",
"do",
"|",
"_cls",
",",
"option",
"|",
"out",
".",
"merge!... | To be called inside OptionParser block
Extract the option in the command line using the OptionParser and map it to the out map.
@return [Hash] Where the options shall be extracted | [
"To",
"be",
"called",
"inside",
"OptionParser",
"block",
"Extract",
"the",
"option",
"in",
"the",
"command",
"line",
"using",
"the",
"OptionParser",
"and",
"map",
"it",
"to",
"the",
"out",
"map",
"."
] | 43d41c47f9c652065ab7ce636d48a9fe1754135e | https://github.com/timotheeguerin/clin/blob/43d41c47f9c652065ab7ce636d48a9fe1754135e/lib/clin/command_mixin/options.rb#L93-L103 |
7,205 | dmerrick/lights_app | lib/philips_hue/bridge.rb | PhilipsHue.Bridge.add_all_lights | def add_all_lights
all_lights = []
overview["lights"].each do |id, light|
all_lights << add_light(id.to_i, light["name"])
end
all_lights
end | ruby | def add_all_lights
all_lights = []
overview["lights"].each do |id, light|
all_lights << add_light(id.to_i, light["name"])
end
all_lights
end | [
"def",
"add_all_lights",
"all_lights",
"=",
"[",
"]",
"overview",
"[",
"\"lights\"",
"]",
".",
"each",
"do",
"|",
"id",
",",
"light",
"|",
"all_lights",
"<<",
"add_light",
"(",
"id",
".",
"to_i",
",",
"light",
"[",
"\"name\"",
"]",
")",
"end",
"all_lig... | loop through the available lights and make corresponding objects | [
"loop",
"through",
"the",
"available",
"lights",
"and",
"make",
"corresponding",
"objects"
] | 0bcbc566fa3964c74f7cfe73708d5ad1a7ce696d | https://github.com/dmerrick/lights_app/blob/0bcbc566fa3964c74f7cfe73708d5ad1a7ce696d/lib/philips_hue/bridge.rb#L143-L149 |
7,206 | ramhoj/table_for | lib/table_for/helper.rb | TableFor.Helper.table_for | def table_for(model_class, records, html = {}, &block)
Table.new(self, model_class, records, html, block).render
end | ruby | def table_for(model_class, records, html = {}, &block)
Table.new(self, model_class, records, html, block).render
end | [
"def",
"table_for",
"(",
"model_class",
",",
"records",
",",
"html",
"=",
"{",
"}",
",",
"&",
"block",
")",
"Table",
".",
"new",
"(",
"self",
",",
"model_class",
",",
"records",
",",
"html",
",",
"block",
")",
".",
"render",
"end"
] | Create a html table for records, using model class for naming things.
Examples:
<tt>table_for Product, @products do |table|
table.head :name, :size, :description, :price
table.body do |row|
row.cell :name
row.cells :size, :description
row.cell number_to_currency(row.record.price)
end
tabl... | [
"Create",
"a",
"html",
"table",
"for",
"records",
"using",
"model",
"class",
"for",
"naming",
"things",
"."
] | be9f53834f0d2cb2e0d900d4a0340ede7302d7f1 | https://github.com/ramhoj/table_for/blob/be9f53834f0d2cb2e0d900d4a0340ede7302d7f1/lib/table_for/helper.rb#L36-L38 |
7,207 | jinx/core | lib/jinx/resource/unique.rb | Jinx.Unique.uniquify_attributes | def uniquify_attributes(attributes)
attributes.each do |ka|
oldval = send(ka)
next unless String === oldval
newval = UniquifierCache.instance.get(self, oldval)
set_property_value(ka, newval)
logger.debug { "Reset #{qp} #{ka} from #{oldval} to unique value #{newval}." }
... | ruby | def uniquify_attributes(attributes)
attributes.each do |ka|
oldval = send(ka)
next unless String === oldval
newval = UniquifierCache.instance.get(self, oldval)
set_property_value(ka, newval)
logger.debug { "Reset #{qp} #{ka} from #{oldval} to unique value #{newval}." }
... | [
"def",
"uniquify_attributes",
"(",
"attributes",
")",
"attributes",
".",
"each",
"do",
"|",
"ka",
"|",
"oldval",
"=",
"send",
"(",
"ka",
")",
"next",
"unless",
"String",
"===",
"oldval",
"newval",
"=",
"UniquifierCache",
".",
"instance",
".",
"get",
"(",
... | Makes this domain object's String values for the given attributes unique.
@param [<Symbol>] the key attributes to uniquify | [
"Makes",
"this",
"domain",
"object",
"s",
"String",
"values",
"for",
"the",
"given",
"attributes",
"unique",
"."
] | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource/unique.rb#L22-L30 |
7,208 | hokstadconsulting/purecdb | lib/purecdb/writer.rb | PureCDB.Writer.store | def store key,value
# In an attempt to save memory, we pack the hash data we gather into
# strings of BER compressed integers...
h = hash(key)
hi = (h % num_hashes)
@hashes[hi] ||= ""
header = build_header(key.length, value.length)
@io.syswrite(header+key+value)
size = h... | ruby | def store key,value
# In an attempt to save memory, we pack the hash data we gather into
# strings of BER compressed integers...
h = hash(key)
hi = (h % num_hashes)
@hashes[hi] ||= ""
header = build_header(key.length, value.length)
@io.syswrite(header+key+value)
size = h... | [
"def",
"store",
"key",
",",
"value",
"# In an attempt to save memory, we pack the hash data we gather into",
"# strings of BER compressed integers...",
"h",
"=",
"hash",
"(",
"key",
")",
"hi",
"=",
"(",
"h",
"%",
"num_hashes",
")",
"@hashes",
"[",
"hi",
"]",
"||=",
... | Store 'value' under 'key'.
Multiple values can we stored for the same key by calling #store multiple times
with the same key value. | [
"Store",
"value",
"under",
"key",
"."
] | d19102e5dffbb2f0de4fab4f86c603880c3ffea8 | https://github.com/hokstadconsulting/purecdb/blob/d19102e5dffbb2f0de4fab4f86c603880c3ffea8/lib/purecdb/writer.rb#L92-L104 |
7,209 | bordeeinc/ico | lib/ico/utils.rb | ICO.Utils.png_to_sizes | def png_to_sizes(input_filename, sizes_array, output_dirname=nil, append_filenames=APPEND_FILE_FORMAT, force_overwrite=false, clear=true, force_clear=false)
basename = File.basename(input_filename, '.*')
output_dirname ||= File.join(File.expand_path(File.dirname(input_filename)), "#{basename}_sizes")
... | ruby | def png_to_sizes(input_filename, sizes_array, output_dirname=nil, append_filenames=APPEND_FILE_FORMAT, force_overwrite=false, clear=true, force_clear=false)
basename = File.basename(input_filename, '.*')
output_dirname ||= File.join(File.expand_path(File.dirname(input_filename)), "#{basename}_sizes")
... | [
"def",
"png_to_sizes",
"(",
"input_filename",
",",
"sizes_array",
",",
"output_dirname",
"=",
"nil",
",",
"append_filenames",
"=",
"APPEND_FILE_FORMAT",
",",
"force_overwrite",
"=",
"false",
",",
"clear",
"=",
"true",
",",
"force_clear",
"=",
"false",
")",
"base... | resize PNG file and write new sizes to directory
@see https://ruby-doc.org/core-2.2.0/Kernel.html#method-i-sprintf
@param input_filename [String] input filename; required: file is PNG file format
@param sizes_array [Array<Array<Integer,Integer]>>, Array<Integer>]
rectangles use Array with XY: `[x,y... | [
"resize",
"PNG",
"file",
"and",
"write",
"new",
"sizes",
"to",
"directory"
] | 008760fafafbb3d3e561e97e3596ffe43f4c21ef | https://github.com/bordeeinc/ico/blob/008760fafafbb3d3e561e97e3596ffe43f4c21ef/lib/ico/utils.rb#L104-L143 |
7,210 | jinx/core | lib/jinx/helpers/pretty_print.rb | Jinx.Hasher.qp | def qp
qph = {}
each { |k, v| qph[k.qp] = v.qp }
qph.pp_s
end | ruby | def qp
qph = {}
each { |k, v| qph[k.qp] = v.qp }
qph.pp_s
end | [
"def",
"qp",
"qph",
"=",
"{",
"}",
"each",
"{",
"|",
"k",
",",
"v",
"|",
"qph",
"[",
"k",
".",
"qp",
"]",
"=",
"v",
".",
"qp",
"}",
"qph",
".",
"pp_s",
"end"
] | qp, short for quick-print, prints this Hasher with a filter that calls qp on each key and value.
@return [String] the quick-print result | [
"qp",
"short",
"for",
"quick",
"-",
"print",
"prints",
"this",
"Hasher",
"with",
"a",
"filter",
"that",
"calls",
"qp",
"on",
"each",
"key",
"and",
"value",
"."
] | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/helpers/pretty_print.rb#L161-L165 |
7,211 | subimage/cashboard-rb | lib/cashboard/base.rb | Cashboard.Base.update | def update
options = self.class.merge_options()
options.merge!({:body => self.to_xml})
response = self.class.put(self.href, options)
begin
self.class.check_status_code(response)
rescue
return false
end
return true
end | ruby | def update
options = self.class.merge_options()
options.merge!({:body => self.to_xml})
response = self.class.put(self.href, options)
begin
self.class.check_status_code(response)
rescue
return false
end
return true
end | [
"def",
"update",
"options",
"=",
"self",
".",
"class",
".",
"merge_options",
"(",
")",
"options",
".",
"merge!",
"(",
"{",
":body",
"=>",
"self",
".",
"to_xml",
"}",
")",
"response",
"=",
"self",
".",
"class",
".",
"put",
"(",
"self",
".",
"href",
... | Updates the object on server, after attributes have been set.
Returns boolean if successful
Example:
te = Cashboard::TimeEntry.new_from_url(time_entry_url)
te.minutes = 60
update_success = te.update | [
"Updates",
"the",
"object",
"on",
"server",
"after",
"attributes",
"have",
"been",
"set",
".",
"Returns",
"boolean",
"if",
"successful"
] | 320e311ea1549cdd0dada0f8a0a4f9942213b28f | https://github.com/subimage/cashboard-rb/blob/320e311ea1549cdd0dada0f8a0a4f9942213b28f/lib/cashboard/base.rb#L96-L106 |
7,212 | subimage/cashboard-rb | lib/cashboard/base.rb | Cashboard.Base.delete | def delete
options = self.class.merge_options()
response = self.class.delete(self.href, options)
begin
self.class.check_status_code(response)
rescue
return false
end
return true
end | ruby | def delete
options = self.class.merge_options()
response = self.class.delete(self.href, options)
begin
self.class.check_status_code(response)
rescue
return false
end
return true
end | [
"def",
"delete",
"options",
"=",
"self",
".",
"class",
".",
"merge_options",
"(",
")",
"response",
"=",
"self",
".",
"class",
".",
"delete",
"(",
"self",
".",
"href",
",",
"options",
")",
"begin",
"self",
".",
"class",
".",
"check_status_code",
"(",
"r... | Destroys Cashboard object on the server.
Returns boolean upon success. | [
"Destroys",
"Cashboard",
"object",
"on",
"the",
"server",
".",
"Returns",
"boolean",
"upon",
"success",
"."
] | 320e311ea1549cdd0dada0f8a0a4f9942213b28f | https://github.com/subimage/cashboard-rb/blob/320e311ea1549cdd0dada0f8a0a4f9942213b28f/lib/cashboard/base.rb#L110-L119 |
7,213 | subimage/cashboard-rb | lib/cashboard/base.rb | Cashboard.Base.to_xml | def to_xml(options={})
options[:indent] ||= 2
xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
xml.instruct! unless options[:skip_instruct]
obj_name = self.class.resource_name.singularize
# Turn our OpenStruct attributes into a hash we can export to X... | ruby | def to_xml(options={})
options[:indent] ||= 2
xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
xml.instruct! unless options[:skip_instruct]
obj_name = self.class.resource_name.singularize
# Turn our OpenStruct attributes into a hash we can export to X... | [
"def",
"to_xml",
"(",
"options",
"=",
"{",
"}",
")",
"options",
"[",
":indent",
"]",
"||=",
"2",
"xml",
"=",
"options",
"[",
":builder",
"]",
"||=",
"Builder",
"::",
"XmlMarkup",
".",
"new",
"(",
":indent",
"=>",
"options",
"[",
":indent",
"]",
")",
... | Utilizes ActiveSupport to turn our objects into XML
that we can pass back to the server.
General concept stolen from Rails CoreExtensions::Hash::Conversions | [
"Utilizes",
"ActiveSupport",
"to",
"turn",
"our",
"objects",
"into",
"XML",
"that",
"we",
"can",
"pass",
"back",
"to",
"the",
"server",
"."
] | 320e311ea1549cdd0dada0f8a0a4f9942213b28f | https://github.com/subimage/cashboard-rb/blob/320e311ea1549cdd0dada0f8a0a4f9942213b28f/lib/cashboard/base.rb#L125-L159 |
7,214 | tclaus/keytechkit.gem | lib/keytechKit/elements/element_handler.rb | KeytechKit.ElementHandler.delete | def delete(element_key)
parameter = { basic_auth: @auth }
response = self.class.delete("/elements/#{element_key}", parameter)
unless response.success?
puts "Could not save element: #{response.headers['x-errordescription']}"
end
response
end | ruby | def delete(element_key)
parameter = { basic_auth: @auth }
response = self.class.delete("/elements/#{element_key}", parameter)
unless response.success?
puts "Could not save element: #{response.headers['x-errordescription']}"
end
response
end | [
"def",
"delete",
"(",
"element_key",
")",
"parameter",
"=",
"{",
"basic_auth",
":",
"@auth",
"}",
"response",
"=",
"self",
".",
"class",
".",
"delete",
"(",
"\"/elements/#{element_key}\"",
",",
"parameter",
")",
"unless",
"response",
".",
"success?",
"puts",
... | Deletes an element with the key
It returns the http response. | [
"Deletes",
"an",
"element",
"with",
"the",
"key",
"It",
"returns",
"the",
"http",
"response",
"."
] | caa7a6bee32b75ec18a4004179ae10cb69d148c2 | https://github.com/tclaus/keytechkit.gem/blob/caa7a6bee32b75ec18a4004179ae10cb69d148c2/lib/keytechKit/elements/element_handler.rb#L76-L83 |
7,215 | tclaus/keytechkit.gem | lib/keytechKit/elements/element_handler.rb | KeytechKit.ElementHandler.notes | def notes(element_key)
parameter = { basic_auth: @auth }
response = self.class.get("/elements/#{element_key}/notes", parameter)
if response.success?
search_response_header = SearchResponseHeader.new(response)
search_response_header.elementList
end
end | ruby | def notes(element_key)
parameter = { basic_auth: @auth }
response = self.class.get("/elements/#{element_key}/notes", parameter)
if response.success?
search_response_header = SearchResponseHeader.new(response)
search_response_header.elementList
end
end | [
"def",
"notes",
"(",
"element_key",
")",
"parameter",
"=",
"{",
"basic_auth",
":",
"@auth",
"}",
"response",
"=",
"self",
".",
"class",
".",
"get",
"(",
"\"/elements/#{element_key}/notes\"",
",",
"parameter",
")",
"if",
"response",
".",
"success?",
"search_res... | It returns the notes of an element if anything are given
Notes list can be empty
It returns nil if no element with this elementKey was found | [
"It",
"returns",
"the",
"notes",
"of",
"an",
"element",
"if",
"anything",
"are",
"given",
"Notes",
"list",
"can",
"be",
"empty",
"It",
"returns",
"nil",
"if",
"no",
"element",
"with",
"this",
"elementKey",
"was",
"found"
] | caa7a6bee32b75ec18a4004179ae10cb69d148c2 | https://github.com/tclaus/keytechkit.gem/blob/caa7a6bee32b75ec18a4004179ae10cb69d148c2/lib/keytechKit/elements/element_handler.rb#L144-L152 |
7,216 | tclaus/keytechkit.gem | lib/keytechKit/elements/element_handler.rb | KeytechKit.ElementHandler.note_handler | def note_handler
@_note_handler = NoteHandler.new(keytechkit.base_url, keytechkit.username, keytechkit.password) if @_note_handler.nil?
@_note_handler
end | ruby | def note_handler
@_note_handler = NoteHandler.new(keytechkit.base_url, keytechkit.username, keytechkit.password) if @_note_handler.nil?
@_note_handler
end | [
"def",
"note_handler",
"@_note_handler",
"=",
"NoteHandler",
".",
"new",
"(",
"keytechkit",
".",
"base_url",
",",
"keytechkit",
".",
"username",
",",
"keytechkit",
".",
"password",
")",
"if",
"@_note_handler",
".",
"nil?",
"@_note_handler",
"end"
] | Returns Notes resource.
Every Element can have zero, one or more notes.
You can notes only access in context of its element which ownes the notes | [
"Returns",
"Notes",
"resource",
".",
"Every",
"Element",
"can",
"have",
"zero",
"one",
"or",
"more",
"notes",
".",
"You",
"can",
"notes",
"only",
"access",
"in",
"context",
"of",
"its",
"element",
"which",
"ownes",
"the",
"notes"
] | caa7a6bee32b75ec18a4004179ae10cb69d148c2 | https://github.com/tclaus/keytechkit.gem/blob/caa7a6bee32b75ec18a4004179ae10cb69d148c2/lib/keytechKit/elements/element_handler.rb#L157-L160 |
7,217 | tclaus/keytechkit.gem | lib/keytechKit/elements/element_handler.rb | KeytechKit.ElementHandler.file_handler | def file_handler
@_element_file_handler = ElementFileHandler.new(keytechkit.base_url, keytechkit.username, keytechkit.password) if @_element_file_handler.nil?
@_element_file_handler
end | ruby | def file_handler
@_element_file_handler = ElementFileHandler.new(keytechkit.base_url, keytechkit.username, keytechkit.password) if @_element_file_handler.nil?
@_element_file_handler
end | [
"def",
"file_handler",
"@_element_file_handler",
"=",
"ElementFileHandler",
".",
"new",
"(",
"keytechkit",
".",
"base_url",
",",
"keytechkit",
".",
"username",
",",
"keytechkit",
".",
"password",
")",
"if",
"@_element_file_handler",
".",
"nil?",
"@_element_file_handle... | Returns the file object.
Every element can have a Masterfile and one or more preview files | [
"Returns",
"the",
"file",
"object",
".",
"Every",
"element",
"can",
"have",
"a",
"Masterfile",
"and",
"one",
"or",
"more",
"preview",
"files"
] | caa7a6bee32b75ec18a4004179ae10cb69d148c2 | https://github.com/tclaus/keytechkit.gem/blob/caa7a6bee32b75ec18a4004179ae10cb69d148c2/lib/keytechKit/elements/element_handler.rb#L164-L167 |
7,218 | treeder/quicky | lib/quicky/results_hash.rb | Quicky.ResultsHash.to_hash | def to_hash
ret = {}
self.each_pair do |k, v|
ret[k] = v.to_hash()
end
ret
end | ruby | def to_hash
ret = {}
self.each_pair do |k, v|
ret[k] = v.to_hash()
end
ret
end | [
"def",
"to_hash",
"ret",
"=",
"{",
"}",
"self",
".",
"each_pair",
"do",
"|",
"k",
",",
"v",
"|",
"ret",
"[",
"k",
"]",
"=",
"v",
".",
"to_hash",
"(",
")",
"end",
"ret",
"end"
] | returns results in a straight up hash. | [
"returns",
"results",
"in",
"a",
"straight",
"up",
"hash",
"."
] | 4ac89408c28ca04745280a4cef2db4f97ed5b6d2 | https://github.com/treeder/quicky/blob/4ac89408c28ca04745280a4cef2db4f97ed5b6d2/lib/quicky/results_hash.rb#L6-L12 |
7,219 | treeder/quicky | lib/quicky/results_hash.rb | Quicky.ResultsHash.merge! | def merge!(rh)
rh.each_pair do |k, v|
# v is a TimeCollector
if self.has_key?(k)
self[k].merge!(v)
else
self[k] = v
end
end
end | ruby | def merge!(rh)
rh.each_pair do |k, v|
# v is a TimeCollector
if self.has_key?(k)
self[k].merge!(v)
else
self[k] = v
end
end
end | [
"def",
"merge!",
"(",
"rh",
")",
"rh",
".",
"each_pair",
"do",
"|",
"k",
",",
"v",
"|",
"# v is a TimeCollector",
"if",
"self",
".",
"has_key?",
"(",
"k",
")",
"self",
"[",
"k",
"]",
".",
"merge!",
"(",
"v",
")",
"else",
"self",
"[",
"k",
"]",
... | merges multiple ResultsHash's | [
"merges",
"multiple",
"ResultsHash",
"s"
] | 4ac89408c28ca04745280a4cef2db4f97ed5b6d2 | https://github.com/treeder/quicky/blob/4ac89408c28ca04745280a4cef2db4f97ed5b6d2/lib/quicky/results_hash.rb#L24-L33 |
7,220 | wied03/opal-factory_girl | opal/opal/active_support/inflector/methods.rb | ActiveSupport.Inflector.titleize | def titleize(word)
# negative lookbehind doesn't work in Firefox / Safari
# humanize(underscore(word)).gsub(/\b(?<!['’`])[a-z]/) { |match| match.capitalize }
humanized = humanize(underscore(word))
humanized.reverse.gsub(/[a-z](?!['’`])\b/) { |match| match.capitalize }.reverse
end | ruby | def titleize(word)
# negative lookbehind doesn't work in Firefox / Safari
# humanize(underscore(word)).gsub(/\b(?<!['’`])[a-z]/) { |match| match.capitalize }
humanized = humanize(underscore(word))
humanized.reverse.gsub(/[a-z](?!['’`])\b/) { |match| match.capitalize }.reverse
end | [
"def",
"titleize",
"(",
"word",
")",
"# negative lookbehind doesn't work in Firefox / Safari",
"# humanize(underscore(word)).gsub(/\\b(?<!['’`])[a-z]/) { |match| match.capitalize }",
"humanized",
"=",
"humanize",
"(",
"underscore",
"(",
"word",
")",
")",
"humanized",
".",
"revers... | Capitalizes all the words and replaces some characters in the string to
create a nicer looking title. +titleize+ is meant for creating pretty
output. It is not used in the Rails internals.
+titleize+ is also aliased as +titlecase+.
titleize('man from the boondocks') # => "Man From The Boondocks"
titleize('... | [
"Capitalizes",
"all",
"the",
"words",
"and",
"replaces",
"some",
"characters",
"in",
"the",
"string",
"to",
"create",
"a",
"nicer",
"looking",
"title",
".",
"+",
"titleize",
"+",
"is",
"meant",
"for",
"creating",
"pretty",
"output",
".",
"It",
"is",
"not",... | 697114a8c63f4cba38b84d27d1f7b823c8d0bb38 | https://github.com/wied03/opal-factory_girl/blob/697114a8c63f4cba38b84d27d1f7b823c8d0bb38/opal/opal/active_support/inflector/methods.rb#L160-L165 |
7,221 | hck/filter_factory | lib/filter_factory/filter.rb | FilterFactory.Filter.attributes | def attributes
fields.each_with_object(HashWithIndifferentAccess.new) do |field, acc|
acc[field.alias] = field.value
end
end | ruby | def attributes
fields.each_with_object(HashWithIndifferentAccess.new) do |field, acc|
acc[field.alias] = field.value
end
end | [
"def",
"attributes",
"fields",
".",
"each_with_object",
"(",
"HashWithIndifferentAccess",
".",
"new",
")",
"do",
"|",
"field",
",",
"acc",
"|",
"acc",
"[",
"field",
".",
"alias",
"]",
"=",
"field",
".",
"value",
"end",
"end"
] | Initializes new instance of Filter class.
Returns list of filter attributes.
@return [HashWithIndifferentAccess] | [
"Initializes",
"new",
"instance",
"of",
"Filter",
"class",
".",
"Returns",
"list",
"of",
"filter",
"attributes",
"."
] | 21f331ed3b1a9eae1a56727617e26407c96daebc | https://github.com/hck/filter_factory/blob/21f331ed3b1a9eae1a56727617e26407c96daebc/lib/filter_factory/filter.rb#L25-L29 |
7,222 | mrsimonfletcher/roroacms | app/helpers/roroacms/routing_helper.rb | Roroacms.RoutingHelper.get_type_by_url | def get_type_by_url
return 'P' if params[:slug].blank?
# split the url up into segments
segments = params[:slug].split('/')
# general variables
url = params[:slug]
article_url = Setting.get('articles_slug')
category_url = Setting.get('category_slug')
tag_url = Setting.... | ruby | def get_type_by_url
return 'P' if params[:slug].blank?
# split the url up into segments
segments = params[:slug].split('/')
# general variables
url = params[:slug]
article_url = Setting.get('articles_slug')
category_url = Setting.get('category_slug')
tag_url = Setting.... | [
"def",
"get_type_by_url",
"return",
"'P'",
"if",
"params",
"[",
":slug",
"]",
".",
"blank?",
"# split the url up into segments",
"segments",
"=",
"params",
"[",
":slug",
"]",
".",
"split",
"(",
"'/'",
")",
"# general variables",
"url",
"=",
"params",
"[",
":sl... | returns that type of page that you are currenly viewing | [
"returns",
"that",
"type",
"of",
"page",
"that",
"you",
"are",
"currenly",
"viewing"
] | 62654a2f2a48e3adb3105f4dafb6e315b460eaf4 | https://github.com/mrsimonfletcher/roroacms/blob/62654a2f2a48e3adb3105f4dafb6e315b460eaf4/app/helpers/roroacms/routing_helper.rb#L96-L136 |
7,223 | houston/houston-conversations | lib/houston/conversations.rb | Houston.Conversations.hear | def hear(message, params={})
raise ArgumentError, "`message` must respond to :channel" unless message.respond_to?(:channel)
raise ArgumentError, "`message` must respond to :sender" unless message.respond_to?(:sender)
listeners.hear(message).each do |match|
event = Houston::Conversations::Even... | ruby | def hear(message, params={})
raise ArgumentError, "`message` must respond to :channel" unless message.respond_to?(:channel)
raise ArgumentError, "`message` must respond to :sender" unless message.respond_to?(:sender)
listeners.hear(message).each do |match|
event = Houston::Conversations::Even... | [
"def",
"hear",
"(",
"message",
",",
"params",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"\"`message` must respond to :channel\"",
"unless",
"message",
".",
"respond_to?",
"(",
":channel",
")",
"raise",
"ArgumentError",
",",
"\"`message` must respond to :sende... | Matches a message against all listeners
and invokes the first listener that mathes | [
"Matches",
"a",
"message",
"against",
"all",
"listeners",
"and",
"invokes",
"the",
"first",
"listener",
"that",
"mathes"
] | b292c90c3a74c73e2a97e23e20fa640dc3e48c54 | https://github.com/houston/houston-conversations/blob/b292c90c3a74c73e2a97e23e20fa640dc3e48c54/lib/houston/conversations.rb#L30-L48 |
7,224 | robertwahler/mutagem | lib/mutagem/mutex.rb | Mutagem.Mutex.execute | def execute(&block)
result = false
raise ArgumentError, "missing block" unless block_given?
begin
open(lockfile, 'w') do |f|
# exclusive non-blocking lock
result = lock(f, File::LOCK_EX | File::LOCK_NB) do |f|
yield
end
end
ensure
... | ruby | def execute(&block)
result = false
raise ArgumentError, "missing block" unless block_given?
begin
open(lockfile, 'w') do |f|
# exclusive non-blocking lock
result = lock(f, File::LOCK_EX | File::LOCK_NB) do |f|
yield
end
end
ensure
... | [
"def",
"execute",
"(",
"&",
"block",
")",
"result",
"=",
"false",
"raise",
"ArgumentError",
",",
"\"missing block\"",
"unless",
"block_given?",
"begin",
"open",
"(",
"lockfile",
",",
"'w'",
")",
"do",
"|",
"f",
"|",
"# exclusive non-blocking lock",
"result",
"... | Creates a new Mutex
@param [String] lockfile filename
Protect a block
@example
require 'rubygems'
require 'mutagem'
mutex = Mutagem::Mutex.new("my_process_name.lck")
mutex.execute do
puts "this block is protected from recursion"
end
@param block the block of code to protect with the m... | [
"Creates",
"a",
"new",
"Mutex"
] | 75ac2f7fd307f575d81114b32e1a3b09c526e01d | https://github.com/robertwahler/mutagem/blob/75ac2f7fd307f575d81114b32e1a3b09c526e01d/lib/mutagem/mutex.rb#L29-L46 |
7,225 | webmonarch/movingsign_api | lib/movingsign_api/commands/command.rb | MovingsignApi.Command.to_bytes | def to_bytes
# set defaults
self.sender ||= :pc
self.receiver ||= 1
bytes = []
bytes.concat [0x00] * 5 # start of command
bytes.concat [0x01] # <SOH>
bytes.concat self.sender.to_bytes # Sender... | ruby | def to_bytes
# set defaults
self.sender ||= :pc
self.receiver ||= 1
bytes = []
bytes.concat [0x00] * 5 # start of command
bytes.concat [0x01] # <SOH>
bytes.concat self.sender.to_bytes # Sender... | [
"def",
"to_bytes",
"# set defaults",
"self",
".",
"sender",
"||=",
":pc",
"self",
".",
"receiver",
"||=",
"1",
"bytes",
"=",
"[",
"]",
"bytes",
".",
"concat",
"[",
"0x00",
"]",
"*",
"5",
"# start of command",
"bytes",
".",
"concat",
"[",
"0x01",
"]",
"... | Returns a byte array representing this command, appropriate for sending to the sign's serial port
@return [Array<Byte>] | [
"Returns",
"a",
"byte",
"array",
"representing",
"this",
"command",
"appropriate",
"for",
"sending",
"to",
"the",
"sign",
"s",
"serial",
"port"
] | 11c820edcb5f3a367b341257dae4f6249ae6d0a3 | https://github.com/webmonarch/movingsign_api/blob/11c820edcb5f3a367b341257dae4f6249ae6d0a3/lib/movingsign_api/commands/command.rb#L36-L55 |
7,226 | trejkaz/futurocube | lib/futurocube/resource_file.rb | FuturoCube.ResourceFile.records | def records
if !@records
@io.seek(44, IO::SEEK_SET)
records = []
header.record_count.times do
records << ResourceRecord.read(@io)
end
@records = records
end
@records
end | ruby | def records
if !@records
@io.seek(44, IO::SEEK_SET)
records = []
header.record_count.times do
records << ResourceRecord.read(@io)
end
@records = records
end
@records
end | [
"def",
"records",
"if",
"!",
"@records",
"@io",
".",
"seek",
"(",
"44",
",",
"IO",
"::",
"SEEK_SET",
")",
"records",
"=",
"[",
"]",
"header",
".",
"record_count",
".",
"times",
"do",
"records",
"<<",
"ResourceRecord",
".",
"read",
"(",
"@io",
")",
"e... | Reads the list of records from the resource file. | [
"Reads",
"the",
"list",
"of",
"records",
"from",
"the",
"resource",
"file",
"."
] | 2000e3d9e301f27fd01a0f331045fae9d6cc1883 | https://github.com/trejkaz/futurocube/blob/2000e3d9e301f27fd01a0f331045fae9d6cc1883/lib/futurocube/resource_file.rb#L42-L52 |
7,227 | trejkaz/futurocube | lib/futurocube/resource_file.rb | FuturoCube.ResourceFile.data | def data(rec)
@io.seek(rec.data_offset, IO::SEEK_SET)
@io.read(rec.data_length)
end | ruby | def data(rec)
@io.seek(rec.data_offset, IO::SEEK_SET)
@io.read(rec.data_length)
end | [
"def",
"data",
"(",
"rec",
")",
"@io",
".",
"seek",
"(",
"rec",
".",
"data_offset",
",",
"IO",
"::",
"SEEK_SET",
")",
"@io",
".",
"read",
"(",
"rec",
".",
"data_length",
")",
"end"
] | Reads the data for a given record.
@param rec [ResourceRecord] the record to read the data for. | [
"Reads",
"the",
"data",
"for",
"a",
"given",
"record",
"."
] | 2000e3d9e301f27fd01a0f331045fae9d6cc1883 | https://github.com/trejkaz/futurocube/blob/2000e3d9e301f27fd01a0f331045fae9d6cc1883/lib/futurocube/resource_file.rb#L57-L60 |
7,228 | trejkaz/futurocube | lib/futurocube/resource_file.rb | FuturoCube.ResourceFile.compute_checksum | def compute_checksum(&block)
crc = CRC.new
# Have to read this first because it might change the seek position.
file_size = header.file_size
@io.seek(8, IO::SEEK_SET)
pos = 8
length = 4096-8
buf = nil
while true
buf = @io.read(length, buf)
break if !buf
... | ruby | def compute_checksum(&block)
crc = CRC.new
# Have to read this first because it might change the seek position.
file_size = header.file_size
@io.seek(8, IO::SEEK_SET)
pos = 8
length = 4096-8
buf = nil
while true
buf = @io.read(length, buf)
break if !buf
... | [
"def",
"compute_checksum",
"(",
"&",
"block",
")",
"crc",
"=",
"CRC",
".",
"new",
"# Have to read this first because it might change the seek position.",
"file_size",
"=",
"header",
".",
"file_size",
"@io",
".",
"seek",
"(",
"8",
",",
"IO",
"::",
"SEEK_SET",
")",
... | Computes the checksum for the resource file.
@yield [done] Provides feedback about the progress of the operation. | [
"Computes",
"the",
"checksum",
"for",
"the",
"resource",
"file",
"."
] | 2000e3d9e301f27fd01a0f331045fae9d6cc1883 | https://github.com/trejkaz/futurocube/blob/2000e3d9e301f27fd01a0f331045fae9d6cc1883/lib/futurocube/resource_file.rb#L65-L82 |
7,229 | Dahie/woro | lib/woro/task.rb | Woro.Task.build_task_template | def build_task_template
b = binding
ERB.new(Woro::TaskHelper.read_template_file).result(b)
end | ruby | def build_task_template
b = binding
ERB.new(Woro::TaskHelper.read_template_file).result(b)
end | [
"def",
"build_task_template",
"b",
"=",
"binding",
"ERB",
".",
"new",
"(",
"Woro",
"::",
"TaskHelper",
".",
"read_template_file",
")",
".",
"result",
"(",
"b",
")",
"end"
] | Read template and inject new name
@return [String] source code for new task | [
"Read",
"template",
"and",
"inject",
"new",
"name"
] | 796873cca145c61cd72c7363551e10d402f867c6 | https://github.com/Dahie/woro/blob/796873cca145c61cd72c7363551e10d402f867c6/lib/woro/task.rb#L48-L51 |
7,230 | barkerest/barkest_core | app/controllers/barkest_core/application_controller_base.rb | BarkestCore.ApplicationControllerBase.authorize! | def authorize!(*group_list)
begin
# an authenticated user must exist.
unless logged_in?
store_location
raise_not_logged_in "You need to login to access '#{request.fullpath}'.",
'nobody is logged in'
end
# clean up the group list.... | ruby | def authorize!(*group_list)
begin
# an authenticated user must exist.
unless logged_in?
store_location
raise_not_logged_in "You need to login to access '#{request.fullpath}'.",
'nobody is logged in'
end
# clean up the group list.... | [
"def",
"authorize!",
"(",
"*",
"group_list",
")",
"begin",
"# an authenticated user must exist.",
"unless",
"logged_in?",
"store_location",
"raise_not_logged_in",
"\"You need to login to access '#{request.fullpath}'.\"",
",",
"'nobody is logged in'",
"end",
"# clean up the group list... | Authorize the current action.
* If +group_list+ is not provided or only contains +false+ then any authenticated user will be authorized.
* If +group_list+ contains +true+ then only system administrators will be authorized.
* Otherwise the +group_list+ contains a list of accepted groups that will be authorized.
A... | [
"Authorize",
"the",
"current",
"action",
"."
] | 3eeb025ec870888cacbc9bae252a39ebf9295f61 | https://github.com/barkerest/barkest_core/blob/3eeb025ec870888cacbc9bae252a39ebf9295f61/app/controllers/barkest_core/application_controller_base.rb#L30-L83 |
7,231 | flyingmachine/higml | lib/higml/applier.rb | Higml.Applier.selector_matches? | def selector_matches?(selector)
selector.any? do |group|
group.keys.all? do |key|
input_has_key?(key) && (@input[key] == group[key] || group[key].nil?)
end
end
end | ruby | def selector_matches?(selector)
selector.any? do |group|
group.keys.all? do |key|
input_has_key?(key) && (@input[key] == group[key] || group[key].nil?)
end
end
end | [
"def",
"selector_matches?",
"(",
"selector",
")",
"selector",
".",
"any?",
"do",
"|",
"group",
"|",
"group",
".",
"keys",
".",
"all?",
"do",
"|",
"key",
"|",
"input_has_key?",
"(",
"key",
")",
"&&",
"(",
"@input",
"[",
"key",
"]",
"==",
"group",
"[",... | REFACTOR to selector class | [
"REFACTOR",
"to",
"selector",
"class"
] | 0c83d236c8911fb8ce23fcd82b5691f9189f41ef | https://github.com/flyingmachine/higml/blob/0c83d236c8911fb8ce23fcd82b5691f9189f41ef/lib/higml/applier.rb#L43-L49 |
7,232 | danlewis/encryptbot | lib/encryptbot/cert.rb | Encryptbot.Cert.ready_for_challenge | def ready_for_challenge(domain, dns_challenge)
record = "#{dns_challenge.record_name}.#{domain}"
challenge_value = dns_challenge.record_content
txt_value = Resolv::DNS.open do |dns|
records = dns.getresources(record, Resolv::DNS::Resource::IN::TXT);
records.empty? ? nil : records.map(&... | ruby | def ready_for_challenge(domain, dns_challenge)
record = "#{dns_challenge.record_name}.#{domain}"
challenge_value = dns_challenge.record_content
txt_value = Resolv::DNS.open do |dns|
records = dns.getresources(record, Resolv::DNS::Resource::IN::TXT);
records.empty? ? nil : records.map(&... | [
"def",
"ready_for_challenge",
"(",
"domain",
",",
"dns_challenge",
")",
"record",
"=",
"\"#{dns_challenge.record_name}.#{domain}\"",
"challenge_value",
"=",
"dns_challenge",
".",
"record_content",
"txt_value",
"=",
"Resolv",
"::",
"DNS",
".",
"open",
"do",
"|",
"dns",... | Check if TXT value has been set correctly | [
"Check",
"if",
"TXT",
"value",
"has",
"been",
"set",
"correctly"
] | 2badb7cfe3f7c3b416d7aa74bd3e339cc859edb2 | https://github.com/danlewis/encryptbot/blob/2badb7cfe3f7c3b416d7aa74bd3e339cc859edb2/lib/encryptbot/cert.rb#L95-L103 |
7,233 | kenjij/kajiki | lib/kajiki/handler.rb | Kajiki.Handler.check_existing_pid | def check_existing_pid
return false unless pid_file_exists?
pid = read_pid
fail 'Existing process found.' if pid > 0 && pid_exists?(pid)
delete_pid
end | ruby | def check_existing_pid
return false unless pid_file_exists?
pid = read_pid
fail 'Existing process found.' if pid > 0 && pid_exists?(pid)
delete_pid
end | [
"def",
"check_existing_pid",
"return",
"false",
"unless",
"pid_file_exists?",
"pid",
"=",
"read_pid",
"fail",
"'Existing process found.'",
"if",
"pid",
">",
"0",
"&&",
"pid_exists?",
"(",
"pid",
")",
"delete_pid",
"end"
] | Check if process exists then fail, otherwise clean up.
@return [Boolean] `false` if no PID file exists, `true` if it cleaned up. | [
"Check",
"if",
"process",
"exists",
"then",
"fail",
"otherwise",
"clean",
"up",
"."
] | 9b036f2741d515e9bfd158571a813987516d89ed | https://github.com/kenjij/kajiki/blob/9b036f2741d515e9bfd158571a813987516d89ed/lib/kajiki/handler.rb#L7-L12 |
7,234 | kenjij/kajiki | lib/kajiki/handler.rb | Kajiki.Handler.trap_default_signals | def trap_default_signals
Signal.trap('INT') do
puts 'Interrupted. Terminating process...'
exit
end
Signal.trap('HUP') do
puts 'SIGHUP - Terminating process...'
exit
end
Signal.trap('TERM') do
puts 'SIGTERM - Terminating process...'
exit
... | ruby | def trap_default_signals
Signal.trap('INT') do
puts 'Interrupted. Terminating process...'
exit
end
Signal.trap('HUP') do
puts 'SIGHUP - Terminating process...'
exit
end
Signal.trap('TERM') do
puts 'SIGTERM - Terminating process...'
exit
... | [
"def",
"trap_default_signals",
"Signal",
".",
"trap",
"(",
"'INT'",
")",
"do",
"puts",
"'Interrupted. Terminating process...'",
"exit",
"end",
"Signal",
".",
"trap",
"(",
"'HUP'",
")",
"do",
"puts",
"'SIGHUP - Terminating process...'",
"exit",
"end",
"Signal",
".",
... | Trap common signals as default. | [
"Trap",
"common",
"signals",
"as",
"default",
"."
] | 9b036f2741d515e9bfd158571a813987516d89ed | https://github.com/kenjij/kajiki/blob/9b036f2741d515e9bfd158571a813987516d89ed/lib/kajiki/handler.rb#L71-L84 |
7,235 | cbetta/snapshotify | lib/snapshotify/document.rb | Snapshotify.Document.links | def links
# Find all anchor elements
doc.xpath('//a').map do |element|
# extract all the href attributes
element.attribute('href')
end.compact.map(&:value).map do |href|
# return them as new document objects
Snapshotify::Document.new(href, url)
end.compact
end | ruby | def links
# Find all anchor elements
doc.xpath('//a').map do |element|
# extract all the href attributes
element.attribute('href')
end.compact.map(&:value).map do |href|
# return them as new document objects
Snapshotify::Document.new(href, url)
end.compact
end | [
"def",
"links",
"# Find all anchor elements",
"doc",
".",
"xpath",
"(",
"'//a'",
")",
".",
"map",
"do",
"|",
"element",
"|",
"# extract all the href attributes",
"element",
".",
"attribute",
"(",
"'href'",
")",
"end",
".",
"compact",
".",
"map",
"(",
":value",... | Initialize the document with a URL, and
the parent page this URL was included on in case of
assets
Find the links in a page and extract all the hrefs | [
"Initialize",
"the",
"document",
"with",
"a",
"URL",
"and",
"the",
"parent",
"page",
"this",
"URL",
"was",
"included",
"on",
"in",
"case",
"of",
"assets",
"Find",
"the",
"links",
"in",
"a",
"page",
"and",
"extract",
"all",
"the",
"hrefs"
] | 7f5553f4281ffc5bf0e54da1141574bd15af45b6 | https://github.com/cbetta/snapshotify/blob/7f5553f4281ffc5bf0e54da1141574bd15af45b6/lib/snapshotify/document.rb#L18-L27 |
7,236 | cbetta/snapshotify | lib/snapshotify/document.rb | Snapshotify.Document.write! | def write!
writer = Snapshotify::Writer.new(self)
writer.emitter = emitter
writer.write
end | ruby | def write!
writer = Snapshotify::Writer.new(self)
writer.emitter = emitter
writer.write
end | [
"def",
"write!",
"writer",
"=",
"Snapshotify",
"::",
"Writer",
".",
"new",
"(",
"self",
")",
"writer",
".",
"emitter",
"=",
"emitter",
"writer",
".",
"write",
"end"
] | Write a document to file | [
"Write",
"a",
"document",
"to",
"file"
] | 7f5553f4281ffc5bf0e54da1141574bd15af45b6 | https://github.com/cbetta/snapshotify/blob/7f5553f4281ffc5bf0e54da1141574bd15af45b6/lib/snapshotify/document.rb#L35-L39 |
7,237 | jgoizueta/sys_cmd | lib/sys_cmd.rb | SysCmd.Definition.option | def option(option, *args)
options = args.pop if args.last.is_a?(Hash)
options ||= {}
raise "Invalid number of arguments (0 or 1 expected)" if args.size > 1
return unless @shell.applicable?(options)
value = args.shift || options[:value]
if options[:os_prefix]
option = @shell.o... | ruby | def option(option, *args)
options = args.pop if args.last.is_a?(Hash)
options ||= {}
raise "Invalid number of arguments (0 or 1 expected)" if args.size > 1
return unless @shell.applicable?(options)
value = args.shift || options[:value]
if options[:os_prefix]
option = @shell.o... | [
"def",
"option",
"(",
"option",
",",
"*",
"args",
")",
"options",
"=",
"args",
".",
"pop",
"if",
"args",
".",
"last",
".",
"is_a?",
"(",
"Hash",
")",
"options",
"||=",
"{",
"}",
"raise",
"\"Invalid number of arguments (0 or 1 expected)\"",
"if",
"args",
".... | Add an option to the command.
option '-x' # flag-style option
option '--y' # long option
option '/z' # Windows-style option
options 'abc' # unprefixed option
If the option +:os_prefix+ is true
then the default system option switch will be used.
option 'x', os_prefix: true # will p... | [
"Add",
"an",
"option",
"to",
"the",
"command",
"."
] | b7f0cb67502be7755679562f318c3aa66510ec63 | https://github.com/jgoizueta/sys_cmd/blob/b7f0cb67502be7755679562f318c3aa66510ec63/lib/sys_cmd.rb#L70-L99 |
7,238 | jgoizueta/sys_cmd | lib/sys_cmd.rb | SysCmd.Definition.os_option | def os_option(option, *args)
options = args.pop if args.last.is_a?(Hash)
options ||= {}
args.push options.merge(os_prefix: true)
option option, *args
end | ruby | def os_option(option, *args)
options = args.pop if args.last.is_a?(Hash)
options ||= {}
args.push options.merge(os_prefix: true)
option option, *args
end | [
"def",
"os_option",
"(",
"option",
",",
"*",
"args",
")",
"options",
"=",
"args",
".",
"pop",
"if",
"args",
".",
"last",
".",
"is_a?",
"(",
"Hash",
")",
"options",
"||=",
"{",
"}",
"args",
".",
"push",
"options",
".",
"merge",
"(",
"os_prefix",
":"... | An +os_option+ has automatically a OS-dependent prefix | [
"An",
"+",
"os_option",
"+",
"has",
"automatically",
"a",
"OS",
"-",
"dependent",
"prefix"
] | b7f0cb67502be7755679562f318c3aa66510ec63 | https://github.com/jgoizueta/sys_cmd/blob/b7f0cb67502be7755679562f318c3aa66510ec63/lib/sys_cmd.rb#L102-L107 |
7,239 | jgoizueta/sys_cmd | lib/sys_cmd.rb | SysCmd.Definition.argument | def argument(value, options = {})
return unless @shell.applicable?(options)
value = value.to_s
if @shell.requires_escaping?(value)
value = @shell.escape_value(value)
end
@command << ' ' << value
@last_arg = :argument
end | ruby | def argument(value, options = {})
return unless @shell.applicable?(options)
value = value.to_s
if @shell.requires_escaping?(value)
value = @shell.escape_value(value)
end
@command << ' ' << value
@last_arg = :argument
end | [
"def",
"argument",
"(",
"value",
",",
"options",
"=",
"{",
"}",
")",
"return",
"unless",
"@shell",
".",
"applicable?",
"(",
"options",
")",
"value",
"=",
"value",
".",
"to_s",
"if",
"@shell",
".",
"requires_escaping?",
"(",
"value",
")",
"value",
"=",
... | Add an unquoted argument to the command.
This is not useful for commands executed directly, since the arguments
are note interpreted by a shell in that case. | [
"Add",
"an",
"unquoted",
"argument",
"to",
"the",
"command",
".",
"This",
"is",
"not",
"useful",
"for",
"commands",
"executed",
"directly",
"since",
"the",
"arguments",
"are",
"note",
"interpreted",
"by",
"a",
"shell",
"in",
"that",
"case",
"."
] | b7f0cb67502be7755679562f318c3aa66510ec63 | https://github.com/jgoizueta/sys_cmd/blob/b7f0cb67502be7755679562f318c3aa66510ec63/lib/sys_cmd.rb#L185-L193 |
7,240 | jgoizueta/sys_cmd | lib/sys_cmd.rb | SysCmd.Command.run | def run(options = {})
@output = @status = @error_output = @error = nil
if options[:direct]
command = @shell.split(@command)
else
command = [@command]
end
stdin_data = options[:stdin_data] || @input
if stdin_data
command << { stdin_data: stdin_data }
end
... | ruby | def run(options = {})
@output = @status = @error_output = @error = nil
if options[:direct]
command = @shell.split(@command)
else
command = [@command]
end
stdin_data = options[:stdin_data] || @input
if stdin_data
command << { stdin_data: stdin_data }
end
... | [
"def",
"run",
"(",
"options",
"=",
"{",
"}",
")",
"@output",
"=",
"@status",
"=",
"@error_output",
"=",
"@error",
"=",
"nil",
"if",
"options",
"[",
":direct",
"]",
"command",
"=",
"@shell",
".",
"split",
"(",
"@command",
")",
"else",
"command",
"=",
... | Execute the command.
By default the command is executed by a shell. In this case,
unquoted arguments are interpreted by the shell, e.g.
SysCmd.command('echo $BASH').run # /bin/bash
When the +:direct+ option is set to true, no shell is used and
the command is directly executed; in this case unquoted arguments
... | [
"Execute",
"the",
"command",
"."
] | b7f0cb67502be7755679562f318c3aa66510ec63 | https://github.com/jgoizueta/sys_cmd/blob/b7f0cb67502be7755679562f318c3aa66510ec63/lib/sys_cmd.rb#L267-L304 |
7,241 | gera-gas/iparser | lib/iparser/machine.rb | Iparser.Machine.interactive_parser | def interactive_parser ( )
puts 'Press <Enter> to exit...'
# Цикл обработки ввода.
loop do
str = interactive_input( )
break if str == ""
# Цикл посимвольной классификаци.
str.bytes.each do |c|
parse( c.chr )
puts 'parser: ' + @parserstate
puts 'symbol: ' + interactive_output... | ruby | def interactive_parser ( )
puts 'Press <Enter> to exit...'
# Цикл обработки ввода.
loop do
str = interactive_input( )
break if str == ""
# Цикл посимвольной классификаци.
str.bytes.each do |c|
parse( c.chr )
puts 'parser: ' + @parserstate
puts 'symbol: ' + interactive_output... | [
"def",
"interactive_parser",
"(",
")",
"puts",
"'Press <Enter> to exit...'",
"# Цикл обработки ввода.",
"loop",
"do",
"str",
"=",
"interactive_input",
"(",
")",
"break",
"if",
"str",
"==",
"\"\"",
"# Цикл посимвольной классификаци.",
"str",
".",
"bytes",
".",
"each",
... | Run parser machine for check in interactive mode. | [
"Run",
"parser",
"machine",
"for",
"check",
"in",
"interactive",
"mode",
"."
] | bef722594541a406d361c6ff6dac8c15a7aa6d2a | https://github.com/gera-gas/iparser/blob/bef722594541a406d361c6ff6dac8c15a7aa6d2a/lib/iparser/machine.rb#L144-L161 |
7,242 | MBO/attrtastic | lib/attrtastic/semantic_attributes_builder.rb | Attrtastic.SemanticAttributesBuilder.attributes | def attributes(*args, &block)
options = args.extract_options!
options[:html] ||= {}
if args.first and args.first.is_a? String
options[:name] = args.shift
end
if options[:for].blank?
attributes_for(record, args, options, &block)
else
for_value = if options[:f... | ruby | def attributes(*args, &block)
options = args.extract_options!
options[:html] ||= {}
if args.first and args.first.is_a? String
options[:name] = args.shift
end
if options[:for].blank?
attributes_for(record, args, options, &block)
else
for_value = if options[:f... | [
"def",
"attributes",
"(",
"*",
"args",
",",
"&",
"block",
")",
"options",
"=",
"args",
".",
"extract_options!",
"options",
"[",
":html",
"]",
"||=",
"{",
"}",
"if",
"args",
".",
"first",
"and",
"args",
".",
"first",
".",
"is_a?",
"String",
"options",
... | Creates block of attributes with optional header. Attributes are surrounded with ordered list.
@overload attributes(options = {}, &block)
Creates attributes list without header, yields block to include each attribute
@param [Hash] options Options for formating attributes block
@option options [String] :name... | [
"Creates",
"block",
"of",
"attributes",
"with",
"optional",
"header",
".",
"Attributes",
"are",
"surrounded",
"with",
"ordered",
"list",
"."
] | c024a1c42b665eed590004236e2d067d1ca59a4e | https://github.com/MBO/attrtastic/blob/c024a1c42b665eed590004236e2d067d1ca59a4e/lib/attrtastic/semantic_attributes_builder.rb#L187-L212 |
7,243 | MBO/attrtastic | lib/attrtastic/semantic_attributes_builder.rb | Attrtastic.SemanticAttributesBuilder.attribute | def attribute(*args, &block)
options = args.extract_options!
options.reverse_merge!(Attrtastic.default_options)
options[:html] ||= {}
method = args.shift
html_label_class = [ "label", options[:html][:label_class] ].compact.join(" ")
html_value_class = [ "value", options[:html][:val... | ruby | def attribute(*args, &block)
options = args.extract_options!
options.reverse_merge!(Attrtastic.default_options)
options[:html] ||= {}
method = args.shift
html_label_class = [ "label", options[:html][:label_class] ].compact.join(" ")
html_value_class = [ "value", options[:html][:val... | [
"def",
"attribute",
"(",
"*",
"args",
",",
"&",
"block",
")",
"options",
"=",
"args",
".",
"extract_options!",
"options",
".",
"reverse_merge!",
"(",
"Attrtastic",
".",
"default_options",
")",
"options",
"[",
":html",
"]",
"||=",
"{",
"}",
"method",
"=",
... | Creates list entry for single record attribute
@overload attribute(method, options = {})
Creates entry for record attribute
@param [Symbol] method Attribute name of given record
@param [Hash] options Options
@option options [Hash] :html ({}) Hash with optional :class, :label_class and :value_class names ... | [
"Creates",
"list",
"entry",
"for",
"single",
"record",
"attribute"
] | c024a1c42b665eed590004236e2d067d1ca59a4e | https://github.com/MBO/attrtastic/blob/c024a1c42b665eed590004236e2d067d1ca59a4e/lib/attrtastic/semantic_attributes_builder.rb#L281-L335 |
7,244 | slate-studio/mongosteen | lib/mongosteen/base_helpers.rb | Mongosteen.BaseHelpers.collection | def collection
get_collection_ivar || begin
chain = end_of_association_chain
# scopes
chain = apply_scopes(chain)
# search
if params[:search]
chain = chain.search(params[:search].to_s.downcase, match: :all)
end
# pagination
if params[:pa... | ruby | def collection
get_collection_ivar || begin
chain = end_of_association_chain
# scopes
chain = apply_scopes(chain)
# search
if params[:search]
chain = chain.search(params[:search].to_s.downcase, match: :all)
end
# pagination
if params[:pa... | [
"def",
"collection",
"get_collection_ivar",
"||",
"begin",
"chain",
"=",
"end_of_association_chain",
"# scopes",
"chain",
"=",
"apply_scopes",
"(",
"chain",
")",
"# search",
"if",
"params",
"[",
":search",
"]",
"chain",
"=",
"chain",
".",
"search",
"(",
"params"... | add support for scopes, search and pagination | [
"add",
"support",
"for",
"scopes",
"search",
"and",
"pagination"
] | f9745fcef269a1eb501b3d0d69b75cfc432d135d | https://github.com/slate-studio/mongosteen/blob/f9745fcef269a1eb501b3d0d69b75cfc432d135d/lib/mongosteen/base_helpers.rb#L7-L29 |
7,245 | slate-studio/mongosteen | lib/mongosteen/base_helpers.rb | Mongosteen.BaseHelpers.get_resource_version | def get_resource_version
resource = get_resource_ivar
version = params[:version].try(:to_i)
if version && version > 0 && version < resource.version
resource.undo(nil, from: version + 1, to: resource.version)
resource.version = version
end
return resource
end | ruby | def get_resource_version
resource = get_resource_ivar
version = params[:version].try(:to_i)
if version && version > 0 && version < resource.version
resource.undo(nil, from: version + 1, to: resource.version)
resource.version = version
end
return resource
end | [
"def",
"get_resource_version",
"resource",
"=",
"get_resource_ivar",
"version",
"=",
"params",
"[",
":version",
"]",
".",
"try",
"(",
":to_i",
")",
"if",
"version",
"&&",
"version",
">",
"0",
"&&",
"version",
"<",
"resource",
".",
"version",
"resource",
".",... | add support for history | [
"add",
"support",
"for",
"history"
] | f9745fcef269a1eb501b3d0d69b75cfc432d135d | https://github.com/slate-studio/mongosteen/blob/f9745fcef269a1eb501b3d0d69b75cfc432d135d/lib/mongosteen/base_helpers.rb#L32-L43 |
7,246 | notCalle/ruby-keytree | lib/key_tree/path.rb | KeyTree.Path.- | def -(other)
other = other.to_key_path
raise KeyError unless prefix?(other)
super(other.length)
end | ruby | def -(other)
other = other.to_key_path
raise KeyError unless prefix?(other)
super(other.length)
end | [
"def",
"-",
"(",
"other",
")",
"other",
"=",
"other",
".",
"to_key_path",
"raise",
"KeyError",
"unless",
"prefix?",
"(",
"other",
")",
"super",
"(",
"other",
".",
"length",
")",
"end"
] | Returns a key path without the leading +prefix+
:call-seq:
Path - other => Path | [
"Returns",
"a",
"key",
"path",
"without",
"the",
"leading",
"+",
"prefix",
"+"
] | 1a88c902c8b5d14f21fd350338776fc094eae8e3 | https://github.com/notCalle/ruby-keytree/blob/1a88c902c8b5d14f21fd350338776fc094eae8e3/lib/key_tree/path.rb#L68-L73 |
7,247 | notCalle/ruby-keytree | lib/key_tree/path.rb | KeyTree.Path.prefix? | def prefix?(other)
other = other.to_key_path
return false if other.length > length
key_enum = each
other.all? { |other_key| key_enum.next == other_key }
end | ruby | def prefix?(other)
other = other.to_key_path
return false if other.length > length
key_enum = each
other.all? { |other_key| key_enum.next == other_key }
end | [
"def",
"prefix?",
"(",
"other",
")",
"other",
"=",
"other",
".",
"to_key_path",
"return",
"false",
"if",
"other",
".",
"length",
">",
"length",
"key_enum",
"=",
"each",
"other",
".",
"all?",
"{",
"|",
"other_key",
"|",
"key_enum",
".",
"next",
"==",
"o... | Is +other+ a prefix?
:call-seq:
prefix?(other) => boolean | [
"Is",
"+",
"other",
"+",
"a",
"prefix?"
] | 1a88c902c8b5d14f21fd350338776fc094eae8e3 | https://github.com/notCalle/ruby-keytree/blob/1a88c902c8b5d14f21fd350338776fc094eae8e3/lib/key_tree/path.rb#L79-L85 |
7,248 | gemeraldbeanstalk/stalk_climber | lib/stalk_climber/climber.rb | StalkClimber.Climber.max_job_ids | def max_job_ids
connection_pairs = connection_pool.connections.map do |connection|
[connection, connection.max_job_id]
end
return Hash[connection_pairs]
end | ruby | def max_job_ids
connection_pairs = connection_pool.connections.map do |connection|
[connection, connection.max_job_id]
end
return Hash[connection_pairs]
end | [
"def",
"max_job_ids",
"connection_pairs",
"=",
"connection_pool",
".",
"connections",
".",
"map",
"do",
"|",
"connection",
"|",
"[",
"connection",
",",
"connection",
".",
"max_job_id",
"]",
"end",
"return",
"Hash",
"[",
"connection_pairs",
"]",
"end"
] | Creates a new Climber instance, optionally yielding the instance for
configuration if a block is given
Climber.new('beanstalk://localhost:11300', 'stalk_climber')
#=> #<StalkClimber::Job beanstalk_addresses="beanstalk://localhost:11300" test_tube="stalk_climber">
:call-seq:
max_job_ids() => Hash{Beaneater... | [
"Creates",
"a",
"new",
"Climber",
"instance",
"optionally",
"yielding",
"the",
"instance",
"for",
"configuration",
"if",
"a",
"block",
"is",
"given"
] | d22f74bbae864ca2771d15621ccbf29d8e86521a | https://github.com/gemeraldbeanstalk/stalk_climber/blob/d22f74bbae864ca2771d15621ccbf29d8e86521a/lib/stalk_climber/climber.rb#L52-L57 |
7,249 | johnny/role-auth | lib/role-auth/parser.rb | RoleAuth.Parser.task | def task(name, options = {})
options[:is] = options[:is].is_a?(Array) ? options[:is] : [options[:is]].compact
@tasks[name] = Task.new(name,options)
end | ruby | def task(name, options = {})
options[:is] = options[:is].is_a?(Array) ? options[:is] : [options[:is]].compact
@tasks[name] = Task.new(name,options)
end | [
"def",
"task",
"(",
"name",
",",
"options",
"=",
"{",
"}",
")",
"options",
"[",
":is",
"]",
"=",
"options",
"[",
":is",
"]",
".",
"is_a?",
"(",
"Array",
")",
"?",
"options",
"[",
":is",
"]",
":",
"[",
"options",
"[",
":is",
"]",
"]",
".",
"co... | Define a new task.
@example Define an entirely new task
task :push
@example Define a publish task
task :publish, :is => :update, :if => only_changed(:published)
@example Define a joined manage task
task :manage, :is => [:update, :create, :delete]
@see #can More examples for the :if option
@see DEFAULT_TASKS... | [
"Define",
"a",
"new",
"task",
"."
] | 2f22e7e7766647483ca0f793be52e27fb8f96a87 | https://github.com/johnny/role-auth/blob/2f22e7e7766647483ca0f793be52e27fb8f96a87/lib/role-auth/parser.rb#L105-L108 |
7,250 | johnny/role-auth | lib/role-auth/parser.rb | RoleAuth.Parser.add_permission | def add_permission(target, *args)
raise '#can and #can_not have to be used inside a role block' unless @role
options = args.last.is_a?(Hash) ? args.pop : {}
tasks = []
models = []
models << args.pop if args.last == :any
args.each {|arg| arg.is_a?(Symbol) ? tasks << arg : models << a... | ruby | def add_permission(target, *args)
raise '#can and #can_not have to be used inside a role block' unless @role
options = args.last.is_a?(Hash) ? args.pop : {}
tasks = []
models = []
models << args.pop if args.last == :any
args.each {|arg| arg.is_a?(Symbol) ? tasks << arg : models << a... | [
"def",
"add_permission",
"(",
"target",
",",
"*",
"args",
")",
"raise",
"'#can and #can_not have to be used inside a role block'",
"unless",
"@role",
"options",
"=",
"args",
".",
"last",
".",
"is_a?",
"(",
"Hash",
")",
"?",
"args",
".",
"pop",
":",
"{",
"}",
... | Creates an internal Permission
@param [Hash] target Either the permissions or the restrictions hash
@param [Array] args The function arguments to the #can, #can_not methods | [
"Creates",
"an",
"internal",
"Permission"
] | 2f22e7e7766647483ca0f793be52e27fb8f96a87 | https://github.com/johnny/role-auth/blob/2f22e7e7766647483ca0f793be52e27fb8f96a87/lib/role-auth/parser.rb#L132-L150 |
7,251 | johnny/role-auth | lib/role-auth/parser.rb | RoleAuth.Parser.process_tasks | def process_tasks
@tasks.each_value do |task|
task.options[:ancestors] = []
set_ancestor_tasks(task)
set_alternative_tasks(task) if @permissions.key? task.name
end
end | ruby | def process_tasks
@tasks.each_value do |task|
task.options[:ancestors] = []
set_ancestor_tasks(task)
set_alternative_tasks(task) if @permissions.key? task.name
end
end | [
"def",
"process_tasks",
"@tasks",
".",
"each_value",
"do",
"|",
"task",
"|",
"task",
".",
"options",
"[",
":ancestors",
"]",
"=",
"[",
"]",
"set_ancestor_tasks",
"(",
"task",
")",
"set_alternative_tasks",
"(",
"task",
")",
"if",
"@permissions",
".",
"key?",
... | Flattens the tasks. It sets the ancestors and the alternative tasks | [
"Flattens",
"the",
"tasks",
".",
"It",
"sets",
"the",
"ancestors",
"and",
"the",
"alternative",
"tasks"
] | 2f22e7e7766647483ca0f793be52e27fb8f96a87 | https://github.com/johnny/role-auth/blob/2f22e7e7766647483ca0f793be52e27fb8f96a87/lib/role-auth/parser.rb#L153-L159 |
7,252 | johnny/role-auth | lib/role-auth/parser.rb | RoleAuth.Parser.set_ancestor_tasks | def set_ancestor_tasks(task, ancestor = nil)
task.options[:ancestors] += (ancestor || task).options[:is]
(ancestor || task).options[:is].each do |parent_task|
set_ancestor_tasks(task, @tasks[parent_task])
end
end | ruby | def set_ancestor_tasks(task, ancestor = nil)
task.options[:ancestors] += (ancestor || task).options[:is]
(ancestor || task).options[:is].each do |parent_task|
set_ancestor_tasks(task, @tasks[parent_task])
end
end | [
"def",
"set_ancestor_tasks",
"(",
"task",
",",
"ancestor",
"=",
"nil",
")",
"task",
".",
"options",
"[",
":ancestors",
"]",
"+=",
"(",
"ancestor",
"||",
"task",
")",
".",
"options",
"[",
":is",
"]",
"(",
"ancestor",
"||",
"task",
")",
".",
"options",
... | Set the ancestors on task.
@param [Task] task The task for which the ancestors are set
@param [Task] ancestor The ancestor to process. This is the recursive parameter | [
"Set",
"the",
"ancestors",
"on",
"task",
"."
] | 2f22e7e7766647483ca0f793be52e27fb8f96a87 | https://github.com/johnny/role-auth/blob/2f22e7e7766647483ca0f793be52e27fb8f96a87/lib/role-auth/parser.rb#L165-L170 |
7,253 | johnny/role-auth | lib/role-auth/parser.rb | RoleAuth.Parser.set_alternative_tasks | def set_alternative_tasks(task, ancestor = nil)
(ancestor || task).options[:is].each do |task_name|
if @permissions.key? task_name
(@tasks[task_name].options[:alternatives] ||= []) << task.name
else
set_alternative_tasks(task, @tasks[task_name])
end
end
end | ruby | def set_alternative_tasks(task, ancestor = nil)
(ancestor || task).options[:is].each do |task_name|
if @permissions.key? task_name
(@tasks[task_name].options[:alternatives] ||= []) << task.name
else
set_alternative_tasks(task, @tasks[task_name])
end
end
end | [
"def",
"set_alternative_tasks",
"(",
"task",
",",
"ancestor",
"=",
"nil",
")",
"(",
"ancestor",
"||",
"task",
")",
".",
"options",
"[",
":is",
"]",
".",
"each",
"do",
"|",
"task_name",
"|",
"if",
"@permissions",
".",
"key?",
"task_name",
"(",
"@tasks",
... | Set the alternatives of the task.
Alternatives are the nearest ancestors, which are used in permission definitions.
@param [Task] task The task for which the alternatives are set
@param [Task] ancestor The ancestor to process. This is the recursive parameter | [
"Set",
"the",
"alternatives",
"of",
"the",
"task",
".",
"Alternatives",
"are",
"the",
"nearest",
"ancestors",
"which",
"are",
"used",
"in",
"permission",
"definitions",
"."
] | 2f22e7e7766647483ca0f793be52e27fb8f96a87 | https://github.com/johnny/role-auth/blob/2f22e7e7766647483ca0f793be52e27fb8f96a87/lib/role-auth/parser.rb#L177-L185 |
7,254 | johnny/role-auth | lib/role-auth/parser.rb | RoleAuth.Parser.set_descendant_roles | def set_descendant_roles(descendant_role, ancestor_role = nil)
role = ancestor_role || descendant_role
return unless role[:is]
role[:is].each do |role_name|
(@roles[role_name][:descendants] ||= []) << descendant_role[:name]
set_descendant_roles(descendant_role, @roles[role_name])
... | ruby | def set_descendant_roles(descendant_role, ancestor_role = nil)
role = ancestor_role || descendant_role
return unless role[:is]
role[:is].each do |role_name|
(@roles[role_name][:descendants] ||= []) << descendant_role[:name]
set_descendant_roles(descendant_role, @roles[role_name])
... | [
"def",
"set_descendant_roles",
"(",
"descendant_role",
",",
"ancestor_role",
"=",
"nil",
")",
"role",
"=",
"ancestor_role",
"||",
"descendant_role",
"return",
"unless",
"role",
"[",
":is",
"]",
"role",
"[",
":is",
"]",
".",
"each",
"do",
"|",
"role_name",
"|... | Set the descendant_role as a descendant of the ancestor | [
"Set",
"the",
"descendant_role",
"as",
"a",
"descendant",
"of",
"the",
"ancestor"
] | 2f22e7e7766647483ca0f793be52e27fb8f96a87 | https://github.com/johnny/role-auth/blob/2f22e7e7766647483ca0f793be52e27fb8f96a87/lib/role-auth/parser.rb#L193-L201 |
7,255 | anga/BetterRailsDebugger | app/models/better_rails_debugger/group_instance.rb | BetterRailsDebugger.GroupInstance.big_classes | def big_classes(max_size=1.megabytes)
return @big_classes if @big_classes
@big_classes = {}
ObjectInformation.where(:group_instance_id => self.id, :memsize.gt => max_size).all.each do |object|
@big_classes[object.class_name] ||= {total_mem: 0, average: 0, count: 0}
@big_classes[object.... | ruby | def big_classes(max_size=1.megabytes)
return @big_classes if @big_classes
@big_classes = {}
ObjectInformation.where(:group_instance_id => self.id, :memsize.gt => max_size).all.each do |object|
@big_classes[object.class_name] ||= {total_mem: 0, average: 0, count: 0}
@big_classes[object.... | [
"def",
"big_classes",
"(",
"max_size",
"=",
"1",
".",
"megabytes",
")",
"return",
"@big_classes",
"if",
"@big_classes",
"@big_classes",
"=",
"{",
"}",
"ObjectInformation",
".",
"where",
"(",
":group_instance_id",
"=>",
"self",
".",
"id",
",",
":memsize",
".",
... | Return an array of hashed that contains some information about the classes that consume more than `max_size` bytess | [
"Return",
"an",
"array",
"of",
"hashed",
"that",
"contains",
"some",
"information",
"about",
"the",
"classes",
"that",
"consume",
"more",
"than",
"max_size",
"bytess"
] | 2ac7af13b8ee12483bd9a92680d8f43042f1f1d5 | https://github.com/anga/BetterRailsDebugger/blob/2ac7af13b8ee12483bd9a92680d8f43042f1f1d5/app/models/better_rails_debugger/group_instance.rb#L72-L84 |
7,256 | mrsimonfletcher/roroacms | app/controllers/roroacms/admin/terms_controller.rb | Roroacms.Admin::TermsController.categories | def categories
# add breadcrumb and set title
add_breadcrumb I18n.t("generic.categories"), :admin_article_categories_path, :title => I18n.t("controllers.admin.terms.categories.breadcrumb_title")
set_title(I18n.t("generic.categories"))
@type = 'category'
@records = Term.term_cats('category'... | ruby | def categories
# add breadcrumb and set title
add_breadcrumb I18n.t("generic.categories"), :admin_article_categories_path, :title => I18n.t("controllers.admin.terms.categories.breadcrumb_title")
set_title(I18n.t("generic.categories"))
@type = 'category'
@records = Term.term_cats('category'... | [
"def",
"categories",
"# add breadcrumb and set title",
"add_breadcrumb",
"I18n",
".",
"t",
"(",
"\"generic.categories\"",
")",
",",
":admin_article_categories_path",
",",
":title",
"=>",
"I18n",
".",
"t",
"(",
"\"controllers.admin.terms.categories.breadcrumb_title\"",
")",
... | displays all the current categories and creates a new category object for creating a new one | [
"displays",
"all",
"the",
"current",
"categories",
"and",
"creates",
"a",
"new",
"category",
"object",
"for",
"creating",
"a",
"new",
"one"
] | 62654a2f2a48e3adb3105f4dafb6e315b460eaf4 | https://github.com/mrsimonfletcher/roroacms/blob/62654a2f2a48e3adb3105f4dafb6e315b460eaf4/app/controllers/roroacms/admin/terms_controller.rb#L7-L16 |
7,257 | mrsimonfletcher/roroacms | app/controllers/roroacms/admin/terms_controller.rb | Roroacms.Admin::TermsController.create | def create
@category = Term.new(term_params)
redirect_url = Term.get_redirect_url(params)
respond_to do |format|
if @category.save
@term_anatomy = @category.create_term_anatomy(:taxonomy => params[:type_taxonomy])
format.html { redirect_to URI.parse(redirect_url).path, o... | ruby | def create
@category = Term.new(term_params)
redirect_url = Term.get_redirect_url(params)
respond_to do |format|
if @category.save
@term_anatomy = @category.create_term_anatomy(:taxonomy => params[:type_taxonomy])
format.html { redirect_to URI.parse(redirect_url).path, o... | [
"def",
"create",
"@category",
"=",
"Term",
".",
"new",
"(",
"term_params",
")",
"redirect_url",
"=",
"Term",
".",
"get_redirect_url",
"(",
"params",
")",
"respond_to",
"do",
"|",
"format",
"|",
"if",
"@category",
".",
"save",
"@term_anatomy",
"=",
"@category... | create tag or category - this is set within the form | [
"create",
"tag",
"or",
"category",
"-",
"this",
"is",
"set",
"within",
"the",
"form"
] | 62654a2f2a48e3adb3105f4dafb6e315b460eaf4 | https://github.com/mrsimonfletcher/roroacms/blob/62654a2f2a48e3adb3105f4dafb6e315b460eaf4/app/controllers/roroacms/admin/terms_controller.rb#L34-L53 |
7,258 | mrsimonfletcher/roroacms | app/controllers/roroacms/admin/terms_controller.rb | Roroacms.Admin::TermsController.update | def update
@category = Term.find(params[:id])
@category.deal_with_cover(params[:has_cover_image])
respond_to do |format|
# deal with abnormalaties - update the structure url
if @category.update_attributes(term_params)
format.html { redirect_to edit_admin_term_path(@category),... | ruby | def update
@category = Term.find(params[:id])
@category.deal_with_cover(params[:has_cover_image])
respond_to do |format|
# deal with abnormalaties - update the structure url
if @category.update_attributes(term_params)
format.html { redirect_to edit_admin_term_path(@category),... | [
"def",
"update",
"@category",
"=",
"Term",
".",
"find",
"(",
"params",
"[",
":id",
"]",
")",
"@category",
".",
"deal_with_cover",
"(",
"params",
"[",
":has_cover_image",
"]",
")",
"respond_to",
"do",
"|",
"format",
"|",
"# deal with abnormalaties - update the st... | update the term record with the given parameters | [
"update",
"the",
"term",
"record",
"with",
"the",
"given",
"parameters"
] | 62654a2f2a48e3adb3105f4dafb6e315b460eaf4 | https://github.com/mrsimonfletcher/roroacms/blob/62654a2f2a48e3adb3105f4dafb6e315b460eaf4/app/controllers/roroacms/admin/terms_controller.rb#L67-L81 |
7,259 | mrsimonfletcher/roroacms | app/controllers/roroacms/admin/terms_controller.rb | Roroacms.Admin::TermsController.destroy | def destroy
@term = Term.find(params[:id])
# return url will be different for either tag or category
redirect_url = Term.get_redirect_url({ type_taxonomy: @term.term_anatomy.taxonomy })
@term.destroy
respond_to do |format|
format.html { redirect_to URI.parse(redirect_url).path, no... | ruby | def destroy
@term = Term.find(params[:id])
# return url will be different for either tag or category
redirect_url = Term.get_redirect_url({ type_taxonomy: @term.term_anatomy.taxonomy })
@term.destroy
respond_to do |format|
format.html { redirect_to URI.parse(redirect_url).path, no... | [
"def",
"destroy",
"@term",
"=",
"Term",
".",
"find",
"(",
"params",
"[",
":id",
"]",
")",
"# return url will be different for either tag or category",
"redirect_url",
"=",
"Term",
".",
"get_redirect_url",
"(",
"{",
"type_taxonomy",
":",
"@term",
".",
"term_anatomy",... | delete the term | [
"delete",
"the",
"term"
] | 62654a2f2a48e3adb3105f4dafb6e315b460eaf4 | https://github.com/mrsimonfletcher/roroacms/blob/62654a2f2a48e3adb3105f4dafb6e315b460eaf4/app/controllers/roroacms/admin/terms_controller.rb#L86-L95 |
7,260 | mrsimonfletcher/roroacms | app/controllers/roroacms/admin/terms_controller.rb | Roroacms.Admin::TermsController.edit_title | def edit_title
if @category.term_anatomy.taxonomy == 'category'
add_breadcrumb I18n.t("generic.categories"), :admin_article_categories_path, :title => I18n.t("controllers.admin.terms.edit_title.category.breadcrumb_title")
add_breadcrumb I18n.t("controllers.admin.terms.edit_title.category.title")
... | ruby | def edit_title
if @category.term_anatomy.taxonomy == 'category'
add_breadcrumb I18n.t("generic.categories"), :admin_article_categories_path, :title => I18n.t("controllers.admin.terms.edit_title.category.breadcrumb_title")
add_breadcrumb I18n.t("controllers.admin.terms.edit_title.category.title")
... | [
"def",
"edit_title",
"if",
"@category",
".",
"term_anatomy",
".",
"taxonomy",
"==",
"'category'",
"add_breadcrumb",
"I18n",
".",
"t",
"(",
"\"generic.categories\"",
")",
",",
":admin_article_categories_path",
",",
":title",
"=>",
"I18n",
".",
"t",
"(",
"\"controll... | set the title and breadcrumbs for the edit screen | [
"set",
"the",
"title",
"and",
"breadcrumbs",
"for",
"the",
"edit",
"screen"
] | 62654a2f2a48e3adb3105f4dafb6e315b460eaf4 | https://github.com/mrsimonfletcher/roroacms/blob/62654a2f2a48e3adb3105f4dafb6e315b460eaf4/app/controllers/roroacms/admin/terms_controller.rb#L116-L130 |
7,261 | buzzware/yore | lib/yore/yore_core.rb | YoreCore.Yore.upload | def upload(aFile)
#ensure_bucket()
logger.debug "Uploading #{aFile} to S3 bucket #{config[:bucket]} ..."
logger.info "Uploading #{File.basename(aFile)} to S3 bucket #{config[:bucket]} ..."
s3client.upload_backup(aFile,config[:bucket],File.basename(aFile))
end | ruby | def upload(aFile)
#ensure_bucket()
logger.debug "Uploading #{aFile} to S3 bucket #{config[:bucket]} ..."
logger.info "Uploading #{File.basename(aFile)} to S3 bucket #{config[:bucket]} ..."
s3client.upload_backup(aFile,config[:bucket],File.basename(aFile))
end | [
"def",
"upload",
"(",
"aFile",
")",
"#ensure_bucket()",
"logger",
".",
"debug",
"\"Uploading #{aFile} to S3 bucket #{config[:bucket]} ...\"",
"logger",
".",
"info",
"\"Uploading #{File.basename(aFile)} to S3 bucket #{config[:bucket]} ...\"",
"s3client",
".",
"upload_backup",
"(",
... | uploads the given file to the current bucket as its basename | [
"uploads",
"the",
"given",
"file",
"to",
"the",
"current",
"bucket",
"as",
"its",
"basename"
] | 96ace47e0574e1405becd4dafb5de0226896ea1e | https://github.com/buzzware/yore/blob/96ace47e0574e1405becd4dafb5de0226896ea1e/lib/yore/yore_core.rb#L308-L313 |
7,262 | buzzware/yore | lib/yore/yore_core.rb | YoreCore.Yore.decode_file_name | def decode_file_name(aFilename)
prefix,date,ext = aFilename.scan(/(.*?)\-(.*?)\.(.*)/).flatten
return Time.from_date_numeric(date)
end | ruby | def decode_file_name(aFilename)
prefix,date,ext = aFilename.scan(/(.*?)\-(.*?)\.(.*)/).flatten
return Time.from_date_numeric(date)
end | [
"def",
"decode_file_name",
"(",
"aFilename",
")",
"prefix",
",",
"date",
",",
"ext",
"=",
"aFilename",
".",
"scan",
"(",
"/",
"\\-",
"\\.",
"/",
")",
".",
"flatten",
"return",
"Time",
".",
"from_date_numeric",
"(",
"date",
")",
"end"
] | return date based on filename | [
"return",
"date",
"based",
"on",
"filename"
] | 96ace47e0574e1405becd4dafb5de0226896ea1e | https://github.com/buzzware/yore/blob/96ace47e0574e1405becd4dafb5de0226896ea1e/lib/yore/yore_core.rb#L334-L337 |
7,263 | Fire-Dragon-DoL/fried-schema | lib/fried/schema/attribute/define_reader.rb | Fried::Schema::Attribute.DefineReader.call | def call(definition, klass)
variable = definition.instance_variable
klass.instance_eval do
define_method(definition.reader) { instance_variable_get(variable) }
end
end | ruby | def call(definition, klass)
variable = definition.instance_variable
klass.instance_eval do
define_method(definition.reader) { instance_variable_get(variable) }
end
end | [
"def",
"call",
"(",
"definition",
",",
"klass",
")",
"variable",
"=",
"definition",
".",
"instance_variable",
"klass",
".",
"instance_eval",
"do",
"define_method",
"(",
"definition",
".",
"reader",
")",
"{",
"instance_variable_get",
"(",
"variable",
")",
"}",
... | Creates read method
@param definition [Definition]
@param klass [Class, Module]
@return [Definition] | [
"Creates",
"read",
"method"
] | 85c5a093f319fc0f0d242264fdd7a2acfd805eea | https://github.com/Fire-Dragon-DoL/fried-schema/blob/85c5a093f319fc0f0d242264fdd7a2acfd805eea/lib/fried/schema/attribute/define_reader.rb#L19-L25 |
7,264 | barkerest/barkest_core | app/helpers/barkest_core/misc_helper.rb | BarkestCore.MiscHelper.fixed | def fixed(value, places = 2)
value = value.to_s.to_f unless value.is_a?(Float)
sprintf("%0.#{places}f", value.round(places))
end | ruby | def fixed(value, places = 2)
value = value.to_s.to_f unless value.is_a?(Float)
sprintf("%0.#{places}f", value.round(places))
end | [
"def",
"fixed",
"(",
"value",
",",
"places",
"=",
"2",
")",
"value",
"=",
"value",
".",
"to_s",
".",
"to_f",
"unless",
"value",
".",
"is_a?",
"(",
"Float",
")",
"sprintf",
"(",
"\"%0.#{places}f\"",
",",
"value",
".",
"round",
"(",
"places",
")",
")",... | Formats a number to the specified number of decimal places.
The +value+ can be either any valid numeric expression that can be converted to a float. | [
"Formats",
"a",
"number",
"to",
"the",
"specified",
"number",
"of",
"decimal",
"places",
"."
] | 3eeb025ec870888cacbc9bae252a39ebf9295f61 | https://github.com/barkerest/barkest_core/blob/3eeb025ec870888cacbc9bae252a39ebf9295f61/app/helpers/barkest_core/misc_helper.rb#L27-L30 |
7,265 | barkerest/barkest_core | app/helpers/barkest_core/misc_helper.rb | BarkestCore.MiscHelper.split_name | def split_name(name)
name ||= ''
if name.include?(',')
last,first = name.split(',', 2)
first,middle = first.to_s.strip.split(' ', 2)
else
first,middle,last = name.split(' ', 3)
if middle && !last
middle,last = last,middle
end
end
... | ruby | def split_name(name)
name ||= ''
if name.include?(',')
last,first = name.split(',', 2)
first,middle = first.to_s.strip.split(' ', 2)
else
first,middle,last = name.split(' ', 3)
if middle && !last
middle,last = last,middle
end
end
... | [
"def",
"split_name",
"(",
"name",
")",
"name",
"||=",
"''",
"if",
"name",
".",
"include?",
"(",
"','",
")",
"last",
",",
"first",
"=",
"name",
".",
"split",
"(",
"','",
",",
"2",
")",
"first",
",",
"middle",
"=",
"first",
".",
"to_s",
".",
"strip... | Splits a name into First, Middle, and Last parts.
Returns an array containing [ First, Middle, Last ]
Any part that is missing will be nil.
'John Doe' => [ 'John', nil, 'Doe' ]
'Doe, John' => [ 'John', nil, 'Doe' ]
'John A. Doe' => [ 'John', 'A.', 'Doe' ]
'Doe, John A.' => [ ... | [
"Splits",
"a",
"name",
"into",
"First",
"Middle",
"and",
"Last",
"parts",
"."
] | 3eeb025ec870888cacbc9bae252a39ebf9295f61 | https://github.com/barkerest/barkest_core/blob/3eeb025ec870888cacbc9bae252a39ebf9295f61/app/helpers/barkest_core/misc_helper.rb#L53-L65 |
7,266 | gabebw/pipio | lib/pipio/parsers/basic_parser.rb | Pipio.BasicParser.parse | def parse
if pre_parse
messages = @file_reader.other_lines.map do |line|
basic_message_match = @line_regex.match(line)
meta_message_match = @line_regex_status.match(line)
if basic_message_match
create_message(basic_message_match)
elsif meta_message_matc... | ruby | def parse
if pre_parse
messages = @file_reader.other_lines.map do |line|
basic_message_match = @line_regex.match(line)
meta_message_match = @line_regex_status.match(line)
if basic_message_match
create_message(basic_message_match)
elsif meta_message_matc... | [
"def",
"parse",
"if",
"pre_parse",
"messages",
"=",
"@file_reader",
".",
"other_lines",
".",
"map",
"do",
"|",
"line",
"|",
"basic_message_match",
"=",
"@line_regex",
".",
"match",
"(",
"line",
")",
"meta_message_match",
"=",
"@line_regex_status",
".",
"match",
... | This method returns a Chat instance, or false if it could not parse the
file. | [
"This",
"method",
"returns",
"a",
"Chat",
"instance",
"or",
"false",
"if",
"it",
"could",
"not",
"parse",
"the",
"file",
"."
] | ce8abe90c9e75d916fd3a5a0f5d73e7ac9c4eacd | https://github.com/gabebw/pipio/blob/ce8abe90c9e75d916fd3a5a0f5d73e7ac9c4eacd/lib/pipio/parsers/basic_parser.rb#L14-L28 |
7,267 | gabebw/pipio | lib/pipio/parsers/basic_parser.rb | Pipio.BasicParser.pre_parse | def pre_parse
@file_reader.read
metadata = Metadata.new(MetadataParser.new(@file_reader.first_line).parse)
if metadata.valid?
@metadata = metadata
@alias_registry = AliasRegistry.new(@metadata.their_screen_name)
@my_aliases.each do |my_alias|
@alias_registry[my_alias]... | ruby | def pre_parse
@file_reader.read
metadata = Metadata.new(MetadataParser.new(@file_reader.first_line).parse)
if metadata.valid?
@metadata = metadata
@alias_registry = AliasRegistry.new(@metadata.their_screen_name)
@my_aliases.each do |my_alias|
@alias_registry[my_alias]... | [
"def",
"pre_parse",
"@file_reader",
".",
"read",
"metadata",
"=",
"Metadata",
".",
"new",
"(",
"MetadataParser",
".",
"new",
"(",
"@file_reader",
".",
"first_line",
")",
".",
"parse",
")",
"if",
"metadata",
".",
"valid?",
"@metadata",
"=",
"metadata",
"@alia... | Extract required data from the file. Run by parse. | [
"Extract",
"required",
"data",
"from",
"the",
"file",
".",
"Run",
"by",
"parse",
"."
] | ce8abe90c9e75d916fd3a5a0f5d73e7ac9c4eacd | https://github.com/gabebw/pipio/blob/ce8abe90c9e75d916fd3a5a0f5d73e7ac9c4eacd/lib/pipio/parsers/basic_parser.rb#L31-L41 |
7,268 | ajsharp/em-stathat | lib/em-stathat.rb | EventMachine.StatHat.time | def time(name, opts = {})
opts[:ez] ||= true
start = Time.now
yield if block_given?
if opts[:ez] == true
ez_value(name, (Time.now - start))
else
value(name, (Time.now - start))
end
end | ruby | def time(name, opts = {})
opts[:ez] ||= true
start = Time.now
yield if block_given?
if opts[:ez] == true
ez_value(name, (Time.now - start))
else
value(name, (Time.now - start))
end
end | [
"def",
"time",
"(",
"name",
",",
"opts",
"=",
"{",
"}",
")",
"opts",
"[",
":ez",
"]",
"||=",
"true",
"start",
"=",
"Time",
".",
"now",
"yield",
"if",
"block_given?",
"if",
"opts",
"[",
":ez",
"]",
"==",
"true",
"ez_value",
"(",
"name",
",",
"(",
... | Time a block of code and send the duration as a value
@example
StatHat.new.time('some identifying name') do
# code
end
@param [String] name the name of the stat
@param [Hash] opts a hash of options
@option [Symbol] :ez Send data via the ez api (default: true) | [
"Time",
"a",
"block",
"of",
"code",
"and",
"send",
"the",
"duration",
"as",
"a",
"value"
] | a5b19339e9720f8b9858d65e020371511ca91b63 | https://github.com/ajsharp/em-stathat/blob/a5b19339e9720f8b9858d65e020371511ca91b63/lib/em-stathat.rb#L47-L58 |
7,269 | mudasobwa/qipowl | lib/qipowl/core/bowler.rb | Qipowl::Bowlers.Bowler.add_entity | def add_entity section, key, value, enclosure_value = null
if (tags = self.class.const_get("#{section.upcase}_TAGS"))
key = key.bowl.to_sym
tags[key] = value.to_sym
self.class.const_get("ENCLOSURES_TAGS")[key] = enclosure_value.to_sym if enclosure_value
self.class.const_get("ENTITI... | ruby | def add_entity section, key, value, enclosure_value = null
if (tags = self.class.const_get("#{section.upcase}_TAGS"))
key = key.bowl.to_sym
tags[key] = value.to_sym
self.class.const_get("ENCLOSURES_TAGS")[key] = enclosure_value.to_sym if enclosure_value
self.class.const_get("ENTITI... | [
"def",
"add_entity",
"section",
",",
"key",
",",
"value",
",",
"enclosure_value",
"=",
"null",
"if",
"(",
"tags",
"=",
"self",
".",
"class",
".",
"const_get",
"(",
"\"#{section.upcase}_TAGS\"",
")",
")",
"key",
"=",
"key",
".",
"bowl",
".",
"to_sym",
"ta... | Adds new +entity+ in the section specified.
E. g., call to
add_spice :linewide, :°, :deg, :degrees
in HTML implementation adds a support for specifying something like:
° 15
° 30
° 45
which is to be converted to the following:
<degrees>
<deg>15</deg>
<deg>30</deg>
<d... | [
"Adds",
"new",
"+",
"entity",
"+",
"in",
"the",
"section",
"specified",
".",
"E",
".",
"g",
".",
"call",
"to"
] | 1d4643a53914d963daa73c649a043ad0ac0d71c8 | https://github.com/mudasobwa/qipowl/blob/1d4643a53914d963daa73c649a043ad0ac0d71c8/lib/qipowl/core/bowler.rb#L99-L112 |
7,270 | jinx/core | lib/jinx/metadata/property.rb | Jinx.Property.restrict_flags | def restrict_flags(declarer, *flags)
copy = restrict(declarer)
copy.qualify(*flags)
copy
end | ruby | def restrict_flags(declarer, *flags)
copy = restrict(declarer)
copy.qualify(*flags)
copy
end | [
"def",
"restrict_flags",
"(",
"declarer",
",",
"*",
"flags",
")",
"copy",
"=",
"restrict",
"(",
"declarer",
")",
"copy",
".",
"qualify",
"(",
"flags",
")",
"copy",
"end"
] | Creates a new declarer attribute which qualifies this attribute for the given declarer.
@param declarer (see #restrict)
@param [<Symbol>] flags the additional flags for the restricted attribute
@return (see #restrict) | [
"Creates",
"a",
"new",
"declarer",
"attribute",
"which",
"qualifies",
"this",
"attribute",
"for",
"the",
"given",
"declarer",
"."
] | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/metadata/property.rb#L95-L99 |
7,271 | jinx/core | lib/jinx/metadata/property.rb | Jinx.Property.inverse= | def inverse=(attribute)
return if inverse == attribute
# if no attribute, then the clear the existing inverse, if any
return clear_inverse if attribute.nil?
# the inverse attribute meta-data
begin
@inv_prop = type.property(attribute)
rescue NameError => e
raise Metada... | ruby | def inverse=(attribute)
return if inverse == attribute
# if no attribute, then the clear the existing inverse, if any
return clear_inverse if attribute.nil?
# the inverse attribute meta-data
begin
@inv_prop = type.property(attribute)
rescue NameError => e
raise Metada... | [
"def",
"inverse",
"=",
"(",
"attribute",
")",
"return",
"if",
"inverse",
"==",
"attribute",
"# if no attribute, then the clear the existing inverse, if any",
"return",
"clear_inverse",
"if",
"attribute",
".",
"nil?",
"# the inverse attribute meta-data",
"begin",
"@inv_prop",
... | Sets the inverse of the subject attribute to the given attribute.
The inverse relation is symmetric, i.e. the inverse of the referenced Property
is set to this Property's subject attribute.
@param [Symbol, nil] attribute the inverse attribute
@raise [MetadataError] if the the inverse of the inverse is already set ... | [
"Sets",
"the",
"inverse",
"of",
"the",
"subject",
"attribute",
"to",
"the",
"given",
"attribute",
".",
"The",
"inverse",
"relation",
"is",
"symmetric",
"i",
".",
"e",
".",
"the",
"inverse",
"of",
"the",
"referenced",
"Property",
"is",
"set",
"to",
"this",
... | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/metadata/property.rb#L107-L128 |
7,272 | jinx/core | lib/jinx/metadata/property.rb | Jinx.Property.owner_flag_set | def owner_flag_set
if dependent? then
raise MetadataError.new("#{declarer.qp}.#{self} cannot be set as a #{type.qp} owner since it is already defined as a #{type.qp} dependent")
end
inv_prop = inverse_property
if inv_prop then
inv_prop.qualify(:dependent) unless inv_prop.dependen... | ruby | def owner_flag_set
if dependent? then
raise MetadataError.new("#{declarer.qp}.#{self} cannot be set as a #{type.qp} owner since it is already defined as a #{type.qp} dependent")
end
inv_prop = inverse_property
if inv_prop then
inv_prop.qualify(:dependent) unless inv_prop.dependen... | [
"def",
"owner_flag_set",
"if",
"dependent?",
"then",
"raise",
"MetadataError",
".",
"new",
"(",
"\"#{declarer.qp}.#{self} cannot be set as a #{type.qp} owner since it is already defined as a #{type.qp} dependent\"",
")",
"end",
"inv_prop",
"=",
"inverse_property",
"if",
"inv_prop",... | This method is called when the owner flag is set.
The inverse is inferred as the referenced owner type's dependent attribute which references
this attribute's type.
@raise [MetadataError] if this attribute is dependent or an inverse could not be inferred | [
"This",
"method",
"is",
"called",
"when",
"the",
"owner",
"flag",
"is",
"set",
".",
"The",
"inverse",
"is",
"inferred",
"as",
"the",
"referenced",
"owner",
"type",
"s",
"dependent",
"attribute",
"which",
"references",
"this",
"attribute",
"s",
"type",
"."
] | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/metadata/property.rb#L285-L300 |
7,273 | 7compass/truncus | lib/truncus.rb | Truncus.Client.get_token | def get_token(url)
req = Net::HTTP::Post.new('/', initheader = {'Content-Type' => 'application/json'})
req.body = {url: url, format: 'json'}.to_json
res = @http.request(req)
data = JSON::parse(res.body)
data['trunct']['token']
end | ruby | def get_token(url)
req = Net::HTTP::Post.new('/', initheader = {'Content-Type' => 'application/json'})
req.body = {url: url, format: 'json'}.to_json
res = @http.request(req)
data = JSON::parse(res.body)
data['trunct']['token']
end | [
"def",
"get_token",
"(",
"url",
")",
"req",
"=",
"Net",
"::",
"HTTP",
"::",
"Post",
".",
"new",
"(",
"'/'",
",",
"initheader",
"=",
"{",
"'Content-Type'",
"=>",
"'application/json'",
"}",
")",
"req",
".",
"body",
"=",
"{",
"url",
":",
"url",
",",
"... | Shortens a URL, returns the shortened token | [
"Shortens",
"a",
"URL",
"returns",
"the",
"shortened",
"token"
] | 504d1bbcb97a862da889fb22d120c070e1877650 | https://github.com/7compass/truncus/blob/504d1bbcb97a862da889fb22d120c070e1877650/lib/truncus.rb#L44-L51 |
7,274 | riddopic/garcun | lib/garcon/task/thread_pool/executor.rb | Garcon.ThreadPoolExecutor.on_worker_exit | def on_worker_exit(worker)
mutex.synchronize do
@pool.delete(worker)
if @pool.empty? && !running?
stop_event.set
stopped_event.set
end
end
end | ruby | def on_worker_exit(worker)
mutex.synchronize do
@pool.delete(worker)
if @pool.empty? && !running?
stop_event.set
stopped_event.set
end
end
end | [
"def",
"on_worker_exit",
"(",
"worker",
")",
"mutex",
".",
"synchronize",
"do",
"@pool",
".",
"delete",
"(",
"worker",
")",
"if",
"@pool",
".",
"empty?",
"&&",
"!",
"running?",
"stop_event",
".",
"set",
"stopped_event",
".",
"set",
"end",
"end",
"end"
] | Run when a thread worker exits.
@!visibility private | [
"Run",
"when",
"a",
"thread",
"worker",
"exits",
"."
] | c2409bd8cf9c14b967a719810dab5269d69b42de | https://github.com/riddopic/garcun/blob/c2409bd8cf9c14b967a719810dab5269d69b42de/lib/garcon/task/thread_pool/executor.rb#L178-L186 |
7,275 | riddopic/garcun | lib/garcon/task/thread_pool/executor.rb | Garcon.ThreadPoolExecutor.execute | def execute(*args, &task)
if ensure_capacity?
@scheduled_task_count += 1
@queue << [args, task]
else
if @max_queue != 0 && @queue.length >= @max_queue
handle_fallback(*args, &task)
end
end
prune_pool
end | ruby | def execute(*args, &task)
if ensure_capacity?
@scheduled_task_count += 1
@queue << [args, task]
else
if @max_queue != 0 && @queue.length >= @max_queue
handle_fallback(*args, &task)
end
end
prune_pool
end | [
"def",
"execute",
"(",
"*",
"args",
",",
"&",
"task",
")",
"if",
"ensure_capacity?",
"@scheduled_task_count",
"+=",
"1",
"@queue",
"<<",
"[",
"args",
",",
"task",
"]",
"else",
"if",
"@max_queue",
"!=",
"0",
"&&",
"@queue",
".",
"length",
">=",
"@max_queu... | A T T E N Z I O N E A R E A P R O T E T T A
@!visibility private | [
"A",
"T",
"T",
"E",
"N",
"Z",
"I",
"O",
"N",
"E",
"A",
"R",
"E",
"A",
"P",
"R",
"O",
"T",
"E",
"T",
"T",
"A"
] | c2409bd8cf9c14b967a719810dab5269d69b42de | https://github.com/riddopic/garcun/blob/c2409bd8cf9c14b967a719810dab5269d69b42de/lib/garcon/task/thread_pool/executor.rb#L191-L201 |
7,276 | riddopic/garcun | lib/garcon/task/thread_pool/executor.rb | Garcon.ThreadPoolExecutor.ensure_capacity? | def ensure_capacity?
additional = 0
capacity = true
if @pool.size < @min_length
additional = @min_length - @pool.size
elsif @queue.empty? && @queue.num_waiting >= 1
additional = 0
elsif @pool.size == 0 && @min_length == 0
additional = 1
elsif @pool.size < ... | ruby | def ensure_capacity?
additional = 0
capacity = true
if @pool.size < @min_length
additional = @min_length - @pool.size
elsif @queue.empty? && @queue.num_waiting >= 1
additional = 0
elsif @pool.size == 0 && @min_length == 0
additional = 1
elsif @pool.size < ... | [
"def",
"ensure_capacity?",
"additional",
"=",
"0",
"capacity",
"=",
"true",
"if",
"@pool",
".",
"size",
"<",
"@min_length",
"additional",
"=",
"@min_length",
"-",
"@pool",
".",
"size",
"elsif",
"@queue",
".",
"empty?",
"&&",
"@queue",
".",
"num_waiting",
">=... | Check the thread pool configuration and determine if the pool
has enought capacity to handle the request. Will grow the size
of the pool if necessary.
@return [Boolean] true if the pool has enough capacity else false
@!visibility private | [
"Check",
"the",
"thread",
"pool",
"configuration",
"and",
"determine",
"if",
"the",
"pool",
"has",
"enought",
"capacity",
"to",
"handle",
"the",
"request",
".",
"Will",
"grow",
"the",
"size",
"of",
"the",
"pool",
"if",
"necessary",
"."
] | c2409bd8cf9c14b967a719810dab5269d69b42de | https://github.com/riddopic/garcun/blob/c2409bd8cf9c14b967a719810dab5269d69b42de/lib/garcon/task/thread_pool/executor.rb#L225-L252 |
7,277 | riddopic/garcun | lib/garcon/task/thread_pool/executor.rb | Garcon.ThreadPoolExecutor.prune_pool | def prune_pool
if Garcon.monotonic_time - @gc_interval >= @last_gc_time
@pool.delete_if { |worker| worker.dead? }
# send :stop for each thread over idletime
@pool.select { |worker| @idletime != 0 &&
Garcon.monotonic_time - @idletime > worker.last_activity
}.each { @queue ... | ruby | def prune_pool
if Garcon.monotonic_time - @gc_interval >= @last_gc_time
@pool.delete_if { |worker| worker.dead? }
# send :stop for each thread over idletime
@pool.select { |worker| @idletime != 0 &&
Garcon.monotonic_time - @idletime > worker.last_activity
}.each { @queue ... | [
"def",
"prune_pool",
"if",
"Garcon",
".",
"monotonic_time",
"-",
"@gc_interval",
">=",
"@last_gc_time",
"@pool",
".",
"delete_if",
"{",
"|",
"worker",
"|",
"worker",
".",
"dead?",
"}",
"# send :stop for each thread over idletime",
"@pool",
".",
"select",
"{",
"|",... | Scan all threads in the pool and reclaim any that are dead or
have been idle too long. Will check the last time the pool was
pruned and only run if the configured garbage collection
interval has passed.
@!visibility private | [
"Scan",
"all",
"threads",
"in",
"the",
"pool",
"and",
"reclaim",
"any",
"that",
"are",
"dead",
"or",
"have",
"been",
"idle",
"too",
"long",
".",
"Will",
"check",
"the",
"last",
"time",
"the",
"pool",
"was",
"pruned",
"and",
"only",
"run",
"if",
"the",
... | c2409bd8cf9c14b967a719810dab5269d69b42de | https://github.com/riddopic/garcun/blob/c2409bd8cf9c14b967a719810dab5269d69b42de/lib/garcon/task/thread_pool/executor.rb#L260-L269 |
7,278 | riddopic/garcun | lib/garcon/task/thread_pool/executor.rb | Garcon.ThreadPoolExecutor.create_worker_thread | def create_worker_thread
wrkr = ThreadPoolWorker.new(@queue, self)
Thread.new(wrkr, self) do |worker, parent|
Thread.current.abort_on_exception = false
worker.run
parent.on_worker_exit(worker)
end
return wrkr
end | ruby | def create_worker_thread
wrkr = ThreadPoolWorker.new(@queue, self)
Thread.new(wrkr, self) do |worker, parent|
Thread.current.abort_on_exception = false
worker.run
parent.on_worker_exit(worker)
end
return wrkr
end | [
"def",
"create_worker_thread",
"wrkr",
"=",
"ThreadPoolWorker",
".",
"new",
"(",
"@queue",
",",
"self",
")",
"Thread",
".",
"new",
"(",
"wrkr",
",",
"self",
")",
"do",
"|",
"worker",
",",
"parent",
"|",
"Thread",
".",
"current",
".",
"abort_on_exception",
... | Create a single worker thread to be added to the pool.
@return [Thread] the new thread.
@!visibility private | [
"Create",
"a",
"single",
"worker",
"thread",
"to",
"be",
"added",
"to",
"the",
"pool",
"."
] | c2409bd8cf9c14b967a719810dab5269d69b42de | https://github.com/riddopic/garcun/blob/c2409bd8cf9c14b967a719810dab5269d69b42de/lib/garcon/task/thread_pool/executor.rb#L284-L292 |
7,279 | omegainteractive/comfypress | lib/comfypress/tag.rb | ComfyPress::Tag.InstanceMethods.render | def render
ignore = [ComfyPress::Tag::Partial, ComfyPress::Tag::Helper].member?(self.class)
ComfyPress::Tag.sanitize_irb(content, ignore)
end | ruby | def render
ignore = [ComfyPress::Tag::Partial, ComfyPress::Tag::Helper].member?(self.class)
ComfyPress::Tag.sanitize_irb(content, ignore)
end | [
"def",
"render",
"ignore",
"=",
"[",
"ComfyPress",
"::",
"Tag",
"::",
"Partial",
",",
"ComfyPress",
"::",
"Tag",
"::",
"Helper",
"]",
".",
"member?",
"(",
"self",
".",
"class",
")",
"ComfyPress",
"::",
"Tag",
".",
"sanitize_irb",
"(",
"content",
",",
"... | Content that is used during page rendering. Outputting existing content
as a default. | [
"Content",
"that",
"is",
"used",
"during",
"page",
"rendering",
".",
"Outputting",
"existing",
"content",
"as",
"a",
"default",
"."
] | 3b64699bf16774b636cb13ecd89281f6e2acb264 | https://github.com/omegainteractive/comfypress/blob/3b64699bf16774b636cb13ecd89281f6e2acb264/lib/comfypress/tag.rb#L83-L86 |
7,280 | jinx/core | lib/jinx/resource/mergeable.rb | Jinx.Mergeable.merge_attributes | def merge_attributes(other, attributes=nil, matches=nil, &filter)
return self if other.nil? or other.equal?(self)
attributes = [attributes] if Symbol === attributes
attributes ||= self.class.mergeable_attributes
# If the source object is not a hash, then convert it to an attribute => value hash.... | ruby | def merge_attributes(other, attributes=nil, matches=nil, &filter)
return self if other.nil? or other.equal?(self)
attributes = [attributes] if Symbol === attributes
attributes ||= self.class.mergeable_attributes
# If the source object is not a hash, then convert it to an attribute => value hash.... | [
"def",
"merge_attributes",
"(",
"other",
",",
"attributes",
"=",
"nil",
",",
"matches",
"=",
"nil",
",",
"&",
"filter",
")",
"return",
"self",
"if",
"other",
".",
"nil?",
"or",
"other",
".",
"equal?",
"(",
"self",
")",
"attributes",
"=",
"[",
"attribut... | Merges the values of the other attributes into this object and returns self.
The other argument can be either a Hash or an object whose class responds to the
+mergeable_attributes+ method.
The optional attributes argument can be either a single attribute symbol or a
collection of attribute symbols.
A hash argumen... | [
"Merges",
"the",
"values",
"of",
"the",
"other",
"attributes",
"into",
"this",
"object",
"and",
"returns",
"self",
".",
"The",
"other",
"argument",
"can",
"be",
"either",
"a",
"Hash",
"or",
"an",
"object",
"whose",
"class",
"responds",
"to",
"the",
"+",
... | 964a274cc9d7ab74613910e8375e12ed210a434d | https://github.com/jinx/core/blob/964a274cc9d7ab74613910e8375e12ed210a434d/lib/jinx/resource/mergeable.rb#L38-L47 |
7,281 | jamescook/layabout | lib/layabout/slack_request.rb | Layabout.SlackRequest.perform_webhook | def perform_webhook
http_request.body = {'text' => params[:text]}.to_json.to_s
http_request.query = {'token' => params[:token]}
HTTPI.post(http_request)
end | ruby | def perform_webhook
http_request.body = {'text' => params[:text]}.to_json.to_s
http_request.query = {'token' => params[:token]}
HTTPI.post(http_request)
end | [
"def",
"perform_webhook",
"http_request",
".",
"body",
"=",
"{",
"'text'",
"=>",
"params",
"[",
":text",
"]",
"}",
".",
"to_json",
".",
"to_s",
"http_request",
".",
"query",
"=",
"{",
"'token'",
"=>",
"params",
"[",
":token",
"]",
"}",
"HTTPI",
".",
"p... | Webhooks are handled in a non-compatible way with the other APIs | [
"Webhooks",
"are",
"handled",
"in",
"a",
"non",
"-",
"compatible",
"way",
"with",
"the",
"other",
"APIs"
] | 87d4cf3f03cd617fba55112ef5339a43ddf828a3 | https://github.com/jamescook/layabout/blob/87d4cf3f03cd617fba55112ef5339a43ddf828a3/lib/layabout/slack_request.rb#L25-L29 |
7,282 | hinrik/ircsupport | lib/ircsupport/case.rb | IRCSupport.Case.irc_upcase! | def irc_upcase!(irc_string, casemapping = :rfc1459)
case casemapping
when :ascii
irc_string.tr!(*@@ascii_map)
when :rfc1459
irc_string.tr!(*@@rfc1459_map)
when :'strict-rfc1459'
irc_string.tr!(*@@strict_rfc1459_map)
else
raise ArgumentError, "Unsupported cas... | ruby | def irc_upcase!(irc_string, casemapping = :rfc1459)
case casemapping
when :ascii
irc_string.tr!(*@@ascii_map)
when :rfc1459
irc_string.tr!(*@@rfc1459_map)
when :'strict-rfc1459'
irc_string.tr!(*@@strict_rfc1459_map)
else
raise ArgumentError, "Unsupported cas... | [
"def",
"irc_upcase!",
"(",
"irc_string",
",",
"casemapping",
"=",
":rfc1459",
")",
"case",
"casemapping",
"when",
":ascii",
"irc_string",
".",
"tr!",
"(",
"@@ascii_map",
")",
"when",
":rfc1459",
"irc_string",
".",
"tr!",
"(",
"@@rfc1459_map",
")",
"when",
":'"... | Turn a string into IRC upper case, modifying it in place.
@param [String] irc_string An IRC string (nickname, channel, etc).
@param [Symbol] casemapping An IRC casemapping.
@return [String] An upper case version of the IRC string according to
the casemapping. | [
"Turn",
"a",
"string",
"into",
"IRC",
"upper",
"case",
"modifying",
"it",
"in",
"place",
"."
] | d028b7d5ccc604a6af175ee2264c18d25b1f7dff | https://github.com/hinrik/ircsupport/blob/d028b7d5ccc604a6af175ee2264c18d25b1f7dff/lib/ircsupport/case.rb#L17-L30 |
7,283 | hinrik/ircsupport | lib/ircsupport/case.rb | IRCSupport.Case.irc_upcase | def irc_upcase(irc_string, casemapping = :rfc1459)
result = irc_string.dup
irc_upcase!(result, casemapping)
return result
end | ruby | def irc_upcase(irc_string, casemapping = :rfc1459)
result = irc_string.dup
irc_upcase!(result, casemapping)
return result
end | [
"def",
"irc_upcase",
"(",
"irc_string",
",",
"casemapping",
"=",
":rfc1459",
")",
"result",
"=",
"irc_string",
".",
"dup",
"irc_upcase!",
"(",
"result",
",",
"casemapping",
")",
"return",
"result",
"end"
] | Turn a string into IRC upper case.
@param [String] irc_string An IRC string (nickname, channel, etc)
@param [Symbol] casemapping An IRC casemapping
@return [String] An upper case version of the IRC string according to
the casemapping. | [
"Turn",
"a",
"string",
"into",
"IRC",
"upper",
"case",
"."
] | d028b7d5ccc604a6af175ee2264c18d25b1f7dff | https://github.com/hinrik/ircsupport/blob/d028b7d5ccc604a6af175ee2264c18d25b1f7dff/lib/ircsupport/case.rb#L37-L41 |
7,284 | hinrik/ircsupport | lib/ircsupport/case.rb | IRCSupport.Case.irc_downcase! | def irc_downcase!(irc_string, casemapping = :rfc1459)
case casemapping
when :ascii
irc_string.tr!(*@@ascii_map.reverse)
when :rfc1459
irc_string.tr!(*@@rfc1459_map.reverse)
when :'strict-rfc1459'
irc_string.tr!(*@@strict_rfc1459_map.reverse)
else
raise Argum... | ruby | def irc_downcase!(irc_string, casemapping = :rfc1459)
case casemapping
when :ascii
irc_string.tr!(*@@ascii_map.reverse)
when :rfc1459
irc_string.tr!(*@@rfc1459_map.reverse)
when :'strict-rfc1459'
irc_string.tr!(*@@strict_rfc1459_map.reverse)
else
raise Argum... | [
"def",
"irc_downcase!",
"(",
"irc_string",
",",
"casemapping",
"=",
":rfc1459",
")",
"case",
"casemapping",
"when",
":ascii",
"irc_string",
".",
"tr!",
"(",
"@@ascii_map",
".",
"reverse",
")",
"when",
":rfc1459",
"irc_string",
".",
"tr!",
"(",
"@@rfc1459_map",
... | Turn a string into IRC lower case, modifying it in place.
@param [String] irc_string An IRC string (nickname, channel, etc)
@param [Symbol] casemapping An IRC casemapping
@return [String] A lower case version of the IRC string according to
the casemapping | [
"Turn",
"a",
"string",
"into",
"IRC",
"lower",
"case",
"modifying",
"it",
"in",
"place",
"."
] | d028b7d5ccc604a6af175ee2264c18d25b1f7dff | https://github.com/hinrik/ircsupport/blob/d028b7d5ccc604a6af175ee2264c18d25b1f7dff/lib/ircsupport/case.rb#L48-L61 |
7,285 | hinrik/ircsupport | lib/ircsupport/case.rb | IRCSupport.Case.irc_downcase | def irc_downcase(irc_string, casemapping = :rfc1459)
result = irc_string.dup
irc_downcase!(result, casemapping)
return result
end | ruby | def irc_downcase(irc_string, casemapping = :rfc1459)
result = irc_string.dup
irc_downcase!(result, casemapping)
return result
end | [
"def",
"irc_downcase",
"(",
"irc_string",
",",
"casemapping",
"=",
":rfc1459",
")",
"result",
"=",
"irc_string",
".",
"dup",
"irc_downcase!",
"(",
"result",
",",
"casemapping",
")",
"return",
"result",
"end"
] | Turn a string into IRC lower case.
@param [String] irc_string An IRC string (nickname, channel, etc).
@param [Symbol] casemapping An IRC casemapping.
@return [String] A lower case version of the IRC string according to
the casemapping | [
"Turn",
"a",
"string",
"into",
"IRC",
"lower",
"case",
"."
] | d028b7d5ccc604a6af175ee2264c18d25b1f7dff | https://github.com/hinrik/ircsupport/blob/d028b7d5ccc604a6af175ee2264c18d25b1f7dff/lib/ircsupport/case.rb#L68-L72 |
7,286 | paydro/js_message | lib/js_message/controller_methods.rb | JsMessage.ControllerMethods.render_js_message | def render_js_message(type, hash = {})
unless [ :ok, :redirect, :error ].include?(type)
raise "Invalid js_message response type: #{type}"
end
js_message = {
:status => type,
:html => nil,
:message => nil,
:to => nil
}.merge(hash)
render_options = {... | ruby | def render_js_message(type, hash = {})
unless [ :ok, :redirect, :error ].include?(type)
raise "Invalid js_message response type: #{type}"
end
js_message = {
:status => type,
:html => nil,
:message => nil,
:to => nil
}.merge(hash)
render_options = {... | [
"def",
"render_js_message",
"(",
"type",
",",
"hash",
"=",
"{",
"}",
")",
"unless",
"[",
":ok",
",",
":redirect",
",",
":error",
"]",
".",
"include?",
"(",
"type",
")",
"raise",
"\"Invalid js_message response type: #{type}\"",
"end",
"js_message",
"=",
"{",
... | Helper to render the js_message response.
Pass in a type of message (:ok, :error, :redirect) and any other
data you need. Default data attributes in the response are:
* html
* message
* to (used for redirects)
Examples:
# Send a successful response with some html
render_js_message :ok, :html => "<... | [
"Helper",
"to",
"render",
"the",
"js_message",
"response",
"."
] | 6adda30f204ef917db3f3595f46f0db8208214e1 | https://github.com/paydro/js_message/blob/6adda30f204ef917db3f3595f46f0db8208214e1/lib/js_message/controller_methods.rb#L28-L44 |
7,287 | jgoizueta/numerals | lib/numerals/format/base_scaler.rb | Numerals.Format::BaseScaler.scaled_digit | def scaled_digit(group)
unless group.size == @base_scale
raise "Invalid digits group size for scaled_digit (is #{group.size}; should be #{@base_scale})"
end
v = 0
group.each do |digit|
v *= @setter.base
v += digit
end
v
end | ruby | def scaled_digit(group)
unless group.size == @base_scale
raise "Invalid digits group size for scaled_digit (is #{group.size}; should be #{@base_scale})"
end
v = 0
group.each do |digit|
v *= @setter.base
v += digit
end
v
end | [
"def",
"scaled_digit",
"(",
"group",
")",
"unless",
"group",
".",
"size",
"==",
"@base_scale",
"raise",
"\"Invalid digits group size for scaled_digit (is #{group.size}; should be #{@base_scale})\"",
"end",
"v",
"=",
"0",
"group",
".",
"each",
"do",
"|",
"digit",
"|",
... | Return the `scaled_base` digit corresponding to a group of `base_scale` `exponent_base` digits | [
"Return",
"the",
"scaled_base",
"digit",
"corresponding",
"to",
"a",
"group",
"of",
"base_scale",
"exponent_base",
"digits"
] | a195e75f689af926537f791441bf8d11590c99c0 | https://github.com/jgoizueta/numerals/blob/a195e75f689af926537f791441bf8d11590c99c0/lib/numerals/format/base_scaler.rb#L97-L107 |
7,288 | jgoizueta/numerals | lib/numerals/format/base_scaler.rb | Numerals.Format::BaseScaler.grouped_digits | def grouped_digits(digits)
unless (digits.size % @base_scale) == 0
raise "Invalid number of digits for group_digits (#{digits.size} is not a multiple of #{@base_scale})"
end
digits.each_slice(@base_scale).map{|group| scaled_digit(group)}
end | ruby | def grouped_digits(digits)
unless (digits.size % @base_scale) == 0
raise "Invalid number of digits for group_digits (#{digits.size} is not a multiple of #{@base_scale})"
end
digits.each_slice(@base_scale).map{|group| scaled_digit(group)}
end | [
"def",
"grouped_digits",
"(",
"digits",
")",
"unless",
"(",
"digits",
".",
"size",
"%",
"@base_scale",
")",
"==",
"0",
"raise",
"\"Invalid number of digits for group_digits (#{digits.size} is not a multiple of #{@base_scale})\"",
"end",
"digits",
".",
"each_slice",
"(",
"... | Convert base `exponent_base` digits to base `scaled_base` digits
the number of digits must be a multiple of base_scale | [
"Convert",
"base",
"exponent_base",
"digits",
"to",
"base",
"scaled_base",
"digits",
"the",
"number",
"of",
"digits",
"must",
"be",
"a",
"multiple",
"of",
"base_scale"
] | a195e75f689af926537f791441bf8d11590c99c0 | https://github.com/jgoizueta/numerals/blob/a195e75f689af926537f791441bf8d11590c99c0/lib/numerals/format/base_scaler.rb#L111-L116 |
7,289 | nrser/nrser.rb | lib/nrser/meta/lazy_attr.rb | NRSER.LazyAttr.call | def call target_method, receiver, *args, &block
unless target_method.parameters.empty?
raise NRSER::ArgumentError.new \
"{NRSER::LazyAttr} can only decorate methods with 0 params",
receiver: receiver,
target_method: target_method
end
unless args.empty?
raise NRSER::A... | ruby | def call target_method, receiver, *args, &block
unless target_method.parameters.empty?
raise NRSER::ArgumentError.new \
"{NRSER::LazyAttr} can only decorate methods with 0 params",
receiver: receiver,
target_method: target_method
end
unless args.empty?
raise NRSER::A... | [
"def",
"call",
"target_method",
",",
"receiver",
",",
"*",
"args",
",",
"&",
"block",
"unless",
"target_method",
".",
"parameters",
".",
"empty?",
"raise",
"NRSER",
"::",
"ArgumentError",
".",
"new",
"\"{NRSER::LazyAttr} can only decorate methods with 0 params\"",
","... | .instance_var_name
Execute the decorator.
@param [Method] target_method
The decorated method, already bound to the receiver.
The `method_decorators` gem calls this `orig`, but I thought
`target_method` made more sense.
@param [*] receiver
The object that will receive the call to `target`.
The `met... | [
".",
"instance_var_name",
"Execute",
"the",
"decorator",
"."
] | 7db9a729ec65894dfac13fd50851beae8b809738 | https://github.com/nrser/nrser.rb/blob/7db9a729ec65894dfac13fd50851beae8b809738/lib/nrser/meta/lazy_attr.rb#L75-L106 |
7,290 | renz45/table_me | lib/table_me/builder.rb | TableMe.Builder.column | def column name,options = {}, &block
@columns << TableMe::Column.new(name,options, &block)
@names << name
end | ruby | def column name,options = {}, &block
@columns << TableMe::Column.new(name,options, &block)
@names << name
end | [
"def",
"column",
"name",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
"@columns",
"<<",
"TableMe",
"::",
"Column",
".",
"new",
"(",
"name",
",",
"options",
",",
"block",
")",
"@names",
"<<",
"name",
"end"
] | Define a column | [
"Define",
"a",
"column"
] | a04bd7c26497828b2f8f0178631253b6749025cf | https://github.com/renz45/table_me/blob/a04bd7c26497828b2f8f0178631253b6749025cf/lib/table_me/builder.rb#L17-L20 |
7,291 | bossmc/milenage | lib/milenage.rb | Milenage.Kernel.op= | def op=(op)
fail "OP must be 128 bits" unless op.each_byte.to_a.length == 16
@opc = xor(enc(op), op)
end | ruby | def op=(op)
fail "OP must be 128 bits" unless op.each_byte.to_a.length == 16
@opc = xor(enc(op), op)
end | [
"def",
"op",
"=",
"(",
"op",
")",
"fail",
"\"OP must be 128 bits\"",
"unless",
"op",
".",
"each_byte",
".",
"to_a",
".",
"length",
"==",
"16",
"@opc",
"=",
"xor",
"(",
"enc",
"(",
"op",
")",
",",
"op",
")",
"end"
] | Create a single user's kernel instance, remember to set OP or OPc before
attempting to use the security functions.
To change the algorithm variables as described in TS 35.206 subclass
this Kernel class and modify `@c`, `@r` or `@kernel` after calling
super. E.G.
class MyKernel < Kernel
def initialize(key)... | [
"Create",
"a",
"single",
"user",
"s",
"kernel",
"instance",
"remember",
"to",
"set",
"OP",
"or",
"OPc",
"before",
"attempting",
"to",
"use",
"the",
"security",
"functions",
"."
] | 7966c0910f66232ea53a50512fd80d3a6b3ad18a | https://github.com/bossmc/milenage/blob/7966c0910f66232ea53a50512fd80d3a6b3ad18a/lib/milenage.rb#L59-L62 |
7,292 | dbalatero/typhoeus_spec_cache | lib/typhoeus/spec_cache.rb | Typhoeus.SpecCache.remove_unnecessary_cache_files! | def remove_unnecessary_cache_files!
current_keys = cache_files.map do |file|
get_cache_key_from_filename(file)
end
inmemory_keys = responses.keys
unneeded_keys = current_keys - inmemory_keys
unneeded_keys.each do |key|
File.unlink(filepath_for(key))
end
end | ruby | def remove_unnecessary_cache_files!
current_keys = cache_files.map do |file|
get_cache_key_from_filename(file)
end
inmemory_keys = responses.keys
unneeded_keys = current_keys - inmemory_keys
unneeded_keys.each do |key|
File.unlink(filepath_for(key))
end
end | [
"def",
"remove_unnecessary_cache_files!",
"current_keys",
"=",
"cache_files",
".",
"map",
"do",
"|",
"file",
"|",
"get_cache_key_from_filename",
"(",
"file",
")",
"end",
"inmemory_keys",
"=",
"responses",
".",
"keys",
"unneeded_keys",
"=",
"current_keys",
"-",
"inme... | Removes any cache files that aren't needed anymore | [
"Removes",
"any",
"cache",
"files",
"that",
"aren",
"t",
"needed",
"anymore"
] | 7141c311c76fe001428c143d90ad927bd8b178e9 | https://github.com/dbalatero/typhoeus_spec_cache/blob/7141c311c76fe001428c143d90ad927bd8b178e9/lib/typhoeus/spec_cache.rb#L35-L45 |
7,293 | dbalatero/typhoeus_spec_cache | lib/typhoeus/spec_cache.rb | Typhoeus.SpecCache.read_cache_fixtures! | def read_cache_fixtures!
files = cache_files
files.each do |file|
cache_key = get_cache_key_from_filename(file)
responses[cache_key] = Marshal.load(File.read(file))
end
end | ruby | def read_cache_fixtures!
files = cache_files
files.each do |file|
cache_key = get_cache_key_from_filename(file)
responses[cache_key] = Marshal.load(File.read(file))
end
end | [
"def",
"read_cache_fixtures!",
"files",
"=",
"cache_files",
"files",
".",
"each",
"do",
"|",
"file",
"|",
"cache_key",
"=",
"get_cache_key_from_filename",
"(",
"file",
")",
"responses",
"[",
"cache_key",
"]",
"=",
"Marshal",
".",
"load",
"(",
"File",
".",
"r... | Reads in the cache fixture files to in-memory cache. | [
"Reads",
"in",
"the",
"cache",
"fixture",
"files",
"to",
"in",
"-",
"memory",
"cache",
"."
] | 7141c311c76fe001428c143d90ad927bd8b178e9 | https://github.com/dbalatero/typhoeus_spec_cache/blob/7141c311c76fe001428c143d90ad927bd8b178e9/lib/typhoeus/spec_cache.rb#L48-L54 |
7,294 | dbalatero/typhoeus_spec_cache | lib/typhoeus/spec_cache.rb | Typhoeus.SpecCache.dump_cache_fixtures! | def dump_cache_fixtures!
responses.each do |cache_key, response|
path = filepath_for(cache_key)
unless File.exist?(path)
File.open(path, "wb") do |fp|
fp.write(Marshal.dump(response))
end
end
end
end | ruby | def dump_cache_fixtures!
responses.each do |cache_key, response|
path = filepath_for(cache_key)
unless File.exist?(path)
File.open(path, "wb") do |fp|
fp.write(Marshal.dump(response))
end
end
end
end | [
"def",
"dump_cache_fixtures!",
"responses",
".",
"each",
"do",
"|",
"cache_key",
",",
"response",
"|",
"path",
"=",
"filepath_for",
"(",
"cache_key",
")",
"unless",
"File",
".",
"exist?",
"(",
"path",
")",
"File",
".",
"open",
"(",
"path",
",",
"\"wb\"",
... | Dumps out any cached items to disk. | [
"Dumps",
"out",
"any",
"cached",
"items",
"to",
"disk",
"."
] | 7141c311c76fe001428c143d90ad927bd8b178e9 | https://github.com/dbalatero/typhoeus_spec_cache/blob/7141c311c76fe001428c143d90ad927bd8b178e9/lib/typhoeus/spec_cache.rb#L57-L66 |
7,295 | mrsimonfletcher/roroacms | app/helpers/roroacms/admin_roroa_helper.rb | Roroacms.AdminRoroaHelper.get_theme_options | def get_theme_options
hash = []
Dir.glob("#{Rails.root}/app/views/themes/*/") do |themes|
opt = themes.split('/').last
if File.exists?("#{themes}theme.yml")
info = YAML.load(File.read("#{themes}theme.yml"))
hash << info if !info['name'].blank? && !info['author'].blank? &... | ruby | def get_theme_options
hash = []
Dir.glob("#{Rails.root}/app/views/themes/*/") do |themes|
opt = themes.split('/').last
if File.exists?("#{themes}theme.yml")
info = YAML.load(File.read("#{themes}theme.yml"))
hash << info if !info['name'].blank? && !info['author'].blank? &... | [
"def",
"get_theme_options",
"hash",
"=",
"[",
"]",
"Dir",
".",
"glob",
"(",
"\"#{Rails.root}/app/views/themes/*/\"",
")",
"do",
"|",
"themes",
"|",
"opt",
"=",
"themes",
".",
"split",
"(",
"'/'",
")",
".",
"last",
"if",
"File",
".",
"exists?",
"(",
"\"#{... | returns a hash of the different themes as a hash with the details kept in the theme.yml file | [
"returns",
"a",
"hash",
"of",
"the",
"different",
"themes",
"as",
"a",
"hash",
"with",
"the",
"details",
"kept",
"in",
"the",
"theme",
".",
"yml",
"file"
] | 62654a2f2a48e3adb3105f4dafb6e315b460eaf4 | https://github.com/mrsimonfletcher/roroacms/blob/62654a2f2a48e3adb3105f4dafb6e315b460eaf4/app/helpers/roroacms/admin_roroa_helper.rb#L15-L27 |
7,296 | mrsimonfletcher/roroacms | app/helpers/roroacms/admin_roroa_helper.rb | Roroacms.AdminRoroaHelper.get_templates | def get_templates
hash = []
current_theme = Setting.get('theme_folder')
Dir.glob("#{Rails.root}/app/views/themes/#{current_theme}/template-*.html.erb") do |my_text_file|
opt = my_text_file.split('/').last
opt['template-'] = ''
opt['.html.erb'] = ''
# strips out the tem... | ruby | def get_templates
hash = []
current_theme = Setting.get('theme_folder')
Dir.glob("#{Rails.root}/app/views/themes/#{current_theme}/template-*.html.erb") do |my_text_file|
opt = my_text_file.split('/').last
opt['template-'] = ''
opt['.html.erb'] = ''
# strips out the tem... | [
"def",
"get_templates",
"hash",
"=",
"[",
"]",
"current_theme",
"=",
"Setting",
".",
"get",
"(",
"'theme_folder'",
")",
"Dir",
".",
"glob",
"(",
"\"#{Rails.root}/app/views/themes/#{current_theme}/template-*.html.erb\"",
")",
"do",
"|",
"my_text_file",
"|",
"opt",
"=... | retuns a hash of the template files within the current theme | [
"retuns",
"a",
"hash",
"of",
"the",
"template",
"files",
"within",
"the",
"current",
"theme"
] | 62654a2f2a48e3adb3105f4dafb6e315b460eaf4 | https://github.com/mrsimonfletcher/roroacms/blob/62654a2f2a48e3adb3105f4dafb6e315b460eaf4/app/helpers/roroacms/admin_roroa_helper.rb#L41-L54 |
7,297 | mrsimonfletcher/roroacms | app/helpers/roroacms/admin_roroa_helper.rb | Roroacms.AdminRoroaHelper.theme_exists | def theme_exists
if !Dir.exists?("app/views/themes/#{Setting.get('theme_folder')}/")
html = "<div class='alert alert-danger'><strong>" + I18n.t("helpers.admin_roroa_helper.theme_exists.warning") + "!</strong> " + I18n.t("helpers.admin_roroa_helper.theme_exists.message") + "!</div>"
render :inline... | ruby | def theme_exists
if !Dir.exists?("app/views/themes/#{Setting.get('theme_folder')}/")
html = "<div class='alert alert-danger'><strong>" + I18n.t("helpers.admin_roroa_helper.theme_exists.warning") + "!</strong> " + I18n.t("helpers.admin_roroa_helper.theme_exists.message") + "!</div>"
render :inline... | [
"def",
"theme_exists",
"if",
"!",
"Dir",
".",
"exists?",
"(",
"\"app/views/themes/#{Setting.get('theme_folder')}/\"",
")",
"html",
"=",
"\"<div class='alert alert-danger'><strong>\"",
"+",
"I18n",
".",
"t",
"(",
"\"helpers.admin_roroa_helper.theme_exists.warning\"",
")",
"+",... | checks if the current theme being used actually exists. If not it will return an error message to the user | [
"checks",
"if",
"the",
"current",
"theme",
"being",
"used",
"actually",
"exists",
".",
"If",
"not",
"it",
"will",
"return",
"an",
"error",
"message",
"to",
"the",
"user"
] | 62654a2f2a48e3adb3105f4dafb6e315b460eaf4 | https://github.com/mrsimonfletcher/roroacms/blob/62654a2f2a48e3adb3105f4dafb6e315b460eaf4/app/helpers/roroacms/admin_roroa_helper.rb#L126-L133 |
7,298 | mrsimonfletcher/roroacms | app/helpers/roroacms/admin_roroa_helper.rb | Roroacms.AdminRoroaHelper.get_notifications | def get_notifications
html = ''
if flash[:error]
html += "<div class='alert alert-danger'><button type='button' class='close' data-dismiss='alert'>x</button><strong>" + I18n.t("helpers.view_helper.generic.flash.error") + "!</strong> #{flash[:error]}</div>"
end
if flash[:notice]
... | ruby | def get_notifications
html = ''
if flash[:error]
html += "<div class='alert alert-danger'><button type='button' class='close' data-dismiss='alert'>x</button><strong>" + I18n.t("helpers.view_helper.generic.flash.error") + "!</strong> #{flash[:error]}</div>"
end
if flash[:notice]
... | [
"def",
"get_notifications",
"html",
"=",
"''",
"if",
"flash",
"[",
":error",
"]",
"html",
"+=",
"\"<div class='alert alert-danger'><button type='button' class='close' data-dismiss='alert'>x</button><strong>\"",
"+",
"I18n",
".",
"t",
"(",
"\"helpers.view_helper.generic.flash.erro... | Returns generic notifications if the flash data exists | [
"Returns",
"generic",
"notifications",
"if",
"the",
"flash",
"data",
"exists"
] | 62654a2f2a48e3adb3105f4dafb6e315b460eaf4 | https://github.com/mrsimonfletcher/roroacms/blob/62654a2f2a48e3adb3105f4dafb6e315b460eaf4/app/helpers/roroacms/admin_roroa_helper.rb#L302-L315 |
7,299 | mrsimonfletcher/roroacms | app/helpers/roroacms/admin_roroa_helper.rb | Roroacms.AdminRoroaHelper.append_application_menu | def append_application_menu
html = ''
Roroacms.append_menu.each do |f|
html += (render :partial => 'roroacms/admin/partials/append_sidebar_menu', :locals => { :menu_block => f })
end
html.html_safe
end | ruby | def append_application_menu
html = ''
Roroacms.append_menu.each do |f|
html += (render :partial => 'roroacms/admin/partials/append_sidebar_menu', :locals => { :menu_block => f })
end
html.html_safe
end | [
"def",
"append_application_menu",
"html",
"=",
"''",
"Roroacms",
".",
"append_menu",
".",
"each",
"do",
"|",
"f",
"|",
"html",
"+=",
"(",
"render",
":partial",
"=>",
"'roroacms/admin/partials/append_sidebar_menu'",
",",
":locals",
"=>",
"{",
":menu_block",
"=>",
... | appends any extra menu items that are set in the applications configurations | [
"appends",
"any",
"extra",
"menu",
"items",
"that",
"are",
"set",
"in",
"the",
"applications",
"configurations"
] | 62654a2f2a48e3adb3105f4dafb6e315b460eaf4 | https://github.com/mrsimonfletcher/roroacms/blob/62654a2f2a48e3adb3105f4dafb6e315b460eaf4/app/helpers/roroacms/admin_roroa_helper.rb#L339-L345 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.