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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
18,000 | akretion/ooor | lib/ooor/type_casting.rb | Ooor.TypeCasting.cast_association | def cast_association(k)
if self.class.one2many_associations[k]
if @loaded_associations[k]
v = @loaded_associations[k].select {|i| i.changed?}
v = @associations[k] if v.empty?
else
v = @associations[k]
end
cast_o2m_association(v)
elsif self.class.... | ruby | def cast_association(k)
if self.class.one2many_associations[k]
if @loaded_associations[k]
v = @loaded_associations[k].select {|i| i.changed?}
v = @associations[k] if v.empty?
else
v = @associations[k]
end
cast_o2m_association(v)
elsif self.class.... | [
"def",
"cast_association",
"(",
"k",
")",
"if",
"self",
".",
"class",
".",
"one2many_associations",
"[",
"k",
"]",
"if",
"@loaded_associations",
"[",
"k",
"]",
"v",
"=",
"@loaded_associations",
"[",
"k",
"]",
".",
"select",
"{",
"|",
"i",
"|",
"i",
"."... | talk OpenERP cryptic associations API | [
"talk",
"OpenERP",
"cryptic",
"associations",
"API"
] | f0aa6c70601cc28dbbb519ebec33af40f57b3943 | https://github.com/akretion/ooor/blob/f0aa6c70601cc28dbbb519ebec33af40f57b3943/lib/ooor/type_casting.rb#L163-L179 |
18,001 | akretion/ooor | lib/ooor/base.rb | Ooor.Base.on_change | def on_change(on_change_method, field_name, field_value, *args)
# NOTE: OpenERP doesn't accept context systematically in on_change events unfortunately
ids = self.id ? [id] : []
result = self.class.object_service(:execute, self.class.openerp_model, on_change_method, ids, *args)
load_on_change_re... | ruby | def on_change(on_change_method, field_name, field_value, *args)
# NOTE: OpenERP doesn't accept context systematically in on_change events unfortunately
ids = self.id ? [id] : []
result = self.class.object_service(:execute, self.class.openerp_model, on_change_method, ids, *args)
load_on_change_re... | [
"def",
"on_change",
"(",
"on_change_method",
",",
"field_name",
",",
"field_value",
",",
"*",
"args",
")",
"# NOTE: OpenERP doesn't accept context systematically in on_change events unfortunately",
"ids",
"=",
"self",
".",
"id",
"?",
"[",
"id",
"]",
":",
"[",
"]",
"... | Generic OpenERP on_change method | [
"Generic",
"OpenERP",
"on_change",
"method"
] | f0aa6c70601cc28dbbb519ebec33af40f57b3943 | https://github.com/akretion/ooor/blob/f0aa6c70601cc28dbbb519ebec33af40f57b3943/lib/ooor/base.rb#L100-L105 |
18,002 | akretion/ooor | lib/ooor/base.rb | Ooor.Base.wkf_action | def wkf_action(action, context={}, reload=true)
self.class.object_service(:exec_workflow, self.class.openerp_model, action, self.id, context)
reload_fields if reload
end | ruby | def wkf_action(action, context={}, reload=true)
self.class.object_service(:exec_workflow, self.class.openerp_model, action, self.id, context)
reload_fields if reload
end | [
"def",
"wkf_action",
"(",
"action",
",",
"context",
"=",
"{",
"}",
",",
"reload",
"=",
"true",
")",
"self",
".",
"class",
".",
"object_service",
"(",
":exec_workflow",
",",
"self",
".",
"class",
".",
"openerp_model",
",",
"action",
",",
"self",
".",
"i... | wrapper for OpenERP exec_workflow Business Process Management engine | [
"wrapper",
"for",
"OpenERP",
"exec_workflow",
"Business",
"Process",
"Management",
"engine"
] | f0aa6c70601cc28dbbb519ebec33af40f57b3943 | https://github.com/akretion/ooor/blob/f0aa6c70601cc28dbbb519ebec33af40f57b3943/lib/ooor/base.rb#L108-L111 |
18,003 | akretion/ooor | lib/ooor/persistence.rb | Ooor.Persistence.load | def load(attributes)
self.class.reload_fields_definition(false)
raise ArgumentError, "expected an attributes Hash, got #{attributes.inspect}" unless attributes.is_a?(Hash)
@associations ||= {}
@attributes ||= {}
@loaded_associations = {}
attributes.each do |key, value|
self.s... | ruby | def load(attributes)
self.class.reload_fields_definition(false)
raise ArgumentError, "expected an attributes Hash, got #{attributes.inspect}" unless attributes.is_a?(Hash)
@associations ||= {}
@attributes ||= {}
@loaded_associations = {}
attributes.each do |key, value|
self.s... | [
"def",
"load",
"(",
"attributes",
")",
"self",
".",
"class",
".",
"reload_fields_definition",
"(",
"false",
")",
"raise",
"ArgumentError",
",",
"\"expected an attributes Hash, got #{attributes.inspect}\"",
"unless",
"attributes",
".",
"is_a?",
"(",
"Hash",
")",
"@asso... | Flushes the current object and loads the +attributes+ Hash
containing the attributes and the associations into the current object | [
"Flushes",
"the",
"current",
"object",
"and",
"loads",
"the",
"+",
"attributes",
"+",
"Hash",
"containing",
"the",
"attributes",
"and",
"the",
"associations",
"into",
"the",
"current",
"object"
] | f0aa6c70601cc28dbbb519ebec33af40f57b3943 | https://github.com/akretion/ooor/blob/f0aa6c70601cc28dbbb519ebec33af40f57b3943/lib/ooor/persistence.rb#L86-L96 |
18,004 | akretion/ooor | lib/ooor/persistence.rb | Ooor.Persistence.copy | def copy(defaults={}, context={})
self.class.find(rpc_execute('copy', id, defaults, context), context: context)
end | ruby | def copy(defaults={}, context={})
self.class.find(rpc_execute('copy', id, defaults, context), context: context)
end | [
"def",
"copy",
"(",
"defaults",
"=",
"{",
"}",
",",
"context",
"=",
"{",
"}",
")",
"self",
".",
"class",
".",
"find",
"(",
"rpc_execute",
"(",
"'copy'",
",",
"id",
",",
"defaults",
",",
"context",
")",
",",
"context",
":",
"context",
")",
"end"
] | OpenERP copy method, load persisted copied Object | [
"OpenERP",
"copy",
"method",
"load",
"persisted",
"copied",
"Object"
] | f0aa6c70601cc28dbbb519ebec33af40f57b3943 | https://github.com/akretion/ooor/blob/f0aa6c70601cc28dbbb519ebec33af40f57b3943/lib/ooor/persistence.rb#L225-L227 |
18,005 | akretion/ooor | lib/ooor/persistence.rb | Ooor.Persistence.perform_validations | def perform_validations(options={}) # :nodoc:
if options.is_a?(Hash)
options[:validate] == false || valid?(options[:context])
else
valid?
end
end | ruby | def perform_validations(options={}) # :nodoc:
if options.is_a?(Hash)
options[:validate] == false || valid?(options[:context])
else
valid?
end
end | [
"def",
"perform_validations",
"(",
"options",
"=",
"{",
"}",
")",
"# :nodoc:",
"if",
"options",
".",
"is_a?",
"(",
"Hash",
")",
"options",
"[",
":validate",
"]",
"==",
"false",
"||",
"valid?",
"(",
"options",
"[",
":context",
"]",
")",
"else",
"valid?",
... | Real validations happens on OpenERP side, only pre-validations can happen here eventually | [
"Real",
"validations",
"happens",
"on",
"OpenERP",
"side",
"only",
"pre",
"-",
"validations",
"can",
"happen",
"here",
"eventually"
] | f0aa6c70601cc28dbbb519ebec33af40f57b3943 | https://github.com/akretion/ooor/blob/f0aa6c70601cc28dbbb519ebec33af40f57b3943/lib/ooor/persistence.rb#L250-L256 |
18,006 | rspec/rspec-activemodel-mocks | lib/rspec/active_model/mocks/mocks.rb | RSpec::ActiveModel::Mocks.Mocks.stub_model | def stub_model(model_class, stubs={})
model_class.new.tap do |m|
m.extend ActiveModelStubExtensions
if defined?(ActiveRecord) && model_class < ActiveRecord::Base && model_class.primary_key
m.extend ActiveRecordStubExtensions
primary_key = model_class.primary_key.to_sym
... | ruby | def stub_model(model_class, stubs={})
model_class.new.tap do |m|
m.extend ActiveModelStubExtensions
if defined?(ActiveRecord) && model_class < ActiveRecord::Base && model_class.primary_key
m.extend ActiveRecordStubExtensions
primary_key = model_class.primary_key.to_sym
... | [
"def",
"stub_model",
"(",
"model_class",
",",
"stubs",
"=",
"{",
"}",
")",
"model_class",
".",
"new",
".",
"tap",
"do",
"|",
"m",
"|",
"m",
".",
"extend",
"ActiveModelStubExtensions",
"if",
"defined?",
"(",
"ActiveRecord",
")",
"&&",
"model_class",
"<",
... | Creates an instance of `Model` with `to_param` stubbed using a
generated value that is unique to each object. If `Model` is an
`ActiveRecord` model, it is prohibited from accessing the database.
For each key in `stubs`, if the model has a matching attribute
(determined by `respond_to?`) it is simply assigned the s... | [
"Creates",
"an",
"instance",
"of",
"Model",
"with",
"to_param",
"stubbed",
"using",
"a",
"generated",
"value",
"that",
"is",
"unique",
"to",
"each",
"object",
".",
"If",
"Model",
"is",
"an",
"ActiveRecord",
"model",
"it",
"is",
"prohibited",
"from",
"accessi... | 0338d50039cad672bbe695fff5591da1ba849308 | https://github.com/rspec/rspec-activemodel-mocks/blob/0338d50039cad672bbe695fff5591da1ba849308/lib/rspec/active_model/mocks/mocks.rb#L243-L267 |
18,007 | tmm1/pygments.rb | lib/pygments/popen.rb | Pygments.Popen.stop | def stop(reason)
if @pid
begin
Process.kill('KILL', @pid)
Process.waitpid(@pid)
rescue Errno::ESRCH, Errno::ECHILD
end
end
@log.info "Killing pid: #{@pid.to_s}. Reason: #{reason}"
@pid = nil
end | ruby | def stop(reason)
if @pid
begin
Process.kill('KILL', @pid)
Process.waitpid(@pid)
rescue Errno::ESRCH, Errno::ECHILD
end
end
@log.info "Killing pid: #{@pid.to_s}. Reason: #{reason}"
@pid = nil
end | [
"def",
"stop",
"(",
"reason",
")",
"if",
"@pid",
"begin",
"Process",
".",
"kill",
"(",
"'KILL'",
",",
"@pid",
")",
"Process",
".",
"waitpid",
"(",
"@pid",
")",
"rescue",
"Errno",
"::",
"ESRCH",
",",
"Errno",
"::",
"ECHILD",
"end",
"end",
"@log",
".",... | Stop the child process by issuing a kill -9.
We then call waitpid() with the pid, which waits for that particular
child and reaps it.
kill() can set errno to ESRCH if, for some reason, the file
is gone; regardless the final outcome of this method
will be to set our @pid variable to nil.
Technically, kill() can... | [
"Stop",
"the",
"child",
"process",
"by",
"issuing",
"a",
"kill",
"-",
"9",
"."
] | 926d1adad88c22f92010a0f284d2dcc10213ec1e | https://github.com/tmm1/pygments.rb/blob/926d1adad88c22f92010a0f284d2dcc10213ec1e/lib/pygments/popen.rb#L96-L106 |
18,008 | tmm1/pygments.rb | lib/pygments/popen.rb | Pygments.Popen.mentos | def mentos(method, args=[], kwargs={}, original_code=nil)
# Open the pipe if necessary
start unless alive?
begin
# Timeout requests that take too long.
# Invalid MENTOS_TIMEOUT results in just using default.
timeout_time = Integer(ENV["MENTOS_TIMEOUT"]) rescue 8
Timeo... | ruby | def mentos(method, args=[], kwargs={}, original_code=nil)
# Open the pipe if necessary
start unless alive?
begin
# Timeout requests that take too long.
# Invalid MENTOS_TIMEOUT results in just using default.
timeout_time = Integer(ENV["MENTOS_TIMEOUT"]) rescue 8
Timeo... | [
"def",
"mentos",
"(",
"method",
",",
"args",
"=",
"[",
"]",
",",
"kwargs",
"=",
"{",
"}",
",",
"original_code",
"=",
"nil",
")",
"# Open the pipe if necessary",
"start",
"unless",
"alive?",
"begin",
"# Timeout requests that take too long.",
"# Invalid MENTOS_TIMEOUT... | Our 'rpc'-ish request to mentos. Requires a method name, and then optional
args, kwargs, code. | [
"Our",
"rpc",
"-",
"ish",
"request",
"to",
"mentos",
".",
"Requires",
"a",
"method",
"name",
"and",
"then",
"optional",
"args",
"kwargs",
"code",
"."
] | 926d1adad88c22f92010a0f284d2dcc10213ec1e | https://github.com/tmm1/pygments.rb/blob/926d1adad88c22f92010a0f284d2dcc10213ec1e/lib/pygments/popen.rb#L245-L299 |
18,009 | tmm1/pygments.rb | lib/pygments/popen.rb | Pygments.Popen.handle_header_and_return | def handle_header_and_return(header, id)
if header
header = header_to_json(header)
bytes = header[:bytes]
# Read more bytes (the actual response body)
res = @out.read(bytes.to_i)
if header[:method] == "highlight"
# Make sure we have a result back; else consider ... | ruby | def handle_header_and_return(header, id)
if header
header = header_to_json(header)
bytes = header[:bytes]
# Read more bytes (the actual response body)
res = @out.read(bytes.to_i)
if header[:method] == "highlight"
# Make sure we have a result back; else consider ... | [
"def",
"handle_header_and_return",
"(",
"header",
",",
"id",
")",
"if",
"header",
"header",
"=",
"header_to_json",
"(",
"header",
")",
"bytes",
"=",
"header",
"[",
":bytes",
"]",
"# Read more bytes (the actual response body)",
"res",
"=",
"@out",
".",
"read",
"(... | Based on the header we receive, determine if we need
to read more bytes, and read those bytes if necessary.
Then, do a sanity check with the ids.
Returns a result — either highlighted text or metadata. | [
"Based",
"on",
"the",
"header",
"we",
"receive",
"determine",
"if",
"we",
"need",
"to",
"read",
"more",
"bytes",
"and",
"read",
"those",
"bytes",
"if",
"necessary",
"."
] | 926d1adad88c22f92010a0f284d2dcc10213ec1e | https://github.com/tmm1/pygments.rb/blob/926d1adad88c22f92010a0f284d2dcc10213ec1e/lib/pygments/popen.rb#L327-L369 |
18,010 | tmm1/pygments.rb | lib/pygments/popen.rb | Pygments.Popen.get_header | def get_header
begin
size = @out.read(33)
size = size[0..-2]
# Sanity check the size
if not size_check(size)
@log.error "Size returned from mentos.py invalid."
stop "Size returned from mentos.py invalid."
raise MentosError, "Size returned from mentos.... | ruby | def get_header
begin
size = @out.read(33)
size = size[0..-2]
# Sanity check the size
if not size_check(size)
@log.error "Size returned from mentos.py invalid."
stop "Size returned from mentos.py invalid."
raise MentosError, "Size returned from mentos.... | [
"def",
"get_header",
"begin",
"size",
"=",
"@out",
".",
"read",
"(",
"33",
")",
"size",
"=",
"size",
"[",
"0",
"..",
"-",
"2",
"]",
"# Sanity check the size",
"if",
"not",
"size_check",
"(",
"size",
")",
"@log",
".",
"error",
"\"Size returned from mentos.p... | Read the header via the pipe.
Returns a header. | [
"Read",
"the",
"header",
"via",
"the",
"pipe",
"."
] | 926d1adad88c22f92010a0f284d2dcc10213ec1e | https://github.com/tmm1/pygments.rb/blob/926d1adad88c22f92010a0f284d2dcc10213ec1e/lib/pygments/popen.rb#L401-L423 |
18,011 | tmm1/pygments.rb | lib/pygments/popen.rb | Pygments.Popen.return_result | def return_result(res, method)
unless method == :lexer_name_for || method == :highlight || method == :css
res = MultiJson.load(res, :symbolize_keys => true)
end
res = res.rstrip if res.class == String
res
end | ruby | def return_result(res, method)
unless method == :lexer_name_for || method == :highlight || method == :css
res = MultiJson.load(res, :symbolize_keys => true)
end
res = res.rstrip if res.class == String
res
end | [
"def",
"return_result",
"(",
"res",
",",
"method",
")",
"unless",
"method",
"==",
":lexer_name_for",
"||",
"method",
"==",
":highlight",
"||",
"method",
"==",
":css",
"res",
"=",
"MultiJson",
".",
"load",
"(",
"res",
",",
":symbolize_keys",
"=>",
"true",
"... | Return the final result for the API. Return Ruby objects for the methods that
want them, text otherwise. | [
"Return",
"the",
"final",
"result",
"for",
"the",
"API",
".",
"Return",
"Ruby",
"objects",
"for",
"the",
"methods",
"that",
"want",
"them",
"text",
"otherwise",
"."
] | 926d1adad88c22f92010a0f284d2dcc10213ec1e | https://github.com/tmm1/pygments.rb/blob/926d1adad88c22f92010a0f284d2dcc10213ec1e/lib/pygments/popen.rb#L427-L433 |
18,012 | tmm1/pygments.rb | lib/pygments/popen.rb | Pygments.Popen.header_to_json | def header_to_json(header)
@log.info "[In header: #{header} "
header = MultiJson.load(header, :symbolize_keys => true)
if header[:error]
# Raise this as a Ruby exception of the MentosError class.
# Stop so we don't leave the pipe in an inconsistent state.
@log.error "Failed to... | ruby | def header_to_json(header)
@log.info "[In header: #{header} "
header = MultiJson.load(header, :symbolize_keys => true)
if header[:error]
# Raise this as a Ruby exception of the MentosError class.
# Stop so we don't leave the pipe in an inconsistent state.
@log.error "Failed to... | [
"def",
"header_to_json",
"(",
"header",
")",
"@log",
".",
"info",
"\"[In header: #{header} \"",
"header",
"=",
"MultiJson",
".",
"load",
"(",
"header",
",",
":symbolize_keys",
"=>",
"true",
")",
"if",
"header",
"[",
":error",
"]",
"# Raise this as a Ruby exception... | Convert a text header into JSON for easy access. | [
"Convert",
"a",
"text",
"header",
"into",
"JSON",
"for",
"easy",
"access",
"."
] | 926d1adad88c22f92010a0f284d2dcc10213ec1e | https://github.com/tmm1/pygments.rb/blob/926d1adad88c22f92010a0f284d2dcc10213ec1e/lib/pygments/popen.rb#L436-L449 |
18,013 | pboling/flag_shih_tzu | lib/flag_shih_tzu.rb | FlagShihTzu.ClassMethods.sql_in_for_flag | def sql_in_for_flag(flag, colmn)
val = flag_mapping[colmn][flag]
flag_value_range_for_column(colmn).select { |bits| bits & val == val }
end | ruby | def sql_in_for_flag(flag, colmn)
val = flag_mapping[colmn][flag]
flag_value_range_for_column(colmn).select { |bits| bits & val == val }
end | [
"def",
"sql_in_for_flag",
"(",
"flag",
",",
"colmn",
")",
"val",
"=",
"flag_mapping",
"[",
"colmn",
"]",
"[",
"flag",
"]",
"flag_value_range_for_column",
"(",
"colmn",
")",
".",
"select",
"{",
"|",
"bits",
"|",
"bits",
"&",
"val",
"==",
"val",
"}",
"en... | returns an array of integers suitable for a SQL IN statement. | [
"returns",
"an",
"array",
"of",
"integers",
"suitable",
"for",
"a",
"SQL",
"IN",
"statement",
"."
] | 07a5b8b817d456d1a663581d4bbce37834a1795c | https://github.com/pboling/flag_shih_tzu/blob/07a5b8b817d456d1a663581d4bbce37834a1795c/lib/flag_shih_tzu.rb#L429-L432 |
18,014 | Dynflow/dynflow | lib/dynflow/action/format.rb | Dynflow.Action::Format.input_format | def input_format(&block)
case
when block && !@input_format_block
@input_format_block = block
when !block && @input_format_block
return @input_format ||= Apipie::Params::Description.define(&@input_format_block)
when block && @input_format_block
raise "The input_format has ... | ruby | def input_format(&block)
case
when block && !@input_format_block
@input_format_block = block
when !block && @input_format_block
return @input_format ||= Apipie::Params::Description.define(&@input_format_block)
when block && @input_format_block
raise "The input_format has ... | [
"def",
"input_format",
"(",
"&",
"block",
")",
"case",
"when",
"block",
"&&",
"!",
"@input_format_block",
"@input_format_block",
"=",
"block",
"when",
"!",
"block",
"&&",
"@input_format_block",
"return",
"@input_format",
"||=",
"Apipie",
"::",
"Params",
"::",
"D... | we don't evaluate tbe block immediatelly, but postpone it till all the
action classes are loaded, because we can use them to reference output format | [
"we",
"don",
"t",
"evaluate",
"tbe",
"block",
"immediatelly",
"but",
"postpone",
"it",
"till",
"all",
"the",
"action",
"classes",
"are",
"loaded",
"because",
"we",
"can",
"use",
"them",
"to",
"reference",
"output",
"format"
] | b52b2a91e36e34f8736200afa7a3fe5e1c94a020 | https://github.com/Dynflow/dynflow/blob/b52b2a91e36e34f8736200afa7a3fe5e1c94a020/lib/dynflow/action/format.rb#L10-L25 |
18,015 | Dynflow/dynflow | lib/dynflow/serializable.rb | Dynflow.Serializable.recursive_to_hash | def recursive_to_hash(*values)
if values.size == 1
value = values.first
case value
when String, Numeric, Symbol, TrueClass, FalseClass, NilClass, Time
value
when Hash
value.inject({}) { |h, (k, v)| h.update k => recursive_to_hash(v) }
when Array
... | ruby | def recursive_to_hash(*values)
if values.size == 1
value = values.first
case value
when String, Numeric, Symbol, TrueClass, FalseClass, NilClass, Time
value
when Hash
value.inject({}) { |h, (k, v)| h.update k => recursive_to_hash(v) }
when Array
... | [
"def",
"recursive_to_hash",
"(",
"*",
"values",
")",
"if",
"values",
".",
"size",
"==",
"1",
"value",
"=",
"values",
".",
"first",
"case",
"value",
"when",
"String",
",",
"Numeric",
",",
"Symbol",
",",
"TrueClass",
",",
"FalseClass",
",",
"NilClass",
","... | recursively traverses hash-array structure and converts all to hashes
accepts more hashes which are then merged | [
"recursively",
"traverses",
"hash",
"-",
"array",
"structure",
"and",
"converts",
"all",
"to",
"hashes",
"accepts",
"more",
"hashes",
"which",
"are",
"then",
"merged"
] | b52b2a91e36e34f8736200afa7a3fe5e1c94a020 | https://github.com/Dynflow/dynflow/blob/b52b2a91e36e34f8736200afa7a3fe5e1c94a020/lib/dynflow/serializable.rb#L39-L56 |
18,016 | Dynflow/dynflow | lib/dynflow/action/with_sub_plans.rb | Dynflow.Action::WithSubPlans.trigger | def trigger(action_class, *args)
if uses_concurrency_control
trigger_with_concurrency_control(action_class, *args)
else
world.trigger { world.plan_with_options(action_class: action_class, args: args, caller_action: self) }
end
end | ruby | def trigger(action_class, *args)
if uses_concurrency_control
trigger_with_concurrency_control(action_class, *args)
else
world.trigger { world.plan_with_options(action_class: action_class, args: args, caller_action: self) }
end
end | [
"def",
"trigger",
"(",
"action_class",
",",
"*",
"args",
")",
"if",
"uses_concurrency_control",
"trigger_with_concurrency_control",
"(",
"action_class",
",",
"args",
")",
"else",
"world",
".",
"trigger",
"{",
"world",
".",
"plan_with_options",
"(",
"action_class",
... | Helper for creating sub plans | [
"Helper",
"for",
"creating",
"sub",
"plans"
] | b52b2a91e36e34f8736200afa7a3fe5e1c94a020 | https://github.com/Dynflow/dynflow/blob/b52b2a91e36e34f8736200afa7a3fe5e1c94a020/lib/dynflow/action/with_sub_plans.rb#L79-L85 |
18,017 | Dynflow/dynflow | lib/dynflow/action/with_bulk_sub_plans.rb | Dynflow.Action::WithBulkSubPlans.current_batch | def current_batch
start_position = output[:planned_count]
size = start_position + batch_size > total_count ? total_count - start_position : batch_size
batch(start_position, size)
end | ruby | def current_batch
start_position = output[:planned_count]
size = start_position + batch_size > total_count ? total_count - start_position : batch_size
batch(start_position, size)
end | [
"def",
"current_batch",
"start_position",
"=",
"output",
"[",
":planned_count",
"]",
"size",
"=",
"start_position",
"+",
"batch_size",
">",
"total_count",
"?",
"total_count",
"-",
"start_position",
":",
"batch_size",
"batch",
"(",
"start_position",
",",
"size",
")... | Returns the items in the current batch | [
"Returns",
"the",
"items",
"in",
"the",
"current",
"batch"
] | b52b2a91e36e34f8736200afa7a3fe5e1c94a020 | https://github.com/Dynflow/dynflow/blob/b52b2a91e36e34f8736200afa7a3fe5e1c94a020/lib/dynflow/action/with_bulk_sub_plans.rb#L49-L53 |
18,018 | Dynflow/dynflow | lib/dynflow/execution_plan/dependency_graph.rb | Dynflow.ExecutionPlan::DependencyGraph.add_dependencies | def add_dependencies(step, action)
action.required_step_ids.each do |required_step_id|
@graph[step.id] << required_step_id
end
end | ruby | def add_dependencies(step, action)
action.required_step_ids.each do |required_step_id|
@graph[step.id] << required_step_id
end
end | [
"def",
"add_dependencies",
"(",
"step",
",",
"action",
")",
"action",
".",
"required_step_ids",
".",
"each",
"do",
"|",
"required_step_id",
"|",
"@graph",
"[",
"step",
".",
"id",
"]",
"<<",
"required_step_id",
"end",
"end"
] | adds dependencies to graph that +step+ has based
on the steps referenced in its +input+ | [
"adds",
"dependencies",
"to",
"graph",
"that",
"+",
"step",
"+",
"has",
"based",
"on",
"the",
"steps",
"referenced",
"in",
"its",
"+",
"input",
"+"
] | b52b2a91e36e34f8736200afa7a3fe5e1c94a020 | https://github.com/Dynflow/dynflow/blob/b52b2a91e36e34f8736200afa7a3fe5e1c94a020/lib/dynflow/execution_plan/dependency_graph.rb#L10-L14 |
18,019 | Dynflow/dynflow | lib/dynflow/world.rb | Dynflow.World.reload! | def reload!
# TODO what happens with newly loaded classes
@action_classes = @action_classes.map do |klass|
begin
Utils.constantize(klass.to_s)
rescue NameError
nil # ignore missing classes
end
end.compact
middleware.clear_cache!
calculate_subscri... | ruby | def reload!
# TODO what happens with newly loaded classes
@action_classes = @action_classes.map do |klass|
begin
Utils.constantize(klass.to_s)
rescue NameError
nil # ignore missing classes
end
end.compact
middleware.clear_cache!
calculate_subscri... | [
"def",
"reload!",
"# TODO what happens with newly loaded classes",
"@action_classes",
"=",
"@action_classes",
".",
"map",
"do",
"|",
"klass",
"|",
"begin",
"Utils",
".",
"constantize",
"(",
"klass",
".",
"to_s",
")",
"rescue",
"NameError",
"nil",
"# ignore missing cla... | reload actions classes, intended only for devel | [
"reload",
"actions",
"classes",
"intended",
"only",
"for",
"devel"
] | b52b2a91e36e34f8736200afa7a3fe5e1c94a020 | https://github.com/Dynflow/dynflow/blob/b52b2a91e36e34f8736200afa7a3fe5e1c94a020/lib/dynflow/world.rb#L117-L128 |
18,020 | Dynflow/dynflow | lib/dynflow/action/rescue.rb | Dynflow.Action::Rescue.rescue_strategy | def rescue_strategy
suggested_strategies = []
if self.steps.compact.any? { |step| step.state == :error }
suggested_strategies << SuggestedStrategy[self, rescue_strategy_for_self]
end
self.planned_actions.each do |planned_action|
rescue_strategy = rescue_strategy_for_planned_act... | ruby | def rescue_strategy
suggested_strategies = []
if self.steps.compact.any? { |step| step.state == :error }
suggested_strategies << SuggestedStrategy[self, rescue_strategy_for_self]
end
self.planned_actions.each do |planned_action|
rescue_strategy = rescue_strategy_for_planned_act... | [
"def",
"rescue_strategy",
"suggested_strategies",
"=",
"[",
"]",
"if",
"self",
".",
"steps",
".",
"compact",
".",
"any?",
"{",
"|",
"step",
"|",
"step",
".",
"state",
"==",
":error",
"}",
"suggested_strategies",
"<<",
"SuggestedStrategy",
"[",
"self",
",",
... | What strategy should be used for rescuing from error in
the action or its sub actions
@return Strategy
When determining the strategy, the algorithm starts from the
entry action that by default takes the strategy from #rescue_strategy_for_self
and #rescue_strategy_for_planned_actions and combines them together. | [
"What",
"strategy",
"should",
"be",
"used",
"for",
"rescuing",
"from",
"error",
"in",
"the",
"action",
"or",
"its",
"sub",
"actions"
] | b52b2a91e36e34f8736200afa7a3fe5e1c94a020 | https://github.com/Dynflow/dynflow/blob/b52b2a91e36e34f8736200afa7a3fe5e1c94a020/lib/dynflow/action/rescue.rb#L21-L35 |
18,021 | Dynflow/dynflow | lib/dynflow/action/rescue.rb | Dynflow.Action::Rescue.combine_suggested_strategies | def combine_suggested_strategies(suggested_strategies)
if suggested_strategies.empty?
nil
else
# TODO: Find the safest rescue strategy among the suggested ones
if suggested_strategies.all? { |suggested_strategy| suggested_strategy.strategy == Skip }
return Skip
elsi... | ruby | def combine_suggested_strategies(suggested_strategies)
if suggested_strategies.empty?
nil
else
# TODO: Find the safest rescue strategy among the suggested ones
if suggested_strategies.all? { |suggested_strategy| suggested_strategy.strategy == Skip }
return Skip
elsi... | [
"def",
"combine_suggested_strategies",
"(",
"suggested_strategies",
")",
"if",
"suggested_strategies",
".",
"empty?",
"nil",
"else",
"# TODO: Find the safest rescue strategy among the suggested ones",
"if",
"suggested_strategies",
".",
"all?",
"{",
"|",
"suggested_strategy",
"|... | Override when different approach should be taken for combining
the suggested strategies | [
"Override",
"when",
"different",
"approach",
"should",
"be",
"taken",
"for",
"combining",
"the",
"suggested",
"strategies"
] | b52b2a91e36e34f8736200afa7a3fe5e1c94a020 | https://github.com/Dynflow/dynflow/blob/b52b2a91e36e34f8736200afa7a3fe5e1c94a020/lib/dynflow/action/rescue.rb#L51-L64 |
18,022 | theodi/csvlint.rb | lib/csvlint/error_collector.rb | Csvlint.ErrorCollector.build_errors | def build_errors(type, category = nil, row = nil, column = nil, content = nil, constraints = {})
@errors << Csvlint::ErrorMessage.new(type, category, row, column, content, constraints)
end | ruby | def build_errors(type, category = nil, row = nil, column = nil, content = nil, constraints = {})
@errors << Csvlint::ErrorMessage.new(type, category, row, column, content, constraints)
end | [
"def",
"build_errors",
"(",
"type",
",",
"category",
"=",
"nil",
",",
"row",
"=",
"nil",
",",
"column",
"=",
"nil",
",",
"content",
"=",
"nil",
",",
"constraints",
"=",
"{",
"}",
")",
"@errors",
"<<",
"Csvlint",
"::",
"ErrorMessage",
".",
"new",
"(",... | Creates a validation error | [
"Creates",
"a",
"validation",
"error"
] | e11a4de001d18a1de1a692a9690f7a66b1430bfb | https://github.com/theodi/csvlint.rb/blob/e11a4de001d18a1de1a692a9690f7a66b1430bfb/lib/csvlint/error_collector.rb#L5-L7 |
18,023 | theodi/csvlint.rb | lib/csvlint/validate.rb | Csvlint.Validator.parse_contents | def parse_contents(stream, line = nil)
# parse_contents will parse one line and apply headers, formats methods and error handle as appropriate
current_line = line.present? ? line : 1
all_errors = []
@csv_options[:encoding] = @encoding
begin
row = LineCSV.parse_line(stream, @csv_o... | ruby | def parse_contents(stream, line = nil)
# parse_contents will parse one line and apply headers, formats methods and error handle as appropriate
current_line = line.present? ? line : 1
all_errors = []
@csv_options[:encoding] = @encoding
begin
row = LineCSV.parse_line(stream, @csv_o... | [
"def",
"parse_contents",
"(",
"stream",
",",
"line",
"=",
"nil",
")",
"# parse_contents will parse one line and apply headers, formats methods and error handle as appropriate",
"current_line",
"=",
"line",
".",
"present?",
"?",
"line",
":",
"1",
"all_errors",
"=",
"[",
"]... | analyses the provided csv and builds errors, warnings and info messages | [
"analyses",
"the",
"provided",
"csv",
"and",
"builds",
"errors",
"warnings",
"and",
"info",
"messages"
] | e11a4de001d18a1de1a692a9690f7a66b1430bfb | https://github.com/theodi/csvlint.rb/blob/e11a4de001d18a1de1a692a9690f7a66b1430bfb/lib/csvlint/validate.rb#L174-L210 |
18,024 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.create_order_reference_for_id | def create_order_reference_for_id(
id,
id_type,
inherit_shipping_address: nil,
confirm_now: nil,
amount: nil,
currency_code: @currency_code,
platform_id: nil,
seller_note: nil,
seller_order_id: nil,
store_name: nil,
custom_information: nil,
supplem... | ruby | def create_order_reference_for_id(
id,
id_type,
inherit_shipping_address: nil,
confirm_now: nil,
amount: nil,
currency_code: @currency_code,
platform_id: nil,
seller_note: nil,
seller_order_id: nil,
store_name: nil,
custom_information: nil,
supplem... | [
"def",
"create_order_reference_for_id",
"(",
"id",
",",
"id_type",
",",
"inherit_shipping_address",
":",
"nil",
",",
"confirm_now",
":",
"nil",
",",
"amount",
":",
"nil",
",",
"currency_code",
":",
"@currency_code",
",",
"platform_id",
":",
"nil",
",",
"seller_n... | Creates an order reference for the given object
@see https://pay.amazon.com/documentation/apireference/201751630#201751670
@param id [String]
@param id_type [String]
@optional inherit_shipping_address [Boolean]
@optional confirm_now [Boolean]
@optional amount [String] (required when confirm_now is set to true)
@... | [
"Creates",
"an",
"order",
"reference",
"for",
"the",
"given",
"object"
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L133-L172 |
18,025 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.get_billing_agreement_details | def get_billing_agreement_details(
amazon_billing_agreement_id,
address_consent_token: nil,
access_token: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'GetBillingAgreementDetails',
'SellerId' => merchant_id,
'AmazonBill... | ruby | def get_billing_agreement_details(
amazon_billing_agreement_id,
address_consent_token: nil,
access_token: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'GetBillingAgreementDetails',
'SellerId' => merchant_id,
'AmazonBill... | [
"def",
"get_billing_agreement_details",
"(",
"amazon_billing_agreement_id",
",",
"address_consent_token",
":",
"nil",
",",
"access_token",
":",
"nil",
",",
"merchant_id",
":",
"@merchant_id",
",",
"mws_auth_token",
":",
"nil",
")",
"parameters",
"=",
"{",
"'Action'",
... | Returns details about the Billing Agreement object and its current state
@see https://pay.amazon.com/documentation/apireference/201751630#201751690
@param amazon_billing_agreement_id [String]
@optional address_consent_token [String]
@optional access_token [String]
@optional merchant_id [String]
@optional mws_auth... | [
"Returns",
"details",
"about",
"the",
"Billing",
"Agreement",
"object",
"and",
"its",
"current",
"state"
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L182-L207 |
18,026 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.set_billing_agreement_details | def set_billing_agreement_details(
amazon_billing_agreement_id,
platform_id: nil,
seller_note: nil,
seller_billing_agreement_id: nil,
custom_information: nil,
store_name: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => '... | ruby | def set_billing_agreement_details(
amazon_billing_agreement_id,
platform_id: nil,
seller_note: nil,
seller_billing_agreement_id: nil,
custom_information: nil,
store_name: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => '... | [
"def",
"set_billing_agreement_details",
"(",
"amazon_billing_agreement_id",
",",
"platform_id",
":",
"nil",
",",
"seller_note",
":",
"nil",
",",
"seller_billing_agreement_id",
":",
"nil",
",",
"custom_information",
":",
"nil",
",",
"store_name",
":",
"nil",
",",
"me... | Sets billing agreement details such as a description of the agreement
and other information about the seller.
@see https://pay.amazon.com/documentation/apireference/201751630#201751700
@param amazon_billing_agreement_id [String]
@optional platform_id [String]
@optional seller_note [String]
@optional seller_billin... | [
"Sets",
"billing",
"agreement",
"details",
"such",
"as",
"a",
"description",
"of",
"the",
"agreement",
"and",
"other",
"information",
"about",
"the",
"seller",
"."
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L220-L247 |
18,027 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.confirm_billing_agreement | def confirm_billing_agreement(
amazon_billing_agreement_id,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'ConfirmBillingAgreement',
'SellerId' => merchant_id,
'AmazonBillingAgreementId' => amazon_billing_agreement_id
}
opti... | ruby | def confirm_billing_agreement(
amazon_billing_agreement_id,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'ConfirmBillingAgreement',
'SellerId' => merchant_id,
'AmazonBillingAgreementId' => amazon_billing_agreement_id
}
opti... | [
"def",
"confirm_billing_agreement",
"(",
"amazon_billing_agreement_id",
",",
"merchant_id",
":",
"@merchant_id",
",",
"mws_auth_token",
":",
"nil",
")",
"parameters",
"=",
"{",
"'Action'",
"=>",
"'ConfirmBillingAgreement'",
",",
"'SellerId'",
"=>",
"merchant_id",
",",
... | Confirms that the billing agreement is free of constraints and all
required information has been set on the billing agreement
@see https://pay.amazon.com/documentation/apireference/201751630#201751710
@param amazon_billing_agreement_id [String]
@optional merchant_id [String]
@optional mws_auth_token [String] | [
"Confirms",
"that",
"the",
"billing",
"agreement",
"is",
"free",
"of",
"constraints",
"and",
"all",
"required",
"information",
"has",
"been",
"set",
"on",
"the",
"billing",
"agreement"
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L255-L272 |
18,028 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.validate_billing_agreement | def validate_billing_agreement(
amazon_billing_agreement_id,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'ValidateBillingAgreement',
'SellerId' => merchant_id,
'AmazonBillingAgreementId' => amazon_billing_agreement_id
}
op... | ruby | def validate_billing_agreement(
amazon_billing_agreement_id,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'ValidateBillingAgreement',
'SellerId' => merchant_id,
'AmazonBillingAgreementId' => amazon_billing_agreement_id
}
op... | [
"def",
"validate_billing_agreement",
"(",
"amazon_billing_agreement_id",
",",
"merchant_id",
":",
"@merchant_id",
",",
"mws_auth_token",
":",
"nil",
")",
"parameters",
"=",
"{",
"'Action'",
"=>",
"'ValidateBillingAgreement'",
",",
"'SellerId'",
"=>",
"merchant_id",
",",... | Validates the status of the BillingAgreement object and the payment
method associated with it
@see https://pay.amazon.com/documentation/apireference/201751630#201751720
@param amazon_billing_agreement_id [String]
@optional merchant_id [String]
@optional mws_auth_token [String] | [
"Validates",
"the",
"status",
"of",
"the",
"BillingAgreement",
"object",
"and",
"the",
"payment",
"method",
"associated",
"with",
"it"
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L280-L297 |
18,029 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.close_billing_agreement | def close_billing_agreement(
amazon_billing_agreement_id,
closure_reason: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'CloseBillingAgreement',
'SellerId' => merchant_id,
'AmazonBillingAgreementId' => amazon_billing_agreement... | ruby | def close_billing_agreement(
amazon_billing_agreement_id,
closure_reason: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'CloseBillingAgreement',
'SellerId' => merchant_id,
'AmazonBillingAgreementId' => amazon_billing_agreement... | [
"def",
"close_billing_agreement",
"(",
"amazon_billing_agreement_id",
",",
"closure_reason",
":",
"nil",
",",
"merchant_id",
":",
"@merchant_id",
",",
"mws_auth_token",
":",
"nil",
")",
"parameters",
"=",
"{",
"'Action'",
"=>",
"'CloseBillingAgreement'",
",",
"'Seller... | Confirms that you want to terminate the billing agreement with the buyer
and that you do not expect to create any new order references or
authorizations on this billing agreement
@see https://pay.amazon.com/documentation/apireference/201751630#201751950
@param amazon_billing_agreement_id [String]
@optional closure... | [
"Confirms",
"that",
"you",
"want",
"to",
"terminate",
"the",
"billing",
"agreement",
"with",
"the",
"buyer",
"and",
"that",
"you",
"do",
"not",
"expect",
"to",
"create",
"any",
"new",
"order",
"references",
"or",
"authorizations",
"on",
"this",
"billing",
"a... | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L374-L393 |
18,030 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.list_order_reference | def list_order_reference(
query_id,
query_id_type,
created_time_range_start: nil,
created_time_range_end: nil,
sort_order: nil,
page_size: nil,
order_reference_status_list_filter: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
payment_domain = paym... | ruby | def list_order_reference(
query_id,
query_id_type,
created_time_range_start: nil,
created_time_range_end: nil,
sort_order: nil,
page_size: nil,
order_reference_status_list_filter: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
payment_domain = paym... | [
"def",
"list_order_reference",
"(",
"query_id",
",",
"query_id_type",
",",
"created_time_range_start",
":",
"nil",
",",
"created_time_range_end",
":",
"nil",
",",
"sort_order",
":",
"nil",
",",
"page_size",
":",
"nil",
",",
"order_reference_status_list_filter",
":",
... | Allows the search of any Amazon Pay order made using secondary
seller order IDs generated manually, a solution provider, or a custom
order fulfillment service.
@param query_id [String]
@param query_id_type [String]
@optional created_time_range_start [String]
@optional created_time_range_end [String]
@optional so... | [
"Allows",
"the",
"search",
"of",
"any",
"Amazon",
"Pay",
"order",
"made",
"using",
"secondary",
"seller",
"order",
"IDs",
"generated",
"manually",
"a",
"solution",
"provider",
"or",
"a",
"custom",
"order",
"fulfillment",
"service",
"."
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L407-L445 |
18,031 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.get_merchant_account_status | def get_merchant_account_status(
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'GetMerchantAccountStatus',
'SellerId' => merchant_id
}
optional = {
'MWSAuthToken' => mws_auth_token
}
operation(parameters, optional)
... | ruby | def get_merchant_account_status(
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'GetMerchantAccountStatus',
'SellerId' => merchant_id
}
optional = {
'MWSAuthToken' => mws_auth_token
}
operation(parameters, optional)
... | [
"def",
"get_merchant_account_status",
"(",
"merchant_id",
":",
"@merchant_id",
",",
"mws_auth_token",
":",
"nil",
")",
"parameters",
"=",
"{",
"'Action'",
"=>",
"'GetMerchantAccountStatus'",
",",
"'SellerId'",
"=>",
"merchant_id",
"}",
"optional",
"=",
"{",
"'MWSAut... | Returns status of the merchant
@optional merchant_id [String]
@optional mws_auth_token [String] | [
"Returns",
"status",
"of",
"the",
"merchant"
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L464-L479 |
18,032 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.get_order_reference_details | def get_order_reference_details(
amazon_order_reference_id,
address_consent_token: nil,
access_token: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'GetOrderReferenceDetails',
'SellerId' => merchant_id,
'AmazonOrderRefer... | ruby | def get_order_reference_details(
amazon_order_reference_id,
address_consent_token: nil,
access_token: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'GetOrderReferenceDetails',
'SellerId' => merchant_id,
'AmazonOrderRefer... | [
"def",
"get_order_reference_details",
"(",
"amazon_order_reference_id",
",",
"address_consent_token",
":",
"nil",
",",
"access_token",
":",
"nil",
",",
"merchant_id",
":",
"@merchant_id",
",",
"mws_auth_token",
":",
"nil",
")",
"parameters",
"=",
"{",
"'Action'",
"=... | Returns details about the Order Reference object and its current state
@see https://pay.amazon.com/documentation/apireference/201751630#201751970
@param amazon_order_reference_id [String]
@optional address_consent_token [String]
@optional access_token [String]
@optional merchant_id [String]
@optional mws_auth_tok... | [
"Returns",
"details",
"about",
"the",
"Order",
"Reference",
"object",
"and",
"its",
"current",
"state"
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L488-L510 |
18,033 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.set_order_reference_details | def set_order_reference_details(
amazon_order_reference_id,
amount,
currency_code: @currency_code,
platform_id: nil,
seller_note: nil,
seller_order_id: nil,
request_payment_authorization: nil,
store_name: nil,
order_item_categories: nil,
custom_information: ni... | ruby | def set_order_reference_details(
amazon_order_reference_id,
amount,
currency_code: @currency_code,
platform_id: nil,
seller_note: nil,
seller_order_id: nil,
request_payment_authorization: nil,
store_name: nil,
order_item_categories: nil,
custom_information: ni... | [
"def",
"set_order_reference_details",
"(",
"amazon_order_reference_id",
",",
"amount",
",",
"currency_code",
":",
"@currency_code",
",",
"platform_id",
":",
"nil",
",",
"seller_note",
":",
"nil",
",",
"seller_order_id",
":",
"nil",
",",
"request_payment_authorization",
... | Sets order reference details such as the order total and a description
for the order
@see https://pay.amazon.com/documentation/apireference/201751630#201751960
@param amazon_order_reference_id [String]
@param amount [String]
@optional currency_code [String]
@optional platform_id [String]
@optional seller_note [S... | [
"Sets",
"order",
"reference",
"details",
"such",
"as",
"the",
"order",
"total",
"and",
"a",
"description",
"for",
"the",
"order"
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L528-L573 |
18,034 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.set_order_attributes | def set_order_attributes(
amazon_order_reference_id,
amount: nil,
currency_code: @currency_code,
platform_id: nil,
seller_note: nil,
seller_order_id: nil,
payment_service_provider_id: nil,
payment_service_provider_order_id: nil,
request_payment_authorization: nil,
... | ruby | def set_order_attributes(
amazon_order_reference_id,
amount: nil,
currency_code: @currency_code,
platform_id: nil,
seller_note: nil,
seller_order_id: nil,
payment_service_provider_id: nil,
payment_service_provider_order_id: nil,
request_payment_authorization: nil,
... | [
"def",
"set_order_attributes",
"(",
"amazon_order_reference_id",
",",
"amount",
":",
"nil",
",",
"currency_code",
":",
"@currency_code",
",",
"platform_id",
":",
"nil",
",",
"seller_note",
":",
"nil",
",",
"seller_order_id",
":",
"nil",
",",
"payment_service_provide... | Sets order attributes such as the order total and a description
for the order
@see https://pay.amazon.com/documentation/apireference/201751630#201751960
@param amazon_order_reference_id [String]
@optional amount [String]
@optional currency_code [String]
@optional platform_id [String]
@optional seller_note [Strin... | [
"Sets",
"order",
"attributes",
"such",
"as",
"the",
"order",
"total",
"and",
"a",
"description",
"for",
"the",
"order"
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L591-L642 |
18,035 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.confirm_order_reference | def confirm_order_reference(
amazon_order_reference_id,
success_url: nil,
failure_url: nil,
authorization_amount: nil,
currency_code: @currency_code,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'ConfirmOrderReference',
... | ruby | def confirm_order_reference(
amazon_order_reference_id,
success_url: nil,
failure_url: nil,
authorization_amount: nil,
currency_code: @currency_code,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'ConfirmOrderReference',
... | [
"def",
"confirm_order_reference",
"(",
"amazon_order_reference_id",
",",
"success_url",
":",
"nil",
",",
"failure_url",
":",
"nil",
",",
"authorization_amount",
":",
"nil",
",",
"currency_code",
":",
"@currency_code",
",",
"merchant_id",
":",
"@merchant_id",
",",
"m... | Confirms that the order reference is free of constraints and all required
information has been set on the order reference
@see https://pay.amazon.com/documentation/apireference/201751630#201751980
@param amazon_order_reference_id [String]
@optional success_url [String]
@optional failure_url [String]
@optional aut... | [
"Confirms",
"that",
"the",
"order",
"reference",
"is",
"free",
"of",
"constraints",
"and",
"all",
"required",
"information",
"has",
"been",
"set",
"on",
"the",
"order",
"reference"
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L654-L681 |
18,036 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.cancel_order_reference | def cancel_order_reference(
amazon_order_reference_id,
cancelation_reason: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'CancelOrderReference',
'SellerId' => merchant_id,
'AmazonOrderReferenceId' => amazon_order_reference_id
... | ruby | def cancel_order_reference(
amazon_order_reference_id,
cancelation_reason: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'CancelOrderReference',
'SellerId' => merchant_id,
'AmazonOrderReferenceId' => amazon_order_reference_id
... | [
"def",
"cancel_order_reference",
"(",
"amazon_order_reference_id",
",",
"cancelation_reason",
":",
"nil",
",",
"merchant_id",
":",
"@merchant_id",
",",
"mws_auth_token",
":",
"nil",
")",
"parameters",
"=",
"{",
"'Action'",
"=>",
"'CancelOrderReference'",
",",
"'Seller... | Cancels a previously confirmed order reference
@see https://pay.amazon.com/documentation/apireference/201751630#201751990
@param amazon_order_reference_id [String]
@optional cancelation_reason [String]
@optional merchant_id [String]
@optional mws_auth_token [String] | [
"Cancels",
"a",
"previously",
"confirmed",
"order",
"reference"
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L689-L708 |
18,037 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.get_authorization_details | def get_authorization_details(
amazon_authorization_id,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'GetAuthorizationDetails',
'SellerId' => merchant_id,
'AmazonAuthorizationId' => amazon_authorization_id
}
optional = {
... | ruby | def get_authorization_details(
amazon_authorization_id,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'GetAuthorizationDetails',
'SellerId' => merchant_id,
'AmazonAuthorizationId' => amazon_authorization_id
}
optional = {
... | [
"def",
"get_authorization_details",
"(",
"amazon_authorization_id",
",",
"merchant_id",
":",
"@merchant_id",
",",
"mws_auth_token",
":",
"nil",
")",
"parameters",
"=",
"{",
"'Action'",
"=>",
"'GetAuthorizationDetails'",
",",
"'SellerId'",
"=>",
"merchant_id",
",",
"'A... | Returns the status of a particular authorization and the total amount
captured on the authorization
@see https://pay.amazon.com/documentation/apireference/201751630#201752030
@param amazon_authorization_id [String]
@optional merchant_id [String]
@optional mws_auth_token [String] | [
"Returns",
"the",
"status",
"of",
"a",
"particular",
"authorization",
"and",
"the",
"total",
"amount",
"captured",
"on",
"the",
"authorization"
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L766-L783 |
18,038 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.capture | def capture(
amazon_authorization_id,
capture_reference_id,
amount,
currency_code: @currency_code,
seller_capture_note: nil,
soft_descriptor: nil,
provider_credit_details: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Actio... | ruby | def capture(
amazon_authorization_id,
capture_reference_id,
amount,
currency_code: @currency_code,
seller_capture_note: nil,
soft_descriptor: nil,
provider_credit_details: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Actio... | [
"def",
"capture",
"(",
"amazon_authorization_id",
",",
"capture_reference_id",
",",
"amount",
",",
"currency_code",
":",
"@currency_code",
",",
"seller_capture_note",
":",
"nil",
",",
"soft_descriptor",
":",
"nil",
",",
"provider_credit_details",
":",
"nil",
",",
"m... | Captures funds from an authorized payment instrument.
@see https://pay.amazon.com/documentation/apireference/201751630#201752040
@param amazon_authorization_id [String]
@param capture_reference_id [String]
@param amount [String]
@optional currency_code [String]
@optional seller_capture_note [String]
@optional so... | [
"Captures",
"funds",
"from",
"an",
"authorized",
"payment",
"instrument",
"."
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L796-L826 |
18,039 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.get_capture_details | def get_capture_details(
amazon_capture_id,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'GetCaptureDetails',
'SellerId' => merchant_id,
'AmazonCaptureId' => amazon_capture_id
}
optional = {
'MWSAuthToken' => mws_au... | ruby | def get_capture_details(
amazon_capture_id,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'GetCaptureDetails',
'SellerId' => merchant_id,
'AmazonCaptureId' => amazon_capture_id
}
optional = {
'MWSAuthToken' => mws_au... | [
"def",
"get_capture_details",
"(",
"amazon_capture_id",
",",
"merchant_id",
":",
"@merchant_id",
",",
"mws_auth_token",
":",
"nil",
")",
"parameters",
"=",
"{",
"'Action'",
"=>",
"'GetCaptureDetails'",
",",
"'SellerId'",
"=>",
"merchant_id",
",",
"'AmazonCaptureId'",
... | Returns the status of a particular capture and the total amount refunded
on the capture
@see https://pay.amazon.com/documentation/apireference/201751630#201752060
@param amazon_capture_id [String]
@optional merchant_id [String]
@optional mws_auth_token [String] | [
"Returns",
"the",
"status",
"of",
"a",
"particular",
"capture",
"and",
"the",
"total",
"amount",
"refunded",
"on",
"the",
"capture"
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L834-L851 |
18,040 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.refund | def refund(
amazon_capture_id,
refund_reference_id,
amount,
currency_code: @currency_code,
seller_refund_note: nil,
soft_descriptor: nil,
provider_credit_reversal_details: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Actio... | ruby | def refund(
amazon_capture_id,
refund_reference_id,
amount,
currency_code: @currency_code,
seller_refund_note: nil,
soft_descriptor: nil,
provider_credit_reversal_details: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Actio... | [
"def",
"refund",
"(",
"amazon_capture_id",
",",
"refund_reference_id",
",",
"amount",
",",
"currency_code",
":",
"@currency_code",
",",
"seller_refund_note",
":",
"nil",
",",
"soft_descriptor",
":",
"nil",
",",
"provider_credit_reversal_details",
":",
"nil",
",",
"m... | Refunds a previously captured amount
@see https://pay.amazon.com/documentation/apireference/201751630#201752080
@param amazon_capture_id [String]
@param refund_reference_id [String]
@param amount [String]
@optional currency_code [String]
@optional seller_refund_note [String]
@optional soft_descriptor [String]
@... | [
"Refunds",
"a",
"previously",
"captured",
"amount"
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L864-L894 |
18,041 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.get_refund_details | def get_refund_details(
amazon_refund_id,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'GetRefundDetails',
'SellerId' => merchant_id,
'AmazonRefundId' => amazon_refund_id
}
optional = {
'MWSAuthToken' => mws_auth_to... | ruby | def get_refund_details(
amazon_refund_id,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'GetRefundDetails',
'SellerId' => merchant_id,
'AmazonRefundId' => amazon_refund_id
}
optional = {
'MWSAuthToken' => mws_auth_to... | [
"def",
"get_refund_details",
"(",
"amazon_refund_id",
",",
"merchant_id",
":",
"@merchant_id",
",",
"mws_auth_token",
":",
"nil",
")",
"parameters",
"=",
"{",
"'Action'",
"=>",
"'GetRefundDetails'",
",",
"'SellerId'",
"=>",
"merchant_id",
",",
"'AmazonRefundId'",
"=... | Returns the status of a particular refund
@see https://pay.amazon.com/documentation/apireference/201751630#201752100
@param amazon_refund_id [String]
@optional merchant_id [String]
@optional mws_auth_token [String] | [
"Returns",
"the",
"status",
"of",
"a",
"particular",
"refund"
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L901-L918 |
18,042 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.close_authorization | def close_authorization(
amazon_authorization_id,
closure_reason: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'CloseAuthorization',
'SellerId' => merchant_id,
'AmazonAuthorizationId' => amazon_authorization_id
}
... | ruby | def close_authorization(
amazon_authorization_id,
closure_reason: nil,
merchant_id: @merchant_id,
mws_auth_token: nil
)
parameters = {
'Action' => 'CloseAuthorization',
'SellerId' => merchant_id,
'AmazonAuthorizationId' => amazon_authorization_id
}
... | [
"def",
"close_authorization",
"(",
"amazon_authorization_id",
",",
"closure_reason",
":",
"nil",
",",
"merchant_id",
":",
"@merchant_id",
",",
"mws_auth_token",
":",
"nil",
")",
"parameters",
"=",
"{",
"'Action'",
"=>",
"'CloseAuthorization'",
",",
"'SellerId'",
"=>... | Closes an authorization
@see https://pay.amazon.com/documentation/apireference/201751630#201752070
@param amazon_authorization_id [String]
@optional closure_reason [String]
@optional merchant_id [String]
@optional mws_auth_token [String] | [
"Closes",
"an",
"authorization"
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L926-L945 |
18,043 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.set_provider_credit_details | def set_provider_credit_details(provider_credit_details)
member_details = {}
provider_credit_details.each_with_index do |val, index|
member = index + 1
member_details["ProviderCreditList.member.#{member}.ProviderId"] = val[:provider_id]
member_details["ProviderCreditList.member.#{mem... | ruby | def set_provider_credit_details(provider_credit_details)
member_details = {}
provider_credit_details.each_with_index do |val, index|
member = index + 1
member_details["ProviderCreditList.member.#{member}.ProviderId"] = val[:provider_id]
member_details["ProviderCreditList.member.#{mem... | [
"def",
"set_provider_credit_details",
"(",
"provider_credit_details",
")",
"member_details",
"=",
"{",
"}",
"provider_credit_details",
".",
"each_with_index",
"do",
"|",
"val",
",",
"index",
"|",
"member",
"=",
"index",
"+",
"1",
"member_details",
"[",
"\"ProviderCr... | This method builds the provider credit details hash
that will be combined with either the authorize or capture
API call. | [
"This",
"method",
"builds",
"the",
"provider",
"credit",
"details",
"hash",
"that",
"will",
"be",
"combined",
"with",
"either",
"the",
"authorize",
"or",
"capture",
"API",
"call",
"."
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L1081-L1091 |
18,044 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client.rb | AmazonPay.Client.set_provider_credit_reversal_details | def set_provider_credit_reversal_details(provider_credit_reversal_details)
member_details = {}
provider_credit_reversal_details.each_with_index do |val, index|
member = index + 1
member_details["ProviderCreditReversalList.member.#{member}.ProviderId"] = val[:provider_id]
member_detai... | ruby | def set_provider_credit_reversal_details(provider_credit_reversal_details)
member_details = {}
provider_credit_reversal_details.each_with_index do |val, index|
member = index + 1
member_details["ProviderCreditReversalList.member.#{member}.ProviderId"] = val[:provider_id]
member_detai... | [
"def",
"set_provider_credit_reversal_details",
"(",
"provider_credit_reversal_details",
")",
"member_details",
"=",
"{",
"}",
"provider_credit_reversal_details",
".",
"each_with_index",
"do",
"|",
"val",
",",
"index",
"|",
"member",
"=",
"index",
"+",
"1",
"member_detai... | This method builds the provider credit reversal
details hash that will be combined with the refund
API call. | [
"This",
"method",
"builds",
"the",
"provider",
"credit",
"reversal",
"details",
"hash",
"that",
"will",
"be",
"combined",
"with",
"the",
"refund",
"API",
"call",
"."
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client.rb#L1096-L1106 |
18,045 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/request.rb | AmazonPay.Request.build_post_url | def build_post_url
@optional.map { |k, v| @parameters[k] = v unless v.nil? }
@parameters['Timestamp'] = Time.now.utc.iso8601 unless @parameters.key?('Timestamp')
@parameters = @default_hash.merge(@parameters)
post_url = @parameters.sort.map { |k, v| "#{k}=#{custom_escape(v)}" }.join('&')
p... | ruby | def build_post_url
@optional.map { |k, v| @parameters[k] = v unless v.nil? }
@parameters['Timestamp'] = Time.now.utc.iso8601 unless @parameters.key?('Timestamp')
@parameters = @default_hash.merge(@parameters)
post_url = @parameters.sort.map { |k, v| "#{k}=#{custom_escape(v)}" }.join('&')
p... | [
"def",
"build_post_url",
"@optional",
".",
"map",
"{",
"|",
"k",
",",
"v",
"|",
"@parameters",
"[",
"k",
"]",
"=",
"v",
"unless",
"v",
".",
"nil?",
"}",
"@parameters",
"[",
"'Timestamp'",
"]",
"=",
"Time",
".",
"now",
".",
"utc",
".",
"iso8601",
"u... | This method combines the required and optional
parameters to sign the post body and generate
the post url. | [
"This",
"method",
"combines",
"the",
"required",
"and",
"optional",
"parameters",
"to",
"sign",
"the",
"post",
"body",
"and",
"generate",
"the",
"post",
"url",
"."
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/request.rb#L65-L78 |
18,046 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/request.rb | AmazonPay.Request.sign | def sign(post_body)
custom_escape(Base64.strict_encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::SHA256.new, @secret_key, post_body)))
end | ruby | def sign(post_body)
custom_escape(Base64.strict_encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::SHA256.new, @secret_key, post_body)))
end | [
"def",
"sign",
"(",
"post_body",
")",
"custom_escape",
"(",
"Base64",
".",
"strict_encode64",
"(",
"OpenSSL",
"::",
"HMAC",
".",
"digest",
"(",
"OpenSSL",
"::",
"Digest",
"::",
"SHA256",
".",
"new",
",",
"@secret_key",
",",
"post_body",
")",
")",
")",
"e... | This method signs the post body that is being sent
using the secret key provided. | [
"This",
"method",
"signs",
"the",
"post",
"body",
"that",
"is",
"being",
"sent",
"using",
"the",
"secret",
"key",
"provided",
"."
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/request.rb#L82-L84 |
18,047 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/request.rb | AmazonPay.Request.post | def post(mws_endpoint, sandbox_str, post_url)
uri = URI("https://#{mws_endpoint}/#{sandbox_str}/#{AmazonPay::API_VERSION}")
https = Net::HTTP.new(uri.host, uri.port, @proxy_addr, @proxy_port, @proxy_user, @proxy_pass)
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
user... | ruby | def post(mws_endpoint, sandbox_str, post_url)
uri = URI("https://#{mws_endpoint}/#{sandbox_str}/#{AmazonPay::API_VERSION}")
https = Net::HTTP.new(uri.host, uri.port, @proxy_addr, @proxy_port, @proxy_user, @proxy_pass)
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
user... | [
"def",
"post",
"(",
"mws_endpoint",
",",
"sandbox_str",
",",
"post_url",
")",
"uri",
"=",
"URI",
"(",
"\"https://#{mws_endpoint}/#{sandbox_str}/#{AmazonPay::API_VERSION}\"",
")",
"https",
"=",
"Net",
"::",
"HTTP",
".",
"new",
"(",
"uri",
".",
"host",
",",
"uri",... | This method performs the post to the MWS endpoint.
It will retry three times after the initial post if
the status code comes back as either 500 or 503. | [
"This",
"method",
"performs",
"the",
"post",
"to",
"the",
"MWS",
"endpoint",
".",
"It",
"will",
"retry",
"three",
"times",
"after",
"the",
"initial",
"post",
"if",
"the",
"status",
"code",
"comes",
"back",
"as",
"either",
"500",
"or",
"503",
"."
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/request.rb#L89-L115 |
18,048 | amzn/amazon-pay-sdk-ruby | lib/amazon_pay/client_helper.rb | AmazonPay.Client.charge | def charge(
amazon_reference_id,
authorization_reference_id,
charge_amount,
charge_currency_code: @currency_code,
charge_note: nil,
charge_order_id: nil,
store_name: nil,
custom_information: nil,
soft_descriptor: nil,
platform_id: nil,
merchant_id: @merc... | ruby | def charge(
amazon_reference_id,
authorization_reference_id,
charge_amount,
charge_currency_code: @currency_code,
charge_note: nil,
charge_order_id: nil,
store_name: nil,
custom_information: nil,
soft_descriptor: nil,
platform_id: nil,
merchant_id: @merc... | [
"def",
"charge",
"(",
"amazon_reference_id",
",",
"authorization_reference_id",
",",
"charge_amount",
",",
"charge_currency_code",
":",
"@currency_code",
",",
"charge_note",
":",
"nil",
",",
"charge_order_id",
":",
"nil",
",",
"store_name",
":",
"nil",
",",
"custom_... | This method combines multiple API calls to perform
a complete transaction with minimum requirements.
@param amazon_reference_id [String]
@param authorization_reference_id [String]
@param charge_amount [String]
@optional charge_currency_code [String]
@optional charge_note [String]
@optional charge_order [String]
... | [
"This",
"method",
"combines",
"multiple",
"API",
"calls",
"to",
"perform",
"a",
"complete",
"transaction",
"with",
"minimum",
"requirements",
"."
] | 6321994cc10b5614630b6743da8d1eb79b2bc1ed | https://github.com/amzn/amazon-pay-sdk-ruby/blob/6321994cc10b5614630b6743da8d1eb79b2bc1ed/lib/amazon_pay/client_helper.rb#L21-L67 |
18,049 | AlexWayfer/flame | lib/flame/router.rb | Flame.Router.add | def add(routes_refine)
routes.deep_merge! routes_refine.routes
reverse_routes.merge! routes_refine.reverse_routes
end | ruby | def add(routes_refine)
routes.deep_merge! routes_refine.routes
reverse_routes.merge! routes_refine.reverse_routes
end | [
"def",
"add",
"(",
"routes_refine",
")",
"routes",
".",
"deep_merge!",
"routes_refine",
".",
"routes",
"reverse_routes",
".",
"merge!",
"routes_refine",
".",
"reverse_routes",
"end"
] | Add RoutesRefine to Router
@param routes_refine [Flame::Router::RoutesRefine] refined routes | [
"Add",
"RoutesRefine",
"to",
"Router"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/router.rb#L36-L39 |
18,050 | AlexWayfer/flame | lib/flame/router.rb | Flame.Router.find_nearest_route | def find_nearest_route(path)
path_parts = path.parts.dup
loop do
route = routes.navigate(*path_parts)&.values&.grep(Route)&.first
break route if route || path_parts.pop.nil?
end
end | ruby | def find_nearest_route(path)
path_parts = path.parts.dup
loop do
route = routes.navigate(*path_parts)&.values&.grep(Route)&.first
break route if route || path_parts.pop.nil?
end
end | [
"def",
"find_nearest_route",
"(",
"path",
")",
"path_parts",
"=",
"path",
".",
"parts",
".",
"dup",
"loop",
"do",
"route",
"=",
"routes",
".",
"navigate",
"(",
"path_parts",
")",
"&.",
"values",
"&.",
"grep",
"(",
"Route",
")",
"&.",
"first",
"break",
... | Find the nearest route by path
@param path [Flame::Path] path for route finding
@return [Flame::Route, nil] return the found nearest route or `nil` | [
"Find",
"the",
"nearest",
"route",
"by",
"path"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/router.rb#L44-L50 |
18,051 | AlexWayfer/flame | lib/flame/router.rb | Flame.Router.path_of | def path_of(route_or_controller, action = nil)
if route_or_controller.is_a?(Flame::Router::Route)
route = route_or_controller
controller = route.controller
action = route.action
else
controller = route_or_controller
end
reverse_routes.dig(controller.to_s, action)
end | ruby | def path_of(route_or_controller, action = nil)
if route_or_controller.is_a?(Flame::Router::Route)
route = route_or_controller
controller = route.controller
action = route.action
else
controller = route_or_controller
end
reverse_routes.dig(controller.to_s, action)
end | [
"def",
"path_of",
"(",
"route_or_controller",
",",
"action",
"=",
"nil",
")",
"if",
"route_or_controller",
".",
"is_a?",
"(",
"Flame",
"::",
"Router",
"::",
"Route",
")",
"route",
"=",
"route_or_controller",
"controller",
"=",
"route",
".",
"controller",
"acti... | Find the path of route
@param route_or_controller [Flame::Router::Route, Flame::Controller]
route or controller
@param action [Symbol, nil] action (or not for route)
@return [Flame::Path] mounted path to action of controller | [
"Find",
"the",
"path",
"of",
"route"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/router.rb#L57-L66 |
18,052 | AlexWayfer/flame | lib/flame/render.rb | Flame.Render.render | def render(cache: true, &block)
@cache = cache
## Compile Tilt to instance hash
return unless @filename
tilt = compile_file
## Render Tilt from instance hash with new options
layout_render tilt.render(@scope, @locals, &block)
end | ruby | def render(cache: true, &block)
@cache = cache
## Compile Tilt to instance hash
return unless @filename
tilt = compile_file
## Render Tilt from instance hash with new options
layout_render tilt.render(@scope, @locals, &block)
end | [
"def",
"render",
"(",
"cache",
":",
"true",
",",
"&",
"block",
")",
"@cache",
"=",
"cache",
"## Compile Tilt to instance hash",
"return",
"unless",
"@filename",
"tilt",
"=",
"compile_file",
"## Render Tilt from instance hash with new options",
"layout_render",
"tilt",
"... | Create a new instance from controller, by path and with options
@param controller [Flame::Controller]
controller for default scope, views directory and cache
@param path [Symbol, String] path (full or the last part) for view search
@param options [Hash] options for template
@option options [Object] :scope (contr... | [
"Create",
"a",
"new",
"instance",
"from",
"controller",
"by",
"path",
"and",
"with",
"options"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/render.rb#L51-L59 |
18,053 | AlexWayfer/flame | lib/flame/render.rb | Flame.Render.compile_file | def compile_file(filename = @filename)
cached = @controller.cached_tilts[filename]
return cached if @cache && cached
compiled = Tilt.new(filename, nil, @tilt_options)
@controller.cached_tilts[filename] ||= compiled if @cache
compiled
end | ruby | def compile_file(filename = @filename)
cached = @controller.cached_tilts[filename]
return cached if @cache && cached
compiled = Tilt.new(filename, nil, @tilt_options)
@controller.cached_tilts[filename] ||= compiled if @cache
compiled
end | [
"def",
"compile_file",
"(",
"filename",
"=",
"@filename",
")",
"cached",
"=",
"@controller",
".",
"cached_tilts",
"[",
"filename",
"]",
"return",
"cached",
"if",
"@cache",
"&&",
"cached",
"compiled",
"=",
"Tilt",
".",
"new",
"(",
"filename",
",",
"nil",
",... | Compile file with Tilt engine
@param filename [String] filename | [
"Compile",
"file",
"with",
"Tilt",
"engine"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/render.rb#L69-L76 |
18,054 | AlexWayfer/flame | lib/flame/render.rb | Flame.Render.find_file | def find_file(path)
caller_path = caller_locations(4..4).first.path
caller_dir =
begin
File.dirname(caller_path).sub(views_dir, '') if Tilt[caller_path]
rescue LoadError
nil
end
find_files(path, controller_dirs | Array(caller_dir))
.find { |file| Tilt[file] }
end | ruby | def find_file(path)
caller_path = caller_locations(4..4).first.path
caller_dir =
begin
File.dirname(caller_path).sub(views_dir, '') if Tilt[caller_path]
rescue LoadError
nil
end
find_files(path, controller_dirs | Array(caller_dir))
.find { |file| Tilt[file] }
end | [
"def",
"find_file",
"(",
"path",
")",
"caller_path",
"=",
"caller_locations",
"(",
"4",
"..",
"4",
")",
".",
"first",
".",
"path",
"caller_dir",
"=",
"begin",
"File",
".",
"dirname",
"(",
"caller_path",
")",
".",
"sub",
"(",
"views_dir",
",",
"''",
")"... | Find template-file by path | [
"Find",
"template",
"-",
"file",
"by",
"path"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/render.rb#L97-L109 |
18,055 | AlexWayfer/flame | lib/flame/render.rb | Flame.Render.find_layouts | def find_layouts(path)
find_files(path, layout_dirs)
.select { |file| Tilt[file] }
.sort! { |a, b| b.split('/').size <=> a.split('/').size }
end | ruby | def find_layouts(path)
find_files(path, layout_dirs)
.select { |file| Tilt[file] }
.sort! { |a, b| b.split('/').size <=> a.split('/').size }
end | [
"def",
"find_layouts",
"(",
"path",
")",
"find_files",
"(",
"path",
",",
"layout_dirs",
")",
".",
"select",
"{",
"|",
"file",
"|",
"Tilt",
"[",
"file",
"]",
"}",
".",
"sort!",
"{",
"|",
"a",
",",
"b",
"|",
"b",
".",
"split",
"(",
"'/'",
")",
".... | Find layout-files by path | [
"Find",
"layout",
"-",
"files",
"by",
"path"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/render.rb#L112-L116 |
18,056 | AlexWayfer/flame | lib/flame/render.rb | Flame.Render.controller_dirs | def controller_dirs
parts = @controller.class.underscore.split('/').map do |part|
%w[_controller _ctrl]
.find { |suffix| part.chomp! suffix }
part
## Alternative, but slower by ~50%:
# part.sub(/_(controller|ctrl)$/, '')
end
combine_parts(parts).map! { |path| path.join('/') }
end | ruby | def controller_dirs
parts = @controller.class.underscore.split('/').map do |part|
%w[_controller _ctrl]
.find { |suffix| part.chomp! suffix }
part
## Alternative, but slower by ~50%:
# part.sub(/_(controller|ctrl)$/, '')
end
combine_parts(parts).map! { |path| path.join('/') }
end | [
"def",
"controller_dirs",
"parts",
"=",
"@controller",
".",
"class",
".",
"underscore",
".",
"split",
"(",
"'/'",
")",
".",
"map",
"do",
"|",
"part",
"|",
"%w[",
"_controller",
"_ctrl",
"]",
".",
"find",
"{",
"|",
"suffix",
"|",
"part",
".",
"chomp!",
... | Find possible directories for the controller | [
"Find",
"possible",
"directories",
"for",
"the",
"controller"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/render.rb#L121-L130 |
18,057 | AlexWayfer/flame | lib/flame/render.rb | Flame.Render.combine_parts | def combine_parts(parts)
parts.size.downto(1).with_object([]) do |i, arr|
arr.push(*parts.combination(i).to_a)
end
# variants.uniq!.reject!(&:empty?)
end | ruby | def combine_parts(parts)
parts.size.downto(1).with_object([]) do |i, arr|
arr.push(*parts.combination(i).to_a)
end
# variants.uniq!.reject!(&:empty?)
end | [
"def",
"combine_parts",
"(",
"parts",
")",
"parts",
".",
"size",
".",
"downto",
"(",
"1",
")",
".",
"with_object",
"(",
"[",
"]",
")",
"do",
"|",
"i",
",",
"arr",
"|",
"arr",
".",
"push",
"(",
"parts",
".",
"combination",
"(",
"i",
")",
".",
"t... | Make combinations in order with different sizes
@example Make parts for ['project', 'namespace', 'controller']
# => [
['project', 'namespace', 'controller'],
['project', 'namespace'],
['namespace', 'controller'],
['namespace']
] | [
"Make",
"combinations",
"in",
"order",
"with",
"different",
"sizes"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/render.rb#L140-L145 |
18,058 | AlexWayfer/flame | lib/flame/render.rb | Flame.Render.layout_render | def layout_render(content)
return content unless @layout
layout_files = find_layouts(@layout)
return content if layout_files.empty?
layout_files.each_with_object(content.dup) do |layout_file, result|
layout = compile_file(layout_file)
result.replace layout.render(@scope, @locals) { result }
end... | ruby | def layout_render(content)
return content unless @layout
layout_files = find_layouts(@layout)
return content if layout_files.empty?
layout_files.each_with_object(content.dup) do |layout_file, result|
layout = compile_file(layout_file)
result.replace layout.render(@scope, @locals) { result }
end... | [
"def",
"layout_render",
"(",
"content",
")",
"return",
"content",
"unless",
"@layout",
"layout_files",
"=",
"find_layouts",
"(",
"@layout",
")",
"return",
"content",
"if",
"layout_files",
".",
"empty?",
"layout_files",
".",
"each_with_object",
"(",
"content",
".",... | Render the layout with template
@param result [String] result of template rendering | [
"Render",
"the",
"layout",
"with",
"template"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/render.rb#L158-L168 |
18,059 | AlexWayfer/flame | lib/flame/path.rb | Flame.Path.adapt | def adapt(ctrl, action)
parameters = ctrl.instance_method(action).parameters
parameters.map! do |parameter|
parameter_type, parameter_name = parameter
path_part = self.class::Part.new parameter_name, arg: parameter_type
path_part unless parts.include? path_part
end
self.class.new @path.empty? ? ... | ruby | def adapt(ctrl, action)
parameters = ctrl.instance_method(action).parameters
parameters.map! do |parameter|
parameter_type, parameter_name = parameter
path_part = self.class::Part.new parameter_name, arg: parameter_type
path_part unless parts.include? path_part
end
self.class.new @path.empty? ? ... | [
"def",
"adapt",
"(",
"ctrl",
",",
"action",
")",
"parameters",
"=",
"ctrl",
".",
"instance_method",
"(",
"action",
")",
".",
"parameters",
"parameters",
".",
"map!",
"do",
"|",
"parameter",
"|",
"parameter_type",
",",
"parameter_name",
"=",
"parameter",
"pat... | Compare by parts count and the first arg position
@param other [Flame::Path] other path
@return [-1, 0, 1] result of comparing
Compare with other path by parts
@param other [Flame::Path, String] other path
@return [true, false] equal or not
Complete path for the action of controller
@param ctrl [Flame::Controlle... | [
"Compare",
"by",
"parts",
"count",
"and",
"the",
"first",
"arg",
"position"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/path.rb#L80-L88 |
18,060 | AlexWayfer/flame | lib/flame/path.rb | Flame.Path.to_routes_with_endpoint | def to_routes_with_endpoint
endpoint =
parts.reduce(result = Flame::Router::Routes.new) do |hash, part|
hash[part] ||= Flame::Router::Routes.new
end
[result, endpoint]
end | ruby | def to_routes_with_endpoint
endpoint =
parts.reduce(result = Flame::Router::Routes.new) do |hash, part|
hash[part] ||= Flame::Router::Routes.new
end
[result, endpoint]
end | [
"def",
"to_routes_with_endpoint",
"endpoint",
"=",
"parts",
".",
"reduce",
"(",
"result",
"=",
"Flame",
"::",
"Router",
"::",
"Routes",
".",
"new",
")",
"do",
"|",
"hash",
",",
"part",
"|",
"hash",
"[",
"part",
"]",
"||=",
"Flame",
"::",
"Router",
"::"... | Path parts as keys of nested Hashes
@return [Array(Flame::Router::Routes, Flame::Router::Routes)]
whole Routes (parent) and the endpoint (most nested Routes) | [
"Path",
"parts",
"as",
"keys",
"of",
"nested",
"Hashes"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/path.rb#L113-L119 |
18,061 | AlexWayfer/flame | lib/flame/path.rb | Flame.Path.assign_argument | def assign_argument(part, args = {})
## Not argument
return part unless part.arg?
## Not required argument
return args.delete(part[2..-1].to_sym) if part.opt_arg?
## Required argument
param = args.delete(part[1..-1].to_sym)
## Required argument is nil
error = Errors::ArgumentNotAssignedError.ne... | ruby | def assign_argument(part, args = {})
## Not argument
return part unless part.arg?
## Not required argument
return args.delete(part[2..-1].to_sym) if part.opt_arg?
## Required argument
param = args.delete(part[1..-1].to_sym)
## Required argument is nil
error = Errors::ArgumentNotAssignedError.ne... | [
"def",
"assign_argument",
"(",
"part",
",",
"args",
"=",
"{",
"}",
")",
"## Not argument",
"return",
"part",
"unless",
"part",
".",
"arg?",
"## Not required argument",
"return",
"args",
".",
"delete",
"(",
"part",
"[",
"2",
"..",
"-",
"1",
"]",
".",
"to_... | Helpers for `assign_arguments` | [
"Helpers",
"for",
"assign_arguments"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/path.rb#L124-L138 |
18,062 | AlexWayfer/flame | lib/flame/dispatcher.rb | Flame.Dispatcher.status | def status(value = nil)
response.status ||= 200
response.headers['X-Cascade'] = 'pass' if value == 404
value ? response.status = value : response.status
end | ruby | def status(value = nil)
response.status ||= 200
response.headers['X-Cascade'] = 'pass' if value == 404
value ? response.status = value : response.status
end | [
"def",
"status",
"(",
"value",
"=",
"nil",
")",
"response",
".",
"status",
"||=",
"200",
"response",
".",
"headers",
"[",
"'X-Cascade'",
"]",
"=",
"'pass'",
"if",
"value",
"==",
"404",
"value",
"?",
"response",
".",
"status",
"=",
"value",
":",
"respon... | Acccess to the status of response
@param value [Ineger, nil] integer value for new status
@return [Integer] current status
@example Set status value
status 200 | [
"Acccess",
"to",
"the",
"status",
"of",
"response"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/dispatcher.rb#L56-L60 |
18,063 | AlexWayfer/flame | lib/flame/dispatcher.rb | Flame.Dispatcher.params | def params
@params ||=
begin
request.params.symbolize_keys(deep: true)
rescue ArgumentError => e
raise unless e.message.include?('invalid %-encoding')
{}
end
end | ruby | def params
@params ||=
begin
request.params.symbolize_keys(deep: true)
rescue ArgumentError => e
raise unless e.message.include?('invalid %-encoding')
{}
end
end | [
"def",
"params",
"@params",
"||=",
"begin",
"request",
".",
"params",
".",
"symbolize_keys",
"(",
"deep",
":",
"true",
")",
"rescue",
"ArgumentError",
"=>",
"e",
"raise",
"unless",
"e",
".",
"message",
".",
"include?",
"(",
"'invalid %-encoding'",
")",
"{",
... | Parameters of the request | [
"Parameters",
"of",
"the",
"request"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/dispatcher.rb#L74-L83 |
18,064 | AlexWayfer/flame | lib/flame/dispatcher.rb | Flame.Dispatcher.dump_error | def dump_error(error)
error_message = [
"#{Time.now.strftime('%Y-%m-%d %H:%M:%S')} - " \
"#{error.class} - #{error.message}:",
*error.backtrace
].join("\n\t")
@env[Rack::RACK_ERRORS].puts(error_message)
end | ruby | def dump_error(error)
error_message = [
"#{Time.now.strftime('%Y-%m-%d %H:%M:%S')} - " \
"#{error.class} - #{error.message}:",
*error.backtrace
].join("\n\t")
@env[Rack::RACK_ERRORS].puts(error_message)
end | [
"def",
"dump_error",
"(",
"error",
")",
"error_message",
"=",
"[",
"\"#{Time.now.strftime('%Y-%m-%d %H:%M:%S')} - \"",
"\"#{error.class} - #{error.message}:\"",
",",
"error",
".",
"backtrace",
"]",
".",
"join",
"(",
"\"\\n\\t\"",
")",
"@env",
"[",
"Rack",
"::",
"RACK_... | Add error's backtrace to @env['rack.errors'] (terminal or file)
@param error [Exception] exception for class, message and backtrace | [
"Add",
"error",
"s",
"backtrace",
"to"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/dispatcher.rb#L125-L132 |
18,065 | AlexWayfer/flame | lib/flame/dispatcher.rb | Flame.Dispatcher.try_options | def try_options
return unless request.http_method == :OPTIONS
allow = available_endpoint&.allow
halt 404 unless allow
response.headers['Allow'] = allow
end | ruby | def try_options
return unless request.http_method == :OPTIONS
allow = available_endpoint&.allow
halt 404 unless allow
response.headers['Allow'] = allow
end | [
"def",
"try_options",
"return",
"unless",
"request",
".",
"http_method",
"==",
":OPTIONS",
"allow",
"=",
"available_endpoint",
"&.",
"allow",
"halt",
"404",
"unless",
"allow",
"response",
".",
"headers",
"[",
"'Allow'",
"]",
"=",
"allow",
"end"
] | Return response if HTTP-method is OPTIONS | [
"Return",
"response",
"if",
"HTTP",
"-",
"method",
"is",
"OPTIONS"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/dispatcher.rb#L157-L163 |
18,066 | AlexWayfer/flame | lib/flame/controller.rb | Flame.Controller.redirect | def redirect(*args)
args[0] = args.first.to_s if args.first.is_a? URI
unless args.first.is_a? String
path_to_args_range = 0..(args.last.is_a?(Integer) ? -2 : -1)
args[path_to_args_range] = path_to(*args[path_to_args_range])
end
response.redirect(*args)
status
end | ruby | def redirect(*args)
args[0] = args.first.to_s if args.first.is_a? URI
unless args.first.is_a? String
path_to_args_range = 0..(args.last.is_a?(Integer) ? -2 : -1)
args[path_to_args_range] = path_to(*args[path_to_args_range])
end
response.redirect(*args)
status
end | [
"def",
"redirect",
"(",
"*",
"args",
")",
"args",
"[",
"0",
"]",
"=",
"args",
".",
"first",
".",
"to_s",
"if",
"args",
".",
"first",
".",
"is_a?",
"URI",
"unless",
"args",
".",
"first",
".",
"is_a?",
"String",
"path_to_args_range",
"=",
"0",
"..",
... | Redirect for response
@overload redirect(path, status)
Redirect to the string path
@param path [String] path
@param status [Ingeter, nil] HTTP status
@return [nil]
@example Redirect to '/hello'
redirect '/hello'
@example Redirect to '/hello' with status 301
redirect '/hello', 301
@overload... | [
"Redirect",
"for",
"response"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/controller.rb#L90-L98 |
18,067 | AlexWayfer/flame | lib/flame/controller.rb | Flame.Controller.attachment | def attachment(filename = nil, disposition = :attachment)
content_dis = 'Content-Disposition'
response[content_dis] = disposition.to_s
return unless filename
response[content_dis] << "; filename=\"#{File.basename(filename)}\""
ext = File.extname(filename)
response.content_type = ext unless ext.empty?... | ruby | def attachment(filename = nil, disposition = :attachment)
content_dis = 'Content-Disposition'
response[content_dis] = disposition.to_s
return unless filename
response[content_dis] << "; filename=\"#{File.basename(filename)}\""
ext = File.extname(filename)
response.content_type = ext unless ext.empty?... | [
"def",
"attachment",
"(",
"filename",
"=",
"nil",
",",
"disposition",
"=",
":attachment",
")",
"content_dis",
"=",
"'Content-Disposition'",
"response",
"[",
"content_dis",
"]",
"=",
"disposition",
".",
"to_s",
"return",
"unless",
"filename",
"response",
"[",
"co... | Set the Content-Disposition to "attachment" with the specified filename,
instructing the user agents to prompt to save,
and set Content-Type by filename.
@param filename [String, nil] filename of attachment
@param disposition [Symbol, String] main content for Content-Disposition
@example Set Content-Disposition he... | [
"Set",
"the",
"Content",
"-",
"Disposition",
"to",
"attachment",
"with",
"the",
"specified",
"filename",
"instructing",
"the",
"user",
"agents",
"to",
"prompt",
"to",
"save",
"and",
"set",
"Content",
"-",
"Type",
"by",
"filename",
"."
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/controller.rb#L109-L117 |
18,068 | AlexWayfer/flame | lib/flame/controller.rb | Flame.Controller.reroute | def reroute(*args)
add_controller_class(args)
ctrl, action = args[0..1]
ctrl_object = ctrl == self.class ? self : ctrl.new(@dispatcher)
ctrl_object.send :execute, action
body
end | ruby | def reroute(*args)
add_controller_class(args)
ctrl, action = args[0..1]
ctrl_object = ctrl == self.class ? self : ctrl.new(@dispatcher)
ctrl_object.send :execute, action
body
end | [
"def",
"reroute",
"(",
"*",
"args",
")",
"add_controller_class",
"(",
"args",
")",
"ctrl",
",",
"action",
"=",
"args",
"[",
"0",
"..",
"1",
"]",
"ctrl_object",
"=",
"ctrl",
"==",
"self",
".",
"class",
"?",
"self",
":",
"ctrl",
".",
"new",
"(",
"@di... | Execute any action from any controller
@example Execute `new` action of `ArticlesController`
reroute ArticlesController, :new
@example Execute `index` action of `ArticlesController`
reroute ArticlesController
@example Execute `foo` action of current controller
reroute :foo | [
"Execute",
"any",
"action",
"from",
"any",
"controller"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/controller.rb#L163-L169 |
18,069 | AlexWayfer/flame | lib/flame/application.rb | Flame.Application.call | def call(env)
@app.call(env) if @app.respond_to? :call
Flame::Dispatcher.new(self.class, env).run!
end | ruby | def call(env)
@app.call(env) if @app.respond_to? :call
Flame::Dispatcher.new(self.class, env).run!
end | [
"def",
"call",
"(",
"env",
")",
"@app",
".",
"call",
"(",
"env",
")",
"if",
"@app",
".",
"respond_to?",
":call",
"Flame",
"::",
"Dispatcher",
".",
"new",
"(",
"self",
".",
"class",
",",
"env",
")",
".",
"run!",
"end"
] | Request recieving method | [
"Request",
"recieving",
"method"
] | aecb2bb22b43abf4d99a36ea580d67923e3a6564 | https://github.com/AlexWayfer/flame/blob/aecb2bb22b43abf4d99a36ea580d67923e3a6564/lib/flame/application.rb#L151-L154 |
18,070 | avinashbot/redd | lib/redd/client.rb | Redd.Client.request | def request(verb, path, options = {})
# puts "#{verb.to_s.upcase} #{path}", ' ' + options.inspect
response = connection.request(verb, path, **options)
Response.new(response.status.code, response.headers, response.body.to_s)
end | ruby | def request(verb, path, options = {})
# puts "#{verb.to_s.upcase} #{path}", ' ' + options.inspect
response = connection.request(verb, path, **options)
Response.new(response.status.code, response.headers, response.body.to_s)
end | [
"def",
"request",
"(",
"verb",
",",
"path",
",",
"options",
"=",
"{",
"}",
")",
"# puts \"#{verb.to_s.upcase} #{path}\", ' ' + options.inspect",
"response",
"=",
"connection",
".",
"request",
"(",
"verb",
",",
"path",
",",
"**",
"options",
")",
"Response",
".",... | Create a new client.
@param endpoint [String] the base endpoint to make all requests from
@param user_agent [String] a user agent string
Make an HTTP request.
@param verb [:get, :post, :put, :patch, :delete] the HTTP verb to use
@param path [String] the path relative to the endpoint
@param options [Hash] the requ... | [
"Create",
"a",
"new",
"client",
"."
] | 3b1519a2d121efd18de59b935da6e652757eee90 | https://github.com/avinashbot/redd/blob/3b1519a2d121efd18de59b935da6e652757eee90/lib/redd/client.rb#L35-L39 |
18,071 | avinashbot/redd | lib/redd/middleware.rb | Redd.Middleware.redirect_to_reddit! | def redirect_to_reddit!
state = SecureRandom.urlsafe_base64
url = Redd.url(
client_id: @client_id,
redirect_uri: @redirect_uri,
scope: @scope,
duration: @duration,
state: state
)
@request.session[:redd_state] = state
[302, { 'Location' => url }, []]
... | ruby | def redirect_to_reddit!
state = SecureRandom.urlsafe_base64
url = Redd.url(
client_id: @client_id,
redirect_uri: @redirect_uri,
scope: @scope,
duration: @duration,
state: state
)
@request.session[:redd_state] = state
[302, { 'Location' => url }, []]
... | [
"def",
"redirect_to_reddit!",
"state",
"=",
"SecureRandom",
".",
"urlsafe_base64",
"url",
"=",
"Redd",
".",
"url",
"(",
"client_id",
":",
"@client_id",
",",
"redirect_uri",
":",
"@redirect_uri",
",",
"scope",
":",
"@scope",
",",
"duration",
":",
"@duration",
"... | Creates a unique state and redirects the user to reddit for authentication. | [
"Creates",
"a",
"unique",
"state",
"and",
"redirects",
"the",
"user",
"to",
"reddit",
"for",
"authentication",
"."
] | 3b1519a2d121efd18de59b935da6e652757eee90 | https://github.com/avinashbot/redd/blob/3b1519a2d121efd18de59b935da6e652757eee90/lib/redd/middleware.rb#L58-L69 |
18,072 | avinashbot/redd | lib/redd/middleware.rb | Redd.Middleware.after_call | def after_call
env_session = @request.env['redd.session']
if env_session && env_session.client.access
# Make sure to flush any changes made to the Session client to the browser.
@request.session[:redd_session] = env_session.client.access.to_h
else
# Clear the session if the app... | ruby | def after_call
env_session = @request.env['redd.session']
if env_session && env_session.client.access
# Make sure to flush any changes made to the Session client to the browser.
@request.session[:redd_session] = env_session.client.access.to_h
else
# Clear the session if the app... | [
"def",
"after_call",
"env_session",
"=",
"@request",
".",
"env",
"[",
"'redd.session'",
"]",
"if",
"env_session",
"&&",
"env_session",
".",
"client",
".",
"access",
"# Make sure to flush any changes made to the Session client to the browser.",
"@request",
".",
"session",
... | Do any cleanup or changes after calling the application. | [
"Do",
"any",
"cleanup",
"or",
"changes",
"after",
"calling",
"the",
"application",
"."
] | 3b1519a2d121efd18de59b935da6e652757eee90 | https://github.com/avinashbot/redd/blob/3b1519a2d121efd18de59b935da6e652757eee90/lib/redd/middleware.rb#L82-L91 |
18,073 | avinashbot/redd | lib/redd/middleware.rb | Redd.Middleware.handle_token_error | def handle_token_error
message = nil
message = 'invalid_state' if @request.GET['state'] != @request.session[:redd_state]
message = @request.GET['error'] if @request.GET['error']
raise Errors::TokenRetrievalError, message if message
end | ruby | def handle_token_error
message = nil
message = 'invalid_state' if @request.GET['state'] != @request.session[:redd_state]
message = @request.GET['error'] if @request.GET['error']
raise Errors::TokenRetrievalError, message if message
end | [
"def",
"handle_token_error",
"message",
"=",
"nil",
"message",
"=",
"'invalid_state'",
"if",
"@request",
".",
"GET",
"[",
"'state'",
"]",
"!=",
"@request",
".",
"session",
"[",
":redd_state",
"]",
"message",
"=",
"@request",
".",
"GET",
"[",
"'error'",
"]",
... | Assigns a single string representing a reddit authentication errors. | [
"Assigns",
"a",
"single",
"string",
"representing",
"a",
"reddit",
"authentication",
"errors",
"."
] | 3b1519a2d121efd18de59b935da6e652757eee90 | https://github.com/avinashbot/redd/blob/3b1519a2d121efd18de59b935da6e652757eee90/lib/redd/middleware.rb#L94-L99 |
18,074 | avinashbot/redd | lib/redd/middleware.rb | Redd.Middleware.create_session! | def create_session!
# Skip authorizing if there was an error from the authorization.
handle_token_error
# Try to get a code (the rescue block will also prevent crazy crashes)
access = @strategy.authenticate(@request.GET['code'])
@request.session[:redd_session] = access.to_h
rescue Erro... | ruby | def create_session!
# Skip authorizing if there was an error from the authorization.
handle_token_error
# Try to get a code (the rescue block will also prevent crazy crashes)
access = @strategy.authenticate(@request.GET['code'])
@request.session[:redd_session] = access.to_h
rescue Erro... | [
"def",
"create_session!",
"# Skip authorizing if there was an error from the authorization.",
"handle_token_error",
"# Try to get a code (the rescue block will also prevent crazy crashes)",
"access",
"=",
"@strategy",
".",
"authenticate",
"(",
"@request",
".",
"GET",
"[",
"'code'",
"... | Store the access token and other details in the user's browser, assigning any errors to
the 'redd.error' env variable. | [
"Store",
"the",
"access",
"token",
"and",
"other",
"details",
"in",
"the",
"user",
"s",
"browser",
"assigning",
"any",
"errors",
"to",
"the",
"redd",
".",
"error",
"env",
"variable",
"."
] | 3b1519a2d121efd18de59b935da6e652757eee90 | https://github.com/avinashbot/redd/blob/3b1519a2d121efd18de59b935da6e652757eee90/lib/redd/middleware.rb#L103-L111 |
18,075 | avinashbot/redd | lib/redd/api_client.rb | Redd.APIClient.request | def request(verb, path, raw: false, params: {}, **options)
# Make sure @access is populated by a valid access
ensure_access_is_valid
# Setup base API params and make request
api_params = { api_type: 'json', raw_json: 1 }.merge(params)
# This loop is retried @max_retries number of times un... | ruby | def request(verb, path, raw: false, params: {}, **options)
# Make sure @access is populated by a valid access
ensure_access_is_valid
# Setup base API params and make request
api_params = { api_type: 'json', raw_json: 1 }.merge(params)
# This loop is retried @max_retries number of times un... | [
"def",
"request",
"(",
"verb",
",",
"path",
",",
"raw",
":",
"false",
",",
"params",
":",
"{",
"}",
",",
"**",
"options",
")",
"# Make sure @access is populated by a valid access",
"ensure_access_is_valid",
"# Setup base API params and make request",
"api_params",
"=",
... | Makes a request, ensuring not to break the rate limit by sleeping.
@see Client#request | [
"Makes",
"a",
"request",
"ensuring",
"not",
"to",
"break",
"the",
"rate",
"limit",
"by",
"sleeping",
"."
] | 3b1519a2d121efd18de59b935da6e652757eee90 | https://github.com/avinashbot/redd/blob/3b1519a2d121efd18de59b935da6e652757eee90/lib/redd/api_client.rb#L65-L80 |
18,076 | ansible/ansible_tower_client_ruby | lib/ansible_tower_client/hash_model.rb | AnsibleTowerClient.HashModel.hash_to_model | def hash_to_model(klass_name, hash)
model_klass =
if self.class.const_defined?("#{self.class}::#{klass_name}")
self.class.const_get(klass_name)
else
self.class.const_set(klass_name, Class.new(HashModel))
end
model_klass.new(hash)
end | ruby | def hash_to_model(klass_name, hash)
model_klass =
if self.class.const_defined?("#{self.class}::#{klass_name}")
self.class.const_get(klass_name)
else
self.class.const_set(klass_name, Class.new(HashModel))
end
model_klass.new(hash)
end | [
"def",
"hash_to_model",
"(",
"klass_name",
",",
"hash",
")",
"model_klass",
"=",
"if",
"self",
".",
"class",
".",
"const_defined?",
"(",
"\"#{self.class}::#{klass_name}\"",
")",
"self",
".",
"class",
".",
"const_get",
"(",
"klass_name",
")",
"else",
"self",
".... | Convert a hash to an instance of nested model class
This is the default implementation; the resulting object is based on HashModel
To be overridden by subclasses | [
"Convert",
"a",
"hash",
"to",
"an",
"instance",
"of",
"nested",
"model",
"class"
] | 39454d74b9d4ea4771b16d4c41cbbbd83ad05df5 | https://github.com/ansible/ansible_tower_client_ruby/blob/39454d74b9d4ea4771b16d4c41cbbbd83ad05df5/lib/ansible_tower_client/hash_model.rb#L133-L141 |
18,077 | roma/roma | lib/roma/tools/mkconfig.rb | Roma.Mkconfig.save_data | def save_data(res)
if res.key?("storage")
case res["storage"].value
when "Ruby Hash"
req = "rh_storage"
storage = "RubyHashStorage"
when "Tokyo Cabinet"
req = "tc_storage"
storage = "TCStorage"
bnum = Calculate.get_bnum(res)
bnum ... | ruby | def save_data(res)
if res.key?("storage")
case res["storage"].value
when "Ruby Hash"
req = "rh_storage"
storage = "RubyHashStorage"
when "Tokyo Cabinet"
req = "tc_storage"
storage = "TCStorage"
bnum = Calculate.get_bnum(res)
bnum ... | [
"def",
"save_data",
"(",
"res",
")",
"if",
"res",
".",
"key?",
"(",
"\"storage\"",
")",
"case",
"res",
"[",
"\"storage\"",
"]",
".",
"value",
"when",
"\"Ruby Hash\"",
"req",
"=",
"\"rh_storage\"",
"storage",
"=",
"\"RubyHashStorage\"",
"when",
"\"Tokyo Cabinet... | make config.rb based on input data | [
"make",
"config",
".",
"rb",
"based",
"on",
"input",
"data"
] | 3dea10df0171742c314ff48f2ed4eebaafc80abf | https://github.com/roma/roma/blob/3dea10df0171742c314ff48f2ed4eebaafc80abf/lib/roma/tools/mkconfig.rb#L511-L574 |
18,078 | ansible/ansible_tower_client_ruby | lib/ansible_tower_client/base_model.rb | AnsibleTowerClient.BaseModel.update_attributes! | def update_attributes!(attributes)
@api.patch(url, attributes.to_json)
attributes.each do |method_name, value|
invoke_name = "#{override_raw_attributes[method_name] || method_name}="
if respond_to?(invoke_name)
send(invoke_name, value)
else
AnsibleTowerClient.logg... | ruby | def update_attributes!(attributes)
@api.patch(url, attributes.to_json)
attributes.each do |method_name, value|
invoke_name = "#{override_raw_attributes[method_name] || method_name}="
if respond_to?(invoke_name)
send(invoke_name, value)
else
AnsibleTowerClient.logg... | [
"def",
"update_attributes!",
"(",
"attributes",
")",
"@api",
".",
"patch",
"(",
"url",
",",
"attributes",
".",
"to_json",
")",
"attributes",
".",
"each",
"do",
"|",
"method_name",
",",
"value",
"|",
"invoke_name",
"=",
"\"#{override_raw_attributes[method_name] || ... | Persist changes passed in as a Hash and return a
representation of that object to the caller.
Example:
project = connection.api.projects.find 2
project.update_attributes!(:name => 'test')
# The values passed to update_attributes! are available in calling object
project.name # => 'test'
E... | [
"Persist",
"changes",
"passed",
"in",
"as",
"a",
"Hash",
"and",
"return",
"a",
"representation",
"of",
"that",
"object",
"to",
"the",
"caller",
"."
] | 39454d74b9d4ea4771b16d4c41cbbbd83ad05df5 | https://github.com/ansible/ansible_tower_client_ruby/blob/39454d74b9d4ea4771b16d4c41cbbbd83ad05df5/lib/ansible_tower_client/base_model.rb#L82-L93 |
18,079 | ansible/ansible_tower_client_ruby | lib/ansible_tower_client/base_model.rb | AnsibleTowerClient.BaseModel.hash_to_model | def hash_to_model(klass_name, hash)
model_klass =
if self.class.const_defined?(klass_name, false)
self.class.const_get(klass_name)
else
self.class.const_set(klass_name, Class.new(BaseModel))
end
model_klass.new(api, hash)
end | ruby | def hash_to_model(klass_name, hash)
model_klass =
if self.class.const_defined?(klass_name, false)
self.class.const_get(klass_name)
else
self.class.const_set(klass_name, Class.new(BaseModel))
end
model_klass.new(api, hash)
end | [
"def",
"hash_to_model",
"(",
"klass_name",
",",
"hash",
")",
"model_klass",
"=",
"if",
"self",
".",
"class",
".",
"const_defined?",
"(",
"klass_name",
",",
"false",
")",
"self",
".",
"class",
".",
"const_get",
"(",
"klass_name",
")",
"else",
"self",
".",
... | convert a hash to an instance of nested model class | [
"convert",
"a",
"hash",
"to",
"an",
"instance",
"of",
"nested",
"model",
"class"
] | 39454d74b9d4ea4771b16d4c41cbbbd83ad05df5 | https://github.com/ansible/ansible_tower_client_ruby/blob/39454d74b9d4ea4771b16d4c41cbbbd83ad05df5/lib/ansible_tower_client/base_model.rb#L164-L172 |
18,080 | Fustrate/mlb_stats_api | lib/mlb_stats_api/stats.rb | MLBStatsAPI.Stats.stats | def stats(options = {})
raise ArgumentError, '#stats requires a stats arg' unless options[:stats]
raise ArgumentError, '#stats requires a group arg' unless options[:group]
get '/stats', options
end | ruby | def stats(options = {})
raise ArgumentError, '#stats requires a stats arg' unless options[:stats]
raise ArgumentError, '#stats requires a group arg' unless options[:group]
get '/stats', options
end | [
"def",
"stats",
"(",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'#stats requires a stats arg'",
"unless",
"options",
"[",
":stats",
"]",
"raise",
"ArgumentError",
",",
"'#stats requires a group arg'",
"unless",
"options",
"[",
":group",
"]",
"g... | View statistics based on statType, group, season, and organization.
@see https://statsapi.mlb.com/docs/#operation/stats | [
"View",
"statistics",
"based",
"on",
"statType",
"group",
"season",
"and",
"organization",
"."
] | 6bbb430dbea4557b5d99c00cdd048b27aeeca231 | https://github.com/Fustrate/mlb_stats_api/blob/6bbb430dbea4557b5d99c00cdd048b27aeeca231/lib/mlb_stats_api/stats.rb#L9-L14 |
18,081 | Fustrate/mlb_stats_api | lib/mlb_stats_api/standings.rb | MLBStatsAPI.Standings.standings | def standings(options = {})
options[:hydrate] = 'team' unless options.key?(:hydrate)
if options[:leagues] && !options[:leagueId]
league_ids = Leagues::LEAGUES.values_at(*options.delete(:leagues))
options[:leagueId] = league_ids
end
options[:leagueId] = [103, 104] unless Array(... | ruby | def standings(options = {})
options[:hydrate] = 'team' unless options.key?(:hydrate)
if options[:leagues] && !options[:leagueId]
league_ids = Leagues::LEAGUES.values_at(*options.delete(:leagues))
options[:leagueId] = league_ids
end
options[:leagueId] = [103, 104] unless Array(... | [
"def",
"standings",
"(",
"options",
"=",
"{",
"}",
")",
"options",
"[",
":hydrate",
"]",
"=",
"'team'",
"unless",
"options",
".",
"key?",
"(",
":hydrate",
")",
"if",
"options",
"[",
":leagues",
"]",
"&&",
"!",
"options",
"[",
":leagueId",
"]",
"league_... | View standings for a league.
@see https://statsapi.mlb.com/docs/#operation/standings | [
"View",
"standings",
"for",
"a",
"league",
"."
] | 6bbb430dbea4557b5d99c00cdd048b27aeeca231 | https://github.com/Fustrate/mlb_stats_api/blob/6bbb430dbea4557b5d99c00cdd048b27aeeca231/lib/mlb_stats_api/standings.rb#L9-L21 |
18,082 | Fustrate/mlb_stats_api | lib/mlb_stats_api/leagues.rb | MLBStatsAPI.Leagues.all_star_ballot | def all_star_ballot(league_id, season = nil, options = {})
options[:season] = season || Time.now.year
get "/league/#{league_id}/allStarBallot", options
end | ruby | def all_star_ballot(league_id, season = nil, options = {})
options[:season] = season || Time.now.year
get "/league/#{league_id}/allStarBallot", options
end | [
"def",
"all_star_ballot",
"(",
"league_id",
",",
"season",
"=",
"nil",
",",
"options",
"=",
"{",
"}",
")",
"options",
"[",
":season",
"]",
"=",
"season",
"||",
"Time",
".",
"now",
".",
"year",
"get",
"\"/league/#{league_id}/allStarBallot\"",
",",
"options",
... | View All-Star Ballots per league.
@see https://statsapi.mlb.com/docs/#operation/allStarBallot | [
"View",
"All",
"-",
"Star",
"Ballots",
"per",
"league",
"."
] | 6bbb430dbea4557b5d99c00cdd048b27aeeca231 | https://github.com/Fustrate/mlb_stats_api/blob/6bbb430dbea4557b5d99c00cdd048b27aeeca231/lib/mlb_stats_api/leagues.rb#L38-L42 |
18,083 | Fustrate/mlb_stats_api | lib/mlb_stats_api/leagues.rb | MLBStatsAPI.Leagues.all_star_write_ins | def all_star_write_ins(league_id, season = nil, options = {})
options[:season] = season || Time.now.year
get "/league/#{league_id}/allStarWriteIns", options
end | ruby | def all_star_write_ins(league_id, season = nil, options = {})
options[:season] = season || Time.now.year
get "/league/#{league_id}/allStarWriteIns", options
end | [
"def",
"all_star_write_ins",
"(",
"league_id",
",",
"season",
"=",
"nil",
",",
"options",
"=",
"{",
"}",
")",
"options",
"[",
":season",
"]",
"=",
"season",
"||",
"Time",
".",
"now",
".",
"year",
"get",
"\"/league/#{league_id}/allStarWriteIns\"",
",",
"optio... | View All-Star Write-ins per league.
@see https://statsapi.mlb.com/docs/#operation/allStarWriteIns | [
"View",
"All",
"-",
"Star",
"Write",
"-",
"ins",
"per",
"league",
"."
] | 6bbb430dbea4557b5d99c00cdd048b27aeeca231 | https://github.com/Fustrate/mlb_stats_api/blob/6bbb430dbea4557b5d99c00cdd048b27aeeca231/lib/mlb_stats_api/leagues.rb#L46-L50 |
18,084 | Fustrate/mlb_stats_api | lib/mlb_stats_api/leagues.rb | MLBStatsAPI.Leagues.all_star_final_vote | def all_star_final_vote(league_id, season = nil, options = {})
options[:season] = season || Time.now.year
get "/league/#{league_id}/allStarFinalVote", options
end | ruby | def all_star_final_vote(league_id, season = nil, options = {})
options[:season] = season || Time.now.year
get "/league/#{league_id}/allStarFinalVote", options
end | [
"def",
"all_star_final_vote",
"(",
"league_id",
",",
"season",
"=",
"nil",
",",
"options",
"=",
"{",
"}",
")",
"options",
"[",
":season",
"]",
"=",
"season",
"||",
"Time",
".",
"now",
".",
"year",
"get",
"\"/league/#{league_id}/allStarFinalVote\"",
",",
"opt... | View All-Star Final Vote per league.
@see https://statsapi.mlb.com/docs/#operation/allStarFinalVote | [
"View",
"All",
"-",
"Star",
"Final",
"Vote",
"per",
"league",
"."
] | 6bbb430dbea4557b5d99c00cdd048b27aeeca231 | https://github.com/Fustrate/mlb_stats_api/blob/6bbb430dbea4557b5d99c00cdd048b27aeeca231/lib/mlb_stats_api/leagues.rb#L54-L58 |
18,085 | Fustrate/mlb_stats_api | lib/mlb_stats_api/people.rb | MLBStatsAPI.People.person | def person(person_ids, options = {})
ids = Array(person_ids)
result = get('/people', options.merge(personIds: ids)).dig('people')
return result.first if ids.length == 1
result
end | ruby | def person(person_ids, options = {})
ids = Array(person_ids)
result = get('/people', options.merge(personIds: ids)).dig('people')
return result.first if ids.length == 1
result
end | [
"def",
"person",
"(",
"person_ids",
",",
"options",
"=",
"{",
"}",
")",
"ids",
"=",
"Array",
"(",
"person_ids",
")",
"result",
"=",
"get",
"(",
"'/people'",
",",
"options",
".",
"merge",
"(",
"personIds",
":",
"ids",
")",
")",
".",
"dig",
"(",
"'pe... | View one or more person's stats and biographical information.
@see https://statsapi.mlb.com/docs/#operation/person | [
"View",
"one",
"or",
"more",
"person",
"s",
"stats",
"and",
"biographical",
"information",
"."
] | 6bbb430dbea4557b5d99c00cdd048b27aeeca231 | https://github.com/Fustrate/mlb_stats_api/blob/6bbb430dbea4557b5d99c00cdd048b27aeeca231/lib/mlb_stats_api/people.rb#L9-L17 |
18,086 | makandra/gemika | lib/gemika/rspec.rb | Gemika.RSpec.run_specs | def run_specs(options = nil)
options ||= {}
files = options.fetch(:files, 'spec')
rspec_options = options.fetch(:options, '--color')
# We need to override the gemfile explicitely, since we have a default Gemfile in the project root
gemfile = options.fetch(:gemfile, Gemika::Env.gemfile)
... | ruby | def run_specs(options = nil)
options ||= {}
files = options.fetch(:files, 'spec')
rspec_options = options.fetch(:options, '--color')
# We need to override the gemfile explicitely, since we have a default Gemfile in the project root
gemfile = options.fetch(:gemfile, Gemika::Env.gemfile)
... | [
"def",
"run_specs",
"(",
"options",
"=",
"nil",
")",
"options",
"||=",
"{",
"}",
"files",
"=",
"options",
".",
"fetch",
"(",
":files",
",",
"'spec'",
")",
"rspec_options",
"=",
"options",
".",
"fetch",
"(",
":options",
",",
"'--color'",
")",
"# We need t... | Runs the RSpec binary. | [
"Runs",
"the",
"RSpec",
"binary",
"."
] | 3cd120c2df2123edcde02489cf6b5b74cd710148 | https://github.com/makandra/gemika/blob/3cd120c2df2123edcde02489cf6b5b74cd710148/lib/gemika/rspec.rb#L10-L28 |
18,087 | makandra/gemika | lib/gemika/rspec.rb | Gemika.RSpec.configure_should_syntax | def configure_should_syntax
if Env.gem?('rspec', '>= 2.11')
configure do |config|
config.expect_with(:rspec) { |c| c.syntax = [:should, :expect] }
config.mock_with(:rspec) { |c| c.syntax = [:should, :expect] }
end
else
# We have an old RSpec that only understands ... | ruby | def configure_should_syntax
if Env.gem?('rspec', '>= 2.11')
configure do |config|
config.expect_with(:rspec) { |c| c.syntax = [:should, :expect] }
config.mock_with(:rspec) { |c| c.syntax = [:should, :expect] }
end
else
# We have an old RSpec that only understands ... | [
"def",
"configure_should_syntax",
"if",
"Env",
".",
"gem?",
"(",
"'rspec'",
",",
"'>= 2.11'",
")",
"configure",
"do",
"|",
"config",
"|",
"config",
".",
"expect_with",
"(",
":rspec",
")",
"{",
"|",
"c",
"|",
"c",
".",
"syntax",
"=",
"[",
":should",
","... | Configures RSpec so it allows the `should` syntax that works across all RSpec versions. | [
"Configures",
"RSpec",
"so",
"it",
"allows",
"the",
"should",
"syntax",
"that",
"works",
"across",
"all",
"RSpec",
"versions",
"."
] | 3cd120c2df2123edcde02489cf6b5b74cd710148 | https://github.com/makandra/gemika/blob/3cd120c2df2123edcde02489cf6b5b74cd710148/lib/gemika/rspec.rb#L68-L77 |
18,088 | makandra/gemika | lib/gemika/database.rb | Gemika.Database.adapter_config | def adapter_config
default_config = {}
default_config['database'] = guess_database_name
if Env.gem?('pg')
default_config['adapter'] = 'postgresql'
default_config['username'] = 'postgres' if Env.travis?
default_config['password'] = ''
user_config = @yaml_config['postgres... | ruby | def adapter_config
default_config = {}
default_config['database'] = guess_database_name
if Env.gem?('pg')
default_config['adapter'] = 'postgresql'
default_config['username'] = 'postgres' if Env.travis?
default_config['password'] = ''
user_config = @yaml_config['postgres... | [
"def",
"adapter_config",
"default_config",
"=",
"{",
"}",
"default_config",
"[",
"'database'",
"]",
"=",
"guess_database_name",
"if",
"Env",
".",
"gem?",
"(",
"'pg'",
")",
"default_config",
"[",
"'adapter'",
"]",
"=",
"'postgresql'",
"default_config",
"[",
"'use... | Returns a hash of ActiveRecord adapter options for the currently activated database gem. | [
"Returns",
"a",
"hash",
"of",
"ActiveRecord",
"adapter",
"options",
"for",
"the",
"currently",
"activated",
"database",
"gem",
"."
] | 3cd120c2df2123edcde02489cf6b5b74cd710148 | https://github.com/makandra/gemika/blob/3cd120c2df2123edcde02489cf6b5b74cd710148/lib/gemika/database.rb#L85-L106 |
18,089 | makandra/gemika | lib/gemika/matrix.rb | Gemika.Matrix.each | def each(&block)
@all_passed = true
rows.each do |row|
gemfile = row.gemfile
if row.compatible_with_ruby?(current_ruby)
@compatible_count += 1
print_title gemfile
gemfile_passed = Env.with_gemfile(gemfile, row, &block)
@all_passed &= gemfile_passed
... | ruby | def each(&block)
@all_passed = true
rows.each do |row|
gemfile = row.gemfile
if row.compatible_with_ruby?(current_ruby)
@compatible_count += 1
print_title gemfile
gemfile_passed = Env.with_gemfile(gemfile, row, &block)
@all_passed &= gemfile_passed
... | [
"def",
"each",
"(",
"&",
"block",
")",
"@all_passed",
"=",
"true",
"rows",
".",
"each",
"do",
"|",
"row",
"|",
"gemfile",
"=",
"row",
".",
"gemfile",
"if",
"row",
".",
"compatible_with_ruby?",
"(",
"current_ruby",
")",
"@compatible_count",
"+=",
"1",
"pr... | Runs the given `block` for each matrix row that is compatible with the current Ruby.
The row's gemfile will be set as an environment variable, so Bundler will use that gemfile if you shell out in `block`.
At the end it will print a summary of which rows have passed, failed or were skipped (due to incompatible Ruby ... | [
"Runs",
"the",
"given",
"block",
"for",
"each",
"matrix",
"row",
"that",
"is",
"compatible",
"with",
"the",
"current",
"Ruby",
"."
] | 3cd120c2df2123edcde02489cf6b5b74cd710148 | https://github.com/makandra/gemika/blob/3cd120c2df2123edcde02489cf6b5b74cd710148/lib/gemika/matrix.rb#L107-L126 |
18,090 | makandra/gemika | lib/gemika/env.rb | Gemika.Env.with_gemfile | def with_gemfile(path, *args, &block)
# Make sure that if block calls #gemfile we still return the gemfile for this
# process, regardless of what's in ENV temporarily
@gemfile_changed = true
@process_gemfile = ENV['BUNDLE_GEMFILE']
Bundler.with_clean_env do
ENV['BUNDLE_GEMFILE'] =... | ruby | def with_gemfile(path, *args, &block)
# Make sure that if block calls #gemfile we still return the gemfile for this
# process, regardless of what's in ENV temporarily
@gemfile_changed = true
@process_gemfile = ENV['BUNDLE_GEMFILE']
Bundler.with_clean_env do
ENV['BUNDLE_GEMFILE'] =... | [
"def",
"with_gemfile",
"(",
"path",
",",
"*",
"args",
",",
"&",
"block",
")",
"# Make sure that if block calls #gemfile we still return the gemfile for this",
"# process, regardless of what's in ENV temporarily",
"@gemfile_changed",
"=",
"true",
"@process_gemfile",
"=",
"ENV",
... | Changes the gemfile to the given `path`, runs the given `block`, then resets
the gemfile to its original path.
@example
Gemika::Env.with_gemfile('gemfiles/Gemfile.rails3') do
system('rspec spec') or raise 'RSpec failed'
end | [
"Changes",
"the",
"gemfile",
"to",
"the",
"given",
"path",
"runs",
"the",
"given",
"block",
"then",
"resets",
"the",
"gemfile",
"to",
"its",
"original",
"path",
"."
] | 3cd120c2df2123edcde02489cf6b5b74cd710148 | https://github.com/makandra/gemika/blob/3cd120c2df2123edcde02489cf6b5b74cd710148/lib/gemika/env.rb#L33-L45 |
18,091 | makandra/gemika | lib/gemika/env.rb | Gemika.Env.gem? | def gem?(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
name, requirement_string = args
if options[:gemfile] && !process_gemfile?(options[:gemfile])
gem_in_gemfile?(options[:gemfile], name, requirement_string)
else
gem_activated?(name, requirement_string)
end
en... | ruby | def gem?(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
name, requirement_string = args
if options[:gemfile] && !process_gemfile?(options[:gemfile])
gem_in_gemfile?(options[:gemfile], name, requirement_string)
else
gem_activated?(name, requirement_string)
end
en... | [
"def",
"gem?",
"(",
"*",
"args",
")",
"options",
"=",
"args",
".",
"last",
".",
"is_a?",
"(",
"Hash",
")",
"?",
"args",
".",
"pop",
":",
"{",
"}",
"name",
",",
"requirement_string",
"=",
"args",
"if",
"options",
"[",
":gemfile",
"]",
"&&",
"!",
"... | Check if the given gem was activated by the current gemfile.
It might or might not have been `require`d yet.
@example
Gemika::Env.gem?('activerecord')
Gemika::Env.gem?('activerecord', '= 5.0.0')
Gemika::Env.gem?('activerecord', '~> 4.2.0') | [
"Check",
"if",
"the",
"given",
"gem",
"was",
"activated",
"by",
"the",
"current",
"gemfile",
".",
"It",
"might",
"or",
"might",
"not",
"have",
"been",
"require",
"d",
"yet",
"."
] | 3cd120c2df2123edcde02489cf6b5b74cd710148 | https://github.com/makandra/gemika/blob/3cd120c2df2123edcde02489cf6b5b74cd710148/lib/gemika/env.rb#L56-L64 |
18,092 | fabienpiette/fetcheable_on_api | lib/fetcheable_on_api/filterable.rb | FetcheableOnApi.Filterable.predicates | def predicates(predicate, collection, klass, column_name, value)
case predicate
when :between
klass.arel_table[column_name].between(value.first..value.last)
when :does_not_match
klass.arel_table[column_name].does_not_match("%#{value}%")
when :does_not_match_all
klass.arel... | ruby | def predicates(predicate, collection, klass, column_name, value)
case predicate
when :between
klass.arel_table[column_name].between(value.first..value.last)
when :does_not_match
klass.arel_table[column_name].does_not_match("%#{value}%")
when :does_not_match_all
klass.arel... | [
"def",
"predicates",
"(",
"predicate",
",",
"collection",
",",
"klass",
",",
"column_name",
",",
"value",
")",
"case",
"predicate",
"when",
":between",
"klass",
".",
"arel_table",
"[",
"column_name",
"]",
".",
"between",
"(",
"value",
".",
"first",
"..",
"... | Apply arel predicate on collection | [
"Apply",
"arel",
"predicate",
"on",
"collection"
] | ad19c38bc3978f4dc1c88ee6c301a09769c0f9f7 | https://github.com/fabienpiette/fetcheable_on_api/blob/ad19c38bc3978f4dc1c88ee6c301a09769c0f9f7/lib/fetcheable_on_api/filterable.rb#L141-L217 |
18,093 | ledbettj/systemd-journal | lib/systemd/journal_entry.rb | Systemd.JournalEntry.catalog | def catalog(opts = {})
return nil unless catalog?
opts[:replace] = true unless opts.key?(:replace)
cat = Systemd::Journal.catalog_for(self[:message_id])
# catalog_for does not do field substitution for us, so we do it here
# if requested
opts[:replace] ? field_substitute(cat) : cat... | ruby | def catalog(opts = {})
return nil unless catalog?
opts[:replace] = true unless opts.key?(:replace)
cat = Systemd::Journal.catalog_for(self[:message_id])
# catalog_for does not do field substitution for us, so we do it here
# if requested
opts[:replace] ? field_substitute(cat) : cat... | [
"def",
"catalog",
"(",
"opts",
"=",
"{",
"}",
")",
"return",
"nil",
"unless",
"catalog?",
"opts",
"[",
":replace",
"]",
"=",
"true",
"unless",
"opts",
".",
"key?",
"(",
":replace",
")",
"cat",
"=",
"Systemd",
"::",
"Journal",
".",
"catalog_for",
"(",
... | Returns the catalog message that this Journal Entry references, if any.
@option opts [Boolean] :replace set to false to not replace placeholder
strings in the catalog with the associated values in this Journal Entry.
defaults to true.
@return [String] the catalog provided message for this Journal Entry, or
n... | [
"Returns",
"the",
"catalog",
"message",
"that",
"this",
"Journal",
"Entry",
"references",
"if",
"any",
"."
] | 823ac01a88da58fd3e703076b1d6e918aba73522 | https://github.com/ledbettj/systemd-journal/blob/823ac01a88da58fd3e703076b1d6e918aba73522/lib/systemd/journal_entry.rb#L71-L80 |
18,094 | ledbettj/systemd-journal | lib/systemd/journal.rb | Systemd.Journal.query_unique | def query_unique(field)
results = []
Native.sd_journal_restart_unique(@ptr)
rc = Native.sd_journal_query_unique(@ptr, field.to_s.upcase)
raise JournalError, rc if rc < 0
while (kvpair = enumerate_helper(:sd_journal_enumerate_unique))
results << kvpair.last
end
resul... | ruby | def query_unique(field)
results = []
Native.sd_journal_restart_unique(@ptr)
rc = Native.sd_journal_query_unique(@ptr, field.to_s.upcase)
raise JournalError, rc if rc < 0
while (kvpair = enumerate_helper(:sd_journal_enumerate_unique))
results << kvpair.last
end
resul... | [
"def",
"query_unique",
"(",
"field",
")",
"results",
"=",
"[",
"]",
"Native",
".",
"sd_journal_restart_unique",
"(",
"@ptr",
")",
"rc",
"=",
"Native",
".",
"sd_journal_query_unique",
"(",
"@ptr",
",",
"field",
".",
"to_s",
".",
"upcase",
")",
"raise",
"Jou... | Get the list of unique values stored in the journal for the given field.
If passed a block, each possible value will be yielded.
@return [Array] the list of possible values.
@example Fetch all possible boot ids from the journal
j = Systemd::Journal.new
j.query_unique('_BOOT_ID') | [
"Get",
"the",
"list",
"of",
"unique",
"values",
"stored",
"in",
"the",
"journal",
"for",
"the",
"given",
"field",
".",
"If",
"passed",
"a",
"block",
"each",
"possible",
"value",
"will",
"be",
"yielded",
"."
] | 823ac01a88da58fd3e703076b1d6e918aba73522 | https://github.com/ledbettj/systemd-journal/blob/823ac01a88da58fd3e703076b1d6e918aba73522/lib/systemd/journal.rb#L155-L168 |
18,095 | ledbettj/systemd-journal | lib/systemd/journal.rb | Systemd.Journal.data_threshold | def data_threshold
size_ptr = FFI::MemoryPointer.new(:size_t, 1)
if (rc = Native.sd_journal_get_data_threshold(@ptr, size_ptr)) < 0
raise JournalError, rc
end
size_ptr.read_size_t
end | ruby | def data_threshold
size_ptr = FFI::MemoryPointer.new(:size_t, 1)
if (rc = Native.sd_journal_get_data_threshold(@ptr, size_ptr)) < 0
raise JournalError, rc
end
size_ptr.read_size_t
end | [
"def",
"data_threshold",
"size_ptr",
"=",
"FFI",
"::",
"MemoryPointer",
".",
"new",
"(",
":size_t",
",",
"1",
")",
"if",
"(",
"rc",
"=",
"Native",
".",
"sd_journal_get_data_threshold",
"(",
"@ptr",
",",
"size_ptr",
")",
")",
"<",
"0",
"raise",
"JournalErro... | Get the maximum length of a data field that will be returned.
Fields longer than this will be truncated. Default is 64K.
@return [Integer] size in bytes. | [
"Get",
"the",
"maximum",
"length",
"of",
"a",
"data",
"field",
"that",
"will",
"be",
"returned",
".",
"Fields",
"longer",
"than",
"this",
"will",
"be",
"truncated",
".",
"Default",
"is",
"64K",
"."
] | 823ac01a88da58fd3e703076b1d6e918aba73522 | https://github.com/ledbettj/systemd-journal/blob/823ac01a88da58fd3e703076b1d6e918aba73522/lib/systemd/journal.rb#L186-L193 |
18,096 | documentcloud/cloud-crowd | lib/cloud_crowd/action.rb | CloudCrowd.Action.download | def download(url, path)
if url.match(FILE_URL)
FileUtils.cp(url.sub(FILE_URL, ''), path)
else
File.open(path, 'w+') do |file|
Net::HTTP.get_response(URI(url)) do |response|
response.read_body do |chunk|
file.write chunk
end
end
... | ruby | def download(url, path)
if url.match(FILE_URL)
FileUtils.cp(url.sub(FILE_URL, ''), path)
else
File.open(path, 'w+') do |file|
Net::HTTP.get_response(URI(url)) do |response|
response.read_body do |chunk|
file.write chunk
end
end
... | [
"def",
"download",
"(",
"url",
",",
"path",
")",
"if",
"url",
".",
"match",
"(",
"FILE_URL",
")",
"FileUtils",
".",
"cp",
"(",
"url",
".",
"sub",
"(",
"FILE_URL",
",",
"''",
")",
",",
"path",
")",
"else",
"File",
".",
"open",
"(",
"path",
",",
... | Download a file to the specified path. | [
"Download",
"a",
"file",
"to",
"the",
"specified",
"path",
"."
] | a66172eabc6cb526b27be2bb821e2ea4258c82d4 | https://github.com/documentcloud/cloud-crowd/blob/a66172eabc6cb526b27be2bb821e2ea4258c82d4/lib/cloud_crowd/action.rb#L44-L57 |
18,097 | documentcloud/cloud-crowd | lib/cloud_crowd/action.rb | CloudCrowd.Action.` | def `(command)
result = super(command)
exit_code = $?.to_i
raise Error::CommandFailed.new(result, exit_code) unless exit_code == 0
result
end | ruby | def `(command)
result = super(command)
exit_code = $?.to_i
raise Error::CommandFailed.new(result, exit_code) unless exit_code == 0
result
end | [
"def",
"`",
"(",
"command",
")",
"result",
"=",
"super",
"(",
"command",
")",
"exit_code",
"=",
"$?",
".",
"to_i",
"raise",
"Error",
"::",
"CommandFailed",
".",
"new",
"(",
"result",
",",
"exit_code",
")",
"unless",
"exit_code",
"==",
"0",
"result",
"e... | Actions have a backticks command that raises a CommandFailed exception
on failure, so that processing doesn't just blithely continue. | [
"Actions",
"have",
"a",
"backticks",
"command",
"that",
"raises",
"a",
"CommandFailed",
"exception",
"on",
"failure",
"so",
"that",
"processing",
"doesn",
"t",
"just",
"blithely",
"continue",
"."
] | a66172eabc6cb526b27be2bb821e2ea4258c82d4 | https://github.com/documentcloud/cloud-crowd/blob/a66172eabc6cb526b27be2bb821e2ea4258c82d4/lib/cloud_crowd/action.rb#L74-L79 |
18,098 | documentcloud/cloud-crowd | lib/cloud_crowd/action.rb | CloudCrowd.Action.safe_filename | def safe_filename(url)
url = url.sub(/\?.*\Z/, '')
ext = File.extname(url)
name = URI.unescape(File.basename(url)).gsub(/[^a-zA-Z0-9_\-.]/, '-').gsub(/-+/, '-')
File.basename(name, ext).gsub('.', '-') + ext
end | ruby | def safe_filename(url)
url = url.sub(/\?.*\Z/, '')
ext = File.extname(url)
name = URI.unescape(File.basename(url)).gsub(/[^a-zA-Z0-9_\-.]/, '-').gsub(/-+/, '-')
File.basename(name, ext).gsub('.', '-') + ext
end | [
"def",
"safe_filename",
"(",
"url",
")",
"url",
"=",
"url",
".",
"sub",
"(",
"/",
"\\?",
"\\Z",
"/",
",",
"''",
")",
"ext",
"=",
"File",
".",
"extname",
"(",
"url",
")",
"name",
"=",
"URI",
".",
"unescape",
"(",
"File",
".",
"basename",
"(",
"u... | Convert an unsafe URL into a filesystem-friendly filename. | [
"Convert",
"an",
"unsafe",
"URL",
"into",
"a",
"filesystem",
"-",
"friendly",
"filename",
"."
] | a66172eabc6cb526b27be2bb821e2ea4258c82d4 | https://github.com/documentcloud/cloud-crowd/blob/a66172eabc6cb526b27be2bb821e2ea4258c82d4/lib/cloud_crowd/action.rb#L85-L90 |
18,099 | documentcloud/cloud-crowd | lib/cloud_crowd/action.rb | CloudCrowd.Action.download_input | def download_input
return unless input_is_url?
Dir.chdir(@work_directory) do
@input_path = File.join(@work_directory, safe_filename(@input))
@file_name = File.basename(@input_path, File.extname(@input_path))
download(@input, @input_path)
end
end | ruby | def download_input
return unless input_is_url?
Dir.chdir(@work_directory) do
@input_path = File.join(@work_directory, safe_filename(@input))
@file_name = File.basename(@input_path, File.extname(@input_path))
download(@input, @input_path)
end
end | [
"def",
"download_input",
"return",
"unless",
"input_is_url?",
"Dir",
".",
"chdir",
"(",
"@work_directory",
")",
"do",
"@input_path",
"=",
"File",
".",
"join",
"(",
"@work_directory",
",",
"safe_filename",
"(",
"@input",
")",
")",
"@file_name",
"=",
"File",
"."... | If the input is a URL, download the file before beginning processing. | [
"If",
"the",
"input",
"is",
"a",
"URL",
"download",
"the",
"file",
"before",
"beginning",
"processing",
"."
] | a66172eabc6cb526b27be2bb821e2ea4258c82d4 | https://github.com/documentcloud/cloud-crowd/blob/a66172eabc6cb526b27be2bb821e2ea4258c82d4/lib/cloud_crowd/action.rb#L118-L125 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.