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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
22,400 | dicom/ruby-dicom | lib/dicom/d_library.rb | DICOM.DLibrary.as_name | def as_name(value)
case true
when value.tag?
element(value).name
when value.dicom_name?
@methods_from_names.has_key?(value) ? value.to_s : nil
when value.dicom_method?
@names_from_methods[value.to_sym]
else
nil
end
end | ruby | def as_name(value)
case true
when value.tag?
element(value).name
when value.dicom_name?
@methods_from_names.has_key?(value) ? value.to_s : nil
when value.dicom_method?
@names_from_methods[value.to_sym]
else
nil
end
end | [
"def",
"as_name",
"(",
"value",
")",
"case",
"true",
"when",
"value",
".",
"tag?",
"element",
"(",
"value",
")",
".",
"name",
"when",
"value",
".",
"dicom_name?",
"@methods_from_names",
".",
"has_key?",
"(",
"value",
")",
"?",
"value",
".",
"to_s",
":",
... | Gives the name corresponding to the specified element string value.
@param [String] value an element tag, element name or an element's method name
@return [String, NilClass] the matched element name, or nil if no match is made | [
"Gives",
"the",
"name",
"corresponding",
"to",
"the",
"specified",
"element",
"string",
"value",
"."
] | 3ffcfe21edc8dcd31298f945781990789fc832ab | https://github.com/dicom/ruby-dicom/blob/3ffcfe21edc8dcd31298f945781990789fc832ab/lib/dicom/d_library.rb#L112-L123 |
22,401 | dicom/ruby-dicom | lib/dicom/d_library.rb | DICOM.DLibrary.as_tag | def as_tag(value)
case true
when value.tag?
element(value) ? value : nil
when value.dicom_name?
get_tag(value)
when value.dicom_method?
get_tag(@names_from_methods[value.to_sym])
else
nil
end
end | ruby | def as_tag(value)
case true
when value.tag?
element(value) ? value : nil
when value.dicom_name?
get_tag(value)
when value.dicom_method?
get_tag(@names_from_methods[value.to_sym])
else
nil
end
end | [
"def",
"as_tag",
"(",
"value",
")",
"case",
"true",
"when",
"value",
".",
"tag?",
"element",
"(",
"value",
")",
"?",
"value",
":",
"nil",
"when",
"value",
".",
"dicom_name?",
"get_tag",
"(",
"value",
")",
"when",
"value",
".",
"dicom_method?",
"get_tag",... | Gives the tag corresponding to the specified element string value.
@param [String] value an element tag, element name or an element's method name
@return [String, NilClass] the matched element tag, or nil if no match is made | [
"Gives",
"the",
"tag",
"corresponding",
"to",
"the",
"specified",
"element",
"string",
"value",
"."
] | 3ffcfe21edc8dcd31298f945781990789fc832ab | https://github.com/dicom/ruby-dicom/blob/3ffcfe21edc8dcd31298f945781990789fc832ab/lib/dicom/d_library.rb#L130-L141 |
22,402 | dicom/ruby-dicom | lib/dicom/d_library.rb | DICOM.DLibrary.element | def element(tag)
element = @elements[tag]
unless element
if tag.group_length?
element = DictionaryElement.new(tag, 'Group Length', ['UL'], '1', '')
else
if tag.private?
element = DictionaryElement.new(tag, 'Private', ['UN'], '1', '')
else
... | ruby | def element(tag)
element = @elements[tag]
unless element
if tag.group_length?
element = DictionaryElement.new(tag, 'Group Length', ['UL'], '1', '')
else
if tag.private?
element = DictionaryElement.new(tag, 'Private', ['UN'], '1', '')
else
... | [
"def",
"element",
"(",
"tag",
")",
"element",
"=",
"@elements",
"[",
"tag",
"]",
"unless",
"element",
"if",
"tag",
".",
"group_length?",
"element",
"=",
"DictionaryElement",
".",
"new",
"(",
"tag",
",",
"'Group Length'",
",",
"[",
"'UL'",
"]",
",",
"'1'"... | Identifies the DictionaryElement that corresponds to the given tag.
@note If a given tag doesn't return a dictionary match, a new DictionaryElement is created.
* For private tags, a name 'Private' and VR 'UN' is assigned
* For unknown tags, a name 'Unknown' and VR 'UN' is assigned
@param [String] tag the tag o... | [
"Identifies",
"the",
"DictionaryElement",
"that",
"corresponds",
"to",
"the",
"given",
"tag",
"."
] | 3ffcfe21edc8dcd31298f945781990789fc832ab | https://github.com/dicom/ruby-dicom/blob/3ffcfe21edc8dcd31298f945781990789fc832ab/lib/dicom/d_library.rb#L151-L165 |
22,403 | dicom/ruby-dicom | lib/dicom/d_library.rb | DICOM.DLibrary.extract_transfer_syntaxes_and_sop_classes | def extract_transfer_syntaxes_and_sop_classes
transfer_syntaxes = Hash.new
sop_classes = Hash.new
@uids.each_value do |uid|
if uid.transfer_syntax?
transfer_syntaxes[uid.value] = uid.name
elsif uid.sop_class?
sop_classes[uid.value] = uid.name
end
end
... | ruby | def extract_transfer_syntaxes_and_sop_classes
transfer_syntaxes = Hash.new
sop_classes = Hash.new
@uids.each_value do |uid|
if uid.transfer_syntax?
transfer_syntaxes[uid.value] = uid.name
elsif uid.sop_class?
sop_classes[uid.value] = uid.name
end
end
... | [
"def",
"extract_transfer_syntaxes_and_sop_classes",
"transfer_syntaxes",
"=",
"Hash",
".",
"new",
"sop_classes",
"=",
"Hash",
".",
"new",
"@uids",
".",
"each_value",
"do",
"|",
"uid",
"|",
"if",
"uid",
".",
"transfer_syntax?",
"transfer_syntaxes",
"[",
"uid",
".",... | Extracts, and returns, all transfer syntaxes and SOP Classes from the dictionary.
@return [Array<Hash, Hash>] transfer syntax and sop class hashes, each with uid as key and name as value | [
"Extracts",
"and",
"returns",
"all",
"transfer",
"syntaxes",
"and",
"SOP",
"Classes",
"from",
"the",
"dictionary",
"."
] | 3ffcfe21edc8dcd31298f945781990789fc832ab | https://github.com/dicom/ruby-dicom/blob/3ffcfe21edc8dcd31298f945781990789fc832ab/lib/dicom/d_library.rb#L171-L182 |
22,404 | dicom/ruby-dicom | lib/dicom/d_library.rb | DICOM.DLibrary.get_tag | def get_tag(name)
tag = nil
name = name.to_s.downcase
@tag_name_pairs_cache ||= Hash.new
return @tag_name_pairs_cache[name] unless @tag_name_pairs_cache[name].nil?
@elements.each_value do |element|
next unless element.name.downcase == name
tag = element.tag
break
... | ruby | def get_tag(name)
tag = nil
name = name.to_s.downcase
@tag_name_pairs_cache ||= Hash.new
return @tag_name_pairs_cache[name] unless @tag_name_pairs_cache[name].nil?
@elements.each_value do |element|
next unless element.name.downcase == name
tag = element.tag
break
... | [
"def",
"get_tag",
"(",
"name",
")",
"tag",
"=",
"nil",
"name",
"=",
"name",
".",
"to_s",
".",
"downcase",
"@tag_name_pairs_cache",
"||=",
"Hash",
".",
"new",
"return",
"@tag_name_pairs_cache",
"[",
"name",
"]",
"unless",
"@tag_name_pairs_cache",
"[",
"name",
... | Gives the tag that matches the supplied data element name, by searching the element dictionary.
@param [String] name a data element name
@return [String, NilClass] the corresponding element tag, or nil if no match is made | [
"Gives",
"the",
"tag",
"that",
"matches",
"the",
"supplied",
"data",
"element",
"name",
"by",
"searching",
"the",
"element",
"dictionary",
"."
] | 3ffcfe21edc8dcd31298f945781990789fc832ab | https://github.com/dicom/ruby-dicom/blob/3ffcfe21edc8dcd31298f945781990789fc832ab/lib/dicom/d_library.rb#L189-L201 |
22,405 | dicom/ruby-dicom | lib/dicom/d_library.rb | DICOM.DLibrary.unknown_or_range_element | def unknown_or_range_element(tag)
element = nil
range_candidates(tag).each do |range_candidate_tag|
if de = @elements[range_candidate_tag]
element = DictionaryElement.new(tag, de.name, de.vrs, de.vm, de.retired)
break
end
end
# If nothing was matched, we are f... | ruby | def unknown_or_range_element(tag)
element = nil
range_candidates(tag).each do |range_candidate_tag|
if de = @elements[range_candidate_tag]
element = DictionaryElement.new(tag, de.name, de.vrs, de.vm, de.retired)
break
end
end
# If nothing was matched, we are f... | [
"def",
"unknown_or_range_element",
"(",
"tag",
")",
"element",
"=",
"nil",
"range_candidates",
"(",
"tag",
")",
".",
"each",
"do",
"|",
"range_candidate_tag",
"|",
"if",
"de",
"=",
"@elements",
"[",
"range_candidate_tag",
"]",
"element",
"=",
"DictionaryElement"... | Matches a tag against the possible range tag candidates, and if no match
is found, returns a dictionary element representing an unknown tag.
@param [String] tag the element tag
@return [DictionaryElement] a matched range element or an unknown element | [
"Matches",
"a",
"tag",
"against",
"the",
"possible",
"range",
"tag",
"candidates",
"and",
"if",
"no",
"match",
"is",
"found",
"returns",
"a",
"dictionary",
"element",
"representing",
"an",
"unknown",
"tag",
"."
] | 3ffcfe21edc8dcd31298f945781990789fc832ab | https://github.com/dicom/ruby-dicom/blob/3ffcfe21edc8dcd31298f945781990789fc832ab/lib/dicom/d_library.rb#L255-L265 |
22,406 | oscar-stack/vagrant-auto_network | lib/auto_network/pool_manager.rb | AutoNetwork.PoolManager.with_pool_for | def with_pool_for(machine, read_only=false)
@pool_storage.transaction(read_only) do
pool = lookup_pool_for(machine)
pool ||= generate_pool_for(machine)
yield pool
end
end | ruby | def with_pool_for(machine, read_only=false)
@pool_storage.transaction(read_only) do
pool = lookup_pool_for(machine)
pool ||= generate_pool_for(machine)
yield pool
end
end | [
"def",
"with_pool_for",
"(",
"machine",
",",
"read_only",
"=",
"false",
")",
"@pool_storage",
".",
"transaction",
"(",
"read_only",
")",
"do",
"pool",
"=",
"lookup_pool_for",
"(",
"machine",
")",
"pool",
"||=",
"generate_pool_for",
"(",
"machine",
")",
"yield"... | Create a new `PoolManager` instance with persistent storage.
@param path [String, Pathname] the location at which to persist the state
of `AutoNetwork` pools.
Looks up the pool associated with the provider for a given machine and
sets up a transaction where the state of the pool can be safely inspected
or modif... | [
"Create",
"a",
"new",
"PoolManager",
"instance",
"with",
"persistent",
"storage",
"."
] | 5b4b4d5b5cb18dc1417e91650adb713b9f54ab01 | https://github.com/oscar-stack/vagrant-auto_network/blob/5b4b4d5b5cb18dc1417e91650adb713b9f54ab01/lib/auto_network/pool_manager.rb#L43-L50 |
22,407 | oscar-stack/vagrant-auto_network | lib/auto_network/action/base.rb | AutoNetwork.Action::Base.machine_auto_networks | def machine_auto_networks(machine)
machine.config.vm.networks.select do |(net_type, options)|
net_type == :private_network and options[:auto_network]
end
end | ruby | def machine_auto_networks(machine)
machine.config.vm.networks.select do |(net_type, options)|
net_type == :private_network and options[:auto_network]
end
end | [
"def",
"machine_auto_networks",
"(",
"machine",
")",
"machine",
".",
"config",
".",
"vm",
".",
"networks",
".",
"select",
"do",
"|",
"(",
"net_type",
",",
"options",
")",
"|",
"net_type",
"==",
":private_network",
"and",
"options",
"[",
":auto_network",
"]",... | Fetch all private networks that are tagged for auto networking
@param machine [Vagrant::Machine]
@return [Array(Symbol, Hash)] All auto_networks | [
"Fetch",
"all",
"private",
"networks",
"that",
"are",
"tagged",
"for",
"auto",
"networking"
] | 5b4b4d5b5cb18dc1417e91650adb713b9f54ab01 | https://github.com/oscar-stack/vagrant-auto_network/blob/5b4b4d5b5cb18dc1417e91650adb713b9f54ab01/lib/auto_network/action/base.rb#L45-L49 |
22,408 | oscar-stack/vagrant-auto_network | lib/auto_network/pool.rb | AutoNetwork.Pool.request | def request(machine)
if (address = address_for(machine))
return address
elsif (address = next_available_lease)
@pool[address] = id_for(machine)
return address
else
raise PoolExhaustedError,
:name => machine.name,
:network => @network_range
e... | ruby | def request(machine)
if (address = address_for(machine))
return address
elsif (address = next_available_lease)
@pool[address] = id_for(machine)
return address
else
raise PoolExhaustedError,
:name => machine.name,
:network => @network_range
e... | [
"def",
"request",
"(",
"machine",
")",
"if",
"(",
"address",
"=",
"address_for",
"(",
"machine",
")",
")",
"return",
"address",
"elsif",
"(",
"address",
"=",
"next_available_lease",
")",
"@pool",
"[",
"address",
"]",
"=",
"id_for",
"(",
"machine",
")",
"... | Create a new Pool object that manages a range of IP addresses.
@param network_range [String] The network address range to use as the
address pool.
Allocate an IP address for the given machine. If a machine already has an
IP address allocated, then return that.
@param machine [Vagrant::Machine]
@return [IPAddr... | [
"Create",
"a",
"new",
"Pool",
"object",
"that",
"manages",
"a",
"range",
"of",
"IP",
"addresses",
"."
] | 5b4b4d5b5cb18dc1417e91650adb713b9f54ab01 | https://github.com/oscar-stack/vagrant-auto_network/blob/5b4b4d5b5cb18dc1417e91650adb713b9f54ab01/lib/auto_network/pool.rb#L35-L46 |
22,409 | oscar-stack/vagrant-auto_network | lib/auto_network/pool.rb | AutoNetwork.Pool.address_for | def address_for(machine)
machine_id = id_for(machine)
addr, _ = @pool.find do |(addr, id)|
if id.is_a?(String)
# Check for old-style UUID values. These should eventually cycle out
# as machines are destroyed.
id == machine.id
else
id == machine_id
... | ruby | def address_for(machine)
machine_id = id_for(machine)
addr, _ = @pool.find do |(addr, id)|
if id.is_a?(String)
# Check for old-style UUID values. These should eventually cycle out
# as machines are destroyed.
id == machine.id
else
id == machine_id
... | [
"def",
"address_for",
"(",
"machine",
")",
"machine_id",
"=",
"id_for",
"(",
"machine",
")",
"addr",
",",
"_",
"=",
"@pool",
".",
"find",
"do",
"|",
"(",
"addr",
",",
"id",
")",
"|",
"if",
"id",
".",
"is_a?",
"(",
"String",
")",
"# Check for old-styl... | Look up the address assigned to a given machine.
@param machine [Vagrant::Machine]
@return [IPAddr] the IP address assigned to the machine.
@return [nil] if the machine has no address assigned. | [
"Look",
"up",
"the",
"address",
"assigned",
"to",
"a",
"given",
"machine",
"."
] | 5b4b4d5b5cb18dc1417e91650adb713b9f54ab01 | https://github.com/oscar-stack/vagrant-auto_network/blob/5b4b4d5b5cb18dc1417e91650adb713b9f54ab01/lib/auto_network/pool.rb#L63-L76 |
22,410 | oscar-stack/vagrant-auto_network | lib/auto_network/settings.rb | AutoNetwork.Settings.default_pool= | def default_pool=(pool)
# Ensure the pool is valid.
begin
IPAddr.new pool
rescue ArgumentError
raise InvalidSettingErrror,
:setting_name => 'default_pool',
:value => pool.inspect
end
@default_pool = pool
end | ruby | def default_pool=(pool)
# Ensure the pool is valid.
begin
IPAddr.new pool
rescue ArgumentError
raise InvalidSettingErrror,
:setting_name => 'default_pool',
:value => pool.inspect
end
@default_pool = pool
end | [
"def",
"default_pool",
"=",
"(",
"pool",
")",
"# Ensure the pool is valid.",
"begin",
"IPAddr",
".",
"new",
"pool",
"rescue",
"ArgumentError",
"raise",
"InvalidSettingErrror",
",",
":setting_name",
"=>",
"'default_pool'",
",",
":value",
"=>",
"pool",
".",
"inspect",... | Set the default pool to a new IP range.
@param pool [String]
@raise [InvalidSettingErrror] if an IPAddr object cannot be initialized
from the value of pool.
@return [void] | [
"Set",
"the",
"default",
"pool",
"to",
"a",
"new",
"IP",
"range",
"."
] | 5b4b4d5b5cb18dc1417e91650adb713b9f54ab01 | https://github.com/oscar-stack/vagrant-auto_network/blob/5b4b4d5b5cb18dc1417e91650adb713b9f54ab01/lib/auto_network/settings.rb#L60-L71 |
22,411 | jarmo/RAutomation | lib/rautomation/element_collections.rb | RAutomation.ElementCollections.has_many | def has_many(*elements)
elements.each do |element|
class_name_plural = element.to_s.split("_").map {|e| e.capitalize}.join
class_name = class_name_plural.chop
adapter_class = self.to_s.scan(/(.*)::/).flatten.first
clazz = RAutomation.constants.include?(class_name) ? RAutomation : c... | ruby | def has_many(*elements)
elements.each do |element|
class_name_plural = element.to_s.split("_").map {|e| e.capitalize}.join
class_name = class_name_plural.chop
adapter_class = self.to_s.scan(/(.*)::/).flatten.first
clazz = RAutomation.constants.include?(class_name) ? RAutomation : c... | [
"def",
"has_many",
"(",
"*",
"elements",
")",
"elements",
".",
"each",
"do",
"|",
"element",
"|",
"class_name_plural",
"=",
"element",
".",
"to_s",
".",
"split",
"(",
"\"_\"",
")",
".",
"map",
"{",
"|",
"e",
"|",
"e",
".",
"capitalize",
"}",
".",
"... | Creates collection classes and methods for elements.
@param [Array<Symbol>] elements for which to create collection classes
and methods. | [
"Creates",
"collection",
"classes",
"and",
"methods",
"for",
"elements",
"."
] | 7314a7e6f8bbba797d276ca1950abde0cba6897a | https://github.com/jarmo/RAutomation/blob/7314a7e6f8bbba797d276ca1950abde0cba6897a/lib/rautomation/element_collections.rb#L10-L53 |
22,412 | hicknhack-software/rails-disco | active_event/lib/active_event/event_source_server.rb | ActiveEvent.EventSourceServer.process_projection | def process_projection(data)
mutex.synchronize do
projection_status = status[data[:projection]]
projection_status.set_error data[:error], data[:backtrace]
projection_status.event = data[:event]
end
end | ruby | def process_projection(data)
mutex.synchronize do
projection_status = status[data[:projection]]
projection_status.set_error data[:error], data[:backtrace]
projection_status.event = data[:event]
end
end | [
"def",
"process_projection",
"(",
"data",
")",
"mutex",
".",
"synchronize",
"do",
"projection_status",
"=",
"status",
"[",
"data",
"[",
":projection",
"]",
"]",
"projection_status",
".",
"set_error",
"data",
"[",
":error",
"]",
",",
"data",
"[",
":backtrace",
... | status of all projections received so far | [
"status",
"of",
"all",
"projections",
"received",
"so",
"far"
] | 5d1f2801a41dc2a1c9f745499bd32c8f634dcc43 | https://github.com/hicknhack-software/rails-disco/blob/5d1f2801a41dc2a1c9f745499bd32c8f634dcc43/active_event/lib/active_event/event_source_server.rb#L94-L100 |
22,413 | RallyTools/RallyRestToolkitForRuby | lib/rally_api/rally_rest_json.rb | RallyAPI.RallyRestJson.allowed_values | def allowed_values(type, field, workspace = nil)
rally_workspace_object(workspace)
type_def = get_typedef_for(type, workspace)
allowed_vals = {}
type_def["Attributes"].each do |attr|
next if attr["ElementName"] != field
attr["AllowedValues"].each do |val_ref|
val = v... | ruby | def allowed_values(type, field, workspace = nil)
rally_workspace_object(workspace)
type_def = get_typedef_for(type, workspace)
allowed_vals = {}
type_def["Attributes"].each do |attr|
next if attr["ElementName"] != field
attr["AllowedValues"].each do |val_ref|
val = v... | [
"def",
"allowed_values",
"(",
"type",
",",
"field",
",",
"workspace",
"=",
"nil",
")",
"rally_workspace_object",
"(",
"workspace",
")",
"type_def",
"=",
"get_typedef_for",
"(",
"type",
",",
"workspace",
")",
"allowed_vals",
"=",
"{",
"}",
"type_def",
"[",
"\... | todo - check support for portfolio item fields | [
"todo",
"-",
"check",
"support",
"for",
"portfolio",
"item",
"fields"
] | a091616254c7a72e9a6f04f757026e5968312777 | https://github.com/RallyTools/RallyRestToolkitForRuby/blob/a091616254c7a72e9a6f04f757026e5968312777/lib/rally_api/rally_rest_json.rb#L357-L371 |
22,414 | RallyTools/RallyRestToolkitForRuby | lib/rally_api/rally_rest_json.rb | RallyAPI.RallyRestJson.check_type | def check_type(type_name)
alias_name = @rally_alias_types[type_name.downcase.to_s]
return alias_name unless alias_name.nil?
return type_name
end | ruby | def check_type(type_name)
alias_name = @rally_alias_types[type_name.downcase.to_s]
return alias_name unless alias_name.nil?
return type_name
end | [
"def",
"check_type",
"(",
"type_name",
")",
"alias_name",
"=",
"@rally_alias_types",
"[",
"type_name",
".",
"downcase",
".",
"to_s",
"]",
"return",
"alias_name",
"unless",
"alias_name",
".",
"nil?",
"return",
"type_name",
"end"
] | check for an alias of a type - eg userstory => hierarchicalrequirement
you can add to @rally_alias_types as desired | [
"check",
"for",
"an",
"alias",
"of",
"a",
"type",
"-",
"eg",
"userstory",
"=",
">",
"hierarchicalrequirement",
"you",
"can",
"add",
"to"
] | a091616254c7a72e9a6f04f757026e5968312777 | https://github.com/RallyTools/RallyRestToolkitForRuby/blob/a091616254c7a72e9a6f04f757026e5968312777/lib/rally_api/rally_rest_json.rb#L431-L435 |
22,415 | RallyTools/RallyRestToolkitForRuby | lib/rally_api/rally_rest_json.rb | RallyAPI.RallyRestJson.check_id | def check_id(type, idstring)
if idstring.class == Fixnum
return make_read_url(type, idstring)
end
if (idstring.class == String)
return idstring if idstring.index("http") == 0
return ref_by_formatted_id(type, idstring.split("|")[1]) if idstring.index("FormattedID") == 0
e... | ruby | def check_id(type, idstring)
if idstring.class == Fixnum
return make_read_url(type, idstring)
end
if (idstring.class == String)
return idstring if idstring.index("http") == 0
return ref_by_formatted_id(type, idstring.split("|")[1]) if idstring.index("FormattedID") == 0
e... | [
"def",
"check_id",
"(",
"type",
",",
"idstring",
")",
"if",
"idstring",
".",
"class",
"==",
"Fixnum",
"return",
"make_read_url",
"(",
"type",
",",
"idstring",
")",
"end",
"if",
"(",
"idstring",
".",
"class",
"==",
"String",
")",
"return",
"idstring",
"if... | expecting idstring to have "FormattedID|DE45" or the objectID or a ref itself | [
"expecting",
"idstring",
"to",
"have",
"FormattedID|DE45",
"or",
"the",
"objectID",
"or",
"a",
"ref",
"itself"
] | a091616254c7a72e9a6f04f757026e5968312777 | https://github.com/RallyTools/RallyRestToolkitForRuby/blob/a091616254c7a72e9a6f04f757026e5968312777/lib/rally_api/rally_rest_json.rb#L451-L461 |
22,416 | RallyTools/RallyRestToolkitForRuby | lib/rally_api/rally_object.rb | RallyAPI.RallyObject.method_missing | def method_missing(sym, *args)
ret_val = get_val(sym.to_s)
if ret_val.nil? && @rally_rest.rally_rest_api_compat
ret_val = get_val(camel_case_word(sym))
end
ret_val
end | ruby | def method_missing(sym, *args)
ret_val = get_val(sym.to_s)
if ret_val.nil? && @rally_rest.rally_rest_api_compat
ret_val = get_val(camel_case_word(sym))
end
ret_val
end | [
"def",
"method_missing",
"(",
"sym",
",",
"*",
"args",
")",
"ret_val",
"=",
"get_val",
"(",
"sym",
".",
"to_s",
")",
"if",
"ret_val",
".",
"nil?",
"&&",
"@rally_rest",
".",
"rally_rest_api_compat",
"ret_val",
"=",
"get_val",
"(",
"camel_case_word",
"(",
"s... | An attempt to be rally_rest_api user friendly -
you can get a field the old way with an underscored field name or the upcase name | [
"An",
"attempt",
"to",
"be",
"rally_rest_api",
"user",
"friendly",
"-",
"you",
"can",
"get",
"a",
"field",
"the",
"old",
"way",
"with",
"an",
"underscored",
"field",
"name",
"or",
"the",
"upcase",
"name"
] | a091616254c7a72e9a6f04f757026e5968312777 | https://github.com/RallyTools/RallyRestToolkitForRuby/blob/a091616254c7a72e9a6f04f757026e5968312777/lib/rally_api/rally_object.rb#L146-L152 |
22,417 | arempe93/bunny-mock | lib/bunny_mock/channel.rb | BunnyMock.Channel.ack | def ack(delivery_tag, multiple = false)
if multiple
@acknowledged_state[:pending].keys.each do |key|
ack(key, false) if key <= delivery_tag
end
elsif @acknowledged_state[:pending].key?(delivery_tag)
update_acknowledgement_state(delivery_tag, :acked)
end
nil
... | ruby | def ack(delivery_tag, multiple = false)
if multiple
@acknowledged_state[:pending].keys.each do |key|
ack(key, false) if key <= delivery_tag
end
elsif @acknowledged_state[:pending].key?(delivery_tag)
update_acknowledgement_state(delivery_tag, :acked)
end
nil
... | [
"def",
"ack",
"(",
"delivery_tag",
",",
"multiple",
"=",
"false",
")",
"if",
"multiple",
"@acknowledged_state",
"[",
":pending",
"]",
".",
"keys",
".",
"each",
"do",
"|",
"key",
"|",
"ack",
"(",
"key",
",",
"false",
")",
"if",
"key",
"<=",
"delivery_ta... | Acknowledge message.
@param [Integer] delivery_tag Delivery tag to acknowledge
@param [Boolean] multiple (false) Should all unacknowledged messages up to this be acknowleded as well?
@return nil
@api public | [
"Acknowledge",
"message",
"."
] | 468fe867815bd86fde9797379964b7336d5bcfec | https://github.com/arempe93/bunny-mock/blob/468fe867815bd86fde9797379964b7336d5bcfec/lib/bunny_mock/channel.rb#L279-L288 |
22,418 | arempe93/bunny-mock | lib/bunny_mock/channel.rb | BunnyMock.Channel.nack | def nack(delivery_tag, multiple = false, requeue = false)
if multiple
@acknowledged_state[:pending].keys.each do |key|
nack(key, false, requeue) if key <= delivery_tag
end
elsif @acknowledged_state[:pending].key?(delivery_tag)
delivery, header, body = update_acknowledgement... | ruby | def nack(delivery_tag, multiple = false, requeue = false)
if multiple
@acknowledged_state[:pending].keys.each do |key|
nack(key, false, requeue) if key <= delivery_tag
end
elsif @acknowledged_state[:pending].key?(delivery_tag)
delivery, header, body = update_acknowledgement... | [
"def",
"nack",
"(",
"delivery_tag",
",",
"multiple",
"=",
"false",
",",
"requeue",
"=",
"false",
")",
"if",
"multiple",
"@acknowledged_state",
"[",
":pending",
"]",
".",
"keys",
".",
"each",
"do",
"|",
"key",
"|",
"nack",
"(",
"key",
",",
"false",
",",... | Unacknowledge message.
@param [Integer] delivery_tag Delivery tag to acknowledge
@param [Boolean] multiple (false) Should all unacknowledged messages up to this be rejected as well?
@param [Boolean] requeue (false) Should this message be requeued instead of dropping it?
@return nil
@api public | [
"Unacknowledge",
"message",
"."
] | 468fe867815bd86fde9797379964b7336d5bcfec | https://github.com/arempe93/bunny-mock/blob/468fe867815bd86fde9797379964b7336d5bcfec/lib/bunny_mock/channel.rb#L301-L311 |
22,419 | arempe93/bunny-mock | lib/bunny_mock/channel.rb | BunnyMock.Channel.reject | def reject(delivery_tag, requeue = false)
if @acknowledged_state[:pending].key?(delivery_tag)
delivery, header, body = update_acknowledgement_state(delivery_tag, :rejected)
delivery.queue.publish(body, header.to_hash) if requeue
end
nil
end | ruby | def reject(delivery_tag, requeue = false)
if @acknowledged_state[:pending].key?(delivery_tag)
delivery, header, body = update_acknowledgement_state(delivery_tag, :rejected)
delivery.queue.publish(body, header.to_hash) if requeue
end
nil
end | [
"def",
"reject",
"(",
"delivery_tag",
",",
"requeue",
"=",
"false",
")",
"if",
"@acknowledged_state",
"[",
":pending",
"]",
".",
"key?",
"(",
"delivery_tag",
")",
"delivery",
",",
"header",
",",
"body",
"=",
"update_acknowledgement_state",
"(",
"delivery_tag",
... | Rejects a message. A rejected message can be requeued or
dropped by RabbitMQ.
@param [Integer] delivery_tag Delivery tag to reject
@param [Boolean] requeue Should this message be requeued instead of dropping it?
@return nil
@api public | [
"Rejects",
"a",
"message",
".",
"A",
"rejected",
"message",
"can",
"be",
"requeued",
"or",
"dropped",
"by",
"RabbitMQ",
"."
] | 468fe867815bd86fde9797379964b7336d5bcfec | https://github.com/arempe93/bunny-mock/blob/468fe867815bd86fde9797379964b7336d5bcfec/lib/bunny_mock/channel.rb#L323-L329 |
22,420 | arempe93/bunny-mock | lib/bunny_mock/queue.rb | BunnyMock.Queue.bind | def bind(exchange, opts = {})
check_queue_deleted!
if exchange.respond_to?(:add_route)
# we can do the binding ourselves
exchange.add_route opts.fetch(:routing_key, @name), self
else
# we need the channel to lookup the exchange
@channel.queue_bind self, opts.fetch(:r... | ruby | def bind(exchange, opts = {})
check_queue_deleted!
if exchange.respond_to?(:add_route)
# we can do the binding ourselves
exchange.add_route opts.fetch(:routing_key, @name), self
else
# we need the channel to lookup the exchange
@channel.queue_bind self, opts.fetch(:r... | [
"def",
"bind",
"(",
"exchange",
",",
"opts",
"=",
"{",
"}",
")",
"check_queue_deleted!",
"if",
"exchange",
".",
"respond_to?",
"(",
":add_route",
")",
"# we can do the binding ourselves",
"exchange",
".",
"add_route",
"opts",
".",
"fetch",
"(",
":routing_key",
"... | Bind this queue to an exchange
@param [BunnyMock::Exchange,String] exchange Exchange to bind to
@param [Hash] opts Binding properties
@option opts [String] :routing_key Custom routing key
@api public | [
"Bind",
"this",
"queue",
"to",
"an",
"exchange"
] | 468fe867815bd86fde9797379964b7336d5bcfec | https://github.com/arempe93/bunny-mock/blob/468fe867815bd86fde9797379964b7336d5bcfec/lib/bunny_mock/queue.rb#L118-L131 |
22,421 | arempe93/bunny-mock | lib/bunny_mock/queue.rb | BunnyMock.Queue.unbind | def unbind(exchange, opts = {})
check_queue_deleted!
if exchange.respond_to?(:remove_route)
# we can do the unbinding ourselves
exchange.remove_route opts.fetch(:routing_key, @name), self
else
# we need the channel to lookup the exchange
@channel.queue_unbind self, o... | ruby | def unbind(exchange, opts = {})
check_queue_deleted!
if exchange.respond_to?(:remove_route)
# we can do the unbinding ourselves
exchange.remove_route opts.fetch(:routing_key, @name), self
else
# we need the channel to lookup the exchange
@channel.queue_unbind self, o... | [
"def",
"unbind",
"(",
"exchange",
",",
"opts",
"=",
"{",
"}",
")",
"check_queue_deleted!",
"if",
"exchange",
".",
"respond_to?",
"(",
":remove_route",
")",
"# we can do the unbinding ourselves",
"exchange",
".",
"remove_route",
"opts",
".",
"fetch",
"(",
":routing... | Unbind this queue from an exchange
@param [BunnyMock::Exchange,String] exchange Exchange to unbind from
@param [Hash] opts Binding properties
@option opts [String] :routing_key Custom routing key
@api public | [
"Unbind",
"this",
"queue",
"from",
"an",
"exchange"
] | 468fe867815bd86fde9797379964b7336d5bcfec | https://github.com/arempe93/bunny-mock/blob/468fe867815bd86fde9797379964b7336d5bcfec/lib/bunny_mock/queue.rb#L143-L155 |
22,422 | arempe93/bunny-mock | lib/bunny_mock/queue.rb | BunnyMock.Queue.pop | def pop(opts = { manual_ack: false }, &block)
if BunnyMock.use_bunny_queue_pop_api
bunny_pop(opts, &block)
else
warn '[DEPRECATED] This behavior is deprecated - please set `BunnyMock::use_bunny_queue_pop_api` to true to use Bunny Queue#pop behavior'
@messages.shift
end
end | ruby | def pop(opts = { manual_ack: false }, &block)
if BunnyMock.use_bunny_queue_pop_api
bunny_pop(opts, &block)
else
warn '[DEPRECATED] This behavior is deprecated - please set `BunnyMock::use_bunny_queue_pop_api` to true to use Bunny Queue#pop behavior'
@messages.shift
end
end | [
"def",
"pop",
"(",
"opts",
"=",
"{",
"manual_ack",
":",
"false",
"}",
",",
"&",
"block",
")",
"if",
"BunnyMock",
".",
"use_bunny_queue_pop_api",
"bunny_pop",
"(",
"opts",
",",
"block",
")",
"else",
"warn",
"'[DEPRECATED] This behavior is deprecated - please set `B... | Get oldest message in queue
@return [Hash] Message data
@api public | [
"Get",
"oldest",
"message",
"in",
"queue"
] | 468fe867815bd86fde9797379964b7336d5bcfec | https://github.com/arempe93/bunny-mock/blob/468fe867815bd86fde9797379964b7336d5bcfec/lib/bunny_mock/queue.rb#L198-L205 |
22,423 | arempe93/bunny-mock | lib/bunny_mock/exchange.rb | BunnyMock.Exchange.bind | def bind(exchange, opts = {})
if exchange.respond_to?(:add_route)
# we can do the binding ourselves
exchange.add_route opts.fetch(:routing_key, @name), self
else
# we need the channel to look up the exchange
@channel.xchg_bind self, opts.fetch(:routing_key, @name), exchange... | ruby | def bind(exchange, opts = {})
if exchange.respond_to?(:add_route)
# we can do the binding ourselves
exchange.add_route opts.fetch(:routing_key, @name), self
else
# we need the channel to look up the exchange
@channel.xchg_bind self, opts.fetch(:routing_key, @name), exchange... | [
"def",
"bind",
"(",
"exchange",
",",
"opts",
"=",
"{",
"}",
")",
"if",
"exchange",
".",
"respond_to?",
"(",
":add_route",
")",
"# we can do the binding ourselves",
"exchange",
".",
"add_route",
"opts",
".",
"fetch",
"(",
":routing_key",
",",
"@name",
")",
",... | Bind this exchange to another exchange
@param [BunnyMock::Exchange,String] exchange Exchange to bind to
@param [Hash] opts Binding properties
@option opts [String] :routing_key Custom routing key
@return [BunnyMock::Exchange] self
@api public | [
"Bind",
"this",
"exchange",
"to",
"another",
"exchange"
] | 468fe867815bd86fde9797379964b7336d5bcfec | https://github.com/arempe93/bunny-mock/blob/468fe867815bd86fde9797379964b7336d5bcfec/lib/bunny_mock/exchange.rb#L144-L156 |
22,424 | arempe93/bunny-mock | lib/bunny_mock/exchange.rb | BunnyMock.Exchange.unbind | def unbind(exchange, opts = {})
if exchange.respond_to?(:remove_route)
# we can do the unbinding ourselves
exchange.remove_route opts.fetch(:routing_key, @name), self
else
# we need the channel to look up the exchange
@channel.xchg_unbind opts.fetch(:routing_key, @name), exch... | ruby | def unbind(exchange, opts = {})
if exchange.respond_to?(:remove_route)
# we can do the unbinding ourselves
exchange.remove_route opts.fetch(:routing_key, @name), self
else
# we need the channel to look up the exchange
@channel.xchg_unbind opts.fetch(:routing_key, @name), exch... | [
"def",
"unbind",
"(",
"exchange",
",",
"opts",
"=",
"{",
"}",
")",
"if",
"exchange",
".",
"respond_to?",
"(",
":remove_route",
")",
"# we can do the unbinding ourselves",
"exchange",
".",
"remove_route",
"opts",
".",
"fetch",
"(",
":routing_key",
",",
"@name",
... | Unbind this exchange from another exchange
@param [BunnyMock::Exchange,String] exchange Exchange to unbind from
@param [Hash] opts Binding properties
@option opts [String] :routing_key Custom routing key
@return [BunnyMock::Exchange] self
@api public | [
"Unbind",
"this",
"exchange",
"from",
"another",
"exchange"
] | 468fe867815bd86fde9797379964b7336d5bcfec | https://github.com/arempe93/bunny-mock/blob/468fe867815bd86fde9797379964b7336d5bcfec/lib/bunny_mock/exchange.rb#L169-L179 |
22,425 | arempe93/bunny-mock | lib/bunny_mock/exchange.rb | BunnyMock.Exchange.routes_to? | def routes_to?(exchange_or_queue, opts = {})
route = exchange_or_queue.respond_to?(:name) ? exchange_or_queue.name : exchange_or_queue
rk = opts.fetch(:routing_key, route)
@routes.key?(rk) && @routes[rk].any? { |r| r == exchange_or_queue }
end | ruby | def routes_to?(exchange_or_queue, opts = {})
route = exchange_or_queue.respond_to?(:name) ? exchange_or_queue.name : exchange_or_queue
rk = opts.fetch(:routing_key, route)
@routes.key?(rk) && @routes[rk].any? { |r| r == exchange_or_queue }
end | [
"def",
"routes_to?",
"(",
"exchange_or_queue",
",",
"opts",
"=",
"{",
"}",
")",
"route",
"=",
"exchange_or_queue",
".",
"respond_to?",
"(",
":name",
")",
"?",
"exchange_or_queue",
".",
"name",
":",
"exchange_or_queue",
"rk",
"=",
"opts",
".",
"fetch",
"(",
... | Check if a queue is bound to this exchange
@param [BunnyMock::Queue,String] exchange_or_queue Exchange or queue to check
@param [Hash] opts Binding properties
@option opts [String] :routing_key Custom routing key
@return [Boolean] true if the given queue or exchange matching options is bound to this exchange, fa... | [
"Check",
"if",
"a",
"queue",
"is",
"bound",
"to",
"this",
"exchange"
] | 468fe867815bd86fde9797379964b7336d5bcfec | https://github.com/arempe93/bunny-mock/blob/468fe867815bd86fde9797379964b7336d5bcfec/lib/bunny_mock/exchange.rb#L216-L220 |
22,426 | piotrmurach/tty-cursor | lib/tty/cursor.rb | TTY.Cursor.move | def move(x, y)
(x < 0 ? backward(-x) : (x > 0 ? forward(x) : '')) +
(y < 0 ? down(-y) : (y > 0 ? up(y) : ''))
end | ruby | def move(x, y)
(x < 0 ? backward(-x) : (x > 0 ? forward(x) : '')) +
(y < 0 ? down(-y) : (y > 0 ? up(y) : ''))
end | [
"def",
"move",
"(",
"x",
",",
"y",
")",
"(",
"x",
"<",
"0",
"?",
"backward",
"(",
"-",
"x",
")",
":",
"(",
"x",
">",
"0",
"?",
"forward",
"(",
"x",
")",
":",
"''",
")",
")",
"+",
"(",
"y",
"<",
"0",
"?",
"down",
"(",
"-",
"y",
")",
... | Move cursor relative to its current position
@param [Integer] x
@param [Integer] y
@api public | [
"Move",
"cursor",
"relative",
"to",
"its",
"current",
"position"
] | eed06fea403ed6d7400ea048435e463cfa538aed | https://github.com/piotrmurach/tty-cursor/blob/eed06fea403ed6d7400ea048435e463cfa538aed/lib/tty/cursor.rb#L70-L73 |
22,427 | piotrmurach/tty-cursor | lib/tty/cursor.rb | TTY.Cursor.clear_lines | def clear_lines(n, direction = :up)
n.times.reduce([]) do |acc, i|
dir = direction == :up ? up : down
acc << clear_line + ((i == n - 1) ? '' : dir)
end.join
end | ruby | def clear_lines(n, direction = :up)
n.times.reduce([]) do |acc, i|
dir = direction == :up ? up : down
acc << clear_line + ((i == n - 1) ? '' : dir)
end.join
end | [
"def",
"clear_lines",
"(",
"n",
",",
"direction",
"=",
":up",
")",
"n",
".",
"times",
".",
"reduce",
"(",
"[",
"]",
")",
"do",
"|",
"acc",
",",
"i",
"|",
"dir",
"=",
"direction",
"==",
":up",
"?",
"up",
":",
"down",
"acc",
"<<",
"clear_line",
"... | Clear a number of lines
@param [Integer] n
the number of lines to clear
@param [Symbol] :direction
the direction to clear, default :up
@api public | [
"Clear",
"a",
"number",
"of",
"lines"
] | eed06fea403ed6d7400ea048435e463cfa538aed | https://github.com/piotrmurach/tty-cursor/blob/eed06fea403ed6d7400ea048435e463cfa538aed/lib/tty/cursor.rb#L169-L174 |
22,428 | iyuuya/jkf | lib/jkf/parser/kif.rb | Jkf::Parser.Kif.transform_move | def transform_move(line, c)
ret = {}
ret["comments"] = c if !c.empty?
if line["move"].is_a? Hash
ret["move"] = line["move"]
else
ret["special"] = special2csa(line["move"])
end
ret["time"] = line["time"] if line["time"]
ret
end | ruby | def transform_move(line, c)
ret = {}
ret["comments"] = c if !c.empty?
if line["move"].is_a? Hash
ret["move"] = line["move"]
else
ret["special"] = special2csa(line["move"])
end
ret["time"] = line["time"] if line["time"]
ret
end | [
"def",
"transform_move",
"(",
"line",
",",
"c",
")",
"ret",
"=",
"{",
"}",
"ret",
"[",
"\"comments\"",
"]",
"=",
"c",
"if",
"!",
"c",
".",
"empty?",
"if",
"line",
"[",
"\"move\"",
"]",
".",
"is_a?",
"Hash",
"ret",
"[",
"\"move\"",
"]",
"=",
"line... | transform move to jkf | [
"transform",
"move",
"to",
"jkf"
] | 4fd229c50737cab7b41281238880f1414e55e061 | https://github.com/iyuuya/jkf/blob/4fd229c50737cab7b41281238880f1414e55e061/lib/jkf/parser/kif.rb#L567-L577 |
22,429 | iyuuya/jkf | lib/jkf/parser/kif.rb | Jkf::Parser.Kif.transform_teban_fugou_from | def transform_teban_fugou_from(teban, fugou, from)
ret = { "color" => teban2color(teban.join), "piece" => fugou["piece"] }
if fugou["to"]
ret["to"] = fugou["to"]
else
ret["same"] = true
end
ret["promote"] = true if fugou["promote"]
ret["from"] = from if from
ret... | ruby | def transform_teban_fugou_from(teban, fugou, from)
ret = { "color" => teban2color(teban.join), "piece" => fugou["piece"] }
if fugou["to"]
ret["to"] = fugou["to"]
else
ret["same"] = true
end
ret["promote"] = true if fugou["promote"]
ret["from"] = from if from
ret... | [
"def",
"transform_teban_fugou_from",
"(",
"teban",
",",
"fugou",
",",
"from",
")",
"ret",
"=",
"{",
"\"color\"",
"=>",
"teban2color",
"(",
"teban",
".",
"join",
")",
",",
"\"piece\"",
"=>",
"fugou",
"[",
"\"piece\"",
"]",
"}",
"if",
"fugou",
"[",
"\"to\"... | transform teban-fugou-from to jkf | [
"transform",
"teban",
"-",
"fugou",
"-",
"from",
"to",
"jkf"
] | 4fd229c50737cab7b41281238880f1414e55e061 | https://github.com/iyuuya/jkf/blob/4fd229c50737cab7b41281238880f1414e55e061/lib/jkf/parser/kif.rb#L580-L590 |
22,430 | iyuuya/jkf | lib/jkf/parser/kif.rb | Jkf::Parser.Kif.reverse_color | def reverse_color(moves)
moves.each do |move|
if move["move"] && move["move"]["color"]
move["move"]["color"] = (move["move"]["color"] + 1) % 2
end
move["forks"].each { |_fork| reverse_color(_fork) } if move["forks"]
end
end | ruby | def reverse_color(moves)
moves.each do |move|
if move["move"] && move["move"]["color"]
move["move"]["color"] = (move["move"]["color"] + 1) % 2
end
move["forks"].each { |_fork| reverse_color(_fork) } if move["forks"]
end
end | [
"def",
"reverse_color",
"(",
"moves",
")",
"moves",
".",
"each",
"do",
"|",
"move",
"|",
"if",
"move",
"[",
"\"move\"",
"]",
"&&",
"move",
"[",
"\"move\"",
"]",
"[",
"\"color\"",
"]",
"move",
"[",
"\"move\"",
"]",
"[",
"\"color\"",
"]",
"=",
"(",
"... | exchange sente gote | [
"exchange",
"sente",
"gote"
] | 4fd229c50737cab7b41281238880f1414e55e061 | https://github.com/iyuuya/jkf/blob/4fd229c50737cab7b41281238880f1414e55e061/lib/jkf/parser/kif.rb#L628-L635 |
22,431 | iyuuya/jkf | lib/jkf/parser/ki2.rb | Jkf::Parser.Ki2.transform_fugou | def transform_fugou(pl, pi, sou, dou, pro, da)
ret = { "piece" => pi }
if pl["same"]
ret["same"] = true
else
ret["to"] = pl
end
ret["promote"] = (pro == "成") if pro
if da
ret["relative"] = "H"
else
rel = soutai2relative(sou) + dousa2relative(dou)... | ruby | def transform_fugou(pl, pi, sou, dou, pro, da)
ret = { "piece" => pi }
if pl["same"]
ret["same"] = true
else
ret["to"] = pl
end
ret["promote"] = (pro == "成") if pro
if da
ret["relative"] = "H"
else
rel = soutai2relative(sou) + dousa2relative(dou)... | [
"def",
"transform_fugou",
"(",
"pl",
",",
"pi",
",",
"sou",
",",
"dou",
",",
"pro",
",",
"da",
")",
"ret",
"=",
"{",
"\"piece\"",
"=>",
"pi",
"}",
"if",
"pl",
"[",
"\"same\"",
"]",
"ret",
"[",
"\"same\"",
"]",
"=",
"true",
"else",
"ret",
"[",
"... | transfrom fugou to jkf | [
"transfrom",
"fugou",
"to",
"jkf"
] | 4fd229c50737cab7b41281238880f1414e55e061 | https://github.com/iyuuya/jkf/blob/4fd229c50737cab7b41281238880f1414e55e061/lib/jkf/parser/ki2.rb#L373-L388 |
22,432 | iyuuya/jkf | lib/jkf/parser/base.rb | Jkf::Parser.Base.match_spaces | def match_spaces
stack = []
matched = match_space
while matched != :failed
stack << matched
matched = match_space
end
stack
end | ruby | def match_spaces
stack = []
matched = match_space
while matched != :failed
stack << matched
matched = match_space
end
stack
end | [
"def",
"match_spaces",
"stack",
"=",
"[",
"]",
"matched",
"=",
"match_space",
"while",
"matched",
"!=",
":failed",
"stack",
"<<",
"matched",
"matched",
"=",
"match_space",
"end",
"stack",
"end"
] | match space one or more | [
"match",
"space",
"one",
"or",
"more"
] | 4fd229c50737cab7b41281238880f1414e55e061 | https://github.com/iyuuya/jkf/blob/4fd229c50737cab7b41281238880f1414e55e061/lib/jkf/parser/base.rb#L70-L78 |
22,433 | iyuuya/jkf | lib/jkf/parser/kifuable.rb | Jkf::Parser.Kifuable.transform_root_forks | def transform_root_forks(forks, moves)
fork_stack = [{ "te" => 0, "moves" => moves }]
forks.each do |f|
now_fork = f
_fork = fork_stack.pop
_fork = fork_stack.pop while _fork["te"] > now_fork["te"]
move = _fork["moves"][now_fork["te"] - _fork["te"]]
move["forks"] ||= ... | ruby | def transform_root_forks(forks, moves)
fork_stack = [{ "te" => 0, "moves" => moves }]
forks.each do |f|
now_fork = f
_fork = fork_stack.pop
_fork = fork_stack.pop while _fork["te"] > now_fork["te"]
move = _fork["moves"][now_fork["te"] - _fork["te"]]
move["forks"] ||= ... | [
"def",
"transform_root_forks",
"(",
"forks",
",",
"moves",
")",
"fork_stack",
"=",
"[",
"{",
"\"te\"",
"=>",
"0",
",",
"\"moves\"",
"=>",
"moves",
"}",
"]",
"forks",
".",
"each",
"do",
"|",
"f",
"|",
"now_fork",
"=",
"f",
"_fork",
"=",
"fork_stack",
... | transfrom forks to jkf | [
"transfrom",
"forks",
"to",
"jkf"
] | 4fd229c50737cab7b41281238880f1414e55e061 | https://github.com/iyuuya/jkf/blob/4fd229c50737cab7b41281238880f1414e55e061/lib/jkf/parser/kifuable.rb#L545-L557 |
22,434 | iyuuya/jkf | lib/jkf/parser/kifuable.rb | Jkf::Parser.Kifuable.transform_initialboard | def transform_initialboard(lines)
board = []
9.times do |i|
line = []
9.times do |j|
line << lines[j][8 - i]
end
board << line
end
{ "preset" => "OTHER", "data" => { "board" => board } }
end | ruby | def transform_initialboard(lines)
board = []
9.times do |i|
line = []
9.times do |j|
line << lines[j][8 - i]
end
board << line
end
{ "preset" => "OTHER", "data" => { "board" => board } }
end | [
"def",
"transform_initialboard",
"(",
"lines",
")",
"board",
"=",
"[",
"]",
"9",
".",
"times",
"do",
"|",
"i",
"|",
"line",
"=",
"[",
"]",
"9",
".",
"times",
"do",
"|",
"j",
"|",
"line",
"<<",
"lines",
"[",
"j",
"]",
"[",
"8",
"-",
"i",
"]",
... | transform initialboard to jkf | [
"transform",
"initialboard",
"to",
"jkf"
] | 4fd229c50737cab7b41281238880f1414e55e061 | https://github.com/iyuuya/jkf/blob/4fd229c50737cab7b41281238880f1414e55e061/lib/jkf/parser/kifuable.rb#L560-L570 |
22,435 | iyuuya/jkf | lib/jkf/parser/csa.rb | Jkf::Parser.Csa.transform_komabetsu_lines | def transform_komabetsu_lines(lines)
board = generate_empty_board
hands = [
{ "FU" => 0, "KY" => 0, "KE" => 0, "GI" => 0, "KI" => 0, "KA" => 0, "HI" => 0 },
{ "FU" => 0, "KY" => 0, "KE" => 0, "GI" => 0, "KI" => 0, "KA" => 0, "HI" => 0 }
]
all = { "FU" => 18, "KY" => 4, "KE" => 4,... | ruby | def transform_komabetsu_lines(lines)
board = generate_empty_board
hands = [
{ "FU" => 0, "KY" => 0, "KE" => 0, "GI" => 0, "KI" => 0, "KA" => 0, "HI" => 0 },
{ "FU" => 0, "KY" => 0, "KE" => 0, "GI" => 0, "KI" => 0, "KA" => 0, "HI" => 0 }
]
all = { "FU" => 18, "KY" => 4, "KE" => 4,... | [
"def",
"transform_komabetsu_lines",
"(",
"lines",
")",
"board",
"=",
"generate_empty_board",
"hands",
"=",
"[",
"{",
"\"FU\"",
"=>",
"0",
",",
"\"KY\"",
"=>",
"0",
",",
"\"KE\"",
"=>",
"0",
",",
"\"GI\"",
"=>",
"0",
",",
"\"KI\"",
"=>",
"0",
",",
"\"KA... | lines to jkf | [
"lines",
"to",
"jkf"
] | 4fd229c50737cab7b41281238880f1414e55e061 | https://github.com/iyuuya/jkf/blob/4fd229c50737cab7b41281238880f1414e55e061/lib/jkf/parser/csa.rb#L743-L770 |
22,436 | iyuuya/jkf | lib/jkf/parser/csa.rb | Jkf::Parser.Csa.generate_empty_board | def generate_empty_board
board = []
9.times do |_i|
line = []
9.times do |_j|
line << {}
end
board << line
end
board
end | ruby | def generate_empty_board
board = []
9.times do |_i|
line = []
9.times do |_j|
line << {}
end
board << line
end
board
end | [
"def",
"generate_empty_board",
"board",
"=",
"[",
"]",
"9",
".",
"times",
"do",
"|",
"_i",
"|",
"line",
"=",
"[",
"]",
"9",
".",
"times",
"do",
"|",
"_j",
"|",
"line",
"<<",
"{",
"}",
"end",
"board",
"<<",
"line",
"end",
"board",
"end"
] | return empty board jkf | [
"return",
"empty",
"board",
"jkf"
] | 4fd229c50737cab7b41281238880f1414e55e061 | https://github.com/iyuuya/jkf/blob/4fd229c50737cab7b41281238880f1414e55e061/lib/jkf/parser/csa.rb#L773-L783 |
22,437 | stellar/ruby-stellar-base | lib/stellar/transaction.rb | Stellar.Transaction.to_operations | def to_operations
cloned = Marshal.load Marshal.dump(operations)
operations.each do |op|
op.source_account ||= self.source_account
end
end | ruby | def to_operations
cloned = Marshal.load Marshal.dump(operations)
operations.each do |op|
op.source_account ||= self.source_account
end
end | [
"def",
"to_operations",
"cloned",
"=",
"Marshal",
".",
"load",
"Marshal",
".",
"dump",
"(",
"operations",
")",
"operations",
".",
"each",
"do",
"|",
"op",
"|",
"op",
".",
"source_account",
"||=",
"self",
".",
"source_account",
"end",
"end"
] | Extracts the operations from this single transaction,
setting the source account on the extracted operations.
Useful for merging transactions.
@return [Array<Operation>] the operations | [
"Extracts",
"the",
"operations",
"from",
"this",
"single",
"transaction",
"setting",
"the",
"source",
"account",
"on",
"the",
"extracted",
"operations",
"."
] | 59ce19d1a71b5a02b67bc18c53b838f3fed6c5d1 | https://github.com/stellar/ruby-stellar-base/blob/59ce19d1a71b5a02b67bc18c53b838f3fed6c5d1/lib/stellar/transaction.rb#L169-L174 |
22,438 | stellar/ruby-stellar-base | lib/stellar/path_payment_result.rb | Stellar.PathPaymentResult.send_amount | def send_amount
s = success!
return s.last.amount if s.offers.blank?
source_asset = s.offers.first.asset_bought
source_offers = s.offers.take_while{|o| o.asset_bought == source_asset}
source_offers.map(&:amount_bought).sum
end | ruby | def send_amount
s = success!
return s.last.amount if s.offers.blank?
source_asset = s.offers.first.asset_bought
source_offers = s.offers.take_while{|o| o.asset_bought == source_asset}
source_offers.map(&:amount_bought).sum
end | [
"def",
"send_amount",
"s",
"=",
"success!",
"return",
"s",
".",
"last",
".",
"amount",
"if",
"s",
".",
"offers",
".",
"blank?",
"source_asset",
"=",
"s",
".",
"offers",
".",
"first",
".",
"asset_bought",
"source_offers",
"=",
"s",
".",
"offers",
".",
"... | send_amount returns the actual amount paid for the corresponding
PathPaymentOp to this result. | [
"send_amount",
"returns",
"the",
"actual",
"amount",
"paid",
"for",
"the",
"corresponding",
"PathPaymentOp",
"to",
"this",
"result",
"."
] | 59ce19d1a71b5a02b67bc18c53b838f3fed6c5d1 | https://github.com/stellar/ruby-stellar-base/blob/59ce19d1a71b5a02b67bc18c53b838f3fed6c5d1/lib/stellar/path_payment_result.rb#L6-L14 |
22,439 | stellar/ruby-stellar-base | lib/stellar/transaction_envelope.rb | Stellar.TransactionEnvelope.signed_correctly? | def signed_correctly?(*key_pairs)
hash = tx.hash
return false if signatures.empty?
key_index = key_pairs.index_by(&:signature_hint)
signatures.all? do |sig|
key_pair = key_index[sig.hint]
break false if key_pair.nil?
key_pair.verify(sig.signature, hash)
en... | ruby | def signed_correctly?(*key_pairs)
hash = tx.hash
return false if signatures.empty?
key_index = key_pairs.index_by(&:signature_hint)
signatures.all? do |sig|
key_pair = key_index[sig.hint]
break false if key_pair.nil?
key_pair.verify(sig.signature, hash)
en... | [
"def",
"signed_correctly?",
"(",
"*",
"key_pairs",
")",
"hash",
"=",
"tx",
".",
"hash",
"return",
"false",
"if",
"signatures",
".",
"empty?",
"key_index",
"=",
"key_pairs",
".",
"index_by",
"(",
":signature_hint",
")",
"signatures",
".",
"all?",
"do",
"|",
... | Checks to ensure that every signature for the envelope is
a valid signature of one of the provided `key_pairs`
NOTE: this does not do any authorization checks, which requires access to
the current ledger state.
@param *key_pairs [Array<Stellar::KeyPair>] The key pairs to check the envelopes signatures against
@... | [
"Checks",
"to",
"ensure",
"that",
"every",
"signature",
"for",
"the",
"envelope",
"is",
"a",
"valid",
"signature",
"of",
"one",
"of",
"the",
"provided",
"key_pairs"
] | 59ce19d1a71b5a02b67bc18c53b838f3fed6c5d1 | https://github.com/stellar/ruby-stellar-base/blob/59ce19d1a71b5a02b67bc18c53b838f3fed6c5d1/lib/stellar/transaction_envelope.rb#L14-L26 |
22,440 | xing/beetle | lib/beetle/client.rb | Beetle.Client.configure | def configure(options={}, &block)
configurator = Configurator.new(self, options)
if block.arity == 1
yield configurator
else
configurator.instance_eval(&block)
end
self
end | ruby | def configure(options={}, &block)
configurator = Configurator.new(self, options)
if block.arity == 1
yield configurator
else
configurator.instance_eval(&block)
end
self
end | [
"def",
"configure",
"(",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"configurator",
"=",
"Configurator",
".",
"new",
"(",
"self",
",",
"options",
")",
"if",
"block",
".",
"arity",
"==",
"1",
"yield",
"configurator",
"else",
"configurator",
".",
... | this is a convenience method to configure exchanges, queues, messages and handlers
with a common set of options. allows one to call all register methods without the
register_ prefix. returns self. if the passed in block has no parameters, the block
will be evaluated in the context of the client configurator.
Examp... | [
"this",
"is",
"a",
"convenience",
"method",
"to",
"configure",
"exchanges",
"queues",
"messages",
"and",
"handlers",
"with",
"a",
"common",
"set",
"of",
"options",
".",
"allows",
"one",
"to",
"call",
"all",
"register",
"methods",
"without",
"the",
"register_",... | 42322edc78e6e181b3b9ee284c3b00bddfc89108 | https://github.com/xing/beetle/blob/42322edc78e6e181b3b9ee284c3b00bddfc89108/lib/beetle/client.rb#L181-L189 |
22,441 | xing/beetle | lib/beetle/client.rb | Beetle.Client.rpc | def rpc(message_name, data=nil, opts={})
message_name = validated_message_name(message_name)
publisher.rpc(message_name, data, opts)
end | ruby | def rpc(message_name, data=nil, opts={})
message_name = validated_message_name(message_name)
publisher.rpc(message_name, data, opts)
end | [
"def",
"rpc",
"(",
"message_name",
",",
"data",
"=",
"nil",
",",
"opts",
"=",
"{",
"}",
")",
"message_name",
"=",
"validated_message_name",
"(",
"message_name",
")",
"publisher",
".",
"rpc",
"(",
"message_name",
",",
"data",
",",
"opts",
")",
"end"
] | sends the given message to one of the configured servers and returns the result of running the associated handler.
unexpected behavior can ensue if the message gets routed to more than one recipient, so be careful. | [
"sends",
"the",
"given",
"message",
"to",
"one",
"of",
"the",
"configured",
"servers",
"and",
"returns",
"the",
"result",
"of",
"running",
"the",
"associated",
"handler",
"."
] | 42322edc78e6e181b3b9ee284c3b00bddfc89108 | https://github.com/xing/beetle/blob/42322edc78e6e181b3b9ee284c3b00bddfc89108/lib/beetle/client.rb#L201-L204 |
22,442 | xing/beetle | lib/beetle/client.rb | Beetle.Client.trace | def trace(queue_names=self.queues.keys, tracer=nil, &block)
queues_to_trace = self.queues.slice(*queue_names)
queues_to_trace.each do |name, opts|
opts.merge! :durable => false, :auto_delete => true, :amqp_name => queue_name_for_tracing(opts[:amqp_name])
end
tracer ||=
lambda do ... | ruby | def trace(queue_names=self.queues.keys, tracer=nil, &block)
queues_to_trace = self.queues.slice(*queue_names)
queues_to_trace.each do |name, opts|
opts.merge! :durable => false, :auto_delete => true, :amqp_name => queue_name_for_tracing(opts[:amqp_name])
end
tracer ||=
lambda do ... | [
"def",
"trace",
"(",
"queue_names",
"=",
"self",
".",
"queues",
".",
"keys",
",",
"tracer",
"=",
"nil",
",",
"&",
"block",
")",
"queues_to_trace",
"=",
"self",
".",
"queues",
".",
"slice",
"(",
"queue_names",
")",
"queues_to_trace",
".",
"each",
"do",
... | traces queues without consuming them. useful for debugging message flow. | [
"traces",
"queues",
"without",
"consuming",
"them",
".",
"useful",
"for",
"debugging",
"message",
"flow",
"."
] | 42322edc78e6e181b3b9ee284c3b00bddfc89108 | https://github.com/xing/beetle/blob/42322edc78e6e181b3b9ee284c3b00bddfc89108/lib/beetle/client.rb#L255-L272 |
22,443 | xing/beetle | lib/beetle/client.rb | Beetle.Client.load | def load(glob)
b = binding
Dir[glob].each do |f|
eval(File.read(f), b, f)
end
end | ruby | def load(glob)
b = binding
Dir[glob].each do |f|
eval(File.read(f), b, f)
end
end | [
"def",
"load",
"(",
"glob",
")",
"b",
"=",
"binding",
"Dir",
"[",
"glob",
"]",
".",
"each",
"do",
"|",
"f",
"|",
"eval",
"(",
"File",
".",
"read",
"(",
"f",
")",
",",
"b",
",",
"f",
")",
"end",
"end"
] | evaluate the ruby files matching the given +glob+ pattern in the context of the client instance. | [
"evaluate",
"the",
"ruby",
"files",
"matching",
"the",
"given",
"+",
"glob",
"+",
"pattern",
"in",
"the",
"context",
"of",
"the",
"client",
"instance",
"."
] | 42322edc78e6e181b3b9ee284c3b00bddfc89108 | https://github.com/xing/beetle/blob/42322edc78e6e181b3b9ee284c3b00bddfc89108/lib/beetle/client.rb#L275-L280 |
22,444 | xing/beetle | lib/beetle/message.rb | Beetle.Message.decode | def decode #:nodoc:
amqp_headers = header.attributes
@uuid = amqp_headers[:message_id]
@timestamp = amqp_headers[:timestamp]
headers = amqp_headers[:headers].symbolize_keys
@format_version = headers[:format_version].to_i
@flags = headers[:flags].to_i
@expires_at = headers[:expi... | ruby | def decode #:nodoc:
amqp_headers = header.attributes
@uuid = amqp_headers[:message_id]
@timestamp = amqp_headers[:timestamp]
headers = amqp_headers[:headers].symbolize_keys
@format_version = headers[:format_version].to_i
@flags = headers[:flags].to_i
@expires_at = headers[:expi... | [
"def",
"decode",
"#:nodoc:",
"amqp_headers",
"=",
"header",
".",
"attributes",
"@uuid",
"=",
"amqp_headers",
"[",
":message_id",
"]",
"@timestamp",
"=",
"amqp_headers",
"[",
":timestamp",
"]",
"headers",
"=",
"amqp_headers",
"[",
":headers",
"]",
".",
"symbolize... | extracts various values from the AMQP header properties | [
"extracts",
"various",
"values",
"from",
"the",
"AMQP",
"header",
"properties"
] | 42322edc78e6e181b3b9ee284c3b00bddfc89108 | https://github.com/xing/beetle/blob/42322edc78e6e181b3b9ee284c3b00bddfc89108/lib/beetle/message.rb#L84-L95 |
22,445 | xing/beetle | lib/beetle/message.rb | Beetle.Message.key_exists? | def key_exists?
old_message = !@store.msetnx(msg_id, :status =>"incomplete", :expires => @expires_at, :timeout => now + timeout)
if old_message
logger.debug "Beetle: received duplicate message: #{msg_id} on queue: #{@queue}"
end
old_message
end | ruby | def key_exists?
old_message = !@store.msetnx(msg_id, :status =>"incomplete", :expires => @expires_at, :timeout => now + timeout)
if old_message
logger.debug "Beetle: received duplicate message: #{msg_id} on queue: #{@queue}"
end
old_message
end | [
"def",
"key_exists?",
"old_message",
"=",
"!",
"@store",
".",
"msetnx",
"(",
"msg_id",
",",
":status",
"=>",
"\"incomplete\"",
",",
":expires",
"=>",
"@expires_at",
",",
":timeout",
"=>",
"now",
"+",
"timeout",
")",
"if",
"old_message",
"logger",
".",
"debug... | have we already seen this message? if not, set the status to "incomplete" and store
the message exipration timestamp in the deduplication store. | [
"have",
"we",
"already",
"seen",
"this",
"message?",
"if",
"not",
"set",
"the",
"status",
"to",
"incomplete",
"and",
"store",
"the",
"message",
"exipration",
"timestamp",
"in",
"the",
"deduplication",
"store",
"."
] | 42322edc78e6e181b3b9ee284c3b00bddfc89108 | https://github.com/xing/beetle/blob/42322edc78e6e181b3b9ee284c3b00bddfc89108/lib/beetle/message.rb#L237-L243 |
22,446 | xing/beetle | lib/beetle/message.rb | Beetle.Message.process | def process(handler)
logger.debug "Beetle: processing message #{msg_id}"
result = nil
begin
result = process_internal(handler)
handler.process_exception(@exception) if @exception
handler.process_failure(result) if result.failure?
rescue Exception => e
Beetle::rera... | ruby | def process(handler)
logger.debug "Beetle: processing message #{msg_id}"
result = nil
begin
result = process_internal(handler)
handler.process_exception(@exception) if @exception
handler.process_failure(result) if result.failure?
rescue Exception => e
Beetle::rera... | [
"def",
"process",
"(",
"handler",
")",
"logger",
".",
"debug",
"\"Beetle: processing message #{msg_id}\"",
"result",
"=",
"nil",
"begin",
"result",
"=",
"process_internal",
"(",
"handler",
")",
"handler",
".",
"process_exception",
"(",
"@exception",
")",
"if",
"@e... | process this message and do not allow any exception to escape to the caller | [
"process",
"this",
"message",
"and",
"do",
"not",
"allow",
"any",
"exception",
"to",
"escape",
"to",
"the",
"caller"
] | 42322edc78e6e181b3b9ee284c3b00bddfc89108 | https://github.com/xing/beetle/blob/42322edc78e6e181b3b9ee284c3b00bddfc89108/lib/beetle/message.rb#L266-L280 |
22,447 | xing/beetle | lib/beetle/message.rb | Beetle.Message.ack! | def ack!
#:doc:
logger.debug "Beetle: ack! for message #{msg_id}"
header.ack
return if simple? # simple messages don't use the deduplication store
if !redundant? || @store.incr(msg_id, :ack_count) == 2
@store.del_keys(msg_id)
end
end | ruby | def ack!
#:doc:
logger.debug "Beetle: ack! for message #{msg_id}"
header.ack
return if simple? # simple messages don't use the deduplication store
if !redundant? || @store.incr(msg_id, :ack_count) == 2
@store.del_keys(msg_id)
end
end | [
"def",
"ack!",
"#:doc:",
"logger",
".",
"debug",
"\"Beetle: ack! for message #{msg_id}\"",
"header",
".",
"ack",
"return",
"if",
"simple?",
"# simple messages don't use the deduplication store",
"if",
"!",
"redundant?",
"||",
"@store",
".",
"incr",
"(",
"msg_id",
",",
... | ack the message for rabbit. deletes all keys associated with this message in the
deduplication store if we are sure this is the last message with the given msg_id. | [
"ack",
"the",
"message",
"for",
"rabbit",
".",
"deletes",
"all",
"keys",
"associated",
"with",
"this",
"message",
"in",
"the",
"deduplication",
"store",
"if",
"we",
"are",
"sure",
"this",
"is",
"the",
"last",
"message",
"with",
"the",
"given",
"msg_id",
".... | 42322edc78e6e181b3b9ee284c3b00bddfc89108 | https://github.com/xing/beetle/blob/42322edc78e6e181b3b9ee284c3b00bddfc89108/lib/beetle/message.rb#L379-L387 |
22,448 | xing/beetle | lib/beetle/publisher.rb | Beetle.Publisher.bunny_exceptions | def bunny_exceptions
[
Bunny::ConnectionError, Bunny::ForcedChannelCloseError, Bunny::ForcedConnectionCloseError,
Bunny::MessageError, Bunny::ProtocolError, Bunny::ServerDownError, Bunny::UnsubscribeError,
Bunny::AcknowledgementError, Qrack::BufferOverflowError, Qrack::InvalidTypeError,
... | ruby | def bunny_exceptions
[
Bunny::ConnectionError, Bunny::ForcedChannelCloseError, Bunny::ForcedConnectionCloseError,
Bunny::MessageError, Bunny::ProtocolError, Bunny::ServerDownError, Bunny::UnsubscribeError,
Bunny::AcknowledgementError, Qrack::BufferOverflowError, Qrack::InvalidTypeError,
... | [
"def",
"bunny_exceptions",
"[",
"Bunny",
"::",
"ConnectionError",
",",
"Bunny",
"::",
"ForcedChannelCloseError",
",",
"Bunny",
"::",
"ForcedConnectionCloseError",
",",
"Bunny",
"::",
"MessageError",
",",
"Bunny",
"::",
"ProtocolError",
",",
"Bunny",
"::",
"ServerDow... | list of exceptions potentially raised by bunny
these need to be lazy, because qrack exceptions are only defined after a connection has been established | [
"list",
"of",
"exceptions",
"potentially",
"raised",
"by",
"bunny",
"these",
"need",
"to",
"be",
"lazy",
"because",
"qrack",
"exceptions",
"are",
"only",
"defined",
"after",
"a",
"connection",
"has",
"been",
"established"
] | 42322edc78e6e181b3b9ee284c3b00bddfc89108 | https://github.com/xing/beetle/blob/42322edc78e6e181b3b9ee284c3b00bddfc89108/lib/beetle/publisher.rb#L17-L24 |
22,449 | xing/beetle | lib/beetle/publisher.rb | Beetle.Publisher.recycle_dead_servers | def recycle_dead_servers
recycle = []
@dead_servers.each do |s, dead_since|
recycle << s if dead_since < 10.seconds.ago
end
if recycle.empty? && @servers.empty?
recycle << @dead_servers.keys.sort_by{|k| @dead_servers[k]}.first
end
@servers.concat recycle
recycle... | ruby | def recycle_dead_servers
recycle = []
@dead_servers.each do |s, dead_since|
recycle << s if dead_since < 10.seconds.ago
end
if recycle.empty? && @servers.empty?
recycle << @dead_servers.keys.sort_by{|k| @dead_servers[k]}.first
end
@servers.concat recycle
recycle... | [
"def",
"recycle_dead_servers",
"recycle",
"=",
"[",
"]",
"@dead_servers",
".",
"each",
"do",
"|",
"s",
",",
"dead_since",
"|",
"recycle",
"<<",
"s",
"if",
"dead_since",
"<",
"10",
".",
"seconds",
".",
"ago",
"end",
"if",
"recycle",
".",
"empty?",
"&&",
... | retry dead servers after ignoring them for 10.seconds
if all servers are dead, retry the one which has been dead for the longest time | [
"retry",
"dead",
"servers",
"after",
"ignoring",
"them",
"for",
"10",
".",
"seconds",
"if",
"all",
"servers",
"are",
"dead",
"retry",
"the",
"one",
"which",
"has",
"been",
"dead",
"for",
"the",
"longest",
"time"
] | 42322edc78e6e181b3b9ee284c3b00bddfc89108 | https://github.com/xing/beetle/blob/42322edc78e6e181b3b9ee284c3b00bddfc89108/lib/beetle/publisher.rb#L187-L197 |
22,450 | xing/beetle | lib/beetle/deduplication_store.rb | Beetle.DeduplicationStore.with_failover | def with_failover #:nodoc:
end_time = Time.now.to_i + @config.redis_failover_timeout.to_i
begin
yield
rescue Exception => e
Beetle::reraise_expectation_errors!
logger.error "Beetle: redis connection error #{e} #{@config.redis_server} (#{e.backtrace[0]})"
if Time.now.to_... | ruby | def with_failover #:nodoc:
end_time = Time.now.to_i + @config.redis_failover_timeout.to_i
begin
yield
rescue Exception => e
Beetle::reraise_expectation_errors!
logger.error "Beetle: redis connection error #{e} #{@config.redis_server} (#{e.backtrace[0]})"
if Time.now.to_... | [
"def",
"with_failover",
"#:nodoc:",
"end_time",
"=",
"Time",
".",
"now",
".",
"to_i",
"+",
"@config",
".",
"redis_failover_timeout",
".",
"to_i",
"begin",
"yield",
"rescue",
"Exception",
"=>",
"e",
"Beetle",
"::",
"reraise_expectation_errors!",
"logger",
".",
"e... | performs redis operations by yielding a passed in block, waiting for a new master to
show up on the network if the operation throws an exception. if a new master doesn't
appear after the configured timeout interval, we raise an exception. | [
"performs",
"redis",
"operations",
"by",
"yielding",
"a",
"passed",
"in",
"block",
"waiting",
"for",
"a",
"new",
"master",
"to",
"show",
"up",
"on",
"the",
"network",
"if",
"the",
"operation",
"throws",
"an",
"exception",
".",
"if",
"a",
"new",
"master",
... | 42322edc78e6e181b3b9ee284c3b00bddfc89108 | https://github.com/xing/beetle/blob/42322edc78e6e181b3b9ee284c3b00bddfc89108/lib/beetle/deduplication_store.rb#L112-L127 |
22,451 | xing/beetle | lib/beetle/deduplication_store.rb | Beetle.DeduplicationStore.extract_redis_master | def extract_redis_master(text)
system_name = @config.system_name
redis_master = ""
text.each_line do |line|
parts = line.split('/', 2)
case parts.size
when 1
redis_master = parts[0]
when 2
name, master = parts
redis_master = master if name ... | ruby | def extract_redis_master(text)
system_name = @config.system_name
redis_master = ""
text.each_line do |line|
parts = line.split('/', 2)
case parts.size
when 1
redis_master = parts[0]
when 2
name, master = parts
redis_master = master if name ... | [
"def",
"extract_redis_master",
"(",
"text",
")",
"system_name",
"=",
"@config",
".",
"system_name",
"redis_master",
"=",
"\"\"",
"text",
".",
"each_line",
"do",
"|",
"line",
"|",
"parts",
"=",
"line",
".",
"split",
"(",
"'/'",
",",
"2",
")",
"case",
"par... | extract redis master from file content and return the server for our system | [
"extract",
"redis",
"master",
"from",
"file",
"content",
"and",
"return",
"the",
"server",
"for",
"our",
"system"
] | 42322edc78e6e181b3b9ee284c3b00bddfc89108 | https://github.com/xing/beetle/blob/42322edc78e6e181b3b9ee284c3b00bddfc89108/lib/beetle/deduplication_store.rb#L153-L167 |
22,452 | xing/beetle | lib/beetle/subscriber.rb | Beetle.Subscriber.close_all_connections | def close_all_connections
if @connections.empty?
EM.stop_event_loop
else
server, connection = @connections.shift
logger.debug "Beetle: closing connection to #{server}"
connection.close { close_all_connections }
end
end | ruby | def close_all_connections
if @connections.empty?
EM.stop_event_loop
else
server, connection = @connections.shift
logger.debug "Beetle: closing connection to #{server}"
connection.close { close_all_connections }
end
end | [
"def",
"close_all_connections",
"if",
"@connections",
".",
"empty?",
"EM",
".",
"stop_event_loop",
"else",
"server",
",",
"connection",
"=",
"@connections",
".",
"shift",
"logger",
".",
"debug",
"\"Beetle: closing connection to #{server}\"",
"connection",
".",
"close",
... | close all connections. this assumes the reactor is running | [
"close",
"all",
"connections",
".",
"this",
"assumes",
"the",
"reactor",
"is",
"running"
] | 42322edc78e6e181b3b9ee284c3b00bddfc89108 | https://github.com/xing/beetle/blob/42322edc78e6e181b3b9ee284c3b00bddfc89108/lib/beetle/subscriber.rb#L84-L92 |
22,453 | theforeman/foreman-digitalocean | app/models/foreman_digitalocean/digitalocean.rb | ForemanDigitalocean.Digitalocean.setup_key_pair | def setup_key_pair
public_key, private_key = generate_key
key_name = "foreman-#{id}#{Foreman.uuid}"
client.create_ssh_key key_name, public_key
KeyPair.create! :name => key_name, :compute_resource_id => id, :secret => private_key
rescue StandardError => e
logger.warn 'failed to generate... | ruby | def setup_key_pair
public_key, private_key = generate_key
key_name = "foreman-#{id}#{Foreman.uuid}"
client.create_ssh_key key_name, public_key
KeyPair.create! :name => key_name, :compute_resource_id => id, :secret => private_key
rescue StandardError => e
logger.warn 'failed to generate... | [
"def",
"setup_key_pair",
"public_key",
",",
"private_key",
"=",
"generate_key",
"key_name",
"=",
"\"foreman-#{id}#{Foreman.uuid}\"",
"client",
".",
"create_ssh_key",
"key_name",
",",
"public_key",
"KeyPair",
".",
"create!",
":name",
"=>",
"key_name",
",",
":compute_reso... | Creates a new key pair for each new DigitalOcean compute resource
After creating the key, it uploads it to DigitalOcean | [
"Creates",
"a",
"new",
"key",
"pair",
"for",
"each",
"new",
"DigitalOcean",
"compute",
"resource",
"After",
"creating",
"the",
"key",
"it",
"uploads",
"it",
"to",
"DigitalOcean"
] | 81a20226af7052a61edb14f1289271ab7b6a2ff7 | https://github.com/theforeman/foreman-digitalocean/blob/81a20226af7052a61edb14f1289271ab7b6a2ff7/app/models/foreman_digitalocean/digitalocean.rb#L119-L130 |
22,454 | keenlabs/keen-gem | lib/keen/saved_queries.rb | Keen.SavedQueries.clear_nil_attributes | def clear_nil_attributes(hash)
hash.reject! do |key, value|
if value.nil?
return true
elsif value.is_a? Hash
value.reject! { |inner_key, inner_value| inner_value.nil? }
end
false
end
hash
end | ruby | def clear_nil_attributes(hash)
hash.reject! do |key, value|
if value.nil?
return true
elsif value.is_a? Hash
value.reject! { |inner_key, inner_value| inner_value.nil? }
end
false
end
hash
end | [
"def",
"clear_nil_attributes",
"(",
"hash",
")",
"hash",
".",
"reject!",
"do",
"|",
"key",
",",
"value",
"|",
"if",
"value",
".",
"nil?",
"return",
"true",
"elsif",
"value",
".",
"is_a?",
"Hash",
"value",
".",
"reject!",
"{",
"|",
"inner_key",
",",
"in... | Remove any attributes with nil values in a saved query hash. The API will
already assume missing attributes are nil | [
"Remove",
"any",
"attributes",
"with",
"nil",
"values",
"in",
"a",
"saved",
"query",
"hash",
".",
"The",
"API",
"will",
"already",
"assume",
"missing",
"attributes",
"are",
"nil"
] | 5309fc62e1211685bf70fb676bce24350fbe7668 | https://github.com/keenlabs/keen-gem/blob/5309fc62e1211685bf70fb676bce24350fbe7668/lib/keen/saved_queries.rb#L101-L113 |
22,455 | chicks/sugarcrm | lib/sugarcrm/connection_pool.rb | SugarCRM.ConnectionPool.with_connection | def with_connection
connection_id = current_connection_id
fresh_connection = true unless @reserved_connections[connection_id]
yield connection
ensure
release_connection(connection_id) if fresh_connection
end | ruby | def with_connection
connection_id = current_connection_id
fresh_connection = true unless @reserved_connections[connection_id]
yield connection
ensure
release_connection(connection_id) if fresh_connection
end | [
"def",
"with_connection",
"connection_id",
"=",
"current_connection_id",
"fresh_connection",
"=",
"true",
"unless",
"@reserved_connections",
"[",
"connection_id",
"]",
"yield",
"connection",
"ensure",
"release_connection",
"(",
"connection_id",
")",
"if",
"fresh_connection"... | If a connection already exists yield it to the block. If no connection
exists checkout a connection, yield it to the block, and checkin the
connection when finished. | [
"If",
"a",
"connection",
"already",
"exists",
"yield",
"it",
"to",
"the",
"block",
".",
"If",
"no",
"connection",
"exists",
"checkout",
"a",
"connection",
"yield",
"it",
"to",
"the",
"block",
"and",
"checkin",
"the",
"connection",
"when",
"finished",
"."
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/connection_pool.rb#L27-L33 |
22,456 | chicks/sugarcrm | lib/sugarcrm/connection_pool.rb | SugarCRM.ConnectionPool.clear_stale_cached_connections! | def clear_stale_cached_connections!
keys = @reserved_connections.keys - Thread.list.find_all { |t|
t.alive?
}.map { |thread| thread.object_id }
keys.each do |key|
checkin @reserved_connections[key]
@reserved_connections.delete(key)
end
end | ruby | def clear_stale_cached_connections!
keys = @reserved_connections.keys - Thread.list.find_all { |t|
t.alive?
}.map { |thread| thread.object_id }
keys.each do |key|
checkin @reserved_connections[key]
@reserved_connections.delete(key)
end
end | [
"def",
"clear_stale_cached_connections!",
"keys",
"=",
"@reserved_connections",
".",
"keys",
"-",
"Thread",
".",
"list",
".",
"find_all",
"{",
"|",
"t",
"|",
"t",
".",
"alive?",
"}",
".",
"map",
"{",
"|",
"thread",
"|",
"thread",
".",
"object_id",
"}",
"... | Return any checked-out connections back to the pool by threads that
are no longer alive. | [
"Return",
"any",
"checked",
"-",
"out",
"connections",
"back",
"to",
"the",
"pool",
"by",
"threads",
"that",
"are",
"no",
"longer",
"alive",
"."
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/connection_pool.rb#L103-L111 |
22,457 | chicks/sugarcrm | lib/sugarcrm/attributes/attribute_methods.rb | SugarCRM.AttributeMethods.merge_attributes | def merge_attributes(attrs={})
# copy attributes from the parent module fields array
@attributes = self.class.attributes_from_module
# populate the attributes with values from the attrs provided to init.
@attributes.keys.each do |name|
write_attribute name, attrs[name] if attrs[name]
end
#... | ruby | def merge_attributes(attrs={})
# copy attributes from the parent module fields array
@attributes = self.class.attributes_from_module
# populate the attributes with values from the attrs provided to init.
@attributes.keys.each do |name|
write_attribute name, attrs[name] if attrs[name]
end
#... | [
"def",
"merge_attributes",
"(",
"attrs",
"=",
"{",
"}",
")",
"# copy attributes from the parent module fields array",
"@attributes",
"=",
"self",
".",
"class",
".",
"attributes_from_module",
"# populate the attributes with values from the attrs provided to init.",
"@attributes",
... | Merges attributes provided as an argument to initialize
with attributes from the module.fields array. Skips any
fields that aren't in the module.fields array
BUG: SugarCRM likes to return fields you don't ask for and
aren't fields on a module (i.e. modified_user_name). This
royally screws up our typecasting cod... | [
"Merges",
"attributes",
"provided",
"as",
"an",
"argument",
"to",
"initialize",
"with",
"attributes",
"from",
"the",
"module",
".",
"fields",
"array",
".",
"Skips",
"any",
"fields",
"that",
"aren",
"t",
"in",
"the",
"module",
".",
"fields",
"array"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/attributes/attribute_methods.rb#L100-L109 |
22,458 | chicks/sugarcrm | lib/sugarcrm/attributes/attribute_methods.rb | SugarCRM.AttributeMethods.save_modified_attributes! | def save_modified_attributes!(opts={})
options = { :validate => true }.merge(opts)
if options[:validate]
# Complain if we aren't valid
raise InvalidRecord, @errors.full_messages.join(", ") unless valid?
end
# Send the save request
response = self.class.session.connection.set_entry(self.c... | ruby | def save_modified_attributes!(opts={})
options = { :validate => true }.merge(opts)
if options[:validate]
# Complain if we aren't valid
raise InvalidRecord, @errors.full_messages.join(", ") unless valid?
end
# Send the save request
response = self.class.session.connection.set_entry(self.c... | [
"def",
"save_modified_attributes!",
"(",
"opts",
"=",
"{",
"}",
")",
"options",
"=",
"{",
":validate",
"=>",
"true",
"}",
".",
"merge",
"(",
"opts",
")",
"if",
"options",
"[",
":validate",
"]",
"# Complain if we aren't valid",
"raise",
"InvalidRecord",
",",
... | Wrapper for invoking save on modified_attributes
sets the id if it's a new record | [
"Wrapper",
"for",
"invoking",
"save",
"on",
"modified_attributes",
"sets",
"the",
"id",
"if",
"it",
"s",
"a",
"new",
"record"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/attributes/attribute_methods.rb#L169-L187 |
22,459 | chicks/sugarcrm | lib/sugarcrm/associations/associations.rb | SugarCRM.Associations.find! | def find!(target)
@associations.each do |a|
return a if a.include? target
end
raise InvalidAssociation, "Could not lookup association for: #{target}"
end | ruby | def find!(target)
@associations.each do |a|
return a if a.include? target
end
raise InvalidAssociation, "Could not lookup association for: #{target}"
end | [
"def",
"find!",
"(",
"target",
")",
"@associations",
".",
"each",
"do",
"|",
"a",
"|",
"return",
"a",
"if",
"a",
".",
"include?",
"target",
"end",
"raise",
"InvalidAssociation",
",",
"\"Could not lookup association for: #{target}\"",
"end"
] | Looks up an association by object, link_field, or method.
Raises an exception if not found | [
"Looks",
"up",
"an",
"association",
"by",
"object",
"link_field",
"or",
"method",
".",
"Raises",
"an",
"exception",
"if",
"not",
"found"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/associations/associations.rb#L31-L36 |
22,460 | chicks/sugarcrm | lib/sugarcrm/associations/association_methods.rb | SugarCRM.AssociationMethods.query_association | def query_association(assoc, reload=false)
association = assoc.to_sym
return @association_cache[association] if association_cached?(association) && !reload
# TODO: Some relationships aren't fetchable via get_relationship (i.e users.contacts)
# even though get_module_fields lists them on the related_fiel... | ruby | def query_association(assoc, reload=false)
association = assoc.to_sym
return @association_cache[association] if association_cached?(association) && !reload
# TODO: Some relationships aren't fetchable via get_relationship (i.e users.contacts)
# even though get_module_fields lists them on the related_fiel... | [
"def",
"query_association",
"(",
"assoc",
",",
"reload",
"=",
"false",
")",
"association",
"=",
"assoc",
".",
"to_sym",
"return",
"@association_cache",
"[",
"association",
"]",
"if",
"association_cached?",
"(",
"association",
")",
"&&",
"!",
"reload",
"# TODO: S... | Returns the records from the associated module or returns the cached copy if we've already
loaded it. Force a reload of the records with reload=true
{"email_addresses"=>
{"name"=>"email_addresses",
"module"=>"EmailAddress",
"bean_name"=>"EmailAddress",
"relationship"=>"users_email_addresses",
... | [
"Returns",
"the",
"records",
"from",
"the",
"associated",
"module",
"or",
"returns",
"the",
"cached",
"copy",
"if",
"we",
"ve",
"already",
"loaded",
"it",
".",
"Force",
"a",
"reload",
"of",
"the",
"records",
"with",
"reload",
"=",
"true"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/associations/association_methods.rb#L78-L89 |
22,461 | chicks/sugarcrm | lib/sugarcrm/associations/association_cache.rb | SugarCRM.AssociationCache.update_association_cache_for | def update_association_cache_for(association, target, action=:add)
return unless association_cached? association
case action
when :add
return if @association_cache[association].collection.include? target
@association_cache[association].push(target) # don't use `<<` because overriden method in As... | ruby | def update_association_cache_for(association, target, action=:add)
return unless association_cached? association
case action
when :add
return if @association_cache[association].collection.include? target
@association_cache[association].push(target) # don't use `<<` because overriden method in As... | [
"def",
"update_association_cache_for",
"(",
"association",
",",
"target",
",",
"action",
"=",
":add",
")",
"return",
"unless",
"association_cached?",
"association",
"case",
"action",
"when",
":add",
"return",
"if",
"@association_cache",
"[",
"association",
"]",
".",... | Updates an association cache entry if it's been initialized | [
"Updates",
"an",
"association",
"cache",
"entry",
"if",
"it",
"s",
"been",
"initialized"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/associations/association_cache.rb#L11-L20 |
22,462 | chicks/sugarcrm | lib/sugarcrm/associations/association_collection.rb | SugarCRM.AssociationCollection.changed? | def changed?
return false unless loaded?
return true if added.length > 0
return true if removed.length > 0
false
end | ruby | def changed?
return false unless loaded?
return true if added.length > 0
return true if removed.length > 0
false
end | [
"def",
"changed?",
"return",
"false",
"unless",
"loaded?",
"return",
"true",
"if",
"added",
".",
"length",
">",
"0",
"return",
"true",
"if",
"removed",
".",
"length",
">",
"0",
"false",
"end"
] | creates a new instance of an AssociationCollection
Owner is the parent object, and association is the target | [
"creates",
"a",
"new",
"instance",
"of",
"an",
"AssociationCollection",
"Owner",
"is",
"the",
"parent",
"object",
"and",
"association",
"is",
"the",
"target"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/associations/association_collection.rb#L18-L23 |
22,463 | chicks/sugarcrm | lib/sugarcrm/associations/association_collection.rb | SugarCRM.AssociationCollection.delete | def delete(record)
load
raise InvalidRecord, "#{record.class} does not have a valid :id!" if record.id.empty?
@collection.delete record
end | ruby | def delete(record)
load
raise InvalidRecord, "#{record.class} does not have a valid :id!" if record.id.empty?
@collection.delete record
end | [
"def",
"delete",
"(",
"record",
")",
"load",
"raise",
"InvalidRecord",
",",
"\"#{record.class} does not have a valid :id!\"",
"if",
"record",
".",
"id",
".",
"empty?",
"@collection",
".",
"delete",
"record",
"end"
] | Removes a record from the collection, uses the id of the record as a test for inclusion. | [
"Removes",
"a",
"record",
"from",
"the",
"collection",
"uses",
"the",
"id",
"of",
"the",
"record",
"as",
"a",
"test",
"for",
"inclusion",
"."
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/associations/association_collection.rb#L50-L54 |
22,464 | chicks/sugarcrm | lib/sugarcrm/associations/association_collection.rb | SugarCRM.AssociationCollection.<< | def <<(record)
load
record.save! if record.new?
result = true
result = false if include?(record)
@owner.update_association_cache_for(@association, record, :add)
record.update_association_cache_for(record.associations.find!(@owner).link_field, @owner, :add)
result && self
en... | ruby | def <<(record)
load
record.save! if record.new?
result = true
result = false if include?(record)
@owner.update_association_cache_for(@association, record, :add)
record.update_association_cache_for(record.associations.find!(@owner).link_field, @owner, :add)
result && self
en... | [
"def",
"<<",
"(",
"record",
")",
"load",
"record",
".",
"save!",
"if",
"record",
".",
"new?",
"result",
"=",
"true",
"result",
"=",
"false",
"if",
"include?",
"(",
"record",
")",
"@owner",
".",
"update_association_cache_for",
"(",
"@association",
",",
"rec... | Add +records+ to this association, saving any unsaved records before adding them.
Returns +self+ so method calls may be chained.
Be sure to call save on the association to commit any association changes | [
"Add",
"+",
"records",
"+",
"to",
"this",
"association",
"saving",
"any",
"unsaved",
"records",
"before",
"adding",
"them",
".",
"Returns",
"+",
"self",
"+",
"so",
"method",
"calls",
"may",
"be",
"chained",
".",
"Be",
"sure",
"to",
"call",
"save",
"on",
... | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/associations/association_collection.rb#L66-L74 |
22,465 | chicks/sugarcrm | lib/sugarcrm/associations/association_collection.rb | SugarCRM.AssociationCollection.method_missing | def method_missing(method_name, *args, &block)
load
@collection.send(method_name.to_sym, *args, &block)
end | ruby | def method_missing(method_name, *args, &block)
load
@collection.send(method_name.to_sym, *args, &block)
end | [
"def",
"method_missing",
"(",
"method_name",
",",
"*",
"args",
",",
"&",
"block",
")",
"load",
"@collection",
".",
"send",
"(",
"method_name",
".",
"to_sym",
",",
"args",
",",
"block",
")",
"end"
] | delegate undefined methods to the @collection array
E.g. contact.cases should behave like an array and allow `length`, `size`, `each`, etc. | [
"delegate",
"undefined",
"methods",
"to",
"the"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/associations/association_collection.rb#L79-L82 |
22,466 | chicks/sugarcrm | lib/sugarcrm/associations/association_collection.rb | SugarCRM.AssociationCollection.save! | def save!
load
added.each do |record|
associate!(record)
end
removed.each do |record|
disassociate!(record)
end
reload
true
end | ruby | def save!
load
added.each do |record|
associate!(record)
end
removed.each do |record|
disassociate!(record)
end
reload
true
end | [
"def",
"save!",
"load",
"added",
".",
"each",
"do",
"|",
"record",
"|",
"associate!",
"(",
"record",
")",
"end",
"removed",
".",
"each",
"do",
"|",
"record",
"|",
"disassociate!",
"(",
"record",
")",
"end",
"reload",
"true",
"end"
] | Pushes collection changes to SugarCRM, and updates the state of the collection | [
"Pushes",
"collection",
"changes",
"to",
"SugarCRM",
"and",
"updates",
"the",
"state",
"of",
"the",
"collection"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/associations/association_collection.rb#L100-L110 |
22,467 | chicks/sugarcrm | lib/sugarcrm/associations/association_collection.rb | SugarCRM.AssociationCollection.load_associated_records | def load_associated_records
array = @owner.class.session.connection.get_relationships(@owner.class._module.name, @owner.id, @association.to_s)
@loaded = true
# we use original to track the state of the collection at start
@collection = Array.wrap(array).dup
@original = Array.wrap(array).... | ruby | def load_associated_records
array = @owner.class.session.connection.get_relationships(@owner.class._module.name, @owner.id, @association.to_s)
@loaded = true
# we use original to track the state of the collection at start
@collection = Array.wrap(array).dup
@original = Array.wrap(array).... | [
"def",
"load_associated_records",
"array",
"=",
"@owner",
".",
"class",
".",
"session",
".",
"connection",
".",
"get_relationships",
"(",
"@owner",
".",
"class",
".",
"_module",
".",
"name",
",",
"@owner",
".",
"id",
",",
"@association",
".",
"to_s",
")",
... | Loads related records for the given association | [
"Loads",
"related",
"records",
"for",
"the",
"given",
"association"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/associations/association_collection.rb#L115-L121 |
22,468 | chicks/sugarcrm | lib/sugarcrm/connection/helper.rb | SugarCRM.Connection.class_for | def class_for(module_name)
begin
class_const = @session.namespace_const.const_get(module_name.classify)
klass = class_const.new
rescue NameError
raise InvalidModule, "Module: #{module_name} is not registered"
end
end | ruby | def class_for(module_name)
begin
class_const = @session.namespace_const.const_get(module_name.classify)
klass = class_const.new
rescue NameError
raise InvalidModule, "Module: #{module_name} is not registered"
end
end | [
"def",
"class_for",
"(",
"module_name",
")",
"begin",
"class_const",
"=",
"@session",
".",
"namespace_const",
".",
"const_get",
"(",
"module_name",
".",
"classify",
")",
"klass",
"=",
"class_const",
".",
"new",
"rescue",
"NameError",
"raise",
"InvalidModule",
",... | Returns an instance of class for the provided module name | [
"Returns",
"an",
"instance",
"of",
"class",
"for",
"the",
"provided",
"module",
"name"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/connection/helper.rb#L32-L39 |
22,469 | chicks/sugarcrm | lib/sugarcrm/connection/connection.rb | SugarCRM.Connection.send! | def send!(method, json, max_retry=3)
if max_retry == 0
raise SugarCRM::RetryLimitExceeded, "SugarCRM::Connection Errors: \n#{@errors.reverse.join "\n\s\s"}"
end
@request = SugarCRM::Request.new(@url, method, json, @options[:debug])
# Send Ze Request
begin
if @request.length > 3900
... | ruby | def send!(method, json, max_retry=3)
if max_retry == 0
raise SugarCRM::RetryLimitExceeded, "SugarCRM::Connection Errors: \n#{@errors.reverse.join "\n\s\s"}"
end
@request = SugarCRM::Request.new(@url, method, json, @options[:debug])
# Send Ze Request
begin
if @request.length > 3900
... | [
"def",
"send!",
"(",
"method",
",",
"json",
",",
"max_retry",
"=",
"3",
")",
"if",
"max_retry",
"==",
"0",
"raise",
"SugarCRM",
"::",
"RetryLimitExceeded",
",",
"\"SugarCRM::Connection Errors: \\n#{@errors.reverse.join \"\\n\\s\\s\"}\"",
"end",
"@request",
"=",
"Sugar... | Send a request to the Sugar Instance | [
"Send",
"a",
"request",
"to",
"the",
"Sugar",
"Instance"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/connection/connection.rb#L76-L107 |
22,470 | chicks/sugarcrm | lib/sugarcrm/session.rb | SugarCRM.Session.reconnect | def reconnect(url=nil, user=nil, pass=nil, opts={})
@connection_pool.disconnect!
connect(url, user, pass, opts)
end | ruby | def reconnect(url=nil, user=nil, pass=nil, opts={})
@connection_pool.disconnect!
connect(url, user, pass, opts)
end | [
"def",
"reconnect",
"(",
"url",
"=",
"nil",
",",
"user",
"=",
"nil",
",",
"pass",
"=",
"nil",
",",
"opts",
"=",
"{",
"}",
")",
"@connection_pool",
".",
"disconnect!",
"connect",
"(",
"url",
",",
"user",
",",
"pass",
",",
"opts",
")",
"end"
] | Re-uses this session and namespace if the user wants to connect with different credentials | [
"Re",
"-",
"uses",
"this",
"session",
"and",
"namespace",
"if",
"the",
"user",
"wants",
"to",
"connect",
"with",
"different",
"credentials"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/session.rb#L76-L79 |
22,471 | chicks/sugarcrm | lib/sugarcrm/session.rb | SugarCRM.Session.load_extensions | def load_extensions
self.class.validate_path @extensions_path
Dir[File.join(@extensions_path, '**', '*.rb').to_s].each { |f| load(f) }
end | ruby | def load_extensions
self.class.validate_path @extensions_path
Dir[File.join(@extensions_path, '**', '*.rb').to_s].each { |f| load(f) }
end | [
"def",
"load_extensions",
"self",
".",
"class",
".",
"validate_path",
"@extensions_path",
"Dir",
"[",
"File",
".",
"join",
"(",
"@extensions_path",
",",
"'**'",
",",
"'*.rb'",
")",
".",
"to_s",
"]",
".",
"each",
"{",
"|",
"f",
"|",
"load",
"(",
"f",
")... | load all the monkey patch extension files in the provided folder | [
"load",
"all",
"the",
"monkey",
"patch",
"extension",
"files",
"in",
"the",
"provided",
"folder"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/session.rb#L204-L207 |
22,472 | chicks/sugarcrm | lib/sugarcrm/associations/association.rb | SugarCRM.Association.include? | def include?(attribute)
return true if attribute.class == @target
return true if attribute == link_field
return true if methods.include? attribute
false
end | ruby | def include?(attribute)
return true if attribute.class == @target
return true if attribute == link_field
return true if methods.include? attribute
false
end | [
"def",
"include?",
"(",
"attribute",
")",
"return",
"true",
"if",
"attribute",
".",
"class",
"==",
"@target",
"return",
"true",
"if",
"attribute",
"==",
"link_field",
"return",
"true",
"if",
"methods",
".",
"include?",
"attribute",
"false",
"end"
] | Creates a new instance of an Association
Returns true if the association includes an attribute that matches
the provided string | [
"Creates",
"a",
"new",
"instance",
"of",
"an",
"Association",
"Returns",
"true",
"if",
"the",
"association",
"includes",
"an",
"attribute",
"that",
"matches",
"the",
"provided",
"string"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/associations/association.rb#L27-L32 |
22,473 | chicks/sugarcrm | lib/sugarcrm/associations/association.rb | SugarCRM.Association.resolve_target | def resolve_target
# Use the link_field name first
klass = @link_field.singularize.camelize
namespace = @owner.class.session.namespace_const
return namespace.const_get(klass) if namespace.const_defined? klass
# Use the link_field attribute "module"
if @attributes["module"].length > 0... | ruby | def resolve_target
# Use the link_field name first
klass = @link_field.singularize.camelize
namespace = @owner.class.session.namespace_const
return namespace.const_get(klass) if namespace.const_defined? klass
# Use the link_field attribute "module"
if @attributes["module"].length > 0... | [
"def",
"resolve_target",
"# Use the link_field name first",
"klass",
"=",
"@link_field",
".",
"singularize",
".",
"camelize",
"namespace",
"=",
"@owner",
".",
"class",
".",
"session",
".",
"namespace_const",
"return",
"namespace",
".",
"const_get",
"(",
"klass",
")"... | Attempts to determine the class of the target in the association | [
"Attempts",
"to",
"determine",
"the",
"class",
"of",
"the",
"target",
"in",
"the",
"association"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/associations/association.rb#L67-L83 |
22,474 | chicks/sugarcrm | lib/sugarcrm/associations/association.rb | SugarCRM.Association.define_methods | def define_methods
methods = []
pretty_name = @relationship[:target][:name]
methods << define_method(@link_field)
methods << define_alias(pretty_name, @link_field) if pretty_name != @link_field
methods
end | ruby | def define_methods
methods = []
pretty_name = @relationship[:target][:name]
methods << define_method(@link_field)
methods << define_alias(pretty_name, @link_field) if pretty_name != @link_field
methods
end | [
"def",
"define_methods",
"methods",
"=",
"[",
"]",
"pretty_name",
"=",
"@relationship",
"[",
":target",
"]",
"[",
":name",
"]",
"methods",
"<<",
"define_method",
"(",
"@link_field",
")",
"methods",
"<<",
"define_alias",
"(",
"pretty_name",
",",
"@link_field",
... | Defines methods for accessing the association target on the owner class.
If the link_field name includes the owner class name, it is stripped before
creating the method. If this occurs, we also create an alias to the stripped
method using the full link_field name. | [
"Defines",
"methods",
"for",
"accessing",
"the",
"association",
"target",
"on",
"the",
"owner",
"class",
".",
"If",
"the",
"link_field",
"name",
"includes",
"the",
"owner",
"class",
"name",
"it",
"is",
"stripped",
"before",
"creating",
"the",
"method",
".",
... | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/associations/association.rb#L89-L95 |
22,475 | chicks/sugarcrm | lib/sugarcrm/associations/association.rb | SugarCRM.Association.define_method | def define_method(link_field)
raise ArgumentError, "argument cannot be nil" if link_field.nil?
if (@owner.respond_to? link_field.to_sym) && @owner.debug
warn "Warning: Overriding method: #{@owner.class}##{link_field}"
end
@owner.class.module_eval %Q?
def #{link_field}
q... | ruby | def define_method(link_field)
raise ArgumentError, "argument cannot be nil" if link_field.nil?
if (@owner.respond_to? link_field.to_sym) && @owner.debug
warn "Warning: Overriding method: #{@owner.class}##{link_field}"
end
@owner.class.module_eval %Q?
def #{link_field}
q... | [
"def",
"define_method",
"(",
"link_field",
")",
"raise",
"ArgumentError",
",",
"\"argument cannot be nil\"",
"if",
"link_field",
".",
"nil?",
"if",
"(",
"@owner",
".",
"respond_to?",
"link_field",
".",
"to_sym",
")",
"&&",
"@owner",
".",
"debug",
"warn",
"\"Warn... | Generates the association proxy method for related module | [
"Generates",
"the",
"association",
"proxy",
"method",
"for",
"related",
"module"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/associations/association.rb#L98-L109 |
22,476 | chicks/sugarcrm | lib/sugarcrm/associations/association.rb | SugarCRM.Association.cardinality_for | def cardinality_for(*args)
args.inject([]) {|results,arg|
result = :many
result = :one if arg.singularize == arg
results << result
}
end | ruby | def cardinality_for(*args)
args.inject([]) {|results,arg|
result = :many
result = :one if arg.singularize == arg
results << result
}
end | [
"def",
"cardinality_for",
"(",
"*",
"args",
")",
"args",
".",
"inject",
"(",
"[",
"]",
")",
"{",
"|",
"results",
",",
"arg",
"|",
"result",
"=",
":many",
"result",
"=",
":one",
"if",
"arg",
".",
"singularize",
"==",
"arg",
"results",
"<<",
"result",
... | Determines if the provided string is plural or singular
Plurality == Cardinality | [
"Determines",
"if",
"the",
"provided",
"string",
"is",
"plural",
"or",
"singular",
"Plurality",
"==",
"Cardinality"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/associations/association.rb#L140-L146 |
22,477 | chicks/sugarcrm | lib/sugarcrm/connection/request.rb | SugarCRM.Request.convert_reserved_characters | def convert_reserved_characters(string)
string.gsub!(/"/, '\"')
string.gsub!(/'/, '\'')
string.gsub!(/&/, '\&')
string.gsub!(/</, '\<')
string.gsub!(/</, '\>')
string
end | ruby | def convert_reserved_characters(string)
string.gsub!(/"/, '\"')
string.gsub!(/'/, '\'')
string.gsub!(/&/, '\&')
string.gsub!(/</, '\<')
string.gsub!(/</, '\>')
string
end | [
"def",
"convert_reserved_characters",
"(",
"string",
")",
"string",
".",
"gsub!",
"(",
"/",
"/",
",",
"'\\\"'",
")",
"string",
".",
"gsub!",
"(",
"/",
"/",
",",
"'\\''",
")",
"string",
".",
"gsub!",
"(",
"/",
"/",
",",
"'\\&'",
")",
"string",
".",
... | A tiny helper for converting reserved characters for html encoding | [
"A",
"tiny",
"helper",
"for",
"converting",
"reserved",
"characters",
"for",
"html",
"encoding"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/connection/request.rb#L49-L56 |
22,478 | chicks/sugarcrm | lib/sugarcrm/module.rb | SugarCRM.Module.fields | def fields
return @fields if fields_registered?
all_fields = @session.connection.get_fields(@name)
@fields = all_fields["module_fields"].with_indifferent_access
@link_fields= all_fields["link_fields"]
handle_empty_arrays
@fields_registered = true
@fields
end | ruby | def fields
return @fields if fields_registered?
all_fields = @session.connection.get_fields(@name)
@fields = all_fields["module_fields"].with_indifferent_access
@link_fields= all_fields["link_fields"]
handle_empty_arrays
@fields_registered = true
@fields
end | [
"def",
"fields",
"return",
"@fields",
"if",
"fields_registered?",
"all_fields",
"=",
"@session",
".",
"connection",
".",
"get_fields",
"(",
"@name",
")",
"@fields",
"=",
"all_fields",
"[",
"\"module_fields\"",
"]",
".",
"with_indifferent_access",
"@link_fields",
"="... | Returns the fields associated with the module | [
"Returns",
"the",
"fields",
"associated",
"with",
"the",
"module"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/module.rb#L38-L46 |
22,479 | chicks/sugarcrm | lib/sugarcrm/module.rb | SugarCRM.Module.required_fields | def required_fields
required_fields = []
ignore_fields = [:id, :date_entered, :date_modified]
self.fields.each_value do |field|
next if ignore_fields.include? field["name"].to_sym
required_fields << field["name"].to_sym if field["required"] == 1
end
required_fields
end | ruby | def required_fields
required_fields = []
ignore_fields = [:id, :date_entered, :date_modified]
self.fields.each_value do |field|
next if ignore_fields.include? field["name"].to_sym
required_fields << field["name"].to_sym if field["required"] == 1
end
required_fields
end | [
"def",
"required_fields",
"required_fields",
"=",
"[",
"]",
"ignore_fields",
"=",
"[",
":id",
",",
":date_entered",
",",
":date_modified",
"]",
"self",
".",
"fields",
".",
"each_value",
"do",
"|",
"field",
"|",
"next",
"if",
"ignore_fields",
".",
"include?",
... | Returns the required fields | [
"Returns",
"the",
"required",
"fields"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/module.rb#L55-L63 |
22,480 | chicks/sugarcrm | lib/sugarcrm/module.rb | SugarCRM.Module.deregister | def deregister
return true unless registered?
klass = self.klass
@session.namespace_const.instance_eval{ remove_const klass }
true
end | ruby | def deregister
return true unless registered?
klass = self.klass
@session.namespace_const.instance_eval{ remove_const klass }
true
end | [
"def",
"deregister",
"return",
"true",
"unless",
"registered?",
"klass",
"=",
"self",
".",
"klass",
"@session",
".",
"namespace_const",
".",
"instance_eval",
"{",
"remove_const",
"klass",
"}",
"true",
"end"
] | Deregisters the module | [
"Deregisters",
"the",
"module"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/module.rb#L99-L104 |
22,481 | chicks/sugarcrm | lib/sugarcrm/attributes/attribute_serializers.rb | SugarCRM.AttributeSerializers.serialize_attribute | def serialize_attribute(name,value)
attr_value = value
attr_type = attr_type_for(name)
case attr_type
when :bool
attr_value = 0
attr_value = 1 if value
when :datetime, :datetimecombo
begin
attr_value = value.strftime("%Y-%m-%d %H:%M:%S")
rescue
attr_value = ... | ruby | def serialize_attribute(name,value)
attr_value = value
attr_type = attr_type_for(name)
case attr_type
when :bool
attr_value = 0
attr_value = 1 if value
when :datetime, :datetimecombo
begin
attr_value = value.strftime("%Y-%m-%d %H:%M:%S")
rescue
attr_value = ... | [
"def",
"serialize_attribute",
"(",
"name",
",",
"value",
")",
"attr_value",
"=",
"value",
"attr_type",
"=",
"attr_type_for",
"(",
"name",
")",
"case",
"attr_type",
"when",
":bool",
"attr_value",
"=",
"0",
"attr_value",
"=",
"1",
"if",
"value",
"when",
":date... | Un-typecasts the attribute - false becomes "0", 5234 becomes "5234", etc. | [
"Un",
"-",
"typecasts",
"the",
"attribute",
"-",
"false",
"becomes",
"0",
"5234",
"becomes",
"5234",
"etc",
"."
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/attributes/attribute_serializers.rb#L37-L54 |
22,482 | chicks/sugarcrm | lib/sugarcrm/base.rb | SugarCRM.Base.save | def save(opts={})
options = { :validate => true }.merge(opts)
return false if !(new_record? || changed?)
if options[:validate]
return false if !valid?
end
begin
save!(options)
rescue
return false
end
true
end | ruby | def save(opts={})
options = { :validate => true }.merge(opts)
return false if !(new_record? || changed?)
if options[:validate]
return false if !valid?
end
begin
save!(options)
rescue
return false
end
true
end | [
"def",
"save",
"(",
"opts",
"=",
"{",
"}",
")",
"options",
"=",
"{",
":validate",
"=>",
"true",
"}",
".",
"merge",
"(",
"opts",
")",
"return",
"false",
"if",
"!",
"(",
"new_record?",
"||",
"changed?",
")",
"if",
"options",
"[",
":validate",
"]",
"r... | Saves the current object, checks that required fields are present.
returns true or false | [
"Saves",
"the",
"current",
"object",
"checks",
"that",
"required",
"fields",
"are",
"present",
".",
"returns",
"true",
"or",
"false"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/base.rb#L190-L202 |
22,483 | chicks/sugarcrm | lib/sugarcrm/attributes/attribute_validations.rb | SugarCRM.AttributeValidations.valid? | def valid?
@errors = (defined?(HashWithIndifferentAccess) ? HashWithIndifferentAccess : ActiveSupport::HashWithIndifferentAccess).new
self.class._module.required_fields.each do |attribute|
valid_attribute?(attribute)
end
# for rails compatibility
def @errors.full_messages
# Aft... | ruby | def valid?
@errors = (defined?(HashWithIndifferentAccess) ? HashWithIndifferentAccess : ActiveSupport::HashWithIndifferentAccess).new
self.class._module.required_fields.each do |attribute|
valid_attribute?(attribute)
end
# for rails compatibility
def @errors.full_messages
# Aft... | [
"def",
"valid?",
"@errors",
"=",
"(",
"defined?",
"(",
"HashWithIndifferentAccess",
")",
"?",
"HashWithIndifferentAccess",
":",
"ActiveSupport",
"::",
"HashWithIndifferentAccess",
")",
".",
"new",
"self",
".",
"class",
".",
"_module",
".",
"required_fields",
".",
... | Checks to see if we have all the neccessary attributes | [
"Checks",
"to",
"see",
"if",
"we",
"have",
"all",
"the",
"neccessary",
"attributes"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/attributes/attribute_validations.rb#L3-L28 |
22,484 | chicks/sugarcrm | lib/sugarcrm/attributes/attribute_validations.rb | SugarCRM.AttributeValidations.validate_class_for | def validate_class_for(attribute, class_array)
return true if class_array.include? @attributes[attribute].class
add_error(attribute, "must be a #{class_array.join(" or ")} object (not #{@attributes[attribute].class})")
false
end | ruby | def validate_class_for(attribute, class_array)
return true if class_array.include? @attributes[attribute].class
add_error(attribute, "must be a #{class_array.join(" or ")} object (not #{@attributes[attribute].class})")
false
end | [
"def",
"validate_class_for",
"(",
"attribute",
",",
"class_array",
")",
"return",
"true",
"if",
"class_array",
".",
"include?",
"@attributes",
"[",
"attribute",
"]",
".",
"class",
"add_error",
"(",
"attribute",
",",
"\"must be a #{class_array.join(\" or \")} object (not... | Compares the class of the attribute with the class or classes provided in the class array
returns true if they match, otherwise adds an entry to the @errors collection, and returns false | [
"Compares",
"the",
"class",
"of",
"the",
"attribute",
"with",
"the",
"class",
"or",
"classes",
"provided",
"in",
"the",
"class",
"array",
"returns",
"true",
"if",
"they",
"match",
"otherwise",
"adds",
"an",
"entry",
"to",
"the"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/attributes/attribute_validations.rb#L50-L54 |
22,485 | chicks/sugarcrm | lib/sugarcrm/attributes/attribute_validations.rb | SugarCRM.AttributeValidations.add_error | def add_error(attribute, message)
@errors[attribute] ||= []
@errors[attribute] = @errors[attribute] << message unless @errors[attribute].include? message
@errors
end | ruby | def add_error(attribute, message)
@errors[attribute] ||= []
@errors[attribute] = @errors[attribute] << message unless @errors[attribute].include? message
@errors
end | [
"def",
"add_error",
"(",
"attribute",
",",
"message",
")",
"@errors",
"[",
"attribute",
"]",
"||=",
"[",
"]",
"@errors",
"[",
"attribute",
"]",
"=",
"@errors",
"[",
"attribute",
"]",
"<<",
"message",
"unless",
"@errors",
"[",
"attribute",
"]",
".",
"incl... | Add an error to the hash | [
"Add",
"an",
"error",
"to",
"the",
"hash"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/attributes/attribute_validations.rb#L57-L61 |
22,486 | chicks/sugarcrm | lib/sugarcrm/connection/response.rb | SugarCRM.Response.to_obj | def to_obj
# If this is not a "entry_list" response, just return
return @response unless @response && @response["entry_list"]
objects = []
@response["entry_list"].each do |object|
attributes = []
_module = resolve_module(object)
attributes = flatten_name_value_list(object)
... | ruby | def to_obj
# If this is not a "entry_list" response, just return
return @response unless @response && @response["entry_list"]
objects = []
@response["entry_list"].each do |object|
attributes = []
_module = resolve_module(object)
attributes = flatten_name_value_list(object)
... | [
"def",
"to_obj",
"# If this is not a \"entry_list\" response, just return",
"return",
"@response",
"unless",
"@response",
"&&",
"@response",
"[",
"\"entry_list\"",
"]",
"objects",
"=",
"[",
"]",
"@response",
"[",
"\"entry_list\"",
"]",
".",
"each",
"do",
"|",
"object"... | Tries to instantiate and return an object with the values
populated from the response | [
"Tries",
"to",
"instantiate",
"and",
"return",
"an",
"object",
"with",
"the",
"values",
"populated",
"from",
"the",
"response"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/connection/response.rb#L37-L62 |
22,487 | chicks/sugarcrm | lib/sugarcrm/attributes/attribute_typecast.rb | SugarCRM.AttributeTypeCast.attr_type_for | def attr_type_for(attribute)
fields = self.class._module.fields
field = fields[attribute]
raise UninitializedModule, "#{self.class.session.namespace_const}Module #{self.class._module.name} was not initialized properly (fields.length == 0)" if fields.length == 0
raise InvalidAttribute, "#{self.class}._m... | ruby | def attr_type_for(attribute)
fields = self.class._module.fields
field = fields[attribute]
raise UninitializedModule, "#{self.class.session.namespace_const}Module #{self.class._module.name} was not initialized properly (fields.length == 0)" if fields.length == 0
raise InvalidAttribute, "#{self.class}._m... | [
"def",
"attr_type_for",
"(",
"attribute",
")",
"fields",
"=",
"self",
".",
"class",
".",
"_module",
".",
"fields",
"field",
"=",
"fields",
"[",
"attribute",
"]",
"raise",
"UninitializedModule",
",",
"\"#{self.class.session.namespace_const}Module #{self.class._module.nam... | Returns the attribute type for a given attribute | [
"Returns",
"the",
"attribute",
"type",
"for",
"a",
"given",
"attribute"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/attributes/attribute_typecast.rb#L6-L13 |
22,488 | chicks/sugarcrm | lib/sugarcrm/attributes/attribute_typecast.rb | SugarCRM.AttributeTypeCast.typecast_attributes | def typecast_attributes
@attributes.each_pair do |name,value|
# skip primary key columns
# ajay Singh --> skip the loop if attribute is null (!name.present?)
next if (name == "id") or (!name.present?)
attr_type = attr_type_for(name)
# empty attributes should stay empty (e.g. an ... | ruby | def typecast_attributes
@attributes.each_pair do |name,value|
# skip primary key columns
# ajay Singh --> skip the loop if attribute is null (!name.present?)
next if (name == "id") or (!name.present?)
attr_type = attr_type_for(name)
# empty attributes should stay empty (e.g. an ... | [
"def",
"typecast_attributes",
"@attributes",
".",
"each_pair",
"do",
"|",
"name",
",",
"value",
"|",
"# skip primary key columns",
"# ajay Singh --> skip the loop if attribute is null (!name.present?)",
"next",
"if",
"(",
"name",
"==",
"\"id\"",
")",
"or",
"(",
"!",
"na... | Attempts to typecast each attribute based on the module field type | [
"Attempts",
"to",
"typecast",
"each",
"attribute",
"based",
"on",
"the",
"module",
"field",
"type"
] | 360060139b13788a7ec462c6ecd08d3dbda9849a | https://github.com/chicks/sugarcrm/blob/360060139b13788a7ec462c6ecd08d3dbda9849a/lib/sugarcrm/attributes/attribute_typecast.rb#L16-L43 |
22,489 | kikonen/capybara-ng | lib/angular/setup.rb | Angular.Setup.make_nodes | def make_nodes(ids, opt)
result = []
ids.each do |id|
id = id.tr('"', '')
selector = "//*[@capybara-ng-match='#{id}']"
nodes = page.driver.find_xpath(selector)
raise NotFound.new("Failed to match found id to node") if nodes.empty?
result.concat(nodes)
end
... | ruby | def make_nodes(ids, opt)
result = []
ids.each do |id|
id = id.tr('"', '')
selector = "//*[@capybara-ng-match='#{id}']"
nodes = page.driver.find_xpath(selector)
raise NotFound.new("Failed to match found id to node") if nodes.empty?
result.concat(nodes)
end
... | [
"def",
"make_nodes",
"(",
"ids",
",",
"opt",
")",
"result",
"=",
"[",
"]",
"ids",
".",
"each",
"do",
"|",
"id",
"|",
"id",
"=",
"id",
".",
"tr",
"(",
"'\"'",
",",
"''",
")",
"selector",
"=",
"\"//*[@capybara-ng-match='#{id}']\"",
"nodes",
"=",
"page"... | Find nodes matching 'capybara-ng-match' attributes using ids
@return nodes matching ids | [
"Find",
"nodes",
"matching",
"capybara",
"-",
"ng",
"-",
"match",
"attributes",
"using",
"ids"
] | a24bc9570629fe2bb441763803dd8aa0d046d46d | https://github.com/kikonen/capybara-ng/blob/a24bc9570629fe2bb441763803dd8aa0d046d46d/lib/angular/setup.rb#L40-L52 |
22,490 | kikonen/capybara-ng | lib/angular/dsl.rb | Angular.DSL.ng_root_selector | def ng_root_selector(root_selector = nil)
opt = ng.page.ng_session_options
if root_selector
opt[:root_selector] = root_selector
end
opt[:root_selector] || ::Angular.root_selector
end | ruby | def ng_root_selector(root_selector = nil)
opt = ng.page.ng_session_options
if root_selector
opt[:root_selector] = root_selector
end
opt[:root_selector] || ::Angular.root_selector
end | [
"def",
"ng_root_selector",
"(",
"root_selector",
"=",
"nil",
")",
"opt",
"=",
"ng",
".",
"page",
".",
"ng_session_options",
"if",
"root_selector",
"opt",
"[",
":root_selector",
"]",
"=",
"root_selector",
"end",
"opt",
"[",
":root_selector",
"]",
"||",
"::",
... | Get or set selector to find ng-app for current capybara test session
TIP: try using '[ng-app]', which will find ng-app as attribute anywhere.
@param root_selector if nil then return current value without change
@return test specific selector to find ng-app,
by default global ::Angular.root_selector is used. | [
"Get",
"or",
"set",
"selector",
"to",
"find",
"ng",
"-",
"app",
"for",
"current",
"capybara",
"test",
"session"
] | a24bc9570629fe2bb441763803dd8aa0d046d46d | https://github.com/kikonen/capybara-ng/blob/a24bc9570629fe2bb441763803dd8aa0d046d46d/lib/angular/dsl.rb#L21-L27 |
22,491 | kikonen/capybara-ng | lib/angular/dsl.rb | Angular.DSL.ng_binding | def ng_binding(binding, opt = {})
opt[:root_selector] ||= ng_root_selector
row = ng.row(opt)
ng_bindings(binding, opt)[row]
end | ruby | def ng_binding(binding, opt = {})
opt[:root_selector] ||= ng_root_selector
row = ng.row(opt)
ng_bindings(binding, opt)[row]
end | [
"def",
"ng_binding",
"(",
"binding",
",",
"opt",
"=",
"{",
"}",
")",
"opt",
"[",
":root_selector",
"]",
"||=",
"ng_root_selector",
"row",
"=",
"ng",
".",
"row",
"(",
"opt",
")",
"ng_bindings",
"(",
"binding",
",",
"opt",
")",
"[",
"row",
"]",
"end"
] | Node for nth binding match
@param opt
- :row
- :exact
- :root_selector
- :wait
@return nth node | [
"Node",
"for",
"nth",
"binding",
"match"
] | a24bc9570629fe2bb441763803dd8aa0d046d46d | https://github.com/kikonen/capybara-ng/blob/a24bc9570629fe2bb441763803dd8aa0d046d46d/lib/angular/dsl.rb#L114-L118 |
22,492 | kikonen/capybara-ng | lib/angular/dsl.rb | Angular.DSL.ng_bindings | def ng_bindings(binding, opt = {})
opt[:root_selector] ||= ng_root_selector
ng.get_nodes_2 :findBindingsIds, [binding, opt[:exact] == true], opt
end | ruby | def ng_bindings(binding, opt = {})
opt[:root_selector] ||= ng_root_selector
ng.get_nodes_2 :findBindingsIds, [binding, opt[:exact] == true], opt
end | [
"def",
"ng_bindings",
"(",
"binding",
",",
"opt",
"=",
"{",
"}",
")",
"opt",
"[",
":root_selector",
"]",
"||=",
"ng_root_selector",
"ng",
".",
"get_nodes_2",
":findBindingsIds",
",",
"[",
"binding",
",",
"opt",
"[",
":exact",
"]",
"==",
"true",
"]",
",",... | All nodes matching binding
@param opt
- :exact
- :root_selector
- :wait
@return [node, ...] | [
"All",
"nodes",
"matching",
"binding"
] | a24bc9570629fe2bb441763803dd8aa0d046d46d | https://github.com/kikonen/capybara-ng/blob/a24bc9570629fe2bb441763803dd8aa0d046d46d/lib/angular/dsl.rb#L129-L132 |
22,493 | kikonen/capybara-ng | lib/angular/dsl.rb | Angular.DSL.ng_model | def ng_model(model, opt = {})
opt[:root_selector] ||= ng_root_selector
row = ng.row(opt)
ng_models(model, opt)[row]
end | ruby | def ng_model(model, opt = {})
opt[:root_selector] ||= ng_root_selector
row = ng.row(opt)
ng_models(model, opt)[row]
end | [
"def",
"ng_model",
"(",
"model",
",",
"opt",
"=",
"{",
"}",
")",
"opt",
"[",
":root_selector",
"]",
"||=",
"ng_root_selector",
"row",
"=",
"ng",
".",
"row",
"(",
"opt",
")",
"ng_models",
"(",
"model",
",",
"opt",
")",
"[",
"row",
"]",
"end"
] | Node for nth model match
@param opt
- :row
- :root_selector
- :wait
@return nth node | [
"Node",
"for",
"nth",
"model",
"match"
] | a24bc9570629fe2bb441763803dd8aa0d046d46d | https://github.com/kikonen/capybara-ng/blob/a24bc9570629fe2bb441763803dd8aa0d046d46d/lib/angular/dsl.rb#L169-L173 |
22,494 | kikonen/capybara-ng | lib/angular/dsl.rb | Angular.DSL.has_ng_options? | def has_ng_options?(options, opt = {})
opt[:root_selector] ||= ng_root_selector
ng_options(options, opt)
true
rescue NotFound
false
end | ruby | def has_ng_options?(options, opt = {})
opt[:root_selector] ||= ng_root_selector
ng_options(options, opt)
true
rescue NotFound
false
end | [
"def",
"has_ng_options?",
"(",
"options",
",",
"opt",
"=",
"{",
"}",
")",
"opt",
"[",
":root_selector",
"]",
"||=",
"ng_root_selector",
"ng_options",
"(",
"options",
",",
"opt",
")",
"true",
"rescue",
"NotFound",
"false",
"end"
] | Does option exist
@param opt
- :root_selector
- :wait
@return true | false | [
"Does",
"option",
"exist"
] | a24bc9570629fe2bb441763803dd8aa0d046d46d | https://github.com/kikonen/capybara-ng/blob/a24bc9570629fe2bb441763803dd8aa0d046d46d/lib/angular/dsl.rb#L196-L202 |
22,495 | kikonen/capybara-ng | lib/angular/dsl.rb | Angular.DSL.ng_option | def ng_option(options, opt = {})
opt[:root_selector] ||= ng_root_selector
row = ng.row(opt)
ng_options(options, opt)[row]
end | ruby | def ng_option(options, opt = {})
opt[:root_selector] ||= ng_root_selector
row = ng.row(opt)
ng_options(options, opt)[row]
end | [
"def",
"ng_option",
"(",
"options",
",",
"opt",
"=",
"{",
"}",
")",
"opt",
"[",
":root_selector",
"]",
"||=",
"ng_root_selector",
"row",
"=",
"ng",
".",
"row",
"(",
"opt",
")",
"ng_options",
"(",
"options",
",",
"opt",
")",
"[",
"row",
"]",
"end"
] | Node for nth option
@param opt
- :row
- :root_selector
- :wait
@return nth node | [
"Node",
"for",
"nth",
"option"
] | a24bc9570629fe2bb441763803dd8aa0d046d46d | https://github.com/kikonen/capybara-ng/blob/a24bc9570629fe2bb441763803dd8aa0d046d46d/lib/angular/dsl.rb#L225-L229 |
22,496 | kikonen/capybara-ng | lib/angular/dsl.rb | Angular.DSL.ng_repeater_row | def ng_repeater_row(repeater, opt = {})
opt[:root_selector] ||= ng_root_selector
row = ng.row(opt)
data = ng.get_nodes_2(:findRepeaterRowsIds, [repeater, row], opt)
data.first
end | ruby | def ng_repeater_row(repeater, opt = {})
opt[:root_selector] ||= ng_root_selector
row = ng.row(opt)
data = ng.get_nodes_2(:findRepeaterRowsIds, [repeater, row], opt)
data.first
end | [
"def",
"ng_repeater_row",
"(",
"repeater",
",",
"opt",
"=",
"{",
"}",
")",
"opt",
"[",
":root_selector",
"]",
"||=",
"ng_root_selector",
"row",
"=",
"ng",
".",
"row",
"(",
"opt",
")",
"data",
"=",
"ng",
".",
"get_nodes_2",
"(",
":findRepeaterRowsIds",
",... | Node for nth repeater row
@param opt
- :row
- :root_selector
- :wait
@return nth node | [
"Node",
"for",
"nth",
"repeater",
"row"
] | a24bc9570629fe2bb441763803dd8aa0d046d46d | https://github.com/kikonen/capybara-ng/blob/a24bc9570629fe2bb441763803dd8aa0d046d46d/lib/angular/dsl.rb#L280-L285 |
22,497 | kikonen/capybara-ng | lib/angular/dsl.rb | Angular.DSL.ng_repeater_column | def ng_repeater_column(repeater, binding, opt = {})
opt[:root_selector] ||= ng_root_selector
row = ng.row(opt)
ng_repeater_columns(repeater, binding, opt)[row]
end | ruby | def ng_repeater_column(repeater, binding, opt = {})
opt[:root_selector] ||= ng_root_selector
row = ng.row(opt)
ng_repeater_columns(repeater, binding, opt)[row]
end | [
"def",
"ng_repeater_column",
"(",
"repeater",
",",
"binding",
",",
"opt",
"=",
"{",
"}",
")",
"opt",
"[",
":root_selector",
"]",
"||=",
"ng_root_selector",
"row",
"=",
"ng",
".",
"row",
"(",
"opt",
")",
"ng_repeater_columns",
"(",
"repeater",
",",
"binding... | Node for column binding value in row
@param opt
- :row
- :root_selector
- :wait
@return nth node | [
"Node",
"for",
"column",
"binding",
"value",
"in",
"row"
] | a24bc9570629fe2bb441763803dd8aa0d046d46d | https://github.com/kikonen/capybara-ng/blob/a24bc9570629fe2bb441763803dd8aa0d046d46d/lib/angular/dsl.rb#L309-L313 |
22,498 | kikonen/capybara-ng | lib/angular/dsl.rb | Angular.DSL.ng_repeater_columns | def ng_repeater_columns(repeater, binding, opt = {})
opt[:root_selector] ||= ng_root_selector
ng.get_nodes_2 :findRepeaterColumnIds, [repeater, binding], opt
end | ruby | def ng_repeater_columns(repeater, binding, opt = {})
opt[:root_selector] ||= ng_root_selector
ng.get_nodes_2 :findRepeaterColumnIds, [repeater, binding], opt
end | [
"def",
"ng_repeater_columns",
"(",
"repeater",
",",
"binding",
",",
"opt",
"=",
"{",
"}",
")",
"opt",
"[",
":root_selector",
"]",
"||=",
"ng_root_selector",
"ng",
".",
"get_nodes_2",
":findRepeaterColumnIds",
",",
"[",
"repeater",
",",
"binding",
"]",
",",
"... | Node for column binding value in all rows
@param opt
- :root_selector
- :wait
@return [node, ...] | [
"Node",
"for",
"column",
"binding",
"value",
"in",
"all",
"rows"
] | a24bc9570629fe2bb441763803dd8aa0d046d46d | https://github.com/kikonen/capybara-ng/blob/a24bc9570629fe2bb441763803dd8aa0d046d46d/lib/angular/dsl.rb#L323-L326 |
22,499 | willglynn/ruby-zbar | lib/zbar/image.rb | ZBar.Image.set_data | def set_data(format, data, width=nil, height=nil)
ZBar.zbar_image_set_format(@img, format)
# Note the @buffer jog: it's to keep Ruby GC from losing the last
# reference to the old @buffer before calling image_set_data.
new_buffer = FFI::MemoryPointer.from_string(data)
ZBar.zbar_imag... | ruby | def set_data(format, data, width=nil, height=nil)
ZBar.zbar_image_set_format(@img, format)
# Note the @buffer jog: it's to keep Ruby GC from losing the last
# reference to the old @buffer before calling image_set_data.
new_buffer = FFI::MemoryPointer.from_string(data)
ZBar.zbar_imag... | [
"def",
"set_data",
"(",
"format",
",",
"data",
",",
"width",
"=",
"nil",
",",
"height",
"=",
"nil",
")",
"ZBar",
".",
"zbar_image_set_format",
"(",
"@img",
",",
"format",
")",
"# Note the @buffer jog: it's to keep Ruby GC from losing the last",
"# reference to the old... | Load arbitrary data from a string into the Image object.
Format must be a ZBar::Format constant. See the ZBar documentation
for what formats are supported, and how the data should be formatted.
Most everyone should use one of the <tt>Image.from_*</tt> methods instead. | [
"Load",
"arbitrary",
"data",
"from",
"a",
"string",
"into",
"the",
"Image",
"object",
"."
] | 014ce55d4f4a41597bf20f5b1c529c53ecfbfd05 | https://github.com/willglynn/ruby-zbar/blob/014ce55d4f4a41597bf20f5b1c529c53ecfbfd05/lib/zbar/image.rb#L75-L87 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.