id int32 0 24.9k | repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 |
|---|---|---|---|---|---|---|---|---|---|---|---|
7,500 | Potpourri-Projects/fbuser | app/controllers/fbuser/api/v1/users_controller.rb | Fbuser.Api::V1::UsersController.index_authorize | def index_authorize
if !::Authorization::Fbuser::V1::User.index?(current_user)
render :json => {errors: "User is not authorized for this action"}, status: :forbidden
end
end | ruby | def index_authorize
if !::Authorization::Fbuser::V1::User.index?(current_user)
render :json => {errors: "User is not authorized for this action"}, status: :forbidden
end
end | [
"def",
"index_authorize",
"if",
"!",
"::",
"Authorization",
"::",
"Fbuser",
"::",
"V1",
"::",
"User",
".",
"index?",
"(",
"current_user",
")",
"render",
":json",
"=>",
"{",
"errors",
":",
"\"User is not authorized for this action\"",
"}",
",",
"status",
":",
"... | Authorizations below here | [
"Authorizations",
"below",
"here"
] | d39e6f107bdcf9d969df5e7b175e0e4f229e877d | https://github.com/Potpourri-Projects/fbuser/blob/d39e6f107bdcf9d969df5e7b175e0e4f229e877d/app/controllers/fbuser/api/v1/users_controller.rb#L70-L74 |
7,501 | ccclin/decay_heat_with_nuclear | lib/decay_heat_with_nuclear/thermal_data.rb | ThermalData.DataForANS_5_1_1979.thePi | def thePi
hash = HashWithThermalFission.new
hash.thermal_fission[:U235] = 0.98
hash.thermal_fission[:Pu239] = 0.01
hash.thermal_fission[:U238] = 0.01
hash.thermal_fission
end | ruby | def thePi
hash = HashWithThermalFission.new
hash.thermal_fission[:U235] = 0.98
hash.thermal_fission[:Pu239] = 0.01
hash.thermal_fission[:U238] = 0.01
hash.thermal_fission
end | [
"def",
"thePi",
"hash",
"=",
"HashWithThermalFission",
".",
"new",
"hash",
".",
"thermal_fission",
"[",
":U235",
"]",
"=",
"0.98",
"hash",
".",
"thermal_fission",
"[",
":Pu239",
"]",
"=",
"0.01",
"hash",
".",
"thermal_fission",
"[",
":U238",
"]",
"=",
"0.0... | thePi is Pi in ANS-5.1-1979. | [
"thePi",
"is",
"Pi",
"in",
"ANS",
"-",
"5",
".",
"1",
"-",
"1979",
"."
] | fc81505803c9d8488420216ca6f0e6597b2c47d7 | https://github.com/ccclin/decay_heat_with_nuclear/blob/fc81505803c9d8488420216ca6f0e6597b2c47d7/lib/decay_heat_with_nuclear/thermal_data.rb#L35-L43 |
7,502 | ccclin/decay_heat_with_nuclear | lib/decay_heat_with_nuclear/thermal_data.rb | ThermalData.DataForANS_5_1_1979.theU235_alpha | def theU235_alpha
array = Array.new(23)
array[0] = 6.5057E-01
array[1] = 5.1264E-01
array[2] = 2.4384E-01
array[3] = 1.3850E-01
array[4] = 5.544E-02
array[5] = 2.2225E-02
array[6] = 3.3088E-03
array[7] = 9.3015E-04
array[8] = 8.0943E-04
arra... | ruby | def theU235_alpha
array = Array.new(23)
array[0] = 6.5057E-01
array[1] = 5.1264E-01
array[2] = 2.4384E-01
array[3] = 1.3850E-01
array[4] = 5.544E-02
array[5] = 2.2225E-02
array[6] = 3.3088E-03
array[7] = 9.3015E-04
array[8] = 8.0943E-04
arra... | [
"def",
"theU235_alpha",
"array",
"=",
"Array",
".",
"new",
"(",
"23",
")",
"array",
"[",
"0",
"]",
"=",
"6.5057E-01",
"array",
"[",
"1",
"]",
"=",
"5.1264E-01",
"array",
"[",
"2",
"]",
"=",
"2.4384E-01",
"array",
"[",
"3",
"]",
"=",
"1.3850E-01",
"... | theU235_alpha is alpha in ANS-5.1-1979 Table 7. | [
"theU235_alpha",
"is",
"alpha",
"in",
"ANS",
"-",
"5",
".",
"1",
"-",
"1979",
"Table",
"7",
"."
] | fc81505803c9d8488420216ca6f0e6597b2c47d7 | https://github.com/ccclin/decay_heat_with_nuclear/blob/fc81505803c9d8488420216ca6f0e6597b2c47d7/lib/decay_heat_with_nuclear/thermal_data.rb#L55-L83 |
7,503 | ccclin/decay_heat_with_nuclear | lib/decay_heat_with_nuclear/thermal_data.rb | ThermalData.DataForANS_5_1_1979.theU235_lamda | def theU235_lamda
array = Array.new(23)
array[0] = 2.2138E+01
array[1] = 5.1587E-01
array[2] = 1.9594E-01
array[3] = 1.0314E-01
array[4] = 3.3656E-02
array[5] = 1.1681E-02
array[6] = 3.5870E-03
array[7] = 1.3930E-03
array[8] = 6.2630E-04
arr... | ruby | def theU235_lamda
array = Array.new(23)
array[0] = 2.2138E+01
array[1] = 5.1587E-01
array[2] = 1.9594E-01
array[3] = 1.0314E-01
array[4] = 3.3656E-02
array[5] = 1.1681E-02
array[6] = 3.5870E-03
array[7] = 1.3930E-03
array[8] = 6.2630E-04
arr... | [
"def",
"theU235_lamda",
"array",
"=",
"Array",
".",
"new",
"(",
"23",
")",
"array",
"[",
"0",
"]",
"=",
"2.2138E+01",
"array",
"[",
"1",
"]",
"=",
"5.1587E-01",
"array",
"[",
"2",
"]",
"=",
"1.9594E-01",
"array",
"[",
"3",
"]",
"=",
"1.0314E-01",
"... | theU235_lamda is lamda in ANS-5.1-1979 Table 7. | [
"theU235_lamda",
"is",
"lamda",
"in",
"ANS",
"-",
"5",
".",
"1",
"-",
"1979",
"Table",
"7",
"."
] | fc81505803c9d8488420216ca6f0e6597b2c47d7 | https://github.com/ccclin/decay_heat_with_nuclear/blob/fc81505803c9d8488420216ca6f0e6597b2c47d7/lib/decay_heat_with_nuclear/thermal_data.rb#L86-L114 |
7,504 | ccclin/decay_heat_with_nuclear | lib/decay_heat_with_nuclear/thermal_data.rb | ThermalData.DataForANS_5_1_1979.thePu239_alpha | def thePu239_alpha
array = Array.new(23)
array[0] = 2.083E-01
array[1] = 3.853E-01
array[2] = 2.213E-01
array[3] = 9.460E-02
array[4] = 3.531E-02
array[5] = 2.292E-02
array[6] = 3.946E-03
array[7] = 1.317E-03
array[8] = 7.052E-04
array[9] = ... | ruby | def thePu239_alpha
array = Array.new(23)
array[0] = 2.083E-01
array[1] = 3.853E-01
array[2] = 2.213E-01
array[3] = 9.460E-02
array[4] = 3.531E-02
array[5] = 2.292E-02
array[6] = 3.946E-03
array[7] = 1.317E-03
array[8] = 7.052E-04
array[9] = ... | [
"def",
"thePu239_alpha",
"array",
"=",
"Array",
".",
"new",
"(",
"23",
")",
"array",
"[",
"0",
"]",
"=",
"2.083E-01",
"array",
"[",
"1",
"]",
"=",
"3.853E-01",
"array",
"[",
"2",
"]",
"=",
"2.213E-01",
"array",
"[",
"3",
"]",
"=",
"9.460E-02",
"arr... | thePu239_alpha is alpha in ANS-5.1-1979 Table 8. | [
"thePu239_alpha",
"is",
"alpha",
"in",
"ANS",
"-",
"5",
".",
"1",
"-",
"1979",
"Table",
"8",
"."
] | fc81505803c9d8488420216ca6f0e6597b2c47d7 | https://github.com/ccclin/decay_heat_with_nuclear/blob/fc81505803c9d8488420216ca6f0e6597b2c47d7/lib/decay_heat_with_nuclear/thermal_data.rb#L117-L145 |
7,505 | ccclin/decay_heat_with_nuclear | lib/decay_heat_with_nuclear/thermal_data.rb | ThermalData.DataForANS_5_1_1979.thePu239_lamda | def thePu239_lamda
array = Array.new(23)
array[0] = 1.002E+01
array[1] = 6.433E-01
array[2] = 2.186E-01
array[3] = 1.004E-01
array[4] = 3.728E-02
array[5] = 1.435E-02
array[6] = 4.549E-03
array[7] = 1.328E-03
array[8] = 5.356E-04
array[9] = ... | ruby | def thePu239_lamda
array = Array.new(23)
array[0] = 1.002E+01
array[1] = 6.433E-01
array[2] = 2.186E-01
array[3] = 1.004E-01
array[4] = 3.728E-02
array[5] = 1.435E-02
array[6] = 4.549E-03
array[7] = 1.328E-03
array[8] = 5.356E-04
array[9] = ... | [
"def",
"thePu239_lamda",
"array",
"=",
"Array",
".",
"new",
"(",
"23",
")",
"array",
"[",
"0",
"]",
"=",
"1.002E+01",
"array",
"[",
"1",
"]",
"=",
"6.433E-01",
"array",
"[",
"2",
"]",
"=",
"2.186E-01",
"array",
"[",
"3",
"]",
"=",
"1.004E-01",
"arr... | thePu239_lamda is lamda in ANS-5.1-1979 Table 8. | [
"thePu239_lamda",
"is",
"lamda",
"in",
"ANS",
"-",
"5",
".",
"1",
"-",
"1979",
"Table",
"8",
"."
] | fc81505803c9d8488420216ca6f0e6597b2c47d7 | https://github.com/ccclin/decay_heat_with_nuclear/blob/fc81505803c9d8488420216ca6f0e6597b2c47d7/lib/decay_heat_with_nuclear/thermal_data.rb#L148-L176 |
7,506 | ccclin/decay_heat_with_nuclear | lib/decay_heat_with_nuclear/thermal_data.rb | ThermalData.DataForANS_5_1_1979.theU238_alpha | def theU238_alpha
array = Array.new(23)
array[0] = 1.2311E+0
array[1] = 1.1486E+0
array[2] = 7.0701E-01
array[3] = 2.5209E-01
array[4] = 7.187E-02
array[5] = 2.8291E-02
array[6] = 6.8382E-03
array[7] = 1.2322E-03
array[8] = 6.8409E-04
array[... | ruby | def theU238_alpha
array = Array.new(23)
array[0] = 1.2311E+0
array[1] = 1.1486E+0
array[2] = 7.0701E-01
array[3] = 2.5209E-01
array[4] = 7.187E-02
array[5] = 2.8291E-02
array[6] = 6.8382E-03
array[7] = 1.2322E-03
array[8] = 6.8409E-04
array[... | [
"def",
"theU238_alpha",
"array",
"=",
"Array",
".",
"new",
"(",
"23",
")",
"array",
"[",
"0",
"]",
"=",
"1.2311E+0",
"array",
"[",
"1",
"]",
"=",
"1.1486E+0",
"array",
"[",
"2",
"]",
"=",
"7.0701E-01",
"array",
"[",
"3",
"]",
"=",
"2.5209E-01",
"ar... | theU238_alpha is alpha in ANS-5.1-1979 Table 9. | [
"theU238_alpha",
"is",
"alpha",
"in",
"ANS",
"-",
"5",
".",
"1",
"-",
"1979",
"Table",
"9",
"."
] | fc81505803c9d8488420216ca6f0e6597b2c47d7 | https://github.com/ccclin/decay_heat_with_nuclear/blob/fc81505803c9d8488420216ca6f0e6597b2c47d7/lib/decay_heat_with_nuclear/thermal_data.rb#L179-L207 |
7,507 | ccclin/decay_heat_with_nuclear | lib/decay_heat_with_nuclear/thermal_data.rb | ThermalData.DataForANS_5_1_1979.theU238_lamda | def theU238_lamda
array = Array.new(23)
array[0] = 3.2881E+0
array[1] = 9.3805E-01
array[2] = 3.7073E-01
array[3] = 1.1118E-01
array[4] = 3.6143E-02
array[5] = 1.3272E-02
array[6] = 5.0133E-03
array[7] = 1.3655E-03
array[8] = 5.5158E-04
arra... | ruby | def theU238_lamda
array = Array.new(23)
array[0] = 3.2881E+0
array[1] = 9.3805E-01
array[2] = 3.7073E-01
array[3] = 1.1118E-01
array[4] = 3.6143E-02
array[5] = 1.3272E-02
array[6] = 5.0133E-03
array[7] = 1.3655E-03
array[8] = 5.5158E-04
arra... | [
"def",
"theU238_lamda",
"array",
"=",
"Array",
".",
"new",
"(",
"23",
")",
"array",
"[",
"0",
"]",
"=",
"3.2881E+0",
"array",
"[",
"1",
"]",
"=",
"9.3805E-01",
"array",
"[",
"2",
"]",
"=",
"3.7073E-01",
"array",
"[",
"3",
"]",
"=",
"1.1118E-01",
"a... | theU238_lamda is lamda in ANS-5.1-1979 Table 9. | [
"theU238_lamda",
"is",
"lamda",
"in",
"ANS",
"-",
"5",
".",
"1",
"-",
"1979",
"Table",
"9",
"."
] | fc81505803c9d8488420216ca6f0e6597b2c47d7 | https://github.com/ccclin/decay_heat_with_nuclear/blob/fc81505803c9d8488420216ca6f0e6597b2c47d7/lib/decay_heat_with_nuclear/thermal_data.rb#L210-L238 |
7,508 | bwillis/rockit | lib/rockit/application.rb | Rockit.Application.run | def run
rockit_file = CONFIG_FILES.select { |f| File.exists?(f) }.first
raise ArgumentError "No Rockitfile found (looking for: #{CONFIG_FILES.join(',')})" unless rockit_file
Dsl.new(self).instance_eval(File.read(rockit_file), rockit_file)
end | ruby | def run
rockit_file = CONFIG_FILES.select { |f| File.exists?(f) }.first
raise ArgumentError "No Rockitfile found (looking for: #{CONFIG_FILES.join(',')})" unless rockit_file
Dsl.new(self).instance_eval(File.read(rockit_file), rockit_file)
end | [
"def",
"run",
"rockit_file",
"=",
"CONFIG_FILES",
".",
"select",
"{",
"|",
"f",
"|",
"File",
".",
"exists?",
"(",
"f",
")",
"}",
".",
"first",
"raise",
"ArgumentError",
"\"No Rockitfile found (looking for: #{CONFIG_FILES.join(',')})\"",
"unless",
"rockit_file",
"Dsl... | Run a Rockit configuration file and Rails dependency checks
unless turned off by configuration. | [
"Run",
"a",
"Rockit",
"configuration",
"file",
"and",
"Rails",
"dependency",
"checks",
"unless",
"turned",
"off",
"by",
"configuration",
"."
] | b0604538e2436d6c26a4e29c605235638e819fee | https://github.com/bwillis/rockit/blob/b0604538e2436d6c26a4e29c605235638e819fee/lib/rockit/application.rb#L26-L30 |
7,509 | bwillis/rockit | lib/rockit/application.rb | Rockit.Application.if_string_digest_changed | def if_string_digest_changed(key, input, &block)
if_string_changed(key, Digest::SHA256.new.update(input.to_s).hexdigest.to_s, &block)
end | ruby | def if_string_digest_changed(key, input, &block)
if_string_changed(key, Digest::SHA256.new.update(input.to_s).hexdigest.to_s, &block)
end | [
"def",
"if_string_digest_changed",
"(",
"key",
",",
"input",
",",
"&",
"block",
")",
"if_string_changed",
"(",
"key",
",",
"Digest",
"::",
"SHA256",
".",
"new",
".",
"update",
"(",
"input",
".",
"to_s",
")",
".",
"hexdigest",
".",
"to_s",
",",
"block",
... | If the digest of the input is different from the stored key, execute the block. | [
"If",
"the",
"digest",
"of",
"the",
"input",
"is",
"different",
"from",
"the",
"stored",
"key",
"execute",
"the",
"block",
"."
] | b0604538e2436d6c26a4e29c605235638e819fee | https://github.com/bwillis/rockit/blob/b0604538e2436d6c26a4e29c605235638e819fee/lib/rockit/application.rb#L78-L80 |
7,510 | bwillis/rockit | lib/rockit/application.rb | Rockit.Application.if_file_changed | def if_file_changed(file, &block)
if_string_changed(file, Digest::SHA256.file(file).hexdigest.to_s, &block)
end | ruby | def if_file_changed(file, &block)
if_string_changed(file, Digest::SHA256.file(file).hexdigest.to_s, &block)
end | [
"def",
"if_file_changed",
"(",
"file",
",",
"&",
"block",
")",
"if_string_changed",
"(",
"file",
",",
"Digest",
"::",
"SHA256",
".",
"file",
"(",
"file",
")",
".",
"hexdigest",
".",
"to_s",
",",
"block",
")",
"end"
] | If the digest of the file is different from the stored digest, execute the block. | [
"If",
"the",
"digest",
"of",
"the",
"file",
"is",
"different",
"from",
"the",
"stored",
"digest",
"execute",
"the",
"block",
"."
] | b0604538e2436d6c26a4e29c605235638e819fee | https://github.com/bwillis/rockit/blob/b0604538e2436d6c26a4e29c605235638e819fee/lib/rockit/application.rb#L83-L85 |
7,511 | bwillis/rockit | lib/rockit/application.rb | Rockit.Application.if_string_changed | def if_string_changed(key, new_value, &block)
if new_value != @hash_store[key]
old_value = @hash_store[key]
@hash_store[key] = new_value
block.call(key, new_value, old_value) if block_given?
end
end | ruby | def if_string_changed(key, new_value, &block)
if new_value != @hash_store[key]
old_value = @hash_store[key]
@hash_store[key] = new_value
block.call(key, new_value, old_value) if block_given?
end
end | [
"def",
"if_string_changed",
"(",
"key",
",",
"new_value",
",",
"&",
"block",
")",
"if",
"new_value",
"!=",
"@hash_store",
"[",
"key",
"]",
"old_value",
"=",
"@hash_store",
"[",
"key",
"]",
"@hash_store",
"[",
"key",
"]",
"=",
"new_value",
"block",
".",
"... | Execute the given block if the input is different from
the output .
key - the key to lookup the stored hash value
new_value - the value to compare with the stored hash value
block - block to execute if the hash value does not match the stored hash value
return if the block was not executed, false, if it is execu... | [
"Execute",
"the",
"given",
"block",
"if",
"the",
"input",
"is",
"different",
"from",
"the",
"output",
"."
] | b0604538e2436d6c26a4e29c605235638e819fee | https://github.com/bwillis/rockit/blob/b0604538e2436d6c26a4e29c605235638e819fee/lib/rockit/application.rb#L96-L102 |
7,512 | bwillis/rockit | lib/rockit/application.rb | Rockit.Application.system_exit_on_error | def system_exit_on_error(command, options={})
options = {'print_command' => true}.merge(string_keys(options))
output command if options['print_command'] || @debug
command_output = system_command(command)
output command_output if @debug
unless last_process.success?
result = options[... | ruby | def system_exit_on_error(command, options={})
options = {'print_command' => true}.merge(string_keys(options))
output command if options['print_command'] || @debug
command_output = system_command(command)
output command_output if @debug
unless last_process.success?
result = options[... | [
"def",
"system_exit_on_error",
"(",
"command",
",",
"options",
"=",
"{",
"}",
")",
"options",
"=",
"{",
"'print_command'",
"=>",
"true",
"}",
".",
"merge",
"(",
"string_keys",
"(",
"options",
")",
")",
"output",
"command",
"if",
"options",
"[",
"'print_com... | Run system commands and if not successful exit and print out an error
message. Default behavior is to print output of a command when it does
not return success.
command - the system command you want to execute
options - 'error_message' - a message to print when command is not successful
'print_command' ... | [
"Run",
"system",
"commands",
"and",
"if",
"not",
"successful",
"exit",
"and",
"print",
"out",
"an",
"error",
"message",
".",
"Default",
"behavior",
"is",
"to",
"print",
"output",
"of",
"a",
"command",
"when",
"it",
"does",
"not",
"return",
"success",
"."
] | b0604538e2436d6c26a4e29c605235638e819fee | https://github.com/bwillis/rockit/blob/b0604538e2436d6c26a4e29c605235638e819fee/lib/rockit/application.rb#L117-L130 |
7,513 | epuber-io/bade | lib/bade/renderer.rb | Bade.Renderer._find_file! | def _find_file!(name, reference_path)
sub_path = File.expand_path(name, File.dirname(reference_path))
if File.exist?(sub_path)
return if sub_path.end_with?('.rb') # handled in Generator
sub_path
else
bade_path = "#{sub_path}.bade"
rb_path = "#{sub_path}.rb"
ba... | ruby | def _find_file!(name, reference_path)
sub_path = File.expand_path(name, File.dirname(reference_path))
if File.exist?(sub_path)
return if sub_path.end_with?('.rb') # handled in Generator
sub_path
else
bade_path = "#{sub_path}.bade"
rb_path = "#{sub_path}.rb"
ba... | [
"def",
"_find_file!",
"(",
"name",
",",
"reference_path",
")",
"sub_path",
"=",
"File",
".",
"expand_path",
"(",
"name",
",",
"File",
".",
"dirname",
"(",
"reference_path",
")",
")",
"if",
"File",
".",
"exist?",
"(",
"sub_path",
")",
"return",
"if",
"sub... | Tries to find file with name, if no file could be found or there are multiple files matching the name error is
raised
@param [String] name name of the file that should be found
@param [String] reference_path path to file from which is loading/finding
@return [String, nil] returns nil when this file should be sk... | [
"Tries",
"to",
"find",
"file",
"with",
"name",
"if",
"no",
"file",
"could",
"be",
"found",
"or",
"there",
"are",
"multiple",
"files",
"matching",
"the",
"name",
"error",
"is",
"raised"
] | fe128e0178d28b5a789d94b861ac6c6d2e4a3a8e | https://github.com/epuber-io/bade/blob/fe128e0178d28b5a789d94b861ac6c6d2e4a3a8e/lib/bade/renderer.rb#L247-L274 |
7,514 | Raybeam/myreplicator | lib/exporter/export_metadata.rb | Myreplicator.ExportMetadata.equals | def equals object
if table == object.table && database == object.database
return true
end
return false
end | ruby | def equals object
if table == object.table && database == object.database
return true
end
return false
end | [
"def",
"equals",
"object",
"if",
"table",
"==",
"object",
".",
"table",
"&&",
"database",
"==",
"object",
".",
"database",
"return",
"true",
"end",
"return",
"false",
"end"
] | Compares the object with another metadata object
Return true if they are for the same table | [
"Compares",
"the",
"object",
"with",
"another",
"metadata",
"object",
"Return",
"true",
"if",
"they",
"are",
"for",
"the",
"same",
"table"
] | 470938e70f46886b525c65a4a464b4cf8383d00d | https://github.com/Raybeam/myreplicator/blob/470938e70f46886b525c65a4a464b4cf8383d00d/lib/exporter/export_metadata.rb#L60-L65 |
7,515 | Raybeam/myreplicator | lib/exporter/export_metadata.rb | Myreplicator.ExportMetadata.store! | def store!
Kernel.p "$$$$$$$$$$$$$$$$$$ @ssh CHECK $$$$$$$$$$$$$$$$$$"
cmd = "echo \"#{self.to_json.gsub("\"","\\\\\"")}\" > #{@filepath}.json"
puts cmd
result = @ssh.exec!(cmd)
puts result
end | ruby | def store!
Kernel.p "$$$$$$$$$$$$$$$$$$ @ssh CHECK $$$$$$$$$$$$$$$$$$"
cmd = "echo \"#{self.to_json.gsub("\"","\\\\\"")}\" > #{@filepath}.json"
puts cmd
result = @ssh.exec!(cmd)
puts result
end | [
"def",
"store!",
"Kernel",
".",
"p",
"\"$$$$$$$$$$$$$$$$$$ @ssh CHECK $$$$$$$$$$$$$$$$$$\"",
"cmd",
"=",
"\"echo \\\"#{self.to_json.gsub(\"\\\"\",\"\\\\\\\\\\\"\")}\\\" > #{@filepath}.json\"",
"puts",
"cmd",
"result",
"=",
"@ssh",
".",
"exec!",
"(",
"cmd",
")",
"puts",
"resul... | Writes Json to file using echo
file is written to remote server via SSH
Echo is used for writing the file | [
"Writes",
"Json",
"to",
"file",
"using",
"echo",
"file",
"is",
"written",
"to",
"remote",
"server",
"via",
"SSH",
"Echo",
"is",
"used",
"for",
"writing",
"the",
"file"
] | 470938e70f46886b525c65a4a464b4cf8383d00d | https://github.com/Raybeam/myreplicator/blob/470938e70f46886b525c65a4a464b4cf8383d00d/lib/exporter/export_metadata.rb#L192-L198 |
7,516 | nulogy/spreadsheet | lib/spreadsheet/row.rb | Spreadsheet.Row.formatted | def formatted
copy = dup
@formats.rcompact!
if copy.length < @formats.size
copy.concat Array.new(@formats.size - copy.length)
end
copy
end | ruby | def formatted
copy = dup
@formats.rcompact!
if copy.length < @formats.size
copy.concat Array.new(@formats.size - copy.length)
end
copy
end | [
"def",
"formatted",
"copy",
"=",
"dup",
"@formats",
".",
"rcompact!",
"if",
"copy",
".",
"length",
"<",
"@formats",
".",
"size",
"copy",
".",
"concat",
"Array",
".",
"new",
"(",
"@formats",
".",
"size",
"-",
"copy",
".",
"length",
")",
"end",
"copy",
... | Returns a copy of self with nil-values appended for empty cells that have
an associated Format.
This is primarily a helper-function for the writer classes. | [
"Returns",
"a",
"copy",
"of",
"self",
"with",
"nil",
"-",
"values",
"appended",
"for",
"empty",
"cells",
"that",
"have",
"an",
"associated",
"Format",
".",
"This",
"is",
"primarily",
"a",
"helper",
"-",
"function",
"for",
"the",
"writer",
"classes",
"."
] | c89825047f02ab26deddaab779f3b4ca349b6a0c | https://github.com/nulogy/spreadsheet/blob/c89825047f02ab26deddaab779f3b4ca349b6a0c/lib/spreadsheet/row.rb#L91-L98 |
7,517 | kenpratt/dbox | lib/dbox/utils.rb | Dbox.Utils.relative_to_local_path | def relative_to_local_path(path)
if path && path.length > 0
case_insensitive_join(local_path, path)
else
case_insensitive_resolve(local_path)
end
end | ruby | def relative_to_local_path(path)
if path && path.length > 0
case_insensitive_join(local_path, path)
else
case_insensitive_resolve(local_path)
end
end | [
"def",
"relative_to_local_path",
"(",
"path",
")",
"if",
"path",
"&&",
"path",
".",
"length",
">",
"0",
"case_insensitive_join",
"(",
"local_path",
",",
"path",
")",
"else",
"case_insensitive_resolve",
"(",
"local_path",
")",
"end",
"end"
] | assumes local_path is defined | [
"assumes",
"local_path",
"is",
"defined"
] | f75dbc9dfd8d6ddba24a812ac676cf07325f1899 | https://github.com/kenpratt/dbox/blob/f75dbc9dfd8d6ddba24a812ac676cf07325f1899/lib/dbox/utils.rb#L45-L51 |
7,518 | kenpratt/dbox | lib/dbox/utils.rb | Dbox.Utils.relative_to_remote_path | def relative_to_remote_path(path)
if path && path.length > 0
File.join(remote_path, path)
else
remote_path
end
end | ruby | def relative_to_remote_path(path)
if path && path.length > 0
File.join(remote_path, path)
else
remote_path
end
end | [
"def",
"relative_to_remote_path",
"(",
"path",
")",
"if",
"path",
"&&",
"path",
".",
"length",
">",
"0",
"File",
".",
"join",
"(",
"remote_path",
",",
"path",
")",
"else",
"remote_path",
"end",
"end"
] | assumes remote_path is defined | [
"assumes",
"remote_path",
"is",
"defined"
] | f75dbc9dfd8d6ddba24a812ac676cf07325f1899 | https://github.com/kenpratt/dbox/blob/f75dbc9dfd8d6ddba24a812ac676cf07325f1899/lib/dbox/utils.rb#L54-L60 |
7,519 | botanicus/nake | lib/nake/abstract_task.rb | Nake.AbstractTask.config | def config
@config ||= begin
Hash.new do |hash, key|
raise ConfigurationError, "Configuration key #{key} in task #{name} doesn't exist"
end.tap do |hash|
hash.define_singleton_method(:declare) do |*keys|
keys.each { |key| self[key] = nil unless self.has_key?(key) }
... | ruby | def config
@config ||= begin
Hash.new do |hash, key|
raise ConfigurationError, "Configuration key #{key} in task #{name} doesn't exist"
end.tap do |hash|
hash.define_singleton_method(:declare) do |*keys|
keys.each { |key| self[key] = nil unless self.has_key?(key) }
... | [
"def",
"config",
"@config",
"||=",
"begin",
"Hash",
".",
"new",
"do",
"|",
"hash",
",",
"key",
"|",
"raise",
"ConfigurationError",
",",
"\"Configuration key #{key} in task #{name} doesn't exist\"",
"end",
".",
"tap",
"do",
"|",
"hash",
"|",
"hash",
".",
"define_... | don't use this if you don't have to! | [
"don",
"t",
"use",
"this",
"if",
"you",
"don",
"t",
"have",
"to!"
] | d0ca22c3ce686dc916bdbe5bbd5475a18371a41d | https://github.com/botanicus/nake/blob/d0ca22c3ce686dc916bdbe5bbd5475a18371a41d/lib/nake/abstract_task.rb#L61-L71 |
7,520 | apostle/apostle-ruby | lib/apostle/mail.rb | Apostle.Mail.deliver! | def deliver!
return true unless Apostle.deliver
unless template_id && template_id != ''
raise DeliveryError,
'No email template_id provided'
end
queue = Apostle::Queue.new
queue.add self
queue.deliver!
# Return true or false depending on successful deli... | ruby | def deliver!
return true unless Apostle.deliver
unless template_id && template_id != ''
raise DeliveryError,
'No email template_id provided'
end
queue = Apostle::Queue.new
queue.add self
queue.deliver!
# Return true or false depending on successful deli... | [
"def",
"deliver!",
"return",
"true",
"unless",
"Apostle",
".",
"deliver",
"unless",
"template_id",
"&&",
"template_id",
"!=",
"''",
"raise",
"DeliveryError",
",",
"'No email template_id provided'",
"end",
"queue",
"=",
"Apostle",
"::",
"Queue",
".",
"new",
"queue"... | Shortcut method to deliver a single message | [
"Shortcut",
"method",
"to",
"deliver",
"a",
"single",
"message"
] | 1d3a99d62da4f4c6cdbc8f061ab7640b8f85d1e2 | https://github.com/apostle/apostle-ruby/blob/1d3a99d62da4f4c6cdbc8f061ab7640b8f85d1e2/lib/apostle/mail.rb#L59-L77 |
7,521 | patchapps/rabbit-hutch | lib/worker.rb | RabbitHutch.Worker.start | def start
@exchange = @channel.topic(@exchange_name, :durable => true, :auto_delete => false, :internal => true)
@queue = @channel.queue(@queue_name, :durable => true, :auto_delete => false)
@queue.bind(@exchange, :routing_key => 'publish.#')
@queue.subscribe(&@consumer.method(:handle_message))
... | ruby | def start
@exchange = @channel.topic(@exchange_name, :durable => true, :auto_delete => false, :internal => true)
@queue = @channel.queue(@queue_name, :durable => true, :auto_delete => false)
@queue.bind(@exchange, :routing_key => 'publish.#')
@queue.subscribe(&@consumer.method(:handle_message))
... | [
"def",
"start",
"@exchange",
"=",
"@channel",
".",
"topic",
"(",
"@exchange_name",
",",
":durable",
"=>",
"true",
",",
":auto_delete",
"=>",
"false",
",",
":internal",
"=>",
"true",
")",
"@queue",
"=",
"@channel",
".",
"queue",
"(",
"@queue_name",
",",
":d... | begin listening for all topics in publish. | [
"begin",
"listening",
"for",
"all",
"topics",
"in",
"publish",
"."
] | 42337b0ddda60b749fc2fe088f4e8dba674d198d | https://github.com/patchapps/rabbit-hutch/blob/42337b0ddda60b749fc2fe088f4e8dba674d198d/lib/worker.rb#L20-L25 |
7,522 | codegram/simple_currency | lib/simple_currency/currency_convertible.rb | CurrencyConvertible.Proxy.cached_rate | def cached_rate(original, target)
if defined?(Rails)
unless rate = Rails.cache.read("#{original}_#{target}_#{stringified_exchange_date}")
rate = (1.0 / Rails.cache.read("#{target}_#{original}_#{stringified_exchange_date}")) rescue nil
end
rate
end
end | ruby | def cached_rate(original, target)
if defined?(Rails)
unless rate = Rails.cache.read("#{original}_#{target}_#{stringified_exchange_date}")
rate = (1.0 / Rails.cache.read("#{target}_#{original}_#{stringified_exchange_date}")) rescue nil
end
rate
end
end | [
"def",
"cached_rate",
"(",
"original",
",",
"target",
")",
"if",
"defined?",
"(",
"Rails",
")",
"unless",
"rate",
"=",
"Rails",
".",
"cache",
".",
"read",
"(",
"\"#{original}_#{target}_#{stringified_exchange_date}\"",
")",
"rate",
"=",
"(",
"1.0",
"/",
"Rails"... | Tries to either get rate or calculate the inverse rate from cache.
First looks for an "usd_eur_25-8-2010" entry in the cache,
and if it does not find it, it looks for "eur_usd_25-8-2010" and
inverts it. | [
"Tries",
"to",
"either",
"get",
"rate",
"or",
"calculate",
"the",
"inverse",
"rate",
"from",
"cache",
"."
] | 4bc4406735dc095ed9ba97ee3a4dcb9b72d047ec | https://github.com/codegram/simple_currency/blob/4bc4406735dc095ed9ba97ee3a4dcb9b72d047ec/lib/simple_currency/currency_convertible.rb#L189-L196 |
7,523 | reggieb/ominous | app/models/ominous/warning.rb | Ominous.Warning.pass_method_to_warning_closer | def pass_method_to_warning_closer(symbol, closer)
raise "A closer is needed to identify the warning_closer" unless closer.kind_of? Closer
warning_closer = warning_closers.where(:closer_id => closer.id).first
warning_closer.send(symbol) if warning_closer
end | ruby | def pass_method_to_warning_closer(symbol, closer)
raise "A closer is needed to identify the warning_closer" unless closer.kind_of? Closer
warning_closer = warning_closers.where(:closer_id => closer.id).first
warning_closer.send(symbol) if warning_closer
end | [
"def",
"pass_method_to_warning_closer",
"(",
"symbol",
",",
"closer",
")",
"raise",
"\"A closer is needed to identify the warning_closer\"",
"unless",
"closer",
".",
"kind_of?",
"Closer",
"warning_closer",
"=",
"warning_closers",
".",
"where",
"(",
":closer_id",
"=>",
"cl... | Allows acts_as_list methods to be used within the warning.
If closers were the act_as_list object, you could do things like this
warning.closers.last.move_higher
However, as closers are used on multiple warnings and they
need to be independently sortable within each warning, it is the
through table ... | [
"Allows",
"acts_as_list",
"methods",
"to",
"be",
"used",
"within",
"the",
"warning",
".",
"If",
"closers",
"were",
"the",
"act_as_list",
"object",
"you",
"could",
"do",
"things",
"like",
"this"
] | 725ec70e9cc718f07a72bb8dd68ed2da4c8a6a13 | https://github.com/reggieb/ominous/blob/725ec70e9cc718f07a72bb8dd68ed2da4c8a6a13/app/models/ominous/warning.rb#L75-L79 |
7,524 | 26fe/tree.rb | lib/tree_rb/core/tree_node.rb | TreeRb.TreeNode.find | def find(content = nil, &block)
if content and block_given?
raise "TreeNode::find - passed content AND block"
end
if content
if content.class == Regexp
block = proc { |l| l.content =~ content }
else
block = proc { |l| l.content == content }
end
... | ruby | def find(content = nil, &block)
if content and block_given?
raise "TreeNode::find - passed content AND block"
end
if content
if content.class == Regexp
block = proc { |l| l.content =~ content }
else
block = proc { |l| l.content == content }
end
... | [
"def",
"find",
"(",
"content",
"=",
"nil",
",",
"&",
"block",
")",
"if",
"content",
"and",
"block_given?",
"raise",
"\"TreeNode::find - passed content AND block\"",
"end",
"if",
"content",
"if",
"content",
".",
"class",
"==",
"Regexp",
"block",
"=",
"proc",
"{... | Find a node down the hierarchy with content
@param [Object,Regexp] content of searched node
@return [Object, nil] nil if not found | [
"Find",
"a",
"node",
"down",
"the",
"hierarchy",
"with",
"content"
] | 5ecf0cfbbc439e27c72b9676d6a1ccee8e6bb02b | https://github.com/26fe/tree.rb/blob/5ecf0cfbbc439e27c72b9676d6a1ccee8e6bb02b/lib/tree_rb/core/tree_node.rb#L229-L251 |
7,525 | kamui/rack-accept_headers | lib/rack/accept_headers/charset.rb | Rack::AcceptHeaders.Charset.matches | def matches(charset)
values.select {|v|
v == charset || v == '*'
}.sort {|a, b|
# "*" gets least precedence, any others should be equal.
a == '*' ? 1 : (b == '*' ? -1 : 0)
}
end | ruby | def matches(charset)
values.select {|v|
v == charset || v == '*'
}.sort {|a, b|
# "*" gets least precedence, any others should be equal.
a == '*' ? 1 : (b == '*' ? -1 : 0)
}
end | [
"def",
"matches",
"(",
"charset",
")",
"values",
".",
"select",
"{",
"|",
"v",
"|",
"v",
"==",
"charset",
"||",
"v",
"==",
"'*'",
"}",
".",
"sort",
"{",
"|",
"a",
",",
"b",
"|",
"# \"*\" gets least precedence, any others should be equal.",
"a",
"==",
"'*... | Returns an array of character sets from this header that match the given
+charset+, ordered by precedence. | [
"Returns",
"an",
"array",
"of",
"character",
"sets",
"from",
"this",
"header",
"that",
"match",
"the",
"given",
"+",
"charset",
"+",
"ordered",
"by",
"precedence",
"."
] | 099bfbb919de86b5842c8e14be42b8b784e53f03 | https://github.com/kamui/rack-accept_headers/blob/099bfbb919de86b5842c8e14be42b8b784e53f03/lib/rack/accept_headers/charset.rb#L27-L34 |
7,526 | timwaters/nypl_repo | lib/nypl_repo.rb | NyplRepo.Client.get_capture_items | def get_capture_items(c_uuid)
url = "#{@server_url}/items/#{c_uuid}.json?per_page=500"
json = self.get_json(url)
captures = []
capture = json["nyplAPI"]["response"]["capture"]
captures << capture
totalPages = json["nyplAPI"]["request"]["totalPages"].to_i
if totalPages >= 2
... | ruby | def get_capture_items(c_uuid)
url = "#{@server_url}/items/#{c_uuid}.json?per_page=500"
json = self.get_json(url)
captures = []
capture = json["nyplAPI"]["response"]["capture"]
captures << capture
totalPages = json["nyplAPI"]["request"]["totalPages"].to_i
if totalPages >= 2
... | [
"def",
"get_capture_items",
"(",
"c_uuid",
")",
"url",
"=",
"\"#{@server_url}/items/#{c_uuid}.json?per_page=500\"",
"json",
"=",
"self",
".",
"get_json",
"(",
"url",
")",
"captures",
"=",
"[",
"]",
"capture",
"=",
"json",
"[",
"\"nyplAPI\"",
"]",
"[",
"\"respons... | Given a container uuid, or biblographic uuid, returns a
list of mods uuids. | [
"Given",
"a",
"container",
"uuid",
"or",
"biblographic",
"uuid",
"returns",
"a",
"list",
"of",
"mods",
"uuids",
"."
] | 213180a6dbeb1608aed0e615f239ee7e7551539c | https://github.com/timwaters/nypl_repo/blob/213180a6dbeb1608aed0e615f239ee7e7551539c/lib/nypl_repo.rb#L44-L65 |
7,527 | timwaters/nypl_repo | lib/nypl_repo.rb | NyplRepo.Client.get_mods_item | def get_mods_item(mods_uuid)
url = "#{@server_url}/items/mods/#{mods_uuid}.json"
json = self.get_json(url)
item = nil
if json["nyplAPI"]["response"]["mods"]
item = json["nyplAPI"]["response"]["mods"]
end
return item
end | ruby | def get_mods_item(mods_uuid)
url = "#{@server_url}/items/mods/#{mods_uuid}.json"
json = self.get_json(url)
item = nil
if json["nyplAPI"]["response"]["mods"]
item = json["nyplAPI"]["response"]["mods"]
end
return item
end | [
"def",
"get_mods_item",
"(",
"mods_uuid",
")",
"url",
"=",
"\"#{@server_url}/items/mods/#{mods_uuid}.json\"",
"json",
"=",
"self",
".",
"get_json",
"(",
"url",
")",
"item",
"=",
"nil",
"if",
"json",
"[",
"\"nyplAPI\"",
"]",
"[",
"\"response\"",
"]",
"[",
"\"mo... | get the item detail from a uuid | [
"get",
"the",
"item",
"detail",
"from",
"a",
"uuid"
] | 213180a6dbeb1608aed0e615f239ee7e7551539c | https://github.com/timwaters/nypl_repo/blob/213180a6dbeb1608aed0e615f239ee7e7551539c/lib/nypl_repo.rb#L68-L78 |
7,528 | timwaters/nypl_repo | lib/nypl_repo.rb | NyplRepo.Client.get_bibl_uuid | def get_bibl_uuid(image_id)
url = "#{@server_url}/items/local_image_id/#{image_id}.json"
json = self.get_json(url)
bibl_uuid = nil
if json["nyplAPI"]["response"]["numResults"].to_i > 0
bibl_uuid = json["nyplAPI"]["response"]["uuid"]
end
return bibl_uuid
end | ruby | def get_bibl_uuid(image_id)
url = "#{@server_url}/items/local_image_id/#{image_id}.json"
json = self.get_json(url)
bibl_uuid = nil
if json["nyplAPI"]["response"]["numResults"].to_i > 0
bibl_uuid = json["nyplAPI"]["response"]["uuid"]
end
return bibl_uuid
end | [
"def",
"get_bibl_uuid",
"(",
"image_id",
")",
"url",
"=",
"\"#{@server_url}/items/local_image_id/#{image_id}.json\"",
"json",
"=",
"self",
".",
"get_json",
"(",
"url",
")",
"bibl_uuid",
"=",
"nil",
"if",
"json",
"[",
"\"nyplAPI\"",
"]",
"[",
"\"response\"",
"]",
... | get bibliographic container uuid from an image_id | [
"get",
"bibliographic",
"container",
"uuid",
"from",
"an",
"image_id"
] | 213180a6dbeb1608aed0e615f239ee7e7551539c | https://github.com/timwaters/nypl_repo/blob/213180a6dbeb1608aed0e615f239ee7e7551539c/lib/nypl_repo.rb#L117-L126 |
7,529 | timwaters/nypl_repo | lib/nypl_repo.rb | NyplRepo.Client.get_highreslink | def get_highreslink(bibl_uuid, image_id)
url = "#{@server_url}/items/#{bibl_uuid}.json?per_page=500"
json = self.get_json(url)
highreslink = nil
json["nyplAPI"]["response"]["capture"].each do | capture|
if capture["imageID"] == image_id
highreslink = capture["highResLin... | ruby | def get_highreslink(bibl_uuid, image_id)
url = "#{@server_url}/items/#{bibl_uuid}.json?per_page=500"
json = self.get_json(url)
highreslink = nil
json["nyplAPI"]["response"]["capture"].each do | capture|
if capture["imageID"] == image_id
highreslink = capture["highResLin... | [
"def",
"get_highreslink",
"(",
"bibl_uuid",
",",
"image_id",
")",
"url",
"=",
"\"#{@server_url}/items/#{bibl_uuid}.json?per_page=500\"",
"json",
"=",
"self",
".",
"get_json",
"(",
"url",
")",
"highreslink",
"=",
"nil",
"json",
"[",
"\"nyplAPI\"",
"]",
"[",
"\"resp... | get highreslink from an item, matching up the image idi
since some bibliographic items may have many maps under them | [
"get",
"highreslink",
"from",
"an",
"item",
"matching",
"up",
"the",
"image",
"idi",
"since",
"some",
"bibliographic",
"items",
"may",
"have",
"many",
"maps",
"under",
"them"
] | 213180a6dbeb1608aed0e615f239ee7e7551539c | https://github.com/timwaters/nypl_repo/blob/213180a6dbeb1608aed0e615f239ee7e7551539c/lib/nypl_repo.rb#L131-L145 |
7,530 | cordawyn/kalimba | lib/kalimba/attribute_assignment.rb | Kalimba.AttributeAssignment.assign_attributes | def assign_attributes(new_attributes = {}, options = {})
return if new_attributes.blank?
attributes = new_attributes.stringify_keys
multi_parameter_attributes = []
nested_parameter_attributes = []
attributes.each do |k, v|
if k.include?("(")
multi_parameter_attributes <... | ruby | def assign_attributes(new_attributes = {}, options = {})
return if new_attributes.blank?
attributes = new_attributes.stringify_keys
multi_parameter_attributes = []
nested_parameter_attributes = []
attributes.each do |k, v|
if k.include?("(")
multi_parameter_attributes <... | [
"def",
"assign_attributes",
"(",
"new_attributes",
"=",
"{",
"}",
",",
"options",
"=",
"{",
"}",
")",
"return",
"if",
"new_attributes",
".",
"blank?",
"attributes",
"=",
"new_attributes",
".",
"stringify_keys",
"multi_parameter_attributes",
"=",
"[",
"]",
"neste... | Assign attributes from the given hash
@param [Hash<[Symbol, String] => Any>] new_attributes
@param [Hash] options
@return [void] | [
"Assign",
"attributes",
"from",
"the",
"given",
"hash"
] | c1b29948744a66cadb643213785a9cdd4c07be83 | https://github.com/cordawyn/kalimba/blob/c1b29948744a66cadb643213785a9cdd4c07be83/lib/kalimba/attribute_assignment.rb#L8-L35 |
7,531 | forecastxl/twinfield-ruby | lib/twinfield/customer.rb | Twinfield.Customer.find_by_code | def find_by_code(code)
Twinfield::Process.new(@session).
request(:process_xml_document, get_dimension_xml(@company, 'DEB', { code: code })).
body[:process_xml_document_response][:process_xml_document_result][:dimension]
end | ruby | def find_by_code(code)
Twinfield::Process.new(@session).
request(:process_xml_document, get_dimension_xml(@company, 'DEB', { code: code })).
body[:process_xml_document_response][:process_xml_document_result][:dimension]
end | [
"def",
"find_by_code",
"(",
"code",
")",
"Twinfield",
"::",
"Process",
".",
"new",
"(",
"@session",
")",
".",
"request",
"(",
":process_xml_document",
",",
"get_dimension_xml",
"(",
"@company",
",",
"'DEB'",
",",
"{",
"code",
":",
"code",
"}",
")",
")",
... | Find customer by twinfield customer code | [
"Find",
"customer",
"by",
"twinfield",
"customer",
"code"
] | 90591ba1f11875c0f5b73c02a5ef5a88fef3ee45 | https://github.com/forecastxl/twinfield-ruby/blob/90591ba1f11875c0f5b73c02a5ef5a88fef3ee45/lib/twinfield/customer.rb#L19-L23 |
7,532 | forecastxl/twinfield-ruby | lib/twinfield/customer.rb | Twinfield.Customer.find_by_name | def find_by_name(name)
Twinfield::Finder.new(@session).
search(Twinfield::FinderSearch.new('DIM', name, 0, 1, 0, { office: @company, dimtype: 'DEB'} )).
body[:search_response][:data]
end | ruby | def find_by_name(name)
Twinfield::Finder.new(@session).
search(Twinfield::FinderSearch.new('DIM', name, 0, 1, 0, { office: @company, dimtype: 'DEB'} )).
body[:search_response][:data]
end | [
"def",
"find_by_name",
"(",
"name",
")",
"Twinfield",
"::",
"Finder",
".",
"new",
"(",
"@session",
")",
".",
"search",
"(",
"Twinfield",
"::",
"FinderSearch",
".",
"new",
"(",
"'DIM'",
",",
"name",
",",
"0",
",",
"1",
",",
"0",
",",
"{",
"office",
... | Find customer by name | [
"Find",
"customer",
"by",
"name"
] | 90591ba1f11875c0f5b73c02a5ef5a88fef3ee45 | https://github.com/forecastxl/twinfield-ruby/blob/90591ba1f11875c0f5b73c02a5ef5a88fef3ee45/lib/twinfield/customer.rb#L26-L30 |
7,533 | forecastxl/twinfield-ruby | lib/twinfield/customer.rb | Twinfield.Customer.get_dimension_xml | def get_dimension_xml(office, dimtype, opts = {})
xml = Builder::XmlMarkup.new
xml = xml.read do
xml.type('dimensions')
xml.office(office)
xml.dimtype(dimtype)
xml.code(opts.fetch(:code){})
end
end | ruby | def get_dimension_xml(office, dimtype, opts = {})
xml = Builder::XmlMarkup.new
xml = xml.read do
xml.type('dimensions')
xml.office(office)
xml.dimtype(dimtype)
xml.code(opts.fetch(:code){})
end
end | [
"def",
"get_dimension_xml",
"(",
"office",
",",
"dimtype",
",",
"opts",
"=",
"{",
"}",
")",
"xml",
"=",
"Builder",
"::",
"XmlMarkup",
".",
"new",
"xml",
"=",
"xml",
".",
"read",
"do",
"xml",
".",
"type",
"(",
"'dimensions'",
")",
"xml",
".",
"office"... | The request for getting all elements in a Twinfield dimension | [
"The",
"request",
"for",
"getting",
"all",
"elements",
"in",
"a",
"Twinfield",
"dimension"
] | 90591ba1f11875c0f5b73c02a5ef5a88fef3ee45 | https://github.com/forecastxl/twinfield-ruby/blob/90591ba1f11875c0f5b73c02a5ef5a88fef3ee45/lib/twinfield/customer.rb#L40-L49 |
7,534 | mirego/emotions | lib/emotions/emotional.rb | Emotions.Emotional.express! | def express!(emotion, emotive)
emotion = _emotions_about(emotive).where(emotion: emotion).first_or_initialize
begin
emotion.tap(&:save!)
rescue ActiveRecord::RecordInvalid => e
raise InvalidEmotion.new(e.record)
end
end | ruby | def express!(emotion, emotive)
emotion = _emotions_about(emotive).where(emotion: emotion).first_or_initialize
begin
emotion.tap(&:save!)
rescue ActiveRecord::RecordInvalid => e
raise InvalidEmotion.new(e.record)
end
end | [
"def",
"express!",
"(",
"emotion",
",",
"emotive",
")",
"emotion",
"=",
"_emotions_about",
"(",
"emotive",
")",
".",
"where",
"(",
"emotion",
":",
"emotion",
")",
".",
"first_or_initialize",
"begin",
"emotion",
".",
"tap",
"(",
":save!",
")",
"rescue",
"Ac... | Express an emotion towards another record
@example
user = User.first
picture = Picture.first
user.express! :happy, picture | [
"Express",
"an",
"emotion",
"towards",
"another",
"record"
] | f0adc687dbdac906d9fcebfb0f3bf6afb6fa5d56 | https://github.com/mirego/emotions/blob/f0adc687dbdac906d9fcebfb0f3bf6afb6fa5d56/lib/emotions/emotional.rb#L37-L45 |
7,535 | mirego/emotions | lib/emotions/emotional.rb | Emotions.Emotional.no_longer_express! | def no_longer_express!(emotion, emotive)
_emotions_about(emotive).where(emotion: emotion).first.tap { |e| e.try(:destroy) }
end | ruby | def no_longer_express!(emotion, emotive)
_emotions_about(emotive).where(emotion: emotion).first.tap { |e| e.try(:destroy) }
end | [
"def",
"no_longer_express!",
"(",
"emotion",
",",
"emotive",
")",
"_emotions_about",
"(",
"emotive",
")",
".",
"where",
"(",
"emotion",
":",
"emotion",
")",
".",
"first",
".",
"tap",
"{",
"|",
"e",
"|",
"e",
".",
"try",
"(",
":destroy",
")",
"}",
"en... | No longer express an emotion towards another record
@example
user = User.first
picture = Picture.first
user.no_longer_express! :happy, picture | [
"No",
"longer",
"express",
"an",
"emotion",
"towards",
"another",
"record"
] | f0adc687dbdac906d9fcebfb0f3bf6afb6fa5d56 | https://github.com/mirego/emotions/blob/f0adc687dbdac906d9fcebfb0f3bf6afb6fa5d56/lib/emotions/emotional.rb#L53-L55 |
7,536 | 26fe/tree.rb | lib/tree_rb/output_plugins/dircat/dircat_visitor.rb | TreeRb.DirCatVisitor.add_entry | def add_entry(e)
@entries.push(e)
if @md5_to_entries.has_key?(e.md5)
@md5_to_entries[e.md5].push(e)
else
@md5_to_entries[e.md5] = [e]
end
end | ruby | def add_entry(e)
@entries.push(e)
if @md5_to_entries.has_key?(e.md5)
@md5_to_entries[e.md5].push(e)
else
@md5_to_entries[e.md5] = [e]
end
end | [
"def",
"add_entry",
"(",
"e",
")",
"@entries",
".",
"push",
"(",
"e",
")",
"if",
"@md5_to_entries",
".",
"has_key?",
"(",
"e",
".",
"md5",
")",
"@md5_to_entries",
"[",
"e",
".",
"md5",
"]",
".",
"push",
"(",
"e",
")",
"else",
"@md5_to_entries",
"[",
... | add entry to this catalog
@private | [
"add",
"entry",
"to",
"this",
"catalog"
] | 5ecf0cfbbc439e27c72b9676d6a1ccee8e6bb02b | https://github.com/26fe/tree.rb/blob/5ecf0cfbbc439e27c72b9676d6a1ccee8e6bb02b/lib/tree_rb/output_plugins/dircat/dircat_visitor.rb#L35-L42 |
7,537 | holman/stars | lib/stars/services/favstar.rb | Stars.Favstar.parse_title | def parse_title(title)
strip = title.split(':').first
title = title.gsub(strip,'')
title = title[2..-1] if title[0..1] == ": "
title
end | ruby | def parse_title(title)
strip = title.split(':').first
title = title.gsub(strip,'')
title = title[2..-1] if title[0..1] == ": "
title
end | [
"def",
"parse_title",
"(",
"title",
")",
"strip",
"=",
"title",
".",
"split",
"(",
"':'",
")",
".",
"first",
"title",
"=",
"title",
".",
"gsub",
"(",
"strip",
",",
"''",
")",
"title",
"=",
"title",
"[",
"2",
"..",
"-",
"1",
"]",
"if",
"title",
... | Parse the title from a Favstar RSS title.
title - a Favstar-formatted String (x stars: title here)
This splits on the first colon, and then use everything after that. To
account for tweets with colons in them, we have to strip the first ": "
String we find, and then shift the String back two characters. | [
"Parse",
"the",
"title",
"from",
"a",
"Favstar",
"RSS",
"title",
"."
] | 4c12a7d2fa935fe746d263aad5208ed0630c0b1e | https://github.com/holman/stars/blob/4c12a7d2fa935fe746d263aad5208ed0630c0b1e/lib/stars/services/favstar.rb#L50-L55 |
7,538 | jemmyw/bisques | lib/bisques/client.rb | Bisques.Client.create_queue | def create_queue(name, attributes = {})
response = action("CreateQueue", {"QueueName" => Queue.sanitize_name("#{queue_prefix}#{name}")}.merge(attributes))
if response.success?
Queue.new(self, response.doc.xpath("//QueueUrl").text)
else
raise "Could not create queue #{name}"
end
... | ruby | def create_queue(name, attributes = {})
response = action("CreateQueue", {"QueueName" => Queue.sanitize_name("#{queue_prefix}#{name}")}.merge(attributes))
if response.success?
Queue.new(self, response.doc.xpath("//QueueUrl").text)
else
raise "Could not create queue #{name}"
end
... | [
"def",
"create_queue",
"(",
"name",
",",
"attributes",
"=",
"{",
"}",
")",
"response",
"=",
"action",
"(",
"\"CreateQueue\"",
",",
"{",
"\"QueueName\"",
"=>",
"Queue",
".",
"sanitize_name",
"(",
"\"#{queue_prefix}#{name}\"",
")",
"}",
".",
"merge",
"(",
"att... | Creates a new SQS queue and returns a Queue object.
@param [String] name
@param [Hash] attributes
@return [Queue]
@raise [AwsActionError] | [
"Creates",
"a",
"new",
"SQS",
"queue",
"and",
"returns",
"a",
"Queue",
"object",
"."
] | c48ab555f07664752bcbf9e8deb99bd75cbdc41b | https://github.com/jemmyw/bisques/blob/c48ab555f07664752bcbf9e8deb99bd75cbdc41b/lib/bisques/client.rb#L52-L67 |
7,539 | jemmyw/bisques | lib/bisques/client.rb | Bisques.Client.get_queue | def get_queue(name, options = {})
response = action("GetQueueUrl", {"QueueName" => Queue.sanitize_name("#{queue_prefix}#{name}")}.merge(options))
if response.success?
Queue.new(self, response.doc.xpath("//QueueUrl").text)
end
rescue Bisques::AwsActionError => e
raise unless e... | ruby | def get_queue(name, options = {})
response = action("GetQueueUrl", {"QueueName" => Queue.sanitize_name("#{queue_prefix}#{name}")}.merge(options))
if response.success?
Queue.new(self, response.doc.xpath("//QueueUrl").text)
end
rescue Bisques::AwsActionError => e
raise unless e... | [
"def",
"get_queue",
"(",
"name",
",",
"options",
"=",
"{",
"}",
")",
"response",
"=",
"action",
"(",
"\"GetQueueUrl\"",
",",
"{",
"\"QueueName\"",
"=>",
"Queue",
".",
"sanitize_name",
"(",
"\"#{queue_prefix}#{name}\"",
")",
"}",
".",
"merge",
"(",
"options",... | Get an SQS queue by name.
@param [String] name
@param [Hash] options
@return [Queue,nil] Returns a Queue object if the queue is found, otherwise nil.
@raise [AwsActionError] | [
"Get",
"an",
"SQS",
"queue",
"by",
"name",
"."
] | c48ab555f07664752bcbf9e8deb99bd75cbdc41b | https://github.com/jemmyw/bisques/blob/c48ab555f07664752bcbf9e8deb99bd75cbdc41b/lib/bisques/client.rb#L82-L91 |
7,540 | jemmyw/bisques | lib/bisques/client.rb | Bisques.Client.list_queues | def list_queues(prefix = "")
response = action("ListQueues", "QueueNamePrefix" => "#{queue_prefix}#{prefix}")
response.doc.xpath("//ListQueuesResult/QueueUrl").map(&:text).map do |url|
Queue.new(self, url)
end
end | ruby | def list_queues(prefix = "")
response = action("ListQueues", "QueueNamePrefix" => "#{queue_prefix}#{prefix}")
response.doc.xpath("//ListQueuesResult/QueueUrl").map(&:text).map do |url|
Queue.new(self, url)
end
end | [
"def",
"list_queues",
"(",
"prefix",
"=",
"\"\"",
")",
"response",
"=",
"action",
"(",
"\"ListQueues\"",
",",
"\"QueueNamePrefix\"",
"=>",
"\"#{queue_prefix}#{prefix}\"",
")",
"response",
".",
"doc",
".",
"xpath",
"(",
"\"//ListQueuesResult/QueueUrl\"",
")",
".",
... | Return an array of Queue objects representing the queues found in SQS. An
optional prefix can be supplied to restrict the queues found. This prefix
is additional to the client prefix.
@param [String] prefix option prefix to restrict the queues found.
@return [Array<Queue>] queue objects found.
@raise [AwsActionEr... | [
"Return",
"an",
"array",
"of",
"Queue",
"objects",
"representing",
"the",
"queues",
"found",
"in",
"SQS",
".",
"An",
"optional",
"prefix",
"can",
"be",
"supplied",
"to",
"restrict",
"the",
"queues",
"found",
".",
"This",
"prefix",
"is",
"additional",
"to",
... | c48ab555f07664752bcbf9e8deb99bd75cbdc41b | https://github.com/jemmyw/bisques/blob/c48ab555f07664752bcbf9e8deb99bd75cbdc41b/lib/bisques/client.rb#L107-L112 |
7,541 | jemmyw/bisques | lib/bisques/client.rb | Bisques.Client.send_message | def send_message(queue_url, message_body, delay_seconds=nil)
options = {"MessageBody" => message_body}
options["DelaySeconds"] = delay_seconds if delay_seconds
tries = 0
md5 = Digest::MD5.hexdigest(message_body)
begin
tries += 1
response = action("SendMessage", queue_url,... | ruby | def send_message(queue_url, message_body, delay_seconds=nil)
options = {"MessageBody" => message_body}
options["DelaySeconds"] = delay_seconds if delay_seconds
tries = 0
md5 = Digest::MD5.hexdigest(message_body)
begin
tries += 1
response = action("SendMessage", queue_url,... | [
"def",
"send_message",
"(",
"queue_url",
",",
"message_body",
",",
"delay_seconds",
"=",
"nil",
")",
"options",
"=",
"{",
"\"MessageBody\"",
"=>",
"message_body",
"}",
"options",
"[",
"\"DelaySeconds\"",
"]",
"=",
"delay_seconds",
"if",
"delay_seconds",
"tries",
... | Put a message on a queue. Takes the queue url and the message body, which
should be a string. An optional delay seconds argument can be added if
the message should not become visible immediately.
@param [String] queue_url
@param [String] message_body
@param [Fixnum] delay_seconds
@return nil
@raise [MessageHasW... | [
"Put",
"a",
"message",
"on",
"a",
"queue",
".",
"Takes",
"the",
"queue",
"url",
"and",
"the",
"message",
"body",
"which",
"should",
"be",
"a",
"string",
".",
"An",
"optional",
"delay",
"seconds",
"argument",
"can",
"be",
"added",
"if",
"the",
"message",
... | c48ab555f07664752bcbf9e8deb99bd75cbdc41b | https://github.com/jemmyw/bisques/blob/c48ab555f07664752bcbf9e8deb99bd75cbdc41b/lib/bisques/client.rb#L146-L166 |
7,542 | ntalbott/mupnp | lib/UPnP.rb | UPnP.UPnP.externalIP | def externalIP()
joinThread()
external_ip = getCString()
r = MiniUPnP.UPNP_GetExternalIPAddress(@urls.controlURL,
@data.servicetype,external_ip)
if r != 0 then
raise UPnPException.new, "Error while retriving the external ip ... | ruby | def externalIP()
joinThread()
external_ip = getCString()
r = MiniUPnP.UPNP_GetExternalIPAddress(@urls.controlURL,
@data.servicetype,external_ip)
if r != 0 then
raise UPnPException.new, "Error while retriving the external ip ... | [
"def",
"externalIP",
"(",
")",
"joinThread",
"(",
")",
"external_ip",
"=",
"getCString",
"(",
")",
"r",
"=",
"MiniUPnP",
".",
"UPNP_GetExternalIPAddress",
"(",
"@urls",
".",
"controlURL",
",",
"@data",
".",
"servicetype",
",",
"external_ip",
")",
"if",
"r",
... | Returns the external network ip | [
"Returns",
"the",
"external",
"network",
"ip"
] | c3c566cd2d7c9ecf1cb2baff253d116be163384d | https://github.com/ntalbott/mupnp/blob/c3c566cd2d7c9ecf1cb2baff253d116be163384d/lib/UPnP.rb#L154-L163 |
7,543 | ntalbott/mupnp | lib/UPnP.rb | UPnP.UPnP.status | def status()
joinThread()
lastconnerror = getCString()
status = getCString()
uptime = 0
begin
uptime_uint = MiniUPnP.new_uintp()
r = MiniUPnP.UPNP_GetStatusInfo(@urls.controlURL,
@data.servicetype, sta... | ruby | def status()
joinThread()
lastconnerror = getCString()
status = getCString()
uptime = 0
begin
uptime_uint = MiniUPnP.new_uintp()
r = MiniUPnP.UPNP_GetStatusInfo(@urls.controlURL,
@data.servicetype, sta... | [
"def",
"status",
"(",
")",
"joinThread",
"(",
")",
"lastconnerror",
"=",
"getCString",
"(",
")",
"status",
"=",
"getCString",
"(",
")",
"uptime",
"=",
"0",
"begin",
"uptime_uint",
"=",
"MiniUPnP",
".",
"new_uintp",
"(",
")",
"r",
"=",
"MiniUPnP",
".",
... | Returns the status of the router which is an array of 3 elements.
Connection status, Last error, Uptime. | [
"Returns",
"the",
"status",
"of",
"the",
"router",
"which",
"is",
"an",
"array",
"of",
"3",
"elements",
".",
"Connection",
"status",
"Last",
"error",
"Uptime",
"."
] | c3c566cd2d7c9ecf1cb2baff253d116be163384d | https://github.com/ntalbott/mupnp/blob/c3c566cd2d7c9ecf1cb2baff253d116be163384d/lib/UPnP.rb#L173-L193 |
7,544 | ntalbott/mupnp | lib/UPnP.rb | UPnP.UPnP.connectionType | def connectionType()
joinThread()
type = getCString()
if MiniUPnP.UPNP_GetConnectionTypeInfo(@urls.controlURL,
@data.servicetype,type) != 0 then
raise UPnPException.new, "Error while retriving connection info."
end
type.r... | ruby | def connectionType()
joinThread()
type = getCString()
if MiniUPnP.UPNP_GetConnectionTypeInfo(@urls.controlURL,
@data.servicetype,type) != 0 then
raise UPnPException.new, "Error while retriving connection info."
end
type.r... | [
"def",
"connectionType",
"(",
")",
"joinThread",
"(",
")",
"type",
"=",
"getCString",
"(",
")",
"if",
"MiniUPnP",
".",
"UPNP_GetConnectionTypeInfo",
"(",
"@urls",
".",
"controlURL",
",",
"@data",
".",
"servicetype",
",",
"type",
")",
"!=",
"0",
"then",
"ra... | Router connection information | [
"Router",
"connection",
"information"
] | c3c566cd2d7c9ecf1cb2baff253d116be163384d | https://github.com/ntalbott/mupnp/blob/c3c566cd2d7c9ecf1cb2baff253d116be163384d/lib/UPnP.rb#L196-L204 |
7,545 | ntalbott/mupnp | lib/UPnP.rb | UPnP.UPnP.totalBytesSent | def totalBytesSent()
joinThread()
v = MiniUPnP.UPNP_GetTotalBytesSent(@urls.controlURL_CIF,
@data.servicetype_CIF)
if v < 0 then
raise UPnPException.new, "Error while retriving total bytes sent."
end
return v
end | ruby | def totalBytesSent()
joinThread()
v = MiniUPnP.UPNP_GetTotalBytesSent(@urls.controlURL_CIF,
@data.servicetype_CIF)
if v < 0 then
raise UPnPException.new, "Error while retriving total bytes sent."
end
return v
end | [
"def",
"totalBytesSent",
"(",
")",
"joinThread",
"(",
")",
"v",
"=",
"MiniUPnP",
".",
"UPNP_GetTotalBytesSent",
"(",
"@urls",
".",
"controlURL_CIF",
",",
"@data",
".",
"servicetype_CIF",
")",
"if",
"v",
"<",
"0",
"then",
"raise",
"UPnPException",
".",
"new",... | Total bytes sent from the router to external network | [
"Total",
"bytes",
"sent",
"from",
"the",
"router",
"to",
"external",
"network"
] | c3c566cd2d7c9ecf1cb2baff253d116be163384d | https://github.com/ntalbott/mupnp/blob/c3c566cd2d7c9ecf1cb2baff253d116be163384d/lib/UPnP.rb#L207-L215 |
7,546 | ntalbott/mupnp | lib/UPnP.rb | UPnP.UPnP.totalBytesReceived | def totalBytesReceived()
joinThread()
v = MiniUPnP.UPNP_GetTotalBytesReceived(@urls.controlURL_CIF,
@data.servicetype_CIF)
if v < 0 then
raise UPnPException.new, "Error while retriving total bytes received."
end
return v... | ruby | def totalBytesReceived()
joinThread()
v = MiniUPnP.UPNP_GetTotalBytesReceived(@urls.controlURL_CIF,
@data.servicetype_CIF)
if v < 0 then
raise UPnPException.new, "Error while retriving total bytes received."
end
return v... | [
"def",
"totalBytesReceived",
"(",
")",
"joinThread",
"(",
")",
"v",
"=",
"MiniUPnP",
".",
"UPNP_GetTotalBytesReceived",
"(",
"@urls",
".",
"controlURL_CIF",
",",
"@data",
".",
"servicetype_CIF",
")",
"if",
"v",
"<",
"0",
"then",
"raise",
"UPnPException",
".",
... | Total bytes received from the external network. | [
"Total",
"bytes",
"received",
"from",
"the",
"external",
"network",
"."
] | c3c566cd2d7c9ecf1cb2baff253d116be163384d | https://github.com/ntalbott/mupnp/blob/c3c566cd2d7c9ecf1cb2baff253d116be163384d/lib/UPnP.rb#L218-L226 |
7,547 | ntalbott/mupnp | lib/UPnP.rb | UPnP.UPnP.totalPacketsSent | def totalPacketsSent()
joinThread()
v = MiniUPnP.UPNP_GetTotalPacketsSent(@urls.controlURL_CIF,
@data.servicetype_CIF);
if v < 0 then
raise UPnPException.new, "Error while retriving total packets sent."
end
return v
... | ruby | def totalPacketsSent()
joinThread()
v = MiniUPnP.UPNP_GetTotalPacketsSent(@urls.controlURL_CIF,
@data.servicetype_CIF);
if v < 0 then
raise UPnPException.new, "Error while retriving total packets sent."
end
return v
... | [
"def",
"totalPacketsSent",
"(",
")",
"joinThread",
"(",
")",
"v",
"=",
"MiniUPnP",
".",
"UPNP_GetTotalPacketsSent",
"(",
"@urls",
".",
"controlURL_CIF",
",",
"@data",
".",
"servicetype_CIF",
")",
";",
"if",
"v",
"<",
"0",
"then",
"raise",
"UPnPException",
".... | Total packets sent from the router to the external network. | [
"Total",
"packets",
"sent",
"from",
"the",
"router",
"to",
"the",
"external",
"network",
"."
] | c3c566cd2d7c9ecf1cb2baff253d116be163384d | https://github.com/ntalbott/mupnp/blob/c3c566cd2d7c9ecf1cb2baff253d116be163384d/lib/UPnP.rb#L229-L237 |
7,548 | ntalbott/mupnp | lib/UPnP.rb | UPnP.UPnP.portMappings | def portMappings()
joinThread()
i, r = 0, 0
mappings = Array.new
while r == 0
rhost = getCString()
enabled = getCString()
duration = getCString()
description = getCString()
nport = getCStrin... | ruby | def portMappings()
joinThread()
i, r = 0, 0
mappings = Array.new
while r == 0
rhost = getCString()
enabled = getCString()
duration = getCString()
description = getCString()
nport = getCStrin... | [
"def",
"portMappings",
"(",
")",
"joinThread",
"(",
")",
"i",
",",
"r",
"=",
"0",
",",
"0",
"mappings",
"=",
"Array",
".",
"new",
"while",
"r",
"==",
"0",
"rhost",
"=",
"getCString",
"(",
")",
"enabled",
"=",
"getCString",
"(",
")",
"duration",
"="... | An array of mappings registered on the router | [
"An",
"array",
"of",
"mappings",
"registered",
"on",
"the",
"router"
] | c3c566cd2d7c9ecf1cb2baff253d116be163384d | https://github.com/ntalbott/mupnp/blob/c3c566cd2d7c9ecf1cb2baff253d116be163384d/lib/UPnP.rb#L275-L303 |
7,549 | ntalbott/mupnp | lib/UPnP.rb | UPnP.UPnP.portMapping | def portMapping(nport,proto)
checkProto(proto)
checkPort(nport)
if nport.to_i == 0 then
raise ArgumentError, "Port must be an int value and greater then 0."
end
joinThread()
client = getCString()
lport = getCString()
... | ruby | def portMapping(nport,proto)
checkProto(proto)
checkPort(nport)
if nport.to_i == 0 then
raise ArgumentError, "Port must be an int value and greater then 0."
end
joinThread()
client = getCString()
lport = getCString()
... | [
"def",
"portMapping",
"(",
"nport",
",",
"proto",
")",
"checkProto",
"(",
"proto",
")",
"checkPort",
"(",
"nport",
")",
"if",
"nport",
".",
"to_i",
"==",
"0",
"then",
"raise",
"ArgumentError",
",",
"\"Port must be an int value and greater then 0.\"",
"end",
"joi... | Get the mapping registered for a specific port and protocol | [
"Get",
"the",
"mapping",
"registered",
"for",
"a",
"specific",
"port",
"and",
"protocol"
] | c3c566cd2d7c9ecf1cb2baff253d116be163384d | https://github.com/ntalbott/mupnp/blob/c3c566cd2d7c9ecf1cb2baff253d116be163384d/lib/UPnP.rb#L306-L321 |
7,550 | ntalbott/mupnp | lib/UPnP.rb | UPnP.UPnP.deletePortMapping | def deletePortMapping(nport,proto)
checkProto(proto)
checkPort(nport)
joinThread()
r = MiniUPnP.UPNP_DeletePortMapping(@urls.controlURL,@data.servicetype,
nport.to_s,proto)
if r != 0 then
raise UPn... | ruby | def deletePortMapping(nport,proto)
checkProto(proto)
checkPort(nport)
joinThread()
r = MiniUPnP.UPNP_DeletePortMapping(@urls.controlURL,@data.servicetype,
nport.to_s,proto)
if r != 0 then
raise UPn... | [
"def",
"deletePortMapping",
"(",
"nport",
",",
"proto",
")",
"checkProto",
"(",
"proto",
")",
"checkPort",
"(",
"nport",
")",
"joinThread",
"(",
")",
"r",
"=",
"MiniUPnP",
".",
"UPNP_DeletePortMapping",
"(",
"@urls",
".",
"controlURL",
",",
"@data",
".",
"... | Delete the port mapping for specified network port and protocol | [
"Delete",
"the",
"port",
"mapping",
"for",
"specified",
"network",
"port",
"and",
"protocol"
] | c3c566cd2d7c9ecf1cb2baff253d116be163384d | https://github.com/ntalbott/mupnp/blob/c3c566cd2d7c9ecf1cb2baff253d116be163384d/lib/UPnP.rb#L341-L350 |
7,551 | ntalbott/mupnp | lib/UPnP.rb | UPnP.UPnP.checkProto | def checkProto(proto)
if proto != Protocol::UDP && proto != Protocol::TCP then
raise ArgumentError, "Unknown protocol #{proto}, only Protocol::TCP and Protocol::UDP are valid."
end
end | ruby | def checkProto(proto)
if proto != Protocol::UDP && proto != Protocol::TCP then
raise ArgumentError, "Unknown protocol #{proto}, only Protocol::TCP and Protocol::UDP are valid."
end
end | [
"def",
"checkProto",
"(",
"proto",
")",
"if",
"proto",
"!=",
"Protocol",
"::",
"UDP",
"&&",
"proto",
"!=",
"Protocol",
"::",
"TCP",
"then",
"raise",
"ArgumentError",
",",
"\"Unknown protocol #{proto}, only Protocol::TCP and Protocol::UDP are valid.\"",
"end",
"end"
] | Check that the protocol is a correct value | [
"Check",
"that",
"the",
"protocol",
"is",
"a",
"correct",
"value"
] | c3c566cd2d7c9ecf1cb2baff253d116be163384d | https://github.com/ntalbott/mupnp/blob/c3c566cd2d7c9ecf1cb2baff253d116be163384d/lib/UPnP.rb#L367-L371 |
7,552 | bilus/akasha | lib/akasha/command_router.rb | Akasha.CommandRouter.register | def register(command, aggregate_class = nil, &block)
raise ArgumentError, 'Pass either aggregate class or block' if aggregate_class && block
handler = aggregate_class || block
@routes[command] = handler
end | ruby | def register(command, aggregate_class = nil, &block)
raise ArgumentError, 'Pass either aggregate class or block' if aggregate_class && block
handler = aggregate_class || block
@routes[command] = handler
end | [
"def",
"register",
"(",
"command",
",",
"aggregate_class",
"=",
"nil",
",",
"&",
"block",
")",
"raise",
"ArgumentError",
",",
"'Pass either aggregate class or block'",
"if",
"aggregate_class",
"&&",
"block",
"handler",
"=",
"aggregate_class",
"||",
"block",
"@routes... | Registers a handler.
As a result, when `#route!` is called for that command, the aggregate will be
loaded from repository, the command will be sent to the object to invoke the
object's method, and finally the aggregate will be saved. | [
"Registers",
"a",
"handler",
"."
] | 5fadefc249f520ae909b762956ac23a6f916b021 | https://github.com/bilus/akasha/blob/5fadefc249f520ae909b762956ac23a6f916b021/lib/akasha/command_router.rb#L18-L22 |
7,553 | bilus/akasha | lib/akasha/command_router.rb | Akasha.CommandRouter.route! | def route!(command, aggregate_id, options = {}, **data)
handler = @routes[command]
case handler
when Class
transactor = options.fetch(:transactor, default_transactor)
transactor.call(handler, command, aggregate_id, options, **data)
when handler.respond_to?(:call)
handler.... | ruby | def route!(command, aggregate_id, options = {}, **data)
handler = @routes[command]
case handler
when Class
transactor = options.fetch(:transactor, default_transactor)
transactor.call(handler, command, aggregate_id, options, **data)
when handler.respond_to?(:call)
handler.... | [
"def",
"route!",
"(",
"command",
",",
"aggregate_id",
",",
"options",
"=",
"{",
"}",
",",
"**",
"data",
")",
"handler",
"=",
"@routes",
"[",
"command",
"]",
"case",
"handler",
"when",
"Class",
"transactor",
"=",
"options",
".",
"fetch",
"(",
":transactor... | Routes a command to the registered target.
Raises `NotFoundError` if no corresponding target can be found.
Arguments:
- command - name of the command
- aggregate_id - aggregate id
- options - flags:
- transactor - transactor instance to replace the default one (`OptimisticTransactor`);
See docs for ... | [
"Routes",
"a",
"command",
"to",
"the",
"registered",
"target",
".",
"Raises",
"NotFoundError",
"if",
"no",
"corresponding",
"target",
"can",
"be",
"found",
"."
] | 5fadefc249f520ae909b762956ac23a6f916b021 | https://github.com/bilus/akasha/blob/5fadefc249f520ae909b762956ac23a6f916b021/lib/akasha/command_router.rb#L33-L48 |
7,554 | emancu/ork | lib/ork/model/class_methods.rb | Ork::Model.ClassMethods.attribute | def attribute(name, options = {})
attributes << name unless attributes.include?(name)
defaults[name] = options[:default] if options.has_key?(:default)
if options.has_key?(:accessors)
to_define = Array(options[:accessors]) & accessor_options
else # Default methods
to_define = [:r... | ruby | def attribute(name, options = {})
attributes << name unless attributes.include?(name)
defaults[name] = options[:default] if options.has_key?(:default)
if options.has_key?(:accessors)
to_define = Array(options[:accessors]) & accessor_options
else # Default methods
to_define = [:r... | [
"def",
"attribute",
"(",
"name",
",",
"options",
"=",
"{",
"}",
")",
"attributes",
"<<",
"name",
"unless",
"attributes",
".",
"include?",
"(",
"name",
")",
"defaults",
"[",
"name",
"]",
"=",
"options",
"[",
":default",
"]",
"if",
"options",
".",
"has_k... | Declares persisted attributes.
All attributes are stored on the Riak hash.
Example:
class User
include Ork::Document
attribute :name
end
# It's the same as:
class User
include Ork::Document
def name
@attributes[:name]
end
def name=(name)
@attributes[:name]... | [
"Declares",
"persisted",
"attributes",
".",
"All",
"attributes",
"are",
"stored",
"on",
"the",
"Riak",
"hash",
"."
] | 83b2deaef0e790d90f98c031f254b5f438b19edf | https://github.com/emancu/ork/blob/83b2deaef0e790d90f98c031f254b5f438b19edf/lib/ork/model/class_methods.rb#L83-L94 |
7,555 | emancu/ork | lib/ork/model/class_methods.rb | Ork::Model.ClassMethods.index | def index(name)
indices[name] = Index.new(name) unless indices.include?(name)
end | ruby | def index(name)
indices[name] = Index.new(name) unless indices.include?(name)
end | [
"def",
"index",
"(",
"name",
")",
"indices",
"[",
"name",
"]",
"=",
"Index",
".",
"new",
"(",
"name",
")",
"unless",
"indices",
".",
"include?",
"(",
"name",
")",
"end"
] | Index any attribute on your model. Once you index an attribute,
you can use it in `find` statements. | [
"Index",
"any",
"attribute",
"on",
"your",
"model",
".",
"Once",
"you",
"index",
"an",
"attribute",
"you",
"can",
"use",
"it",
"in",
"find",
"statements",
"."
] | 83b2deaef0e790d90f98c031f254b5f438b19edf | https://github.com/emancu/ork/blob/83b2deaef0e790d90f98c031f254b5f438b19edf/lib/ork/model/class_methods.rb#L99-L101 |
7,556 | gzigzigzeo/stateful_link | lib/stateful_link/action_any_of.rb | StatefulLink.ActionAnyOf.action_any_of? | def action_any_of?(*actions)
actions.any? do |sub_ca|
if sub_ca.present?
sub_controller, sub_action = extract_controller_and_action(sub_ca)
((self.controller_path == sub_controller) || (sub_controller.blank?)) && (self.action_name == sub_action || (sub_action == '' || sub_action == '*'... | ruby | def action_any_of?(*actions)
actions.any? do |sub_ca|
if sub_ca.present?
sub_controller, sub_action = extract_controller_and_action(sub_ca)
((self.controller_path == sub_controller) || (sub_controller.blank?)) && (self.action_name == sub_action || (sub_action == '' || sub_action == '*'... | [
"def",
"action_any_of?",
"(",
"*",
"actions",
")",
"actions",
".",
"any?",
"do",
"|",
"sub_ca",
"|",
"if",
"sub_ca",
".",
"present?",
"sub_controller",
",",
"sub_action",
"=",
"extract_controller_and_action",
"(",
"sub_ca",
")",
"(",
"(",
"self",
".",
"contr... | Returns true if current controller and action names equals to any of passed.
Asterik as action name matches all controller's action.
Examples:
<%= "we are in PostsController::index" if action_any_of?("posts#index") %>
<%= "we are not in PostsController::index" unless action_any_of?("posts#index") %>
<% if... | [
"Returns",
"true",
"if",
"current",
"controller",
"and",
"action",
"names",
"equals",
"to",
"any",
"of",
"passed",
".",
"Asterik",
"as",
"action",
"name",
"matches",
"all",
"controller",
"s",
"action",
"."
] | e9073fcb3523bb15e17cc1bf40ca813dd0fd7659 | https://github.com/gzigzigzeo/stateful_link/blob/e9073fcb3523bb15e17cc1bf40ca813dd0fd7659/lib/stateful_link/action_any_of.rb#L21-L28 |
7,557 | gzigzigzeo/stateful_link | lib/stateful_link/action_any_of.rb | StatefulLink.ActionAnyOf.extract_controller_and_action | def extract_controller_and_action(ca)
raise ArgumentError, "Pass the string" if ca.nil?
slash_pos = ca.rindex('#')
raise ArgumentError, "Invalid action: #{ca}" if slash_pos.nil?
controller = ca[0, slash_pos]
action = ca[slash_pos+1..-1] || ""
raise ArgumentError, "Invalid action or c... | ruby | def extract_controller_and_action(ca)
raise ArgumentError, "Pass the string" if ca.nil?
slash_pos = ca.rindex('#')
raise ArgumentError, "Invalid action: #{ca}" if slash_pos.nil?
controller = ca[0, slash_pos]
action = ca[slash_pos+1..-1] || ""
raise ArgumentError, "Invalid action or c... | [
"def",
"extract_controller_and_action",
"(",
"ca",
")",
"raise",
"ArgumentError",
",",
"\"Pass the string\"",
"if",
"ca",
".",
"nil?",
"slash_pos",
"=",
"ca",
".",
"rindex",
"(",
"'#'",
")",
"raise",
"ArgumentError",
",",
"\"Invalid action: #{ca}\"",
"if",
"slash_... | Extracts controller and action names from a string.
Examples:
extract_controller_and_action("posts#index") # ["posts", "index"]
extract_controller_and_action("admin/posts#index") # ["admin/posts", "index"]
extract_controller_and_action("admin/posts#index") # raises ArgumentError | [
"Extracts",
"controller",
"and",
"action",
"names",
"from",
"a",
"string",
"."
] | e9073fcb3523bb15e17cc1bf40ca813dd0fd7659 | https://github.com/gzigzigzeo/stateful_link/blob/e9073fcb3523bb15e17cc1bf40ca813dd0fd7659/lib/stateful_link/action_any_of.rb#L38-L47 |
7,558 | bumi/validation_rage | lib/validation_rage/fnord_metric_notifier.rb | ValidationRage.FnordMetricNotifier.call | def call(event_name, payload)
return unless data_present?(payload)
# global validation error event
self.fnord.event({
:_type => event_name,
:payload => payload
})
# class level validation error event
self.fnord.event({
:_type => "validation_rage_error.#{paylo... | ruby | def call(event_name, payload)
return unless data_present?(payload)
# global validation error event
self.fnord.event({
:_type => event_name,
:payload => payload
})
# class level validation error event
self.fnord.event({
:_type => "validation_rage_error.#{paylo... | [
"def",
"call",
"(",
"event_name",
",",
"payload",
")",
"return",
"unless",
"data_present?",
"(",
"payload",
")",
"# global validation error event",
"self",
".",
"fnord",
".",
"event",
"(",
"{",
":_type",
"=>",
"event_name",
",",
":payload",
"=>",
"payload",
"}... | I guess this is toooooo sloooow but anyhow let's play with it | [
"I",
"guess",
"this",
"is",
"toooooo",
"sloooow",
"but",
"anyhow",
"let",
"s",
"play",
"with",
"it"
] | 0680444bac70e1d9ab42a7b421a09e8ba9d0d7c6 | https://github.com/bumi/validation_rage/blob/0680444bac70e1d9ab42a7b421a09e8ba9d0d7c6/lib/validation_rage/fnord_metric_notifier.rb#L11-L32 |
7,559 | vidibus/vidibus-tempfile | lib/vidibus/tempfile.rb | Vidibus.Tempfile.make_tmpname | def make_tmpname(basename, n)
extension = File.extname(basename)
sprintf("%s,%d,%d%s", File.basename(basename, extension), $$, n.to_i, extension)
end | ruby | def make_tmpname(basename, n)
extension = File.extname(basename)
sprintf("%s,%d,%d%s", File.basename(basename, extension), $$, n.to_i, extension)
end | [
"def",
"make_tmpname",
"(",
"basename",
",",
"n",
")",
"extension",
"=",
"File",
".",
"extname",
"(",
"basename",
")",
"sprintf",
"(",
"\"%s,%d,%d%s\"",
",",
"File",
".",
"basename",
"(",
"basename",
",",
"extension",
")",
",",
"$$",
",",
"n",
".",
"to... | Replaces Tempfile's +make_tmpname+ with one that honors file extensions.
Copied from Paperclip | [
"Replaces",
"Tempfile",
"s",
"+",
"make_tmpname",
"+",
"with",
"one",
"that",
"honors",
"file",
"extensions",
".",
"Copied",
"from",
"Paperclip"
] | 3c06359ccb28cfc36a4dfcbb856d257a18df7c95 | https://github.com/vidibus/vidibus-tempfile/blob/3c06359ccb28cfc36a4dfcbb856d257a18df7c95/lib/vidibus/tempfile.rb#L34-L37 |
7,560 | kennon/litmos-client | lib/litmos_client.rb | LitmosClient.API.get | def get(path, params={})
dont_parse_response = params.delete(:dont_parse_response)
options = {
:content_type => :json,
:accept => :json,
:params => params.merge(:apikey => @api_key, :source => @source)
}
RestClient.get("#{@litmosURL}/#{path}", options) do |response, r... | ruby | def get(path, params={})
dont_parse_response = params.delete(:dont_parse_response)
options = {
:content_type => :json,
:accept => :json,
:params => params.merge(:apikey => @api_key, :source => @source)
}
RestClient.get("#{@litmosURL}/#{path}", options) do |response, r... | [
"def",
"get",
"(",
"path",
",",
"params",
"=",
"{",
"}",
")",
"dont_parse_response",
"=",
"params",
".",
"delete",
"(",
":dont_parse_response",
")",
"options",
"=",
"{",
":content_type",
"=>",
":json",
",",
":accept",
"=>",
":json",
",",
":params",
"=>",
... | Initialize with an API key and config options | [
"Initialize",
"with",
"an",
"API",
"key",
"and",
"config",
"options"
] | 376008a961ee33543853790a0172c571b31d81f1 | https://github.com/kennon/litmos-client/blob/376008a961ee33543853790a0172c571b31d81f1/lib/litmos_client.rb#L36-L70 |
7,561 | kencrocken/dcmetro | lib/dcmetro.rb | DCMetro.Information.station_time | def station_time(station)
# If a station has multiple stations codes we join the codes together
@station_code = station['Code']
if !station['StationTogether1'].empty?
@station_code += ",#{station['StationTogether1']}"
end
if !station['StationTogether2'].empty?
@station_cod... | ruby | def station_time(station)
# If a station has multiple stations codes we join the codes together
@station_code = station['Code']
if !station['StationTogether1'].empty?
@station_code += ",#{station['StationTogether1']}"
end
if !station['StationTogether2'].empty?
@station_cod... | [
"def",
"station_time",
"(",
"station",
")",
"# If a station has multiple stations codes we join the codes together",
"@station_code",
"=",
"station",
"[",
"'Code'",
"]",
"if",
"!",
"station",
"[",
"'StationTogether1'",
"]",
".",
"empty?",
"@station_code",
"+=",
"\",#{stat... | This makes an api call to grab the train arrival and departure predictions.
If more than one line is present at a station, such is concatenated and
the call is made on all lines. | [
"This",
"makes",
"an",
"api",
"call",
"to",
"grab",
"the",
"train",
"arrival",
"and",
"departure",
"predictions",
".",
"If",
"more",
"than",
"one",
"line",
"is",
"present",
"at",
"a",
"station",
"such",
"is",
"concatenated",
"and",
"the",
"call",
"is",
"... | 9fecdea1e619da4828ae7b94c156ce705c2975fc | https://github.com/kencrocken/dcmetro/blob/9fecdea1e619da4828ae7b94c156ce705c2975fc/lib/dcmetro.rb#L168-L185 |
7,562 | gnumarcelo/campaigning | lib/campaigning/template.rb | Campaigning.Template.update! | def update!(params)
response = @@soap.updateTemplate(
:apiKey => params[:apiKey] || CAMPAIGN_MONITOR_API_KEY,
:templateID => @templateID,
:templateName => params[:templateName],
:hTMLPageURL => params[:htmlPageURL],
:zipFileURL => params[:zipFileURL],
:screenshotUR... | ruby | def update!(params)
response = @@soap.updateTemplate(
:apiKey => params[:apiKey] || CAMPAIGN_MONITOR_API_KEY,
:templateID => @templateID,
:templateName => params[:templateName],
:hTMLPageURL => params[:htmlPageURL],
:zipFileURL => params[:zipFileURL],
:screenshotUR... | [
"def",
"update!",
"(",
"params",
")",
"response",
"=",
"@@soap",
".",
"updateTemplate",
"(",
":apiKey",
"=>",
"params",
"[",
":apiKey",
"]",
"||",
"CAMPAIGN_MONITOR_API_KEY",
",",
":templateID",
"=>",
"@templateID",
",",
":templateName",
"=>",
"params",
"[",
"... | Updates an existing template.
Available _params_ argument are:
* :templateID - The ID of the template to be updated.
* :templateName - The name of the template. Maximum of 30 characters (will be truncated to 30 characters if longer).
* :htmlPageURL - The URL of the HTML page you have created for the template.... | [
"Updates",
"an",
"existing",
"template",
"."
] | f3d7da053b65cfa376269533183919dc890964fd | https://github.com/gnumarcelo/campaigning/blob/f3d7da053b65cfa376269533183919dc890964fd/lib/campaigning/template.rb#L79-L89 |
7,563 | godfat/jellyfish | lib/jellyfish/normalized_params.rb | Jellyfish.NormalizedParams.force_encoding | def force_encoding(data, encoding=Encoding.default_external)
return data if data.respond_to?(:rewind) # e.g. Tempfile, File, etc
if data.respond_to?(:force_encoding)
data.force_encoding(encoding).encode!
elsif data.respond_to?(:each_value)
data.each_value{ |v| force_encoding(v, encodin... | ruby | def force_encoding(data, encoding=Encoding.default_external)
return data if data.respond_to?(:rewind) # e.g. Tempfile, File, etc
if data.respond_to?(:force_encoding)
data.force_encoding(encoding).encode!
elsif data.respond_to?(:each_value)
data.each_value{ |v| force_encoding(v, encodin... | [
"def",
"force_encoding",
"(",
"data",
",",
"encoding",
"=",
"Encoding",
".",
"default_external",
")",
"return",
"data",
"if",
"data",
".",
"respond_to?",
"(",
":rewind",
")",
"# e.g. Tempfile, File, etc",
"if",
"data",
".",
"respond_to?",
"(",
":force_encoding",
... | stolen from sinatra
Fixes encoding issues by casting params to Encoding.default_external | [
"stolen",
"from",
"sinatra",
"Fixes",
"encoding",
"issues",
"by",
"casting",
"params",
"to",
"Encoding",
".",
"default_external"
] | e0a9e07ee010d5f097dc62348b0b83d17d3143ff | https://github.com/godfat/jellyfish/blob/e0a9e07ee010d5f097dc62348b0b83d17d3143ff/lib/jellyfish/normalized_params.rb#L43-L53 |
7,564 | experteer/codeqa | lib/codeqa/installer.rb | Codeqa.Installer.install_codeqa_git_hook | def install_codeqa_git_hook
git_root = app_path.join('.git')
pre_commit_path = git_root.join 'hooks', 'pre-commit'
return false unless File.exist?(git_root)
return false if File.exist?(pre_commit_path)
# an alternative would be to backup the old hook
# FileUtils.mv(pre_commit_path,
... | ruby | def install_codeqa_git_hook
git_root = app_path.join('.git')
pre_commit_path = git_root.join 'hooks', 'pre-commit'
return false unless File.exist?(git_root)
return false if File.exist?(pre_commit_path)
# an alternative would be to backup the old hook
# FileUtils.mv(pre_commit_path,
... | [
"def",
"install_codeqa_git_hook",
"git_root",
"=",
"app_path",
".",
"join",
"(",
"'.git'",
")",
"pre_commit_path",
"=",
"git_root",
".",
"join",
"'hooks'",
",",
"'pre-commit'",
"return",
"false",
"unless",
"File",
".",
"exist?",
"(",
"git_root",
")",
"return",
... | return true if installation succeeded
return false if either no git repo or hook already present | [
"return",
"true",
"if",
"installation",
"succeeded",
"return",
"false",
"if",
"either",
"no",
"git",
"repo",
"or",
"hook",
"already",
"present"
] | 199fa9b686737293a3c20148ad708a60e6fef667 | https://github.com/experteer/codeqa/blob/199fa9b686737293a3c20148ad708a60e6fef667/lib/codeqa/installer.rb#L34-L46 |
7,565 | jtimberman/ubuntu_ami | lib/chef/knife/ec2_amis_ubuntu.rb | KnifePlugins.Ec2AmisUbuntu.list_amis | def list_amis(distro)
amis = Hash.new
Ubuntu.release(distro).amis.each do |ami|
amis[build_type(ami.region, ami.arch, ami.root_store, ami.virtualization_type)] = ami.name
end
amis
end | ruby | def list_amis(distro)
amis = Hash.new
Ubuntu.release(distro).amis.each do |ami|
amis[build_type(ami.region, ami.arch, ami.root_store, ami.virtualization_type)] = ami.name
end
amis
end | [
"def",
"list_amis",
"(",
"distro",
")",
"amis",
"=",
"Hash",
".",
"new",
"Ubuntu",
".",
"release",
"(",
"distro",
")",
".",
"amis",
".",
"each",
"do",
"|",
"ami",
"|",
"amis",
"[",
"build_type",
"(",
"ami",
".",
"region",
",",
"ami",
".",
"arch",
... | Iterates over the AMIs available for the specified distro.
=== Parameters
distro<String>:: Release name of the distro to display.
=== Returns
Hash:: Keys are the AMI type, values are the AMI ID. | [
"Iterates",
"over",
"the",
"AMIs",
"available",
"for",
"the",
"specified",
"distro",
"."
] | 6df6308be3c90d038ffb5a93c4967b0444a635c8 | https://github.com/jtimberman/ubuntu_ami/blob/6df6308be3c90d038ffb5a93c4967b0444a635c8/lib/chef/knife/ec2_amis_ubuntu.rb#L110-L116 |
7,566 | 26fe/tree.rb | lib/tree_rb/core/tree_node_visitor.rb | TreeRb.TreeNodeVisitor.exit_node | def exit_node(tree_node)
parent = @stack.last
if @delegate
@delegate.exit_node(tree_node) if @delegate.respond_to? :exit_node
else
@on_exit_tree_node_blocks.each do |b|
if b.arity == 1
b.call(tree_node)
elsif b.arity == 2
b.call(tree_node, pa... | ruby | def exit_node(tree_node)
parent = @stack.last
if @delegate
@delegate.exit_node(tree_node) if @delegate.respond_to? :exit_node
else
@on_exit_tree_node_blocks.each do |b|
if b.arity == 1
b.call(tree_node)
elsif b.arity == 2
b.call(tree_node, pa... | [
"def",
"exit_node",
"(",
"tree_node",
")",
"parent",
"=",
"@stack",
".",
"last",
"if",
"@delegate",
"@delegate",
".",
"exit_node",
"(",
"tree_node",
")",
"if",
"@delegate",
".",
"respond_to?",
":exit_node",
"else",
"@on_exit_tree_node_blocks",
".",
"each",
"do",... | called on tree node at end of the visit i.e. oll subtree are visited | [
"called",
"on",
"tree",
"node",
"at",
"end",
"of",
"the",
"visit",
"i",
".",
"e",
".",
"oll",
"subtree",
"are",
"visited"
] | 5ecf0cfbbc439e27c72b9676d6a1ccee8e6bb02b | https://github.com/26fe/tree.rb/blob/5ecf0cfbbc439e27c72b9676d6a1ccee8e6bb02b/lib/tree_rb/core/tree_node_visitor.rb#L64-L78 |
7,567 | 26fe/tree.rb | lib/tree_rb/core/tree_node_visitor.rb | TreeRb.TreeNodeVisitor.visit_leaf | def visit_leaf(leaf_node)
parent = @stack.last
if @delegate
@delegate.visit_leaf(leaf_node) if @delegate.respond_to? :visit_leaf
else
@on_visit_leaf_node_blocks.each do |b|
if b.arity == 1
b.call(leaf_node)
elsif b.arity == 2
b.call(leaf_node... | ruby | def visit_leaf(leaf_node)
parent = @stack.last
if @delegate
@delegate.visit_leaf(leaf_node) if @delegate.respond_to? :visit_leaf
else
@on_visit_leaf_node_blocks.each do |b|
if b.arity == 1
b.call(leaf_node)
elsif b.arity == 2
b.call(leaf_node... | [
"def",
"visit_leaf",
"(",
"leaf_node",
")",
"parent",
"=",
"@stack",
".",
"last",
"if",
"@delegate",
"@delegate",
".",
"visit_leaf",
"(",
"leaf_node",
")",
"if",
"@delegate",
".",
"respond_to?",
":visit_leaf",
"else",
"@on_visit_leaf_node_blocks",
".",
"each",
"... | called when visit leaf node | [
"called",
"when",
"visit",
"leaf",
"node"
] | 5ecf0cfbbc439e27c72b9676d6a1ccee8e6bb02b | https://github.com/26fe/tree.rb/blob/5ecf0cfbbc439e27c72b9676d6a1ccee8e6bb02b/lib/tree_rb/core/tree_node_visitor.rb#L83-L96 |
7,568 | kirkbowers/rdoc2md | lib/rdoc2md.rb | Rdoc2md.Document.to_md | def to_md
# Usually ruby is extremely readable, but I think "-1" means "give me all the
# trailing blank lines" is surprisingly opaque. That's what the -1 does...
lines = @text.split("\n", -1)
lines.collect do |line|
result = line
# Leave lines that start with 4 spaces alone.... | ruby | def to_md
# Usually ruby is extremely readable, but I think "-1" means "give me all the
# trailing blank lines" is surprisingly opaque. That's what the -1 does...
lines = @text.split("\n", -1)
lines.collect do |line|
result = line
# Leave lines that start with 4 spaces alone.... | [
"def",
"to_md",
"# Usually ruby is extremely readable, but I think \"-1\" means \"give me all the ",
"# trailing blank lines\" is surprisingly opaque. That's what the -1 does...",
"lines",
"=",
"@text",
".",
"split",
"(",
"\"\\n\"",
",",
"-",
"1",
")",
"lines",
".",
"collect",
"... | The initializer takes an optional text, which is the document to be converted from
rdoc style to markdown.
Convert the existing document to markdown. The result is returned as a String. | [
"The",
"initializer",
"takes",
"an",
"optional",
"text",
"which",
"is",
"the",
"document",
"to",
"be",
"converted",
"from",
"rdoc",
"style",
"to",
"markdown",
".",
"Convert",
"the",
"existing",
"document",
"to",
"markdown",
".",
"The",
"result",
"is",
"retur... | 5e32cc2de9e64140034a3fbb767ef52c8261ce06 | https://github.com/kirkbowers/rdoc2md/blob/5e32cc2de9e64140034a3fbb767ef52c8261ce06/lib/rdoc2md.rb#L23-L65 |
7,569 | gnumarcelo/campaigning | lib/campaigning/client.rb | Campaigning.Client.templates | def templates
response = @@soap.getClientTemplates(:apiKey => @apiKey, :clientID => @clientID)
templates = handle_response response.client_GetTemplatesResult
templates.collect {|template| Template.new(template.templateID, template.name, template.previewURL, template.screenshotURL, :apiKey=> @api... | ruby | def templates
response = @@soap.getClientTemplates(:apiKey => @apiKey, :clientID => @clientID)
templates = handle_response response.client_GetTemplatesResult
templates.collect {|template| Template.new(template.templateID, template.name, template.previewURL, template.screenshotURL, :apiKey=> @api... | [
"def",
"templates",
"response",
"=",
"@@soap",
".",
"getClientTemplates",
"(",
":apiKey",
"=>",
"@apiKey",
",",
":clientID",
"=>",
"@clientID",
")",
"templates",
"=",
"handle_response",
"response",
".",
"client_GetTemplatesResult",
"templates",
".",
"collect",
"{",
... | Gets a list of all templates for a client.
*Return*:
*Success*: Upon a successful call, this method will return a collection of Campaigning::Template objects.
*Error*: An Exception containing the cause of the error will be raised. | [
"Gets",
"a",
"list",
"of",
"all",
"templates",
"for",
"a",
"client",
"."
] | f3d7da053b65cfa376269533183919dc890964fd | https://github.com/gnumarcelo/campaigning/blob/f3d7da053b65cfa376269533183919dc890964fd/lib/campaigning/client.rb#L24-L28 |
7,570 | gnumarcelo/campaigning | lib/campaigning/client.rb | Campaigning.Client.lists | def lists
response = @@soap.getClientLists(:apiKey => @apiKey, :clientID => @clientID)
lists = handle_response response.client_GetListsResult
lists.collect {|list| List.new(list.listID, list.name, :apiKey=> @apiKey)}
end | ruby | def lists
response = @@soap.getClientLists(:apiKey => @apiKey, :clientID => @clientID)
lists = handle_response response.client_GetListsResult
lists.collect {|list| List.new(list.listID, list.name, :apiKey=> @apiKey)}
end | [
"def",
"lists",
"response",
"=",
"@@soap",
".",
"getClientLists",
"(",
":apiKey",
"=>",
"@apiKey",
",",
":clientID",
"=>",
"@clientID",
")",
"lists",
"=",
"handle_response",
"response",
".",
"client_GetListsResult",
"lists",
".",
"collect",
"{",
"|",
"list",
"... | Gets a list of all subscriber lists for a client.
*Return*:
*Success*: Upon a successful call, this method will return a collection of Campaigning::List objects.
*Error*: An Exception containing the cause of the error will be raised. | [
"Gets",
"a",
"list",
"of",
"all",
"subscriber",
"lists",
"for",
"a",
"client",
"."
] | f3d7da053b65cfa376269533183919dc890964fd | https://github.com/gnumarcelo/campaigning/blob/f3d7da053b65cfa376269533183919dc890964fd/lib/campaigning/client.rb#L38-L42 |
7,571 | gnumarcelo/campaigning | lib/campaigning/client.rb | Campaigning.Client.campaigns | def campaigns
response = @@soap.getClientCampaigns(:apiKey => @apiKey, :clientID => @clientID )
campaign_list = handle_response response.client_GetCampaignsResult
campaign_list.collect do |campaign|
Campaign.new(campaign.campaignID, campaign.subject, campaign.name, campaign.sentDate, campaig... | ruby | def campaigns
response = @@soap.getClientCampaigns(:apiKey => @apiKey, :clientID => @clientID )
campaign_list = handle_response response.client_GetCampaignsResult
campaign_list.collect do |campaign|
Campaign.new(campaign.campaignID, campaign.subject, campaign.name, campaign.sentDate, campaig... | [
"def",
"campaigns",
"response",
"=",
"@@soap",
".",
"getClientCampaigns",
"(",
":apiKey",
"=>",
"@apiKey",
",",
":clientID",
"=>",
"@clientID",
")",
"campaign_list",
"=",
"handle_response",
"response",
".",
"client_GetCampaignsResult",
"campaign_list",
".",
"collect",... | Gets a list of all campaigns that have been sent for a client.
*Return*:
*Success*: Upon a successful call, this method will return a collection of Campaigning::Campaign objects.
*Error*: An Exception containing the cause of the error will be raised. | [
"Gets",
"a",
"list",
"of",
"all",
"campaigns",
"that",
"have",
"been",
"sent",
"for",
"a",
"client",
"."
] | f3d7da053b65cfa376269533183919dc890964fd | https://github.com/gnumarcelo/campaigning/blob/f3d7da053b65cfa376269533183919dc890964fd/lib/campaigning/client.rb#L195-L201 |
7,572 | gnumarcelo/campaigning | lib/campaigning/client.rb | Campaigning.Client.update_access_and_billing! | def update_access_and_billing!(params)
response = @@soap.updateClientAccessAndBilling(
:apiKey => @apiKey,
:clientID => @clientID,
:accessLevel => params[:accessLevel],
:username => params.fetch(:username, ""),
:password => params.fetch(:password, ""),
:billingType => params.fe... | ruby | def update_access_and_billing!(params)
response = @@soap.updateClientAccessAndBilling(
:apiKey => @apiKey,
:clientID => @clientID,
:accessLevel => params[:accessLevel],
:username => params.fetch(:username, ""),
:password => params.fetch(:password, ""),
:billingType => params.fe... | [
"def",
"update_access_and_billing!",
"(",
"params",
")",
"response",
"=",
"@@soap",
".",
"updateClientAccessAndBilling",
"(",
":apiKey",
"=>",
"@apiKey",
",",
":clientID",
"=>",
"@clientID",
",",
":accessLevel",
"=>",
"params",
"[",
":accessLevel",
"]",
",",
":use... | Update the access and billing settings of an existing client, leaving the basic details untouched.
Here's a list of all the parameters you'll need to pass to the Campaigning::Client#update_access_and_billing! method. Only the :+access_level+ parameter
is required for all calls. The relevance and necessity of the other... | [
"Update",
"the",
"access",
"and",
"billing",
"settings",
"of",
"an",
"existing",
"client",
"leaving",
"the",
"basic",
"details",
"untouched",
"."
] | f3d7da053b65cfa376269533183919dc890964fd | https://github.com/gnumarcelo/campaigning/blob/f3d7da053b65cfa376269533183919dc890964fd/lib/campaigning/client.rb#L286-L300 |
7,573 | gnumarcelo/campaigning | lib/campaigning/client.rb | Campaigning.Client.update_basics! | def update_basics!(params)
response = @@soap.updateClientBasics(
:apiKey => @apiKey,
:clientID => @clientID,
:companyName => params[:companyName],
:contactName => params[:contactName],
:emailAddress => params[:emailAddress],
:country => params[:country],
:timezone => para... | ruby | def update_basics!(params)
response = @@soap.updateClientBasics(
:apiKey => @apiKey,
:clientID => @clientID,
:companyName => params[:companyName],
:contactName => params[:contactName],
:emailAddress => params[:emailAddress],
:country => params[:country],
:timezone => para... | [
"def",
"update_basics!",
"(",
"params",
")",
"response",
"=",
"@@soap",
".",
"updateClientBasics",
"(",
":apiKey",
"=>",
"@apiKey",
",",
":clientID",
"=>",
"@clientID",
",",
":companyName",
"=>",
"params",
"[",
":companyName",
"]",
",",
":contactName",
"=>",
"... | Updates the basic details of an existing client.
If you wish to change only some details, the others must be included as they currently are. Please note that the client's existing
access and billing details will remain unchanged by a call to this method.
Available _params_ argument are:
* :companyName - The client ... | [
"Updates",
"the",
"basic",
"details",
"of",
"an",
"existing",
"client",
".",
"If",
"you",
"wish",
"to",
"change",
"only",
"some",
"details",
"the",
"others",
"must",
"be",
"included",
"as",
"they",
"currently",
"are",
".",
"Please",
"note",
"that",
"the",
... | f3d7da053b65cfa376269533183919dc890964fd | https://github.com/gnumarcelo/campaigning/blob/f3d7da053b65cfa376269533183919dc890964fd/lib/campaigning/client.rb#L320-L331 |
7,574 | bilus/akasha | lib/akasha/repository.rb | Akasha.Repository.save_aggregate | def save_aggregate(aggregate, concurrency: :none)
changeset = aggregate.changeset
events = changeset.events.map { |event| event.with_metadata(namespace: @namespace) }
revision = aggregate.revision if concurrency == :optimistic
stream(aggregate.class, changeset.aggregate_id).write_events(events, ... | ruby | def save_aggregate(aggregate, concurrency: :none)
changeset = aggregate.changeset
events = changeset.events.map { |event| event.with_metadata(namespace: @namespace) }
revision = aggregate.revision if concurrency == :optimistic
stream(aggregate.class, changeset.aggregate_id).write_events(events, ... | [
"def",
"save_aggregate",
"(",
"aggregate",
",",
"concurrency",
":",
":none",
")",
"changeset",
"=",
"aggregate",
".",
"changeset",
"events",
"=",
"changeset",
".",
"events",
".",
"map",
"{",
"|",
"event",
"|",
"event",
".",
"with_metadata",
"(",
"namespace",... | Saves an aggregate to the repository, appending events to the corresponding stream. | [
"Saves",
"an",
"aggregate",
"to",
"the",
"repository",
"appending",
"events",
"to",
"the",
"corresponding",
"stream",
"."
] | 5fadefc249f520ae909b762956ac23a6f916b021 | https://github.com/bilus/akasha/blob/5fadefc249f520ae909b762956ac23a6f916b021/lib/akasha/repository.rb#L35-L41 |
7,575 | xinge/gcm_helper | lib/gcm_helper/sender.rb | GcmHelper.Sender.update_status | def update_status(unsent_reg_ids, all_results, multicast_result)
results = multicast_result.results
raise RuntimeError, "Internal error: sizes do not match. currentResults: #{results}; unsentRegIds: #{unsent_reg_ids}" unless results.size==unsent_reg_ids.size
new_unsent_reg_ids = []
unsent_reg_id... | ruby | def update_status(unsent_reg_ids, all_results, multicast_result)
results = multicast_result.results
raise RuntimeError, "Internal error: sizes do not match. currentResults: #{results}; unsentRegIds: #{unsent_reg_ids}" unless results.size==unsent_reg_ids.size
new_unsent_reg_ids = []
unsent_reg_id... | [
"def",
"update_status",
"(",
"unsent_reg_ids",
",",
"all_results",
",",
"multicast_result",
")",
"results",
"=",
"multicast_result",
".",
"results",
"raise",
"RuntimeError",
",",
"\"Internal error: sizes do not match. currentResults: #{results}; unsentRegIds: #{unsent_reg_ids}\"",
... | Updates the status of the messages sent to devices and the list of devices that should be retried.
@param [Array] unsent_reg_ids
@param [Hash] all_results
@param [GcmHelper::MulticastResult] multicast_result | [
"Updates",
"the",
"status",
"of",
"the",
"messages",
"sent",
"to",
"devices",
"and",
"the",
"list",
"of",
"devices",
"that",
"should",
"be",
"retried",
"."
] | f998f0e6bde0147613a9cb2ff2f62363adf2b227 | https://github.com/xinge/gcm_helper/blob/f998f0e6bde0147613a9cb2ff2f62363adf2b227/lib/gcm_helper/sender.rb#L218-L228 |
7,576 | nigelr/selections | lib/selections/form_builder_extensions.rb | Selections.FormBuilderExtensions.selections | def selections(field, options = {}, html_options = {})
SelectionTag.new(self, object, field, options, html_options).select_tag
end | ruby | def selections(field, options = {}, html_options = {})
SelectionTag.new(self, object, field, options, html_options).select_tag
end | [
"def",
"selections",
"(",
"field",
",",
"options",
"=",
"{",
"}",
",",
"html_options",
"=",
"{",
"}",
")",
"SelectionTag",
".",
"new",
"(",
"self",
",",
"object",
",",
"field",
",",
"options",
",",
"html_options",
")",
".",
"select_tag",
"end"
] | Create a select list based on the field name finding items within Selection.
Example
form_for(@ticket) do |f|
f.select("priority")
Uses priority_id from the ticket table and creates options list based on items in Selection table with a system_code of
either priority or ticket_priority
options = {} and ht... | [
"Create",
"a",
"select",
"list",
"based",
"on",
"the",
"field",
"name",
"finding",
"items",
"within",
"Selection",
"."
] | f4702869ffaf11fbcdc8fdad4c0e91b3d0a1ce45 | https://github.com/nigelr/selections/blob/f4702869ffaf11fbcdc8fdad4c0e91b3d0a1ce45/lib/selections/form_builder_extensions.rb#L17-L19 |
7,577 | nigelr/selections | lib/selections/form_builder_extensions.rb | Selections.FormBuilderExtensions.radios | def radios(field, options = {})
html_options = options.clone
html_options.delete_if {|key, value| key == :system_code}
SelectionTag.new(self, object, field, options, html_options).radio_tag
end | ruby | def radios(field, options = {})
html_options = options.clone
html_options.delete_if {|key, value| key == :system_code}
SelectionTag.new(self, object, field, options, html_options).radio_tag
end | [
"def",
"radios",
"(",
"field",
",",
"options",
"=",
"{",
"}",
")",
"html_options",
"=",
"options",
".",
"clone",
"html_options",
".",
"delete_if",
"{",
"|",
"key",
",",
"value",
"|",
"key",
"==",
":system_code",
"}",
"SelectionTag",
".",
"new",
"(",
"s... | Build a radio button list based field name finding items within Selection
Example
form_for(@ticket) do |f|
f.select :priority
options
* +system_code+ - Overrides the automatic system_code name based on the fieldname and looks up the list of items in Selection | [
"Build",
"a",
"radio",
"button",
"list",
"based",
"field",
"name",
"finding",
"items",
"within",
"Selection"
] | f4702869ffaf11fbcdc8fdad4c0e91b3d0a1ce45 | https://github.com/nigelr/selections/blob/f4702869ffaf11fbcdc8fdad4c0e91b3d0a1ce45/lib/selections/form_builder_extensions.rb#L29-L33 |
7,578 | jarhart/rattler | lib/rattler/util/node.rb | Rattler::Util.Node.method_missing | def method_missing(symbol, *args)
(args.empty? and attrs.has_key?(symbol)) ? attrs[symbol] : super
end | ruby | def method_missing(symbol, *args)
(args.empty? and attrs.has_key?(symbol)) ? attrs[symbol] : super
end | [
"def",
"method_missing",
"(",
"symbol",
",",
"*",
"args",
")",
"(",
"args",
".",
"empty?",
"and",
"attrs",
".",
"has_key?",
"(",
"symbol",
")",
")",
"?",
"attrs",
"[",
"symbol",
"]",
":",
"super",
"end"
] | Return +true+ if the node is equal to +other+. Normally this means
+other+ is an instance of the same class or a subclass and has equal
children and attributes.
@return [Boolean] +true+ if the node is equal to +other+
Return +true+ if the node has the same value as +other+, i.e. +other+
is an instance of the same... | [
"Return",
"+",
"true",
"+",
"if",
"the",
"node",
"is",
"equal",
"to",
"+",
"other",
"+",
".",
"Normally",
"this",
"means",
"+",
"other",
"+",
"is",
"an",
"instance",
"of",
"the",
"same",
"class",
"or",
"a",
"subclass",
"and",
"has",
"equal",
"childre... | 8b4efde2a05e9e790955bb635d4a1a9615893719 | https://github.com/jarhart/rattler/blob/8b4efde2a05e9e790955bb635d4a1a9615893719/lib/rattler/util/node.rb#L166-L168 |
7,579 | jmpage/dirty_associations | lib/dirty_associations.rb | DirtyAssociations.ClassMethods.monitor_association_changes | def monitor_association_changes(association)
define_method "#{association}=" do |value|
attribute_will_change!(association.to_s) if _association_will_change?(association, value)
super(value)
end
ids = "#{association.to_s.singularize}_ids"
define_method "#{ids}=" do |value|
... | ruby | def monitor_association_changes(association)
define_method "#{association}=" do |value|
attribute_will_change!(association.to_s) if _association_will_change?(association, value)
super(value)
end
ids = "#{association.to_s.singularize}_ids"
define_method "#{ids}=" do |value|
... | [
"def",
"monitor_association_changes",
"(",
"association",
")",
"define_method",
"\"#{association}=\"",
"do",
"|",
"value",
"|",
"attribute_will_change!",
"(",
"association",
".",
"to_s",
")",
"if",
"_association_will_change?",
"(",
"association",
",",
"value",
")",
"s... | Creates methods that allows an +association+ to be monitored.
The +association+ parameter should be a string or symbol representing the name of an association. | [
"Creates",
"methods",
"that",
"allows",
"an",
"+",
"association",
"+",
"to",
"be",
"monitored",
"."
] | 33e9cb36e93632d3fee69277063eb42f56c9b7bf | https://github.com/jmpage/dirty_associations/blob/33e9cb36e93632d3fee69277063eb42f56c9b7bf/lib/dirty_associations.rb#L15-L46 |
7,580 | jrochkind/borrow_direct | lib/borrow_direct/encryption.rb | BorrowDirect.Encryption.encode_with_ts | def encode_with_ts(value)
# Not sure if this object is thread-safe, so we re-create
# each time.
public_key = OpenSSL::PKey::RSA.new(self.public_key_str)
payload = "#{value}|#{self.now_timestamp}"
return Base64.encode64(public_key.public_encrypt(payload))
end | ruby | def encode_with_ts(value)
# Not sure if this object is thread-safe, so we re-create
# each time.
public_key = OpenSSL::PKey::RSA.new(self.public_key_str)
payload = "#{value}|#{self.now_timestamp}"
return Base64.encode64(public_key.public_encrypt(payload))
end | [
"def",
"encode_with_ts",
"(",
"value",
")",
"# Not sure if this object is thread-safe, so we re-create",
"# each time. ",
"public_key",
"=",
"OpenSSL",
"::",
"PKey",
"::",
"RSA",
".",
"new",
"(",
"self",
".",
"public_key_str",
")",
"payload",
"=",
"\"#{value}|#{self.now... | Will add on timestamp according to Relais protocol, encrypt,
and Base64-encode, all per Relais protocol. | [
"Will",
"add",
"on",
"timestamp",
"according",
"to",
"Relais",
"protocol",
"encrypt",
"and",
"Base64",
"-",
"encode",
"all",
"per",
"Relais",
"protocol",
"."
] | f2f53760e15d742a5c5584dd641f20dea315f99f | https://github.com/jrochkind/borrow_direct/blob/f2f53760e15d742a5c5584dd641f20dea315f99f/lib/borrow_direct/encryption.rb#L18-L27 |
7,581 | elifoster/weatheruby | lib/weather/actions.rb | Weather.Actions.moon_phase | def moon_phase(location)
response = get('astronomy', location)
{
age: response['moon_phase']['ageOfMoon'].to_i,
illumination: response['moon_phase']['percentIlluminated'].to_i
}
end | ruby | def moon_phase(location)
response = get('astronomy', location)
{
age: response['moon_phase']['ageOfMoon'].to_i,
illumination: response['moon_phase']['percentIlluminated'].to_i
}
end | [
"def",
"moon_phase",
"(",
"location",
")",
"response",
"=",
"get",
"(",
"'astronomy'",
",",
"location",
")",
"{",
"age",
":",
"response",
"[",
"'moon_phase'",
"]",
"[",
"'ageOfMoon'",
"]",
".",
"to_i",
",",
"illumination",
":",
"response",
"[",
"'moon_phas... | Gets the current moon phase of the location.
@param location [String] The place to get the phase for.
@return [Hash<Symbol, Integer>] A hash of two integers for the moon phase
information. The `:age` key in the hash contains the moon's age in days,
and the `:illumination` key contains the percentage of how illu... | [
"Gets",
"the",
"current",
"moon",
"phase",
"of",
"the",
"location",
"."
] | 4d97db082448765b67ef5112c89346e502a74858 | https://github.com/elifoster/weatheruby/blob/4d97db082448765b67ef5112c89346e502a74858/lib/weather/actions.rb#L39-L45 |
7,582 | elifoster/weatheruby | lib/weather/actions.rb | Weather.Actions.sun_info | def sun_info(location)
response = get('astronomy', location)
{
rise: {
hour: response['moon_phase']['sunrise']['hour'].to_i,
minute: response['moon_phase']['sunrise']['minute'].to_i
},
set: {
hour: response['moon_phase']['sunset']['hour'].to_i,
... | ruby | def sun_info(location)
response = get('astronomy', location)
{
rise: {
hour: response['moon_phase']['sunrise']['hour'].to_i,
minute: response['moon_phase']['sunrise']['minute'].to_i
},
set: {
hour: response['moon_phase']['sunset']['hour'].to_i,
... | [
"def",
"sun_info",
"(",
"location",
")",
"response",
"=",
"get",
"(",
"'astronomy'",
",",
"location",
")",
"{",
"rise",
":",
"{",
"hour",
":",
"response",
"[",
"'moon_phase'",
"]",
"[",
"'sunrise'",
"]",
"[",
"'hour'",
"]",
".",
"to_i",
",",
"minute",
... | Gets sunrise and sunset information for the current day at the current location.
@param location [String] The place to get the info for.
@return [Hash<Symbol, Hash<Symbol, Integer>>] A hash containing two hashes at keys :rise and :set for sunrise
and sunset information respectively. They each contain an :hour key ... | [
"Gets",
"sunrise",
"and",
"sunset",
"information",
"for",
"the",
"current",
"day",
"at",
"the",
"current",
"location",
"."
] | 4d97db082448765b67ef5112c89346e502a74858 | https://github.com/elifoster/weatheruby/blob/4d97db082448765b67ef5112c89346e502a74858/lib/weather/actions.rb#L52-L64 |
7,583 | elifoster/weatheruby | lib/weather/actions.rb | Weather.Actions.parse_simple_forecast | def parse_simple_forecast(response)
ret = {}
response['forecast']['txt_forecast']['forecastday'].each do |f|
ret[f['period']] = {
weekday_name: f['title'],
text: f['fcttext'],
text_metric: f['fcttext_metric'],
image_url: f['icon_url']
}
end
... | ruby | def parse_simple_forecast(response)
ret = {}
response['forecast']['txt_forecast']['forecastday'].each do |f|
ret[f['period']] = {
weekday_name: f['title'],
text: f['fcttext'],
text_metric: f['fcttext_metric'],
image_url: f['icon_url']
}
end
... | [
"def",
"parse_simple_forecast",
"(",
"response",
")",
"ret",
"=",
"{",
"}",
"response",
"[",
"'forecast'",
"]",
"[",
"'txt_forecast'",
"]",
"[",
"'forecastday'",
"]",
".",
"each",
"do",
"|",
"f",
"|",
"ret",
"[",
"f",
"[",
"'period'",
"]",
"]",
"=",
... | Parses the simple forecast information. | [
"Parses",
"the",
"simple",
"forecast",
"information",
"."
] | 4d97db082448765b67ef5112c89346e502a74858 | https://github.com/elifoster/weatheruby/blob/4d97db082448765b67ef5112c89346e502a74858/lib/weather/actions.rb#L257-L270 |
7,584 | elifoster/weatheruby | lib/weather/actions.rb | Weather.Actions.parse_complex_forecast | def parse_complex_forecast(response)
ret = {}
response['forecast']['simpleforecast']['forecastday'].each do |f|
date = f['date']
ret[f['period'] - 1] = {
date: DateTime.new(date['year'], date['month'], date['day'], date['hour'], date['min'].to_i, date['sec'], date['tz_short']),
... | ruby | def parse_complex_forecast(response)
ret = {}
response['forecast']['simpleforecast']['forecastday'].each do |f|
date = f['date']
ret[f['period'] - 1] = {
date: DateTime.new(date['year'], date['month'], date['day'], date['hour'], date['min'].to_i, date['sec'], date['tz_short']),
... | [
"def",
"parse_complex_forecast",
"(",
"response",
")",
"ret",
"=",
"{",
"}",
"response",
"[",
"'forecast'",
"]",
"[",
"'simpleforecast'",
"]",
"[",
"'forecastday'",
"]",
".",
"each",
"do",
"|",
"f",
"|",
"date",
"=",
"f",
"[",
"'date'",
"]",
"ret",
"["... | Parses the complex forecast information. | [
"Parses",
"the",
"complex",
"forecast",
"information",
"."
] | 4d97db082448765b67ef5112c89346e502a74858 | https://github.com/elifoster/weatheruby/blob/4d97db082448765b67ef5112c89346e502a74858/lib/weather/actions.rb#L273-L317 |
7,585 | wilson/revenant | lib/revenant/manager.rb | Revenant.Manager.reopen_io | def reopen_io(io, path, mode = nil)
begin
if mode
io.reopen(path, mode)
else
io.reopen(path)
end
io.binmode
rescue ::Exception
end
end | ruby | def reopen_io(io, path, mode = nil)
begin
if mode
io.reopen(path, mode)
else
io.reopen(path)
end
io.binmode
rescue ::Exception
end
end | [
"def",
"reopen_io",
"(",
"io",
",",
"path",
",",
"mode",
"=",
"nil",
")",
"begin",
"if",
"mode",
"io",
".",
"reopen",
"(",
"path",
",",
"mode",
")",
"else",
"io",
".",
"reopen",
"(",
"path",
")",
"end",
"io",
".",
"binmode",
"rescue",
"::",
"Exce... | Attempts to reopen an IO object. | [
"Attempts",
"to",
"reopen",
"an",
"IO",
"object",
"."
] | 80fe65742de54ce0c5a8e6c56cea7003fe286746 | https://github.com/wilson/revenant/blob/80fe65742de54ce0c5a8e6c56cea7003fe286746/lib/revenant/manager.rb#L49-L59 |
7,586 | dlangevin/gxapi_rails | lib/gxapi/controller_methods.rb | Gxapi.ControllerMethods.gxapi_get_variant | def gxapi_get_variant(identifier, ivar_name = :variant)
# handle override
if params[ivar_name]
val = Gxapi::Ostruct.new(
value: {
index: -1,
experiment_id: nil,
name: params[ivar_name]
}
)
else
val = self.gxapi_base.get_va... | ruby | def gxapi_get_variant(identifier, ivar_name = :variant)
# handle override
if params[ivar_name]
val = Gxapi::Ostruct.new(
value: {
index: -1,
experiment_id: nil,
name: params[ivar_name]
}
)
else
val = self.gxapi_base.get_va... | [
"def",
"gxapi_get_variant",
"(",
"identifier",
",",
"ivar_name",
"=",
":variant",
")",
"# handle override",
"if",
"params",
"[",
"ivar_name",
"]",
"val",
"=",
"Gxapi",
"::",
"Ostruct",
".",
"new",
"(",
"value",
":",
"{",
"index",
":",
"-",
"1",
",",
"exp... | Get the variant and set it as an instance variable, handling
overriding by passing in the URL
@param identifier [String, Hash] Name for the experiment or ID hash
for the experiment
@param ivar_name [String, Symbol] Name for the variable
@example
def my_action
gxapi_get_variant("Name")
end
# OR
... | [
"Get",
"the",
"variant",
"and",
"set",
"it",
"as",
"an",
"instance",
"variable",
"handling",
"overriding",
"by",
"passing",
"in",
"the",
"URL"
] | 21361227f0c70118b38f7fa372a18c0ae7aab810 | https://github.com/dlangevin/gxapi_rails/blob/21361227f0c70118b38f7fa372a18c0ae7aab810/lib/gxapi/controller_methods.rb#L25-L39 |
7,587 | rack-webprofiler/rack-webprofiler | lib/rack/web_profiler.rb | Rack.WebProfiler.process | def process(request, body, status, headers, exception = nil)
request.env[ENV_RUNTIME] = Time.now.to_f - request.env[ENV_RUNTIME_START]
request.env[ENV_EXCEPTION] = nil
if !exception.nil?
request.env[ENV_EXCEPTION] = exception
WebProfiler::Engine.process_exception(request).finish
... | ruby | def process(request, body, status, headers, exception = nil)
request.env[ENV_RUNTIME] = Time.now.to_f - request.env[ENV_RUNTIME_START]
request.env[ENV_EXCEPTION] = nil
if !exception.nil?
request.env[ENV_EXCEPTION] = exception
WebProfiler::Engine.process_exception(request).finish
... | [
"def",
"process",
"(",
"request",
",",
"body",
",",
"status",
",",
"headers",
",",
"exception",
"=",
"nil",
")",
"request",
".",
"env",
"[",
"ENV_RUNTIME",
"]",
"=",
"Time",
".",
"now",
".",
"to_f",
"-",
"request",
".",
"env",
"[",
"ENV_RUNTIME_START",... | Process the request.
@param request [Rack::WebProfiler::Request]
@param body
@param status [Integer]
@param headers [Hash]
@param exception [Exception, nil]
@return [Rack::Response] | [
"Process",
"the",
"request",
"."
] | bdb411fbb41eeddf612bbde91301ff94b3853a12 | https://github.com/rack-webprofiler/rack-webprofiler/blob/bdb411fbb41eeddf612bbde91301ff94b3853a12/lib/rack/web_profiler.rb#L134-L144 |
7,588 | strong-code/pirata | lib/pirata/search.rb | Pirata.Search.search | def search(page = 0)
#build URL ex: http://thepiratebay.se/search/cats/0/99/0
url = Pirata.config[:base_url] + "/search/#{URI.escape(@query)}" + "/#{page.to_s}" + "/#{@sort_type}" + "/#{@category}"
html = Pirata::Search.parse_html(url)
Pirata::Search::parse_search_page(html, self)
end | ruby | def search(page = 0)
#build URL ex: http://thepiratebay.se/search/cats/0/99/0
url = Pirata.config[:base_url] + "/search/#{URI.escape(@query)}" + "/#{page.to_s}" + "/#{@sort_type}" + "/#{@category}"
html = Pirata::Search.parse_html(url)
Pirata::Search::parse_search_page(html, self)
end | [
"def",
"search",
"(",
"page",
"=",
"0",
")",
"#build URL ex: http://thepiratebay.se/search/cats/0/99/0",
"url",
"=",
"Pirata",
".",
"config",
"[",
":base_url",
"]",
"+",
"\"/search/#{URI.escape(@query)}\"",
"+",
"\"/#{page.to_s}\"",
"+",
"\"/#{@sort_type}\"",
"+",
"\"/#... | Perform a search and return an array of Torrent objects | [
"Perform",
"a",
"search",
"and",
"return",
"an",
"array",
"of",
"Torrent",
"objects"
] | 6b4b0d58bda71caf053aeadaae59834e5a45a1c6 | https://github.com/strong-code/pirata/blob/6b4b0d58bda71caf053aeadaae59834e5a45a1c6/lib/pirata/search.rb#L24-L29 |
7,589 | strong-code/pirata | lib/pirata/search.rb | Pirata.Search.search_page | def search_page(page)
raise "Search must be multipage to search pages" if !multipage?
raise "Page must be a valid, positive integer" if page.class != Fixnum || page < 0
raise "Invalid page range" if page > @pages
self.search(page)
end | ruby | def search_page(page)
raise "Search must be multipage to search pages" if !multipage?
raise "Page must be a valid, positive integer" if page.class != Fixnum || page < 0
raise "Invalid page range" if page > @pages
self.search(page)
end | [
"def",
"search_page",
"(",
"page",
")",
"raise",
"\"Search must be multipage to search pages\"",
"if",
"!",
"multipage?",
"raise",
"\"Page must be a valid, positive integer\"",
"if",
"page",
".",
"class",
"!=",
"Fixnum",
"||",
"page",
"<",
"0",
"raise",
"\"Invalid page ... | Return the n page results of a search, assuming it is multipage | [
"Return",
"the",
"n",
"page",
"results",
"of",
"a",
"search",
"assuming",
"it",
"is",
"multipage"
] | 6b4b0d58bda71caf053aeadaae59834e5a45a1c6 | https://github.com/strong-code/pirata/blob/6b4b0d58bda71caf053aeadaae59834e5a45a1c6/lib/pirata/search.rb#L32-L38 |
7,590 | strong-code/pirata | lib/pirata/search.rb | Pirata.Search.parse_html | def parse_html(url)
response = open(url, :allow_redirections => Pirata.config[:redirect])
Nokogiri::HTML(response)
end | ruby | def parse_html(url)
response = open(url, :allow_redirections => Pirata.config[:redirect])
Nokogiri::HTML(response)
end | [
"def",
"parse_html",
"(",
"url",
")",
"response",
"=",
"open",
"(",
"url",
",",
":allow_redirections",
"=>",
"Pirata",
".",
"config",
"[",
":redirect",
"]",
")",
"Nokogiri",
"::",
"HTML",
"(",
"response",
")",
"end"
] | Parse HTML body of a supplied URL | [
"Parse",
"HTML",
"body",
"of",
"a",
"supplied",
"URL"
] | 6b4b0d58bda71caf053aeadaae59834e5a45a1c6 | https://github.com/strong-code/pirata/blob/6b4b0d58bda71caf053aeadaae59834e5a45a1c6/lib/pirata/search.rb#L70-L73 |
7,591 | etailer/parcel_api | lib/parcel_api/shipping_options.rb | ParcelApi.ShippingOptions.get_international | def get_international(parcel_params)
response = @connection.get INTERNATIONAL_URL, params: parcel_params
options = response.parsed.tap do |so|
so.delete('success')
so.delete('message_id')
end
RecursiveOpenStruct.new(options, recurse_over_arrays: true)
end | ruby | def get_international(parcel_params)
response = @connection.get INTERNATIONAL_URL, params: parcel_params
options = response.parsed.tap do |so|
so.delete('success')
so.delete('message_id')
end
RecursiveOpenStruct.new(options, recurse_over_arrays: true)
end | [
"def",
"get_international",
"(",
"parcel_params",
")",
"response",
"=",
"@connection",
".",
"get",
"INTERNATIONAL_URL",
",",
"params",
":",
"parcel_params",
"options",
"=",
"response",
".",
"parsed",
".",
"tap",
"do",
"|",
"so",
"|",
"so",
".",
"delete",
"("... | Search for International Shipping Options
@param parcel_params [Hash] parcel parameters
@return [Array] return array of shipping options | [
"Search",
"for",
"International",
"Shipping",
"Options"
] | fcb8d64e45f7ba72bab48f143ac5115b0441aced | https://github.com/etailer/parcel_api/blob/fcb8d64e45f7ba72bab48f143ac5115b0441aced/lib/parcel_api/shipping_options.rb#L34-L41 |
7,592 | 26fe/tree.rb | lib/tree_rb/input_plugins/file_system/directory_walker.rb | TreeRb.DirTreeWalker.run | def run(dirname = nil, tree_node_visitor = nil, &block)
#
# args detection
#
if dirname and dirname.respond_to?(:enter_node)
tree_node_visitor = dirname
dirname = nil
end
#
# check dirname
#
if @dirname.nil? and dirname.nil?
raise... | ruby | def run(dirname = nil, tree_node_visitor = nil, &block)
#
# args detection
#
if dirname and dirname.respond_to?(:enter_node)
tree_node_visitor = dirname
dirname = nil
end
#
# check dirname
#
if @dirname.nil? and dirname.nil?
raise... | [
"def",
"run",
"(",
"dirname",
"=",
"nil",
",",
"tree_node_visitor",
"=",
"nil",
",",
"&",
"block",
")",
"#",
"# args detection",
"#",
"if",
"dirname",
"and",
"dirname",
".",
"respond_to?",
"(",
":enter_node",
")",
"tree_node_visitor",
"=",
"dirname",
"dirnam... | Run the visitor through the directory tree
@overload run
@overload run(dirname)
@param [String] dirname
@yield define TreeNodeVisitor
@overload run(tree_node_visitor)
@param [TreeNodeVisitor]
@yield define TreeNodeVisitor
@overload run(dirname, tree_node_visitor)
@param [String] dirname
@param... | [
"Run",
"the",
"visitor",
"through",
"the",
"directory",
"tree"
] | 5ecf0cfbbc439e27c72b9676d6a1ccee8e6bb02b | https://github.com/26fe/tree.rb/blob/5ecf0cfbbc439e27c72b9676d6a1ccee8e6bb02b/lib/tree_rb/input_plugins/file_system/directory_walker.rb#L215-L257 |
7,593 | 26fe/tree.rb | lib/tree_rb/input_plugins/file_system/directory_walker.rb | TreeRb.DirTreeWalker.process_directory | def process_directory(dirname, level=1)
begin
entries = Dir.entries(dirname).sort
rescue Errno::EACCES => e
$stderr.puts e
@visitor.cannot_enter_node(dirname, e)
return
rescue Errno::EPERM => e
$stderr.puts e
@visitor.cannot_enter_node(dirname, e)
... | ruby | def process_directory(dirname, level=1)
begin
entries = Dir.entries(dirname).sort
rescue Errno::EACCES => e
$stderr.puts e
@visitor.cannot_enter_node(dirname, e)
return
rescue Errno::EPERM => e
$stderr.puts e
@visitor.cannot_enter_node(dirname, e)
... | [
"def",
"process_directory",
"(",
"dirname",
",",
"level",
"=",
"1",
")",
"begin",
"entries",
"=",
"Dir",
".",
"entries",
"(",
"dirname",
")",
".",
"sort",
"rescue",
"Errno",
"::",
"EACCES",
"=>",
"e",
"$stderr",
".",
"puts",
"e",
"@visitor",
".",
"cann... | recurse on other directories | [
"recurse",
"on",
"other",
"directories"
] | 5ecf0cfbbc439e27c72b9676d6a1ccee8e6bb02b | https://github.com/26fe/tree.rb/blob/5ecf0cfbbc439e27c72b9676d6a1ccee8e6bb02b/lib/tree_rb/input_plugins/file_system/directory_walker.rb#L274-L317 |
7,594 | marcmo/cxxproject | lib/cxxproject/plugin_context.rb | Cxxproject.PluginContext.cxx_plugin | def cxx_plugin(&blk)
if blk.arity != @expected_arity
return
end
case blk.arity
when 0
blk.call()
when 3
blk.call(@cxxproject2rake, @building_blocks, @log)
end
end | ruby | def cxx_plugin(&blk)
if blk.arity != @expected_arity
return
end
case blk.arity
when 0
blk.call()
when 3
blk.call(@cxxproject2rake, @building_blocks, @log)
end
end | [
"def",
"cxx_plugin",
"(",
"&",
"blk",
")",
"if",
"blk",
".",
"arity",
"!=",
"@expected_arity",
"return",
"end",
"case",
"blk",
".",
"arity",
"when",
"0",
"blk",
".",
"call",
"(",
")",
"when",
"3",
"blk",
".",
"call",
"(",
"@cxxproject2rake",
",",
"@b... | method for plugins to get the
cxxproject2rake
building_blocks
log | [
"method",
"for",
"plugins",
"to",
"get",
"the",
"cxxproject2rake",
"building_blocks",
"log"
] | 3740a09d6a143acd96bde3d2ff79055a6b810da4 | https://github.com/marcmo/cxxproject/blob/3740a09d6a143acd96bde3d2ff79055a6b810da4/lib/cxxproject/plugin_context.rb#L37-L48 |
7,595 | payout/podbay | lib/podbay/consul.rb | Podbay.Consul.node_healthy? | def node_healthy?(hostname, services = [], iterations = 60)
print "Waiting for #{hostname} to become healthy"
services = services.reject { |s| get_service_check(s).empty? }.freeze
iterations.times do
print '.'
checks = hostname_health_checks(hostname)
has_services = (service... | ruby | def node_healthy?(hostname, services = [], iterations = 60)
print "Waiting for #{hostname} to become healthy"
services = services.reject { |s| get_service_check(s).empty? }.freeze
iterations.times do
print '.'
checks = hostname_health_checks(hostname)
has_services = (service... | [
"def",
"node_healthy?",
"(",
"hostname",
",",
"services",
"=",
"[",
"]",
",",
"iterations",
"=",
"60",
")",
"print",
"\"Waiting for #{hostname} to become healthy\"",
"services",
"=",
"services",
".",
"reject",
"{",
"|",
"s",
"|",
"get_service_check",
"(",
"s",
... | Wait for all health checks on the host to become healthy.
services - services to perform health checks on (if health checks are
defined) | [
"Wait",
"for",
"all",
"health",
"checks",
"on",
"the",
"host",
"to",
"become",
"healthy",
"."
] | a17cc1db6a1f032d9d7005136e4176dbe7f3a73d | https://github.com/payout/podbay/blob/a17cc1db6a1f032d9d7005136e4176dbe7f3a73d/lib/podbay/consul.rb#L31-L56 |
7,596 | payout/podbay | lib/podbay/consul.rb | Podbay.Consul.available_services | def available_services(index = nil)
loop do
begin
resp, nindex = _service.get_all(index: index)
return [resp.keys - ['consul'], nindex] if nindex != index
rescue Diplomat::Timeout
# Continue waiting
end
end
end | ruby | def available_services(index = nil)
loop do
begin
resp, nindex = _service.get_all(index: index)
return [resp.keys - ['consul'], nindex] if nindex != index
rescue Diplomat::Timeout
# Continue waiting
end
end
end | [
"def",
"available_services",
"(",
"index",
"=",
"nil",
")",
"loop",
"do",
"begin",
"resp",
",",
"nindex",
"=",
"_service",
".",
"get_all",
"(",
"index",
":",
"index",
")",
"return",
"[",
"resp",
".",
"keys",
"-",
"[",
"'consul'",
"]",
",",
"nindex",
... | Blocks forever waiting for updates to the list of available services. | [
"Blocks",
"forever",
"waiting",
"for",
"updates",
"to",
"the",
"list",
"of",
"available",
"services",
"."
] | a17cc1db6a1f032d9d7005136e4176dbe7f3a73d | https://github.com/payout/podbay/blob/a17cc1db6a1f032d9d7005136e4176dbe7f3a73d/lib/podbay/consul.rb#L102-L111 |
7,597 | payout/podbay | lib/podbay/consul.rb | Podbay.Consul.service_addresses | def service_addresses(service, index = nil)
loop do
addresses, nindex = service_addresses!(service, index)
return [addresses, nindex] if addresses && nindex
end
end | ruby | def service_addresses(service, index = nil)
loop do
addresses, nindex = service_addresses!(service, index)
return [addresses, nindex] if addresses && nindex
end
end | [
"def",
"service_addresses",
"(",
"service",
",",
"index",
"=",
"nil",
")",
"loop",
"do",
"addresses",
",",
"nindex",
"=",
"service_addresses!",
"(",
"service",
",",
"index",
")",
"return",
"[",
"addresses",
",",
"nindex",
"]",
"if",
"addresses",
"&&",
"nin... | Blocks forever waiting for updates to service addresses. | [
"Blocks",
"forever",
"waiting",
"for",
"updates",
"to",
"service",
"addresses",
"."
] | a17cc1db6a1f032d9d7005136e4176dbe7f3a73d | https://github.com/payout/podbay/blob/a17cc1db6a1f032d9d7005136e4176dbe7f3a73d/lib/podbay/consul.rb#L115-L120 |
7,598 | payout/podbay | lib/podbay/consul.rb | Podbay.Consul.service_addresses! | def service_addresses!(service, index = nil)
meta = {}
resp = _service.get(service, :all, {index: index, wait: '2s'}, meta)
if (nindex = meta[:index]) != index
addresses = resp.map do |address|
{
id: address.ServiceID,
ip: address.ServiceAddress,
... | ruby | def service_addresses!(service, index = nil)
meta = {}
resp = _service.get(service, :all, {index: index, wait: '2s'}, meta)
if (nindex = meta[:index]) != index
addresses = resp.map do |address|
{
id: address.ServiceID,
ip: address.ServiceAddress,
... | [
"def",
"service_addresses!",
"(",
"service",
",",
"index",
"=",
"nil",
")",
"meta",
"=",
"{",
"}",
"resp",
"=",
"_service",
".",
"get",
"(",
"service",
",",
":all",
",",
"{",
"index",
":",
"index",
",",
"wait",
":",
"'2s'",
"}",
",",
"meta",
")",
... | Non-blocking request for service_addresses. | [
"Non",
"-",
"blocking",
"request",
"for",
"service_addresses",
"."
] | a17cc1db6a1f032d9d7005136e4176dbe7f3a73d | https://github.com/payout/podbay/blob/a17cc1db6a1f032d9d7005136e4176dbe7f3a73d/lib/podbay/consul.rb#L124-L140 |
7,599 | kamui/rack-accept_headers | lib/rack/accept_headers/media_type.rb | Rack::AcceptHeaders.MediaType.matches | def matches(media_type)
type, subtype, params = parse_media_type(media_type)
values.select {|v|
if v == media_type || v == '*/*'
true
else
t, s, p = parse_media_type(v)
t == type && (s == '*' || s == subtype) && (p == '' || params_match?(params, p))
end
... | ruby | def matches(media_type)
type, subtype, params = parse_media_type(media_type)
values.select {|v|
if v == media_type || v == '*/*'
true
else
t, s, p = parse_media_type(v)
t == type && (s == '*' || s == subtype) && (p == '' || params_match?(params, p))
end
... | [
"def",
"matches",
"(",
"media_type",
")",
"type",
",",
"subtype",
",",
"params",
"=",
"parse_media_type",
"(",
"media_type",
")",
"values",
".",
"select",
"{",
"|",
"v",
"|",
"if",
"v",
"==",
"media_type",
"||",
"v",
"==",
"'*/*'",
"true",
"else",
"t",... | Returns an array of media types from this header that match the given
+media_type+, ordered by precedence. | [
"Returns",
"an",
"array",
"of",
"media",
"types",
"from",
"this",
"header",
"that",
"match",
"the",
"given",
"+",
"media_type",
"+",
"ordered",
"by",
"precedence",
"."
] | 099bfbb919de86b5842c8e14be42b8b784e53f03 | https://github.com/kamui/rack-accept_headers/blob/099bfbb919de86b5842c8e14be42b8b784e53f03/lib/rack/accept_headers/media_type.rb#L27-L40 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.