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",
":",
"nil",
"when",
"value",
".",
"dicom_method?",
"@names_from_methods",
"[",
"value",
".",
"to_sym",
"]",
"else",
"nil",
"end",
"end"
] |
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",
"(",
"@names_from_methods",
"[",
"value",
".",
"to_sym",
"]",
")",
"else",
"nil",
"end",
"end"
] |
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
element = unknown_or_range_element(tag)
end
end
end
element
end
|
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
element = unknown_or_range_element(tag)
end
end
end
element
end
|
[
"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",
"element",
"=",
"unknown_or_range_element",
"(",
"tag",
")",
"end",
"end",
"end",
"element",
"end"
] |
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 of the element
@return [DictionaryElement] a corresponding DictionaryElement
|
[
"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
return transfer_syntaxes, sop_classes
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
return transfer_syntaxes, sop_classes
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",
".",
"value",
"]",
"=",
"uid",
".",
"name",
"elsif",
"uid",
".",
"sop_class?",
"sop_classes",
"[",
"uid",
".",
"value",
"]",
"=",
"uid",
".",
"name",
"end",
"end",
"return",
"transfer_syntaxes",
",",
"sop_classes",
"end"
] |
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
end
@tag_name_pairs_cache[name]=tag
return tag
end
|
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
end
@tag_name_pairs_cache[name]=tag
return tag
end
|
[
"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",
"end",
"@tag_name_pairs_cache",
"[",
"name",
"]",
"=",
"tag",
"return",
"tag",
"end"
] |
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 facing an unknown (but not private) tag:
element ||= DictionaryElement.new(tag, 'Unknown', ['UN'], '1', '')
end
|
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 facing an unknown (but not private) tag:
element ||= DictionaryElement.new(tag, 'Unknown', ['UN'], '1', '')
end
|
[
"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 facing an unknown (but not private) tag:",
"element",
"||=",
"DictionaryElement",
".",
"new",
"(",
"tag",
",",
"'Unknown'",
",",
"[",
"'UN'",
"]",
",",
"'1'",
",",
"''",
")",
"end"
] |
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",
"pool",
"end",
"end"
] |
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 modified. If a pool does not exist for the machine provider, one will
automatically be created.
@param machine [Vagrant::Machine]
@param read_only [Boolean] whether to create a read_only transaction.
@yieldparam pool [AutoNetwork::Pool]
|
[
"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",
"]",
"end",
"end"
] |
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
end
end
|
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
end
end
|
[
"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",
"end",
"end"
] |
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] the IP address assigned to the machine.
@raise [PoolExhaustedError] if no allocatable addresses remain in the
range managed by the pool.
|
[
"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
end
end
addr
end
|
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
end
end
addr
end
|
[
"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",
"end",
"end",
"addr",
"end"
] |
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",
"end",
"@default_pool",
"=",
"pool",
"end"
] |
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 : class_eval(adapter_class)
clazz.class_eval %Q{
class #{class_name_plural}
include Enumerable
def initialize(window, locators)
if locators[:hwnd] || locators[:pid]
raise UnsupportedLocatorException,
":hwnd or :pid in " + locators.inspect + " are not supported for #{adapter_class}::#{class_name_plural}"
end
@window = window
@locators = locators
end
def each
i = -1
while true
args = [@window, @locators.merge(:index => i += 1)].compact
object = #{clazz}::#{class_name}.new(*args)
break unless object.exists?
yield object
end
end
def method_missing(name, *args)
ary = self.to_a
ary.respond_to?(name) ? ary.send(name, *args) : super
end
end
}
class_eval %Q{
def #{element}(locators = {})
#{adapter_class}::#{class_name_plural}.new(@window || self, locators)
end
}
end
end
|
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 : class_eval(adapter_class)
clazz.class_eval %Q{
class #{class_name_plural}
include Enumerable
def initialize(window, locators)
if locators[:hwnd] || locators[:pid]
raise UnsupportedLocatorException,
":hwnd or :pid in " + locators.inspect + " are not supported for #{adapter_class}::#{class_name_plural}"
end
@window = window
@locators = locators
end
def each
i = -1
while true
args = [@window, @locators.merge(:index => i += 1)].compact
object = #{clazz}::#{class_name}.new(*args)
break unless object.exists?
yield object
end
end
def method_missing(name, *args)
ary = self.to_a
ary.respond_to?(name) ? ary.send(name, *args) : super
end
end
}
class_eval %Q{
def #{element}(locators = {})
#{adapter_class}::#{class_name_plural}.new(@window || self, locators)
end
}
end
end
|
[
"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",
":",
"class_eval",
"(",
"adapter_class",
")",
"clazz",
".",
"class_eval",
"%Q{\n class #{class_name_plural}\n include Enumerable\n\n def initialize(window, locators)\n if locators[:hwnd] || locators[:pid]\n raise UnsupportedLocatorException, \n \":hwnd or :pid in \" + locators.inspect + \" are not supported for #{adapter_class}::#{class_name_plural}\"\n end\n\n @window = window\n @locators = locators\n end\n\n def each\n i = -1 \n while true\n args = [@window, @locators.merge(:index => i += 1)].compact\n object = #{clazz}::#{class_name}.new(*args)\n break unless object.exists?\n yield object\n end\n end\n\n def method_missing(name, *args)\n ary = self.to_a\n ary.respond_to?(name) ? ary.send(name, *args) : super\n end\n end\n }",
"class_eval",
"%Q{\n def #{element}(locators = {})\n #{adapter_class}::#{class_name_plural}.new(@window || self, locators)\n end\n }",
"end",
"end"
] |
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",
"]",
"projection_status",
".",
"event",
"=",
"data",
"[",
":event",
"]",
"end",
"end"
] |
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 = val_ref["StringValue"]
val = "Null" if val.nil? || val.empty?
allowed_vals[val] = true
end
end
allowed_vals
end
|
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 = val_ref["StringValue"]
val = "Null" if val.nil? || val.empty?
allowed_vals[val] = true
end
end
allowed_vals
end
|
[
"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",
"=",
"val_ref",
"[",
"\"StringValue\"",
"]",
"val",
"=",
"\"Null\"",
"if",
"val",
".",
"nil?",
"||",
"val",
".",
"empty?",
"allowed_vals",
"[",
"val",
"]",
"=",
"true",
"end",
"end",
"allowed_vals",
"end"
] |
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
end
make_read_url(type, idstring)
end
|
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
end
make_read_url(type, idstring)
end
|
[
"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",
"end",
"make_read_url",
"(",
"type",
",",
"idstring",
")",
"end"
] |
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",
"(",
"sym",
")",
")",
"end",
"ret_val",
"end"
] |
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
end
|
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
end
|
[
"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",
"end"
] |
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_state(delivery_tag, :nacked)
delivery.queue.publish(body, header.to_hash) if requeue
end
nil
end
|
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_state(delivery_tag, :nacked)
delivery.queue.publish(body, header.to_hash) if requeue
end
nil
end
|
[
"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_state",
"(",
"delivery_tag",
",",
":nacked",
")",
"delivery",
".",
"queue",
".",
"publish",
"(",
"body",
",",
"header",
".",
"to_hash",
")",
"if",
"requeue",
"end",
"nil",
"end"
] |
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",
",",
":rejected",
")",
"delivery",
".",
"queue",
".",
"publish",
"(",
"body",
",",
"header",
".",
"to_hash",
")",
"if",
"requeue",
"end",
"nil",
"end"
] |
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(:routing_key, @name), exchange
end
self
end
|
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(:routing_key, @name), exchange
end
self
end
|
[
"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",
"(",
":routing_key",
",",
"@name",
")",
",",
"exchange",
"end",
"self",
"end"
] |
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, opts.fetch(:routing_key, @name), exchange
end
end
|
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, opts.fetch(:routing_key, @name), exchange
end
end
|
[
"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",
",",
"opts",
".",
"fetch",
"(",
":routing_key",
",",
"@name",
")",
",",
"exchange",
"end",
"end"
] |
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 `BunnyMock::use_bunny_queue_pop_api` to true to use Bunny Queue#pop behavior'",
"@messages",
".",
"shift",
"end",
"end"
] |
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
end
self
end
|
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
end
self
end
|
[
"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",
"end",
"self",
"end"
] |
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), exchange, self
end
self
end
|
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), exchange, self
end
self
end
|
[
"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",
")",
",",
"exchange",
",",
"self",
"end",
"self",
"end"
] |
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",
"(",
":routing_key",
",",
"route",
")",
"@routes",
".",
"key?",
"(",
"rk",
")",
"&&",
"@routes",
"[",
"rk",
"]",
".",
"any?",
"{",
"|",
"r",
"|",
"r",
"==",
"exchange_or_queue",
"}",
"end"
] |
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, false otherwise
@api public
|
[
"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",
")",
":",
"(",
"y",
">",
"0",
"?",
"up",
"(",
"y",
")",
":",
"''",
")",
")",
"end"
] |
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",
"+",
"(",
"(",
"i",
"==",
"n",
"-",
"1",
")",
"?",
"''",
":",
"dir",
")",
"end",
".",
"join",
"end"
] |
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",
"[",
"\"move\"",
"]",
"else",
"ret",
"[",
"\"special\"",
"]",
"=",
"special2csa",
"(",
"line",
"[",
"\"move\"",
"]",
")",
"end",
"ret",
"[",
"\"time\"",
"]",
"=",
"line",
"[",
"\"time\"",
"]",
"if",
"line",
"[",
"\"time\"",
"]",
"ret",
"end"
] |
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
end
|
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
end
|
[
"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",
"end"
] |
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\"",
"]",
"=",
"(",
"move",
"[",
"\"move\"",
"]",
"[",
"\"color\"",
"]",
"+",
"1",
")",
"%",
"2",
"end",
"move",
"[",
"\"forks\"",
"]",
".",
"each",
"{",
"|",
"_fork",
"|",
"reverse_color",
"(",
"_fork",
")",
"}",
"if",
"move",
"[",
"\"forks\"",
"]",
"end",
"end"
] |
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)
ret["relative"] = rel unless rel.empty?
end
ret
end
|
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)
ret["relative"] = rel unless rel.empty?
end
ret
end
|
[
"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",
"==",
"\"成\") ",
"i",
" p",
"o",
"if",
"da",
"ret",
"[",
"\"relative\"",
"]",
"=",
"\"H\"",
"else",
"rel",
"=",
"soutai2relative",
"(",
"sou",
")",
"+",
"dousa2relative",
"(",
"dou",
")",
"ret",
"[",
"\"relative\"",
"]",
"=",
"rel",
"unless",
"rel",
".",
"empty?",
"end",
"ret",
"end"
] |
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"] ||= []
move["forks"] << now_fork["moves"]
fork_stack << _fork
fork_stack << now_fork
end
end
|
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"] ||= []
move["forks"] << now_fork["moves"]
fork_stack << _fork
fork_stack << now_fork
end
end
|
[
"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\"",
"]",
"||=",
"[",
"]",
"move",
"[",
"\"forks\"",
"]",
"<<",
"now_fork",
"[",
"\"moves\"",
"]",
"fork_stack",
"<<",
"_fork",
"fork_stack",
"<<",
"now_fork",
"end",
"end"
] |
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",
"]",
"end",
"board",
"<<",
"line",
"end",
"{",
"\"preset\"",
"=>",
"\"OTHER\"",
",",
"\"data\"",
"=>",
"{",
"\"board\"",
"=>",
"board",
"}",
"}",
"end"
] |
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, "GI" => 4, "KI" => 4, "KA" => 2, "HI" => 2 }
lines.each do |line|
line["pieces"].each do |piece|
xy = piece["xy"]
if xy["x"] == 0
if piece["piece"] == "AL"
hands[line["teban"]] = all
return { "preset" => "OTHER", "data" => { "board" => board, "hands" => hands } }
end
obj = hands[line["teban"]]
obj[piece["piece"]] += 1
else
board[xy["x"] - 1][xy["y"] - 1] = { "color" => line["teban"],
"kind" => piece["piece"] }
end
all[piece["piece"]] -= 1 if piece["piece"] != "OU"
end
end
{ "preset" => "OTHER", "data" => { "board" => board, "hands" => hands } }
end
|
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, "GI" => 4, "KI" => 4, "KA" => 2, "HI" => 2 }
lines.each do |line|
line["pieces"].each do |piece|
xy = piece["xy"]
if xy["x"] == 0
if piece["piece"] == "AL"
hands[line["teban"]] = all
return { "preset" => "OTHER", "data" => { "board" => board, "hands" => hands } }
end
obj = hands[line["teban"]]
obj[piece["piece"]] += 1
else
board[xy["x"] - 1][xy["y"] - 1] = { "color" => line["teban"],
"kind" => piece["piece"] }
end
all[piece["piece"]] -= 1 if piece["piece"] != "OU"
end
end
{ "preset" => "OTHER", "data" => { "board" => board, "hands" => hands } }
end
|
[
"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",
",",
"\"GI\"",
"=>",
"4",
",",
"\"KI\"",
"=>",
"4",
",",
"\"KA\"",
"=>",
"2",
",",
"\"HI\"",
"=>",
"2",
"}",
"lines",
".",
"each",
"do",
"|",
"line",
"|",
"line",
"[",
"\"pieces\"",
"]",
".",
"each",
"do",
"|",
"piece",
"|",
"xy",
"=",
"piece",
"[",
"\"xy\"",
"]",
"if",
"xy",
"[",
"\"x\"",
"]",
"==",
"0",
"if",
"piece",
"[",
"\"piece\"",
"]",
"==",
"\"AL\"",
"hands",
"[",
"line",
"[",
"\"teban\"",
"]",
"]",
"=",
"all",
"return",
"{",
"\"preset\"",
"=>",
"\"OTHER\"",
",",
"\"data\"",
"=>",
"{",
"\"board\"",
"=>",
"board",
",",
"\"hands\"",
"=>",
"hands",
"}",
"}",
"end",
"obj",
"=",
"hands",
"[",
"line",
"[",
"\"teban\"",
"]",
"]",
"obj",
"[",
"piece",
"[",
"\"piece\"",
"]",
"]",
"+=",
"1",
"else",
"board",
"[",
"xy",
"[",
"\"x\"",
"]",
"-",
"1",
"]",
"[",
"xy",
"[",
"\"y\"",
"]",
"-",
"1",
"]",
"=",
"{",
"\"color\"",
"=>",
"line",
"[",
"\"teban\"",
"]",
",",
"\"kind\"",
"=>",
"piece",
"[",
"\"piece\"",
"]",
"}",
"end",
"all",
"[",
"piece",
"[",
"\"piece\"",
"]",
"]",
"-=",
"1",
"if",
"piece",
"[",
"\"piece\"",
"]",
"!=",
"\"OU\"",
"end",
"end",
"{",
"\"preset\"",
"=>",
"\"OTHER\"",
",",
"\"data\"",
"=>",
"{",
"\"board\"",
"=>",
"board",
",",
"\"hands\"",
"=>",
"hands",
"}",
"}",
"end"
] |
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",
".",
"take_while",
"{",
"|",
"o",
"|",
"o",
".",
"asset_bought",
"==",
"source_asset",
"}",
"source_offers",
".",
"map",
"(",
":amount_bought",
")",
".",
"sum",
"end"
] |
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)
end
end
|
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)
end
end
|
[
"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",
")",
"end",
"end"
] |
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
@return [Boolean] true if all signatures are from the provided key_pairs and validly sign the tx's hash
|
[
"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",
".",
"instance_eval",
"(",
"block",
")",
"end",
"self",
"end"
] |
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.
Example: (block with config argument)
client = Beetle.client.new.configure :exchange => :foobar do |config|
config.queue :q1, :key => "foo"
config.queue :q2, :key => "bar"
config.message :foo
config.message :bar
config.handler :q1 { puts "got foo"}
config.handler :q2 { puts "got bar"}
end
Example: (block without config argument)
client = Beetle.client.new.configure :exchange => :foobar do
queue :q1, :key => "foo"
queue :q2, :key => "bar"
message :foo
message :bar
handler :q1 { puts "got foo"}
handler :q2 { puts "got bar"}
end
|
[
"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",
"."
] |
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 |msg|
puts "-----===== new message =====-----"
puts "SERVER: #{msg.server}"
puts "HEADER: #{msg.header.attributes[:headers].inspect}"
puts "EXCHANGE: #{msg.header.method.exchange}"
puts "KEY: #{msg.header.method.routing_key}"
puts "MSGID: #{msg.msg_id}"
puts "DATA: #{msg.data}"
end
register_handler(queue_names){|msg| tracer.call msg }
listen_queues(queue_names, &block)
end
|
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 |msg|
puts "-----===== new message =====-----"
puts "SERVER: #{msg.server}"
puts "HEADER: #{msg.header.attributes[:headers].inspect}"
puts "EXCHANGE: #{msg.header.method.exchange}"
puts "KEY: #{msg.header.method.routing_key}"
puts "MSGID: #{msg.msg_id}"
puts "DATA: #{msg.data}"
end
register_handler(queue_names){|msg| tracer.call msg }
listen_queues(queue_names, &block)
end
|
[
"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",
"|",
"msg",
"|",
"puts",
"\"-----===== new message =====-----\"",
"puts",
"\"SERVER: #{msg.server}\"",
"puts",
"\"HEADER: #{msg.header.attributes[:headers].inspect}\"",
"puts",
"\"EXCHANGE: #{msg.header.method.exchange}\"",
"puts",
"\"KEY: #{msg.header.method.routing_key}\"",
"puts",
"\"MSGID: #{msg.msg_id}\"",
"puts",
"\"DATA: #{msg.data}\"",
"end",
"register_handler",
"(",
"queue_names",
")",
"{",
"|",
"msg",
"|",
"tracer",
".",
"call",
"msg",
"}",
"listen_queues",
"(",
"queue_names",
",",
"block",
")",
"end"
] |
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[:expires_at].to_i
rescue Exception => @exception
Beetle::reraise_expectation_errors!
logger.error "Could not decode message. #{self.inspect}"
end
|
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[:expires_at].to_i
rescue Exception => @exception
Beetle::reraise_expectation_errors!
logger.error "Could not decode message. #{self.inspect}"
end
|
[
"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",
"[",
":expires_at",
"]",
".",
"to_i",
"rescue",
"Exception",
"=>",
"@exception",
"Beetle",
"::",
"reraise_expectation_errors!",
"logger",
".",
"error",
"\"Could not decode message. #{self.inspect}\"",
"end"
] |
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 = [email protected](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 = [email protected](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",
"\"Beetle: received duplicate message: #{msg_id} on queue: #{@queue}\"",
"end",
"old_message",
"end"
] |
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::reraise_expectation_errors!
logger.warn "Beetle: exception '#{e}' during processing of message #{msg_id}"
logger.warn "Beetle: backtrace: #{e.backtrace.join("\n")}"
result = RC::InternalError
end
result
end
|
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::reraise_expectation_errors!
logger.warn "Beetle: exception '#{e}' during processing of message #{msg_id}"
logger.warn "Beetle: backtrace: #{e.backtrace.join("\n")}"
result = RC::InternalError
end
result
end
|
[
"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",
"::",
"reraise_expectation_errors!",
"logger",
".",
"warn",
"\"Beetle: exception '#{e}' during processing of message #{msg_id}\"",
"logger",
".",
"warn",
"\"Beetle: backtrace: #{e.backtrace.join(\"\\n\")}\"",
"result",
"=",
"RC",
"::",
"InternalError",
"end",
"result",
"end"
] |
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_count",
")",
"==",
"2",
"@store",
".",
"del_keys",
"(",
"msg_id",
")",
"end",
"end"
] |
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,
Errno::EHOSTUNREACH, Errno::ECONNRESET, Timeout::Error
]
end
|
ruby
|
def bunny_exceptions
[
Bunny::ConnectionError, Bunny::ForcedChannelCloseError, Bunny::ForcedConnectionCloseError,
Bunny::MessageError, Bunny::ProtocolError, Bunny::ServerDownError, Bunny::UnsubscribeError,
Bunny::AcknowledgementError, Qrack::BufferOverflowError, Qrack::InvalidTypeError,
Errno::EHOSTUNREACH, Errno::ECONNRESET, Timeout::Error
]
end
|
[
"def",
"bunny_exceptions",
"[",
"Bunny",
"::",
"ConnectionError",
",",
"Bunny",
"::",
"ForcedChannelCloseError",
",",
"Bunny",
"::",
"ForcedConnectionCloseError",
",",
"Bunny",
"::",
"MessageError",
",",
"Bunny",
"::",
"ProtocolError",
",",
"Bunny",
"::",
"ServerDownError",
",",
"Bunny",
"::",
"UnsubscribeError",
",",
"Bunny",
"::",
"AcknowledgementError",
",",
"Qrack",
"::",
"BufferOverflowError",
",",
"Qrack",
"::",
"InvalidTypeError",
",",
"Errno",
"::",
"EHOSTUNREACH",
",",
"Errno",
"::",
"ECONNRESET",
",",
"Timeout",
"::",
"Error",
"]",
"end"
] |
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.each {|s| @dead_servers.delete(s)}
end
|
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.each {|s| @dead_servers.delete(s)}
end
|
[
"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",
".",
"each",
"{",
"|",
"s",
"|",
"@dead_servers",
".",
"delete",
"(",
"s",
")",
"}",
"end"
] |
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_i < end_time
sleep 1
logger.info "Beetle: retrying redis operation"
retry
else
raise NoRedisMaster.new(e.to_s)
end
end
end
|
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_i < end_time
sleep 1
logger.info "Beetle: retrying redis operation"
retry
else
raise NoRedisMaster.new(e.to_s)
end
end
end
|
[
"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_i",
"<",
"end_time",
"sleep",
"1",
"logger",
".",
"info",
"\"Beetle: retrying redis operation\"",
"retry",
"else",
"raise",
"NoRedisMaster",
".",
"new",
"(",
"e",
".",
"to_s",
")",
"end",
"end",
"end"
] |
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",
"doesn",
"t",
"appear",
"after",
"the",
"configured",
"timeout",
"interval",
"we",
"raise",
"an",
"exception",
"."
] |
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 == system_name
end
end
redis_master
end
|
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 == system_name
end
end
redis_master
end
|
[
"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",
"==",
"system_name",
"end",
"end",
"redis_master",
"end"
] |
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",
"}",
"end",
"end"
] |
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 key pair'
logger.error e.message
logger.error e.backtrace.join("\n")
destroy_key_pair
raise
end
|
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 key pair'
logger.error e.message
logger.error e.backtrace.join("\n")
destroy_key_pair
raise
end
|
[
"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 key pair'",
"logger",
".",
"error",
"e",
".",
"message",
"logger",
".",
"error",
"e",
".",
"backtrace",
".",
"join",
"(",
"\"\\n\"",
")",
"destroy_key_pair",
"raise",
"end"
] |
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",
",",
"inner_value",
"|",
"inner_value",
".",
"nil?",
"}",
"end",
"false",
"end",
"hash",
"end"
] |
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",
"end"
] |
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",
"}",
"keys",
".",
"each",
"do",
"|",
"key",
"|",
"checkin",
"@reserved_connections",
"[",
"key",
"]",
"@reserved_connections",
".",
"delete",
"(",
"key",
")",
"end",
"end"
] |
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
# If this is an existing record, blank out the modified_attributes hash
@modified_attributes = {} unless new?
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
# If this is an existing record, blank out the modified_attributes hash
@modified_attributes = {} unless new?
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",
".",
"keys",
".",
"each",
"do",
"|",
"name",
"|",
"write_attribute",
"name",
",",
"attrs",
"[",
"name",
"]",
"if",
"attrs",
"[",
"name",
"]",
"end",
"# If this is an existing record, blank out the modified_attributes hash",
"@modified_attributes",
"=",
"{",
"}",
"unless",
"new?",
"end"
] |
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 code, so we handle it here.
|
[
"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.class._module.name, serialize_modified_attributes)
# Complain if we don't get a parseable response back
raise RecordsaveFailed, "Failed to save record: #{self}. Response was not a Hash" unless response.is_a? Hash
# Complain if we don't get a valid id back
raise RecordSaveFailed, "Failed to save record: #{self}. Response did not contain a valid 'id'." if response["id"].nil?
# Save the id to the record, if it's a new record
@attributes[:id] = response["id"] if new?
raise InvalidRecord, "Failed to update id for: #{self}." if id.nil?
# Clear the modified attributes Hash
@modified_attributes = {}
true
end
|
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.class._module.name, serialize_modified_attributes)
# Complain if we don't get a parseable response back
raise RecordsaveFailed, "Failed to save record: #{self}. Response was not a Hash" unless response.is_a? Hash
# Complain if we don't get a valid id back
raise RecordSaveFailed, "Failed to save record: #{self}. Response did not contain a valid 'id'." if response["id"].nil?
# Save the id to the record, if it's a new record
@attributes[:id] = response["id"] if new?
raise InvalidRecord, "Failed to update id for: #{self}." if id.nil?
# Clear the modified attributes Hash
@modified_attributes = {}
true
end
|
[
"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",
".",
"class",
".",
"_module",
".",
"name",
",",
"serialize_modified_attributes",
")",
"# Complain if we don't get a parseable response back",
"raise",
"RecordsaveFailed",
",",
"\"Failed to save record: #{self}. Response was not a Hash\"",
"unless",
"response",
".",
"is_a?",
"Hash",
"# Complain if we don't get a valid id back",
"raise",
"RecordSaveFailed",
",",
"\"Failed to save record: #{self}. Response did not contain a valid 'id'.\"",
"if",
"response",
"[",
"\"id\"",
"]",
".",
"nil?",
"# Save the id to the record, if it's a new record",
"@attributes",
"[",
":id",
"]",
"=",
"response",
"[",
"\"id\"",
"]",
"if",
"new?",
"raise",
"InvalidRecord",
",",
"\"Failed to update id for: #{self}.\"",
"if",
"id",
".",
"nil?",
"# Clear the modified attributes Hash",
"@modified_attributes",
"=",
"{",
"}",
"true",
"end"
] |
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_fields array. This is most
# commonly seen with one-to-many relationships without a join table. We need to cook
# up some elegant way to handle this.
collection = AssociationCollection.new(self,association,true)
# add it to the cache
@association_cache[association] = collection
collection
end
|
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_fields array. This is most
# commonly seen with one-to-many relationships without a join table. We need to cook
# up some elegant way to handle this.
collection = AssociationCollection.new(self,association,true)
# add it to the cache
@association_cache[association] = collection
collection
end
|
[
"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_fields array. This is most ",
"# commonly seen with one-to-many relationships without a join table. We need to cook ",
"# up some elegant way to handle this.",
"collection",
"=",
"AssociationCollection",
".",
"new",
"(",
"self",
",",
"association",
",",
"true",
")",
"# add it to the cache",
"@association_cache",
"[",
"association",
"]",
"=",
"collection",
"collection",
"end"
] |
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",
"type"=>"link"},
|
[
"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 AssociationCollection gets called instead
when :delete
@association_cache[association].delete target
end
end
|
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 AssociationCollection gets called instead
when :delete
@association_cache[association].delete target
end
end
|
[
"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 AssociationCollection gets called instead",
"when",
":delete",
"@association_cache",
"[",
"association",
"]",
".",
"delete",
"target",
"end",
"end"
] |
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
end
|
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
end
|
[
"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",
"end"
] |
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",
"the",
"association",
"to",
"commit",
"any",
"association",
"changes"
] |
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).freeze
end
|
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).freeze
end
|
[
"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",
")",
".",
"freeze",
"end"
] |
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",
",",
"\"Module: #{module_name} is not registered\"",
"end",
"end"
] |
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
@response = @connection.post(@url.path, @request)
else
@response = @connection.get(@url.path.dup + "?" + @request.to_s)
end
return handle_response
# Timeouts are usually a server side issue
rescue Timeout::Error => error
@errors << error
send!(method, json, max_retry.pred)
# Lower level errors requiring a reconnect
rescue Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPIPE, EOFError => error
@errors << error
reconnect!
send!(method, json, max_retry.pred)
# Handle invalid sessions
rescue SugarCRM::InvalidSession => error
@errors << error
old_session = @sugar_session_id.dup
login!
# Update the session id in the request that we want to retry.
json.gsub!(old_session, @sugar_session_id)
send!(method, json, max_retry.pred)
end
end
|
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
@response = @connection.post(@url.path, @request)
else
@response = @connection.get(@url.path.dup + "?" + @request.to_s)
end
return handle_response
# Timeouts are usually a server side issue
rescue Timeout::Error => error
@errors << error
send!(method, json, max_retry.pred)
# Lower level errors requiring a reconnect
rescue Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPIPE, EOFError => error
@errors << error
reconnect!
send!(method, json, max_retry.pred)
# Handle invalid sessions
rescue SugarCRM::InvalidSession => error
@errors << error
old_session = @sugar_session_id.dup
login!
# Update the session id in the request that we want to retry.
json.gsub!(old_session, @sugar_session_id)
send!(method, json, max_retry.pred)
end
end
|
[
"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",
"@response",
"=",
"@connection",
".",
"post",
"(",
"@url",
".",
"path",
",",
"@request",
")",
"else",
"@response",
"=",
"@connection",
".",
"get",
"(",
"@url",
".",
"path",
".",
"dup",
"+",
"\"?\"",
"+",
"@request",
".",
"to_s",
")",
"end",
"return",
"handle_response",
"# Timeouts are usually a server side issue",
"rescue",
"Timeout",
"::",
"Error",
"=>",
"error",
"@errors",
"<<",
"error",
"send!",
"(",
"method",
",",
"json",
",",
"max_retry",
".",
"pred",
")",
"# Lower level errors requiring a reconnect",
"rescue",
"Errno",
"::",
"ECONNRESET",
",",
"Errno",
"::",
"ECONNABORTED",
",",
"Errno",
"::",
"EPIPE",
",",
"EOFError",
"=>",
"error",
"@errors",
"<<",
"error",
"reconnect!",
"send!",
"(",
"method",
",",
"json",
",",
"max_retry",
".",
"pred",
")",
"# Handle invalid sessions",
"rescue",
"SugarCRM",
"::",
"InvalidSession",
"=>",
"error",
"@errors",
"<<",
"error",
"old_session",
"=",
"@sugar_session_id",
".",
"dup",
"login!",
"# Update the session id in the request that we want to retry.",
"json",
".",
"gsub!",
"(",
"old_session",
",",
"@sugar_session_id",
")",
"send!",
"(",
"method",
",",
"json",
",",
"max_retry",
".",
"pred",
")",
"end",
"end"
] |
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",
")",
"}",
"end"
] |
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
module_name = SugarCRM::Module.find(@attributes["module"], @owner.class.session)
return namespace.const_get(module_name.klass) if module_name && namespace.const_defined?(module_name.klass)
end
# Use the "relationship" target
if @attributes["relationship"].length > 0
klass = @relationship[:target][:name].singularize.camelize
return namespace.const_get(klass) if namespace.const_defined? klass
end
false
end
|
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
module_name = SugarCRM::Module.find(@attributes["module"], @owner.class.session)
return namespace.const_get(module_name.klass) if module_name && namespace.const_defined?(module_name.klass)
end
# Use the "relationship" target
if @attributes["relationship"].length > 0
klass = @relationship[:target][:name].singularize.camelize
return namespace.const_get(klass) if namespace.const_defined? klass
end
false
end
|
[
"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",
"module_name",
"=",
"SugarCRM",
"::",
"Module",
".",
"find",
"(",
"@attributes",
"[",
"\"module\"",
"]",
",",
"@owner",
".",
"class",
".",
"session",
")",
"return",
"namespace",
".",
"const_get",
"(",
"module_name",
".",
"klass",
")",
"if",
"module_name",
"&&",
"namespace",
".",
"const_defined?",
"(",
"module_name",
".",
"klass",
")",
"end",
"# Use the \"relationship\" target",
"if",
"@attributes",
"[",
"\"relationship\"",
"]",
".",
"length",
">",
"0",
"klass",
"=",
"@relationship",
"[",
":target",
"]",
"[",
":name",
"]",
".",
"singularize",
".",
"camelize",
"return",
"namespace",
".",
"const_get",
"(",
"klass",
")",
"if",
"namespace",
".",
"const_defined?",
"klass",
"end",
"false",
"end"
] |
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",
")",
"if",
"pretty_name",
"!=",
"@link_field",
"methods",
"end"
] |
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",
".",
"If",
"this",
"occurs",
"we",
"also",
"create",
"an",
"alias",
"to",
"the",
"stripped",
"method",
"using",
"the",
"full",
"link_field",
"name",
"."
] |
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}
query_association :#{link_field}
end
?
link_field
end
|
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}
query_association :#{link_field}
end
?
link_field
end
|
[
"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?\n def #{link_field}\n query_association :#{link_field}\n end\n ?",
"link_field",
"end"
] |
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",
"}",
"end"
] |
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",
".",
"gsub!",
"(",
"/",
"/",
",",
"'\\<'",
")",
"string",
".",
"gsub!",
"(",
"/",
"/",
",",
"'\\>'",
")",
"string",
"end"
] |
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",
"=",
"all_fields",
"[",
"\"link_fields\"",
"]",
"handle_empty_arrays",
"@fields_registered",
"=",
"true",
"@fields",
"end"
] |
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?",
"field",
"[",
"\"name\"",
"]",
".",
"to_sym",
"required_fields",
"<<",
"field",
"[",
"\"name\"",
"]",
".",
"to_sym",
"if",
"field",
"[",
"\"required\"",
"]",
"==",
"1",
"end",
"required_fields",
"end"
] |
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 = value
end
when :int
attr_value = value.to_s
end
{:name => name, :value => attr_value}
end
|
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 = value
end
when :int
attr_value = value.to_s
end
{:name => name, :value => attr_value}
end
|
[
"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",
"=",
"value",
"end",
"when",
":int",
"attr_value",
"=",
"value",
".",
"to_s",
"end",
"{",
":name",
"=>",
"name",
",",
":value",
"=>",
"attr_value",
"}",
"end"
] |
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",
"]",
"return",
"false",
"if",
"!",
"valid?",
"end",
"begin",
"save!",
"(",
"options",
")",
"rescue",
"return",
"false",
"end",
"true",
"end"
] |
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
# After removing attributes without errors, flatten the error hash, repeating the name of the attribute before each message:
# e.g. {'name' => ['cannot be blank', 'is too long'], 'website' => ['is not valid']}
# will become 'name cannot be blank, name is too long, website is not valid
self.inject([]){|memo, obj| memo.concat(obj[1].inject([]){|m, o| m << "#{obj[0].to_s.humanize} #{o}" })}
end
# Rails needs each attribute to be present in the error hash (if the attribute has no error, it has [] as a value)
# Redefine the [] method for the errors hash to return [] instead of nil is the hash doesn't contain the key
class << @errors
alias :old_key_lookup :[]
def [](key)
old_key_lookup(key) || Array.new
end
end
@errors.size == 0
end
|
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
# After removing attributes without errors, flatten the error hash, repeating the name of the attribute before each message:
# e.g. {'name' => ['cannot be blank', 'is too long'], 'website' => ['is not valid']}
# will become 'name cannot be blank, name is too long, website is not valid
self.inject([]){|memo, obj| memo.concat(obj[1].inject([]){|m, o| m << "#{obj[0].to_s.humanize} #{o}" })}
end
# Rails needs each attribute to be present in the error hash (if the attribute has no error, it has [] as a value)
# Redefine the [] method for the errors hash to return [] instead of nil is the hash doesn't contain the key
class << @errors
alias :old_key_lookup :[]
def [](key)
old_key_lookup(key) || Array.new
end
end
@errors.size == 0
end
|
[
"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",
"# After removing attributes without errors, flatten the error hash, repeating the name of the attribute before each message:",
"# e.g. {'name' => ['cannot be blank', 'is too long'], 'website' => ['is not valid']}",
"# will become 'name cannot be blank, name is too long, website is not valid",
"self",
".",
"inject",
"(",
"[",
"]",
")",
"{",
"|",
"memo",
",",
"obj",
"|",
"memo",
".",
"concat",
"(",
"obj",
"[",
"1",
"]",
".",
"inject",
"(",
"[",
"]",
")",
"{",
"|",
"m",
",",
"o",
"|",
"m",
"<<",
"\"#{obj[0].to_s.humanize} #{o}\"",
"}",
")",
"}",
"end",
"# Rails needs each attribute to be present in the error hash (if the attribute has no error, it has [] as a value)",
"# Redefine the [] method for the errors hash to return [] instead of nil is the hash doesn't contain the key",
"class",
"<<",
"@errors",
"alias",
":old_key_lookup",
":[]",
"def",
"[]",
"(",
"key",
")",
"old_key_lookup",
"(",
"key",
")",
"||",
"Array",
".",
"new",
"end",
"end",
"@errors",
".",
"size",
"==",
"0",
"end"
] |
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 #{@attributes[attribute].class})\"",
")",
"false",
"end"
] |
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",
"]",
".",
"include?",
"message",
"@errors",
"end"
] |
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)
namespace = @session.namespace_const
if namespace.const_get(_module)
if attributes.length == 0
raise AttributeParsingError, "response contains objects without attributes!"
end
objects << namespace.const_get(_module).new(attributes)
else
raise InvalidModule, "#{_module} does not exist, or is not accessible"
end
end
# If we only have one result, just return the object
if objects.length == 1 && !@options[:always_return_array]
return objects[0]
else
return objects
end
end
|
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)
namespace = @session.namespace_const
if namespace.const_get(_module)
if attributes.length == 0
raise AttributeParsingError, "response contains objects without attributes!"
end
objects << namespace.const_get(_module).new(attributes)
else
raise InvalidModule, "#{_module} does not exist, or is not accessible"
end
end
# If we only have one result, just return the object
if objects.length == 1 && !@options[:always_return_array]
return objects[0]
else
return objects
end
end
|
[
"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",
")",
"namespace",
"=",
"@session",
".",
"namespace_const",
"if",
"namespace",
".",
"const_get",
"(",
"_module",
")",
"if",
"attributes",
".",
"length",
"==",
"0",
"raise",
"AttributeParsingError",
",",
"\"response contains objects without attributes!\"",
"end",
"objects",
"<<",
"namespace",
".",
"const_get",
"(",
"_module",
")",
".",
"new",
"(",
"attributes",
")",
"else",
"raise",
"InvalidModule",
",",
"\"#{_module} does not exist, or is not accessible\"",
"end",
"end",
"# If we only have one result, just return the object",
"if",
"objects",
".",
"length",
"==",
"1",
"&&",
"!",
"@options",
"[",
":always_return_array",
"]",
"return",
"objects",
"[",
"0",
"]",
"else",
"return",
"objects",
"end",
"end"
] |
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}._module.fields does not contain an entry for #{attribute} (of type: #{attribute.class})\nValid fields: #{self.class._module.fields.keys.sort.join(", ")}" if field.nil?
raise InvalidAttributeType, "#{self.class}._module.fields[#{attribute}] does not have a key for \'type\'" if field["type"].nil?
field["type"].to_sym
end
|
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}._module.fields does not contain an entry for #{attribute} (of type: #{attribute.class})\nValid fields: #{self.class._module.fields.keys.sort.join(", ")}" if field.nil?
raise InvalidAttributeType, "#{self.class}._module.fields[#{attribute}] does not have a key for \'type\'" if field["type"].nil?
field["type"].to_sym
end
|
[
"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}._module.fields does not contain an entry for #{attribute} (of type: #{attribute.class})\\nValid fields: #{self.class._module.fields.keys.sort.join(\", \")}\"",
"if",
"field",
".",
"nil?",
"raise",
"InvalidAttributeType",
",",
"\"#{self.class}._module.fields[#{attribute}] does not have a key for \\'type\\'\"",
"if",
"field",
"[",
"\"type\"",
"]",
".",
"nil?",
"field",
"[",
"\"type\"",
"]",
".",
"to_sym",
"end"
] |
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 empty int field shouldn't be typecast as 0)
if [:datetime, :datetimecombo, :int].include? attr_type && (value.nil? || value == '')
@attributes[name] = nil
next
end
case attr_type
when :bool
@attributes[name] = (value == "1")
when :datetime, :datetimecombo
begin
@attributes[name] = DateTime.parse(value)
rescue
@attributes[name] = value
end
when :int
@attributes[name] = value.to_i
end
end
@attributes
end
|
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 empty int field shouldn't be typecast as 0)
if [:datetime, :datetimecombo, :int].include? attr_type && (value.nil? || value == '')
@attributes[name] = nil
next
end
case attr_type
when :bool
@attributes[name] = (value == "1")
when :datetime, :datetimecombo
begin
@attributes[name] = DateTime.parse(value)
rescue
@attributes[name] = value
end
when :int
@attributes[name] = value.to_i
end
end
@attributes
end
|
[
"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 empty int field shouldn't be typecast as 0)",
"if",
"[",
":datetime",
",",
":datetimecombo",
",",
":int",
"]",
".",
"include?",
"attr_type",
"&&",
"(",
"value",
".",
"nil?",
"||",
"value",
"==",
"''",
")",
"@attributes",
"[",
"name",
"]",
"=",
"nil",
"next",
"end",
"case",
"attr_type",
"when",
":bool",
"@attributes",
"[",
"name",
"]",
"=",
"(",
"value",
"==",
"\"1\"",
")",
"when",
":datetime",
",",
":datetimecombo",
"begin",
"@attributes",
"[",
"name",
"]",
"=",
"DateTime",
".",
"parse",
"(",
"value",
")",
"rescue",
"@attributes",
"[",
"name",
"]",
"=",
"value",
"end",
"when",
":int",
"@attributes",
"[",
"name",
"]",
"=",
"value",
".",
"to_i",
"end",
"end",
"@attributes",
"end"
] |
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
page.evaluate_script("clearCapybaraNgMatches('#{opt[:root_selector]}')");
result
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
page.evaluate_script("clearCapybaraNgMatches('#{opt[:root_selector]}')");
result
end
|
[
"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",
"page",
".",
"evaluate_script",
"(",
"\"clearCapybaraNgMatches('#{opt[:root_selector]}')\"",
")",
";",
"result",
"end"
] |
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",
"]",
"||",
"::",
"Angular",
".",
"root_selector",
"end"
] |
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",
"]",
",",
"opt",
"end"
] |
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",
",",
"[",
"repeater",
",",
"row",
"]",
",",
"opt",
")",
"data",
".",
"first",
"end"
] |
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",
",",
"opt",
")",
"[",
"row",
"]",
"end"
] |
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",
"]",
",",
"opt",
"end"
] |
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_image_set_data(@img, new_buffer, data.size, nil)
@buffer = new_buffer
if width && height
ZBar.zbar_image_set_size(@img, width.to_i, height.to_i)
end
end
|
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_image_set_data(@img, new_buffer, data.size, nil)
@buffer = new_buffer
if width && height
ZBar.zbar_image_set_size(@img, width.to_i, height.to_i)
end
end
|
[
"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_image_set_data",
"(",
"@img",
",",
"new_buffer",
",",
"data",
".",
"size",
",",
"nil",
")",
"@buffer",
"=",
"new_buffer",
"if",
"width",
"&&",
"height",
"ZBar",
".",
"zbar_image_set_size",
"(",
"@img",
",",
"width",
".",
"to_i",
",",
"height",
".",
"to_i",
")",
"end",
"end"
] |
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.