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
sequence | docstring
stringlengths 8
16k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 94
266
|
---|---|---|---|---|---|---|---|---|---|---|---|
23,500 | cbeer/fcrepo_wrapper | lib/fcrepo_wrapper/instance.rb | FcrepoWrapper.Instance.status | def status
return true unless config.managed?
return false if pid.nil?
begin
Process.getpgid(pid)
rescue Errno::ESRCH
return false
end
begin
TCPSocket.new(host, port).close
Net::HTTP.start(host, port) do |http|
http.request(Net::HTTP::Get.new('/'))
end
true
rescue Errno::ECONNREFUSED, Errno::EINVAL
false
end
end | ruby | def status
return true unless config.managed?
return false if pid.nil?
begin
Process.getpgid(pid)
rescue Errno::ESRCH
return false
end
begin
TCPSocket.new(host, port).close
Net::HTTP.start(host, port) do |http|
http.request(Net::HTTP::Get.new('/'))
end
true
rescue Errno::ECONNREFUSED, Errno::EINVAL
false
end
end | [
"def",
"status",
"return",
"true",
"unless",
"config",
".",
"managed?",
"return",
"false",
"if",
"pid",
".",
"nil?",
"begin",
"Process",
".",
"getpgid",
"(",
"pid",
")",
"rescue",
"Errno",
"::",
"ESRCH",
"return",
"false",
"end",
"begin",
"TCPSocket",
".",
"new",
"(",
"host",
",",
"port",
")",
".",
"close",
"Net",
"::",
"HTTP",
".",
"start",
"(",
"host",
",",
"port",
")",
"do",
"|",
"http",
"|",
"http",
".",
"request",
"(",
"Net",
"::",
"HTTP",
"::",
"Get",
".",
"new",
"(",
"'/'",
")",
")",
"end",
"true",
"rescue",
"Errno",
"::",
"ECONNREFUSED",
",",
"Errno",
"::",
"EINVAL",
"false",
"end",
"end"
] | Check the status of a managed fcrepo service | [
"Check",
"the",
"status",
"of",
"a",
"managed",
"fcrepo",
"service"
] | 6b91a72e1c91848364a30b73b6e6e4b9b2d21296 | https://github.com/cbeer/fcrepo_wrapper/blob/6b91a72e1c91848364a30b73b6e6e4b9b2d21296/lib/fcrepo_wrapper/instance.rb#L95-L116 |
23,501 | cbeer/fcrepo_wrapper | lib/fcrepo_wrapper/instance.rb | FcrepoWrapper.Instance.clean! | def clean!
stop
remove_instance_dir!
FileUtils.remove_entry(config.download_path) if File.exists?(config.download_path)
FileUtils.remove_entry(config.tmp_save_dir, true) if File.exists? config.tmp_save_dir
md5.clean!
FileUtils.remove_entry(config.version_file) if File.exists? config.version_file
end | ruby | def clean!
stop
remove_instance_dir!
FileUtils.remove_entry(config.download_path) if File.exists?(config.download_path)
FileUtils.remove_entry(config.tmp_save_dir, true) if File.exists? config.tmp_save_dir
md5.clean!
FileUtils.remove_entry(config.version_file) if File.exists? config.version_file
end | [
"def",
"clean!",
"stop",
"remove_instance_dir!",
"FileUtils",
".",
"remove_entry",
"(",
"config",
".",
"download_path",
")",
"if",
"File",
".",
"exists?",
"(",
"config",
".",
"download_path",
")",
"FileUtils",
".",
"remove_entry",
"(",
"config",
".",
"tmp_save_dir",
",",
"true",
")",
"if",
"File",
".",
"exists?",
"config",
".",
"tmp_save_dir",
"md5",
".",
"clean!",
"FileUtils",
".",
"remove_entry",
"(",
"config",
".",
"version_file",
")",
"if",
"File",
".",
"exists?",
"config",
".",
"version_file",
"end"
] | Clean up any files fcrepo_wrapper may have downloaded | [
"Clean",
"up",
"any",
"files",
"fcrepo_wrapper",
"may",
"have",
"downloaded"
] | 6b91a72e1c91848364a30b73b6e6e4b9b2d21296 | https://github.com/cbeer/fcrepo_wrapper/blob/6b91a72e1c91848364a30b73b6e6e4b9b2d21296/lib/fcrepo_wrapper/instance.rb#L154-L161 |
23,502 | cbeer/fcrepo_wrapper | lib/fcrepo_wrapper/instance.rb | FcrepoWrapper.Instance.remove_instance_dir! | def remove_instance_dir!
FileUtils.remove_entry(config.instance_dir, true) if File.exists? config.instance_dir
end | ruby | def remove_instance_dir!
FileUtils.remove_entry(config.instance_dir, true) if File.exists? config.instance_dir
end | [
"def",
"remove_instance_dir!",
"FileUtils",
".",
"remove_entry",
"(",
"config",
".",
"instance_dir",
",",
"true",
")",
"if",
"File",
".",
"exists?",
"config",
".",
"instance_dir",
"end"
] | Clean up any files in the fcrepo instance dir | [
"Clean",
"up",
"any",
"files",
"in",
"the",
"fcrepo",
"instance",
"dir"
] | 6b91a72e1c91848364a30b73b6e6e4b9b2d21296 | https://github.com/cbeer/fcrepo_wrapper/blob/6b91a72e1c91848364a30b73b6e6e4b9b2d21296/lib/fcrepo_wrapper/instance.rb#L165-L167 |
23,503 | cbeer/fcrepo_wrapper | lib/fcrepo_wrapper/instance.rb | FcrepoWrapper.Instance.extract | def extract
return config.instance_dir if extracted?
jar_file = download
FileUtils.mkdir_p config.instance_dir
FileUtils.cp jar_file, config.binary_path
self.extracted_version = config.version
config.instance_dir
end | ruby | def extract
return config.instance_dir if extracted?
jar_file = download
FileUtils.mkdir_p config.instance_dir
FileUtils.cp jar_file, config.binary_path
self.extracted_version = config.version
config.instance_dir
end | [
"def",
"extract",
"return",
"config",
".",
"instance_dir",
"if",
"extracted?",
"jar_file",
"=",
"download",
"FileUtils",
".",
"mkdir_p",
"config",
".",
"instance_dir",
"FileUtils",
".",
"cp",
"jar_file",
",",
"config",
".",
"binary_path",
"self",
".",
"extracted_version",
"=",
"config",
".",
"version",
"config",
".",
"instance_dir",
"end"
] | extract a copy of fcrepo to instance_dir
Does noting if fcrepo already exists at instance_dir
@return [String] instance_dir Directory where fcrepo has been installed | [
"extract",
"a",
"copy",
"of",
"fcrepo",
"to",
"instance_dir",
"Does",
"noting",
"if",
"fcrepo",
"already",
"exists",
"at",
"instance_dir"
] | 6b91a72e1c91848364a30b73b6e6e4b9b2d21296 | https://github.com/cbeer/fcrepo_wrapper/blob/6b91a72e1c91848364a30b73b6e6e4b9b2d21296/lib/fcrepo_wrapper/instance.rb#L182-L192 |
23,504 | emonti/rbkb | lib/rbkb/cli.rb | Rbkb::Cli.Executable.exit | def exit(ret)
@exit_status = ret
if defined? Rbkb::Cli::TESTING
throw(((ret==0)? :exit_zero : :exit_err), ret)
else
Kernel.exit(ret)
end
end | ruby | def exit(ret)
@exit_status = ret
if defined? Rbkb::Cli::TESTING
throw(((ret==0)? :exit_zero : :exit_err), ret)
else
Kernel.exit(ret)
end
end | [
"def",
"exit",
"(",
"ret",
")",
"@exit_status",
"=",
"ret",
"if",
"defined?",
"Rbkb",
"::",
"Cli",
"::",
"TESTING",
"throw",
"(",
"(",
"(",
"ret",
"==",
"0",
")",
"?",
":exit_zero",
":",
":exit_err",
")",
",",
"ret",
")",
"else",
"Kernel",
".",
"exit",
"(",
"ret",
")",
"end",
"end"
] | Instantiates a new Executable object.
The 'param' argument is a named value hash. The following keys are
significant:
:argv - An array of cli arguments (default ARGV)
:opts - executable/function options for use when running 'go'
:stdout, - IO redirection (mostly for unit tests)
:stderr,
:stdin
The above keys are deleted from the 'param' hash and stored as instance
variables with attr_accessors. All other parameters are ignored.
Wrapper for Kernel.exit() so we can unit test cli tools | [
"Instantiates",
"a",
"new",
"Executable",
"object",
"."
] | a6d35c0fd785bae135034502b1d07ed626aebde5 | https://github.com/emonti/rbkb/blob/a6d35c0fd785bae135034502b1d07ed626aebde5/lib/rbkb/cli.rb#L48-L55 |
23,505 | emonti/rbkb | lib/rbkb/cli.rb | Rbkb::Cli.Executable.add_range_opts | def add_range_opts(fkey, lkey)
@oparse.on("-r", "--range=START[:END]",
"Start and optional end range") do |r|
raise "-x and -r are mutually exclusive" if @parser_got_range
@parser_got_range=true
unless /^(-?[0-9]+)(?::(-?[0-9]+))?$/.match(r)
raise "invalid range #{r.inspect}"
end
@opts[fkey] = $1.to_i
@opts[lkey] = $2.to_i if $2
end
@oparse.on("-x", "--hexrange=START[:END]",
"Start and optional end range in hex") do |r|
raise "-x and -r are mutually exclusive" if @parser_got_range
@parser_got_range=true
unless /^(-?[0-9a-f]+)(?::(-?[0-9a-f]+))?$/i.match(r)
raise "invalid range #{r.inspect}"
end
@opts[fkey] =
if ($1[0,1] == '-')
($1[1..-1]).hex_to_num * -1
else
$1.hex_to_num
end
if $2
@opts[lkey] =
if($2[0,1] == '-')
$2[1..-1].hex_to_num * -1
else
$2.hex_to_num
end
end
end
end | ruby | def add_range_opts(fkey, lkey)
@oparse.on("-r", "--range=START[:END]",
"Start and optional end range") do |r|
raise "-x and -r are mutually exclusive" if @parser_got_range
@parser_got_range=true
unless /^(-?[0-9]+)(?::(-?[0-9]+))?$/.match(r)
raise "invalid range #{r.inspect}"
end
@opts[fkey] = $1.to_i
@opts[lkey] = $2.to_i if $2
end
@oparse.on("-x", "--hexrange=START[:END]",
"Start and optional end range in hex") do |r|
raise "-x and -r are mutually exclusive" if @parser_got_range
@parser_got_range=true
unless /^(-?[0-9a-f]+)(?::(-?[0-9a-f]+))?$/i.match(r)
raise "invalid range #{r.inspect}"
end
@opts[fkey] =
if ($1[0,1] == '-')
($1[1..-1]).hex_to_num * -1
else
$1.hex_to_num
end
if $2
@opts[lkey] =
if($2[0,1] == '-')
$2[1..-1].hex_to_num * -1
else
$2.hex_to_num
end
end
end
end | [
"def",
"add_range_opts",
"(",
"fkey",
",",
"lkey",
")",
"@oparse",
".",
"on",
"(",
"\"-r\"",
",",
"\"--range=START[:END]\"",
",",
"\"Start and optional end range\"",
")",
"do",
"|",
"r",
"|",
"raise",
"\"-x and -r are mutually exclusive\"",
"if",
"@parser_got_range",
"@parser_got_range",
"=",
"true",
"unless",
"/",
"/",
".",
"match",
"(",
"r",
")",
"raise",
"\"invalid range #{r.inspect}\"",
"end",
"@opts",
"[",
"fkey",
"]",
"=",
"$1",
".",
"to_i",
"@opts",
"[",
"lkey",
"]",
"=",
"$2",
".",
"to_i",
"if",
"$2",
"end",
"@oparse",
".",
"on",
"(",
"\"-x\"",
",",
"\"--hexrange=START[:END]\"",
",",
"\"Start and optional end range in hex\"",
")",
"do",
"|",
"r",
"|",
"raise",
"\"-x and -r are mutually exclusive\"",
"if",
"@parser_got_range",
"@parser_got_range",
"=",
"true",
"unless",
"/",
"/i",
".",
"match",
"(",
"r",
")",
"raise",
"\"invalid range #{r.inspect}\"",
"end",
"@opts",
"[",
"fkey",
"]",
"=",
"if",
"(",
"$1",
"[",
"0",
",",
"1",
"]",
"==",
"'-'",
")",
"(",
"$1",
"[",
"1",
"..",
"-",
"1",
"]",
")",
".",
"hex_to_num",
"*",
"-",
"1",
"else",
"$1",
".",
"hex_to_num",
"end",
"if",
"$2",
"@opts",
"[",
"lkey",
"]",
"=",
"if",
"(",
"$2",
"[",
"0",
",",
"1",
"]",
"==",
"'-'",
")",
"$2",
"[",
"1",
"..",
"-",
"1",
"]",
".",
"hex_to_num",
"*",
"-",
"1",
"else",
"$2",
".",
"hex_to_num",
"end",
"end",
"end",
"end"
] | Implements numeric and hex range options via '-r' and '-x'
Takes two arguments which are the @opts hash key names for
first and last parameters.
(Used commonly throughout several executables) | [
"Implements",
"numeric",
"and",
"hex",
"range",
"options",
"via",
"-",
"r",
"and",
"-",
"x"
] | a6d35c0fd785bae135034502b1d07ed626aebde5 | https://github.com/emonti/rbkb/blob/a6d35c0fd785bae135034502b1d07ed626aebde5/lib/rbkb/cli.rb#L148-L189 |
23,506 | eWAYPayment/eway-rapid-ruby | lib/eway_rapid/rapid_client.rb | EwayRapid.RapidClient.create_transaction | def create_transaction(payment_method, transaction)
unless get_valid?
return make_response_with_exception(Exceptions::APIKeyInvalidException.new('API key, password or Rapid endpoint missing or invalid'), CreateTransactionResponse)
end
begin
case payment_method
when Enums::PaymentMethod::DIRECT
url = @web_url + Constants::DIRECT_PAYMENT_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::TransactionProcess::TransDirectPaymentMsgProcess.create_request(transaction)
response = Message::TransactionProcess::TransDirectPaymentMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::TransactionProcess::TransDirectPaymentMsgProcess.make_result(response)
when Enums::PaymentMethod::RESPONSIVE_SHARED
url = @web_url + Constants::RESPONSIVE_SHARED_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::TransactionProcess::TransResponsiveSharedMsgProcess.create_request(transaction)
response = Message::TransactionProcess::TransResponsiveSharedMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::TransactionProcess::TransResponsiveSharedMsgProcess.make_result(response)
when Enums::PaymentMethod::TRANSPARENT_REDIRECT
url = @web_url + Constants::TRANSPARENT_REDIRECT_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::TransactionProcess::TransTransparentRedirectMsgProcess.create_request(transaction)
response = Message::TransactionProcess::TransTransparentRedirectMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::TransactionProcess::TransTransparentRedirectMsgProcess.make_result(response)
when Enums::PaymentMethod::WALLET
if transaction.capture
url = @web_url + Constants::DIRECT_PAYMENT_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::TransactionProcess::TransDirectPaymentMsgProcess.create_request(transaction)
response = Message::TransactionProcess::TransDirectPaymentMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::TransactionProcess::TransDirectPaymentMsgProcess.make_result(response)
else
url = @web_url + Constants::CAPTURE_PAYMENT_METHOD
request = Message::TransactionProcess::CapturePaymentMsgProcess.create_request(transaction)
response = Message::TransactionProcess::CapturePaymentMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::TransactionProcess::CapturePaymentMsgProcess.make_result(response)
end
when Enums::PaymentMethod::AUTHORISATION
url = @web_url + Constants::CAPTURE_PAYMENT_METHOD
request = Message::TransactionProcess::CapturePaymentMsgProcess.create_request(transaction)
response = Message::TransactionProcess::CapturePaymentMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::TransactionProcess::CapturePaymentMsgProcess.make_result(response)
else
make_response_with_exception(Exceptions::ParameterInvalidException.new('Unsupported payment type'), CreateTransactionResponse)
end
rescue => e
@logger.error(e.to_s) if @logger
make_response_with_exception(e, CreateTransactionResponse)
end
end | ruby | def create_transaction(payment_method, transaction)
unless get_valid?
return make_response_with_exception(Exceptions::APIKeyInvalidException.new('API key, password or Rapid endpoint missing or invalid'), CreateTransactionResponse)
end
begin
case payment_method
when Enums::PaymentMethod::DIRECT
url = @web_url + Constants::DIRECT_PAYMENT_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::TransactionProcess::TransDirectPaymentMsgProcess.create_request(transaction)
response = Message::TransactionProcess::TransDirectPaymentMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::TransactionProcess::TransDirectPaymentMsgProcess.make_result(response)
when Enums::PaymentMethod::RESPONSIVE_SHARED
url = @web_url + Constants::RESPONSIVE_SHARED_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::TransactionProcess::TransResponsiveSharedMsgProcess.create_request(transaction)
response = Message::TransactionProcess::TransResponsiveSharedMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::TransactionProcess::TransResponsiveSharedMsgProcess.make_result(response)
when Enums::PaymentMethod::TRANSPARENT_REDIRECT
url = @web_url + Constants::TRANSPARENT_REDIRECT_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::TransactionProcess::TransTransparentRedirectMsgProcess.create_request(transaction)
response = Message::TransactionProcess::TransTransparentRedirectMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::TransactionProcess::TransTransparentRedirectMsgProcess.make_result(response)
when Enums::PaymentMethod::WALLET
if transaction.capture
url = @web_url + Constants::DIRECT_PAYMENT_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::TransactionProcess::TransDirectPaymentMsgProcess.create_request(transaction)
response = Message::TransactionProcess::TransDirectPaymentMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::TransactionProcess::TransDirectPaymentMsgProcess.make_result(response)
else
url = @web_url + Constants::CAPTURE_PAYMENT_METHOD
request = Message::TransactionProcess::CapturePaymentMsgProcess.create_request(transaction)
response = Message::TransactionProcess::CapturePaymentMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::TransactionProcess::CapturePaymentMsgProcess.make_result(response)
end
when Enums::PaymentMethod::AUTHORISATION
url = @web_url + Constants::CAPTURE_PAYMENT_METHOD
request = Message::TransactionProcess::CapturePaymentMsgProcess.create_request(transaction)
response = Message::TransactionProcess::CapturePaymentMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::TransactionProcess::CapturePaymentMsgProcess.make_result(response)
else
make_response_with_exception(Exceptions::ParameterInvalidException.new('Unsupported payment type'), CreateTransactionResponse)
end
rescue => e
@logger.error(e.to_s) if @logger
make_response_with_exception(e, CreateTransactionResponse)
end
end | [
"def",
"create_transaction",
"(",
"payment_method",
",",
"transaction",
")",
"unless",
"get_valid?",
"return",
"make_response_with_exception",
"(",
"Exceptions",
"::",
"APIKeyInvalidException",
".",
"new",
"(",
"'API key, password or Rapid endpoint missing or invalid'",
")",
",",
"CreateTransactionResponse",
")",
"end",
"begin",
"case",
"payment_method",
"when",
"Enums",
"::",
"PaymentMethod",
"::",
"DIRECT",
"url",
"=",
"@web_url",
"+",
"Constants",
"::",
"DIRECT_PAYMENT_METHOD_NAME",
"+",
"Constants",
"::",
"JSON_SUFFIX",
"request",
"=",
"Message",
"::",
"TransactionProcess",
"::",
"TransDirectPaymentMsgProcess",
".",
"create_request",
"(",
"transaction",
")",
"response",
"=",
"Message",
"::",
"TransactionProcess",
"::",
"TransDirectPaymentMsgProcess",
".",
"send_request",
"(",
"url",
",",
"@api_key",
",",
"@password",
",",
"@version",
",",
"request",
")",
"Message",
"::",
"TransactionProcess",
"::",
"TransDirectPaymentMsgProcess",
".",
"make_result",
"(",
"response",
")",
"when",
"Enums",
"::",
"PaymentMethod",
"::",
"RESPONSIVE_SHARED",
"url",
"=",
"@web_url",
"+",
"Constants",
"::",
"RESPONSIVE_SHARED_METHOD_NAME",
"+",
"Constants",
"::",
"JSON_SUFFIX",
"request",
"=",
"Message",
"::",
"TransactionProcess",
"::",
"TransResponsiveSharedMsgProcess",
".",
"create_request",
"(",
"transaction",
")",
"response",
"=",
"Message",
"::",
"TransactionProcess",
"::",
"TransResponsiveSharedMsgProcess",
".",
"send_request",
"(",
"url",
",",
"@api_key",
",",
"@password",
",",
"@version",
",",
"request",
")",
"Message",
"::",
"TransactionProcess",
"::",
"TransResponsiveSharedMsgProcess",
".",
"make_result",
"(",
"response",
")",
"when",
"Enums",
"::",
"PaymentMethod",
"::",
"TRANSPARENT_REDIRECT",
"url",
"=",
"@web_url",
"+",
"Constants",
"::",
"TRANSPARENT_REDIRECT_METHOD_NAME",
"+",
"Constants",
"::",
"JSON_SUFFIX",
"request",
"=",
"Message",
"::",
"TransactionProcess",
"::",
"TransTransparentRedirectMsgProcess",
".",
"create_request",
"(",
"transaction",
")",
"response",
"=",
"Message",
"::",
"TransactionProcess",
"::",
"TransTransparentRedirectMsgProcess",
".",
"send_request",
"(",
"url",
",",
"@api_key",
",",
"@password",
",",
"@version",
",",
"request",
")",
"Message",
"::",
"TransactionProcess",
"::",
"TransTransparentRedirectMsgProcess",
".",
"make_result",
"(",
"response",
")",
"when",
"Enums",
"::",
"PaymentMethod",
"::",
"WALLET",
"if",
"transaction",
".",
"capture",
"url",
"=",
"@web_url",
"+",
"Constants",
"::",
"DIRECT_PAYMENT_METHOD_NAME",
"+",
"Constants",
"::",
"JSON_SUFFIX",
"request",
"=",
"Message",
"::",
"TransactionProcess",
"::",
"TransDirectPaymentMsgProcess",
".",
"create_request",
"(",
"transaction",
")",
"response",
"=",
"Message",
"::",
"TransactionProcess",
"::",
"TransDirectPaymentMsgProcess",
".",
"send_request",
"(",
"url",
",",
"@api_key",
",",
"@password",
",",
"@version",
",",
"request",
")",
"Message",
"::",
"TransactionProcess",
"::",
"TransDirectPaymentMsgProcess",
".",
"make_result",
"(",
"response",
")",
"else",
"url",
"=",
"@web_url",
"+",
"Constants",
"::",
"CAPTURE_PAYMENT_METHOD",
"request",
"=",
"Message",
"::",
"TransactionProcess",
"::",
"CapturePaymentMsgProcess",
".",
"create_request",
"(",
"transaction",
")",
"response",
"=",
"Message",
"::",
"TransactionProcess",
"::",
"CapturePaymentMsgProcess",
".",
"send_request",
"(",
"url",
",",
"@api_key",
",",
"@password",
",",
"@version",
",",
"request",
")",
"Message",
"::",
"TransactionProcess",
"::",
"CapturePaymentMsgProcess",
".",
"make_result",
"(",
"response",
")",
"end",
"when",
"Enums",
"::",
"PaymentMethod",
"::",
"AUTHORISATION",
"url",
"=",
"@web_url",
"+",
"Constants",
"::",
"CAPTURE_PAYMENT_METHOD",
"request",
"=",
"Message",
"::",
"TransactionProcess",
"::",
"CapturePaymentMsgProcess",
".",
"create_request",
"(",
"transaction",
")",
"response",
"=",
"Message",
"::",
"TransactionProcess",
"::",
"CapturePaymentMsgProcess",
".",
"send_request",
"(",
"url",
",",
"@api_key",
",",
"@password",
",",
"@version",
",",
"request",
")",
"Message",
"::",
"TransactionProcess",
"::",
"CapturePaymentMsgProcess",
".",
"make_result",
"(",
"response",
")",
"else",
"make_response_with_exception",
"(",
"Exceptions",
"::",
"ParameterInvalidException",
".",
"new",
"(",
"'Unsupported payment type'",
")",
",",
"CreateTransactionResponse",
")",
"end",
"rescue",
"=>",
"e",
"@logger",
".",
"error",
"(",
"e",
".",
"to_s",
")",
"if",
"@logger",
"make_response_with_exception",
"(",
"e",
",",
"CreateTransactionResponse",
")",
"end",
"end"
] | Creates a transaction either using an authorisation, the responsive shared
page, transparent redirect, or direct as the source of funds
@param [Enums::PaymentMethod] payment_method Describes where the card details will be coming from for this transaction (Direct, Responsive Shared, Transparent Redirect etc)
@param [Models::Transaction] transaction Request containing the transaction details
@return [CreateTransactionResponse] CreateTransactionResponse | [
"Creates",
"a",
"transaction",
"either",
"using",
"an",
"authorisation",
"the",
"responsive",
"shared",
"page",
"transparent",
"redirect",
"or",
"direct",
"as",
"the",
"source",
"of",
"funds"
] | 49b0e3845e442dff58466c06cef01b5f8f037990 | https://github.com/eWAYPayment/eway-rapid-ruby/blob/49b0e3845e442dff58466c06cef01b5f8f037990/lib/eway_rapid/rapid_client.rb#L48-L99 |
23,507 | eWAYPayment/eway-rapid-ruby | lib/eway_rapid/rapid_client.rb | EwayRapid.RapidClient.query_transaction_by_filter | def query_transaction_by_filter(filter)
index_of_value = filter.calculate_index_of_value
if index_of_value.nil?
return make_response_with_exception(Exceptions::APIKeyInvalidException.new('Invalid transaction filter'), QueryTransactionResponse)
end
case index_of_value
when Enums::TransactionFilter::TRANSACTION_ID_INDEX
query_transaction_by_id(filter.transaction_id.to_s)
when Enums::TransactionFilter::ACCESS_CODE_INDEX
query_transaction_by_access_code(filter.access_code)
when Enums::TransactionFilter::INVOICE_NUMBER_INDEX
query_transaction_with_path(filter.invoice_number, Constants::TRANSACTION_METHOD + '/' + Constants::TRANSACTION_QUERY_WITH_INVOICE_NUM_METHOD)
when Enums::TransactionFilter::INVOICE_REFERENCE_INDEX
query_transaction_with_path(filter.invoice_reference, Constants::TRANSACTION_METHOD + '/' + Constants::TRANSACTION_QUERY_WITH_INVOICE_REF_METHOD)
else
make_response_with_exception(Exceptions::APIKeyInvalidException.new('Invalid transaction filter'), QueryTransactionResponse)
end
end | ruby | def query_transaction_by_filter(filter)
index_of_value = filter.calculate_index_of_value
if index_of_value.nil?
return make_response_with_exception(Exceptions::APIKeyInvalidException.new('Invalid transaction filter'), QueryTransactionResponse)
end
case index_of_value
when Enums::TransactionFilter::TRANSACTION_ID_INDEX
query_transaction_by_id(filter.transaction_id.to_s)
when Enums::TransactionFilter::ACCESS_CODE_INDEX
query_transaction_by_access_code(filter.access_code)
when Enums::TransactionFilter::INVOICE_NUMBER_INDEX
query_transaction_with_path(filter.invoice_number, Constants::TRANSACTION_METHOD + '/' + Constants::TRANSACTION_QUERY_WITH_INVOICE_NUM_METHOD)
when Enums::TransactionFilter::INVOICE_REFERENCE_INDEX
query_transaction_with_path(filter.invoice_reference, Constants::TRANSACTION_METHOD + '/' + Constants::TRANSACTION_QUERY_WITH_INVOICE_REF_METHOD)
else
make_response_with_exception(Exceptions::APIKeyInvalidException.new('Invalid transaction filter'), QueryTransactionResponse)
end
end | [
"def",
"query_transaction_by_filter",
"(",
"filter",
")",
"index_of_value",
"=",
"filter",
".",
"calculate_index_of_value",
"if",
"index_of_value",
".",
"nil?",
"return",
"make_response_with_exception",
"(",
"Exceptions",
"::",
"APIKeyInvalidException",
".",
"new",
"(",
"'Invalid transaction filter'",
")",
",",
"QueryTransactionResponse",
")",
"end",
"case",
"index_of_value",
"when",
"Enums",
"::",
"TransactionFilter",
"::",
"TRANSACTION_ID_INDEX",
"query_transaction_by_id",
"(",
"filter",
".",
"transaction_id",
".",
"to_s",
")",
"when",
"Enums",
"::",
"TransactionFilter",
"::",
"ACCESS_CODE_INDEX",
"query_transaction_by_access_code",
"(",
"filter",
".",
"access_code",
")",
"when",
"Enums",
"::",
"TransactionFilter",
"::",
"INVOICE_NUMBER_INDEX",
"query_transaction_with_path",
"(",
"filter",
".",
"invoice_number",
",",
"Constants",
"::",
"TRANSACTION_METHOD",
"+",
"'/'",
"+",
"Constants",
"::",
"TRANSACTION_QUERY_WITH_INVOICE_NUM_METHOD",
")",
"when",
"Enums",
"::",
"TransactionFilter",
"::",
"INVOICE_REFERENCE_INDEX",
"query_transaction_with_path",
"(",
"filter",
".",
"invoice_reference",
",",
"Constants",
"::",
"TRANSACTION_METHOD",
"+",
"'/'",
"+",
"Constants",
"::",
"TRANSACTION_QUERY_WITH_INVOICE_REF_METHOD",
")",
"else",
"make_response_with_exception",
"(",
"Exceptions",
"::",
"APIKeyInvalidException",
".",
"new",
"(",
"'Invalid transaction filter'",
")",
",",
"QueryTransactionResponse",
")",
"end",
"end"
] | Query a transaction by one of four properties transaction id, access
code, invoice number, invoice reference
@param [Enums::TransactionFilter] filter Filter definition for searching
@return [QueryTransactionResponse] | [
"Query",
"a",
"transaction",
"by",
"one",
"of",
"four",
"properties",
"transaction",
"id",
"access",
"code",
"invoice",
"number",
"invoice",
"reference"
] | 49b0e3845e442dff58466c06cef01b5f8f037990 | https://github.com/eWAYPayment/eway-rapid-ruby/blob/49b0e3845e442dff58466c06cef01b5f8f037990/lib/eway_rapid/rapid_client.rb#L122-L140 |
23,508 | eWAYPayment/eway-rapid-ruby | lib/eway_rapid/rapid_client.rb | EwayRapid.RapidClient.refund | def refund(refund)
unless @is_valid
return make_response_with_exception(Exceptions::APIKeyInvalidException.new('API key, password or Rapid endpoint missing or invalid'), RefundResponse)
end
begin
url = @web_url + Constants::TRANSACTION_METHOD
request = Message::RefundProcess::RefundMsgProcess.create_request(refund)
response = Message::RefundProcess::RefundMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::RefundProcess::RefundMsgProcess.make_result(response)
rescue => e
@logger.error(e.to_s) if @logger
make_response_with_exception(e, RefundResponse)
end
end | ruby | def refund(refund)
unless @is_valid
return make_response_with_exception(Exceptions::APIKeyInvalidException.new('API key, password or Rapid endpoint missing or invalid'), RefundResponse)
end
begin
url = @web_url + Constants::TRANSACTION_METHOD
request = Message::RefundProcess::RefundMsgProcess.create_request(refund)
response = Message::RefundProcess::RefundMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::RefundProcess::RefundMsgProcess.make_result(response)
rescue => e
@logger.error(e.to_s) if @logger
make_response_with_exception(e, RefundResponse)
end
end | [
"def",
"refund",
"(",
"refund",
")",
"unless",
"@is_valid",
"return",
"make_response_with_exception",
"(",
"Exceptions",
"::",
"APIKeyInvalidException",
".",
"new",
"(",
"'API key, password or Rapid endpoint missing or invalid'",
")",
",",
"RefundResponse",
")",
"end",
"begin",
"url",
"=",
"@web_url",
"+",
"Constants",
"::",
"TRANSACTION_METHOD",
"request",
"=",
"Message",
"::",
"RefundProcess",
"::",
"RefundMsgProcess",
".",
"create_request",
"(",
"refund",
")",
"response",
"=",
"Message",
"::",
"RefundProcess",
"::",
"RefundMsgProcess",
".",
"send_request",
"(",
"url",
",",
"@api_key",
",",
"@password",
",",
"@version",
",",
"request",
")",
"Message",
"::",
"RefundProcess",
"::",
"RefundMsgProcess",
".",
"make_result",
"(",
"response",
")",
"rescue",
"=>",
"e",
"@logger",
".",
"error",
"(",
"e",
".",
"to_s",
")",
"if",
"@logger",
"make_response_with_exception",
"(",
"e",
",",
"RefundResponse",
")",
"end",
"end"
] | Refunds all or part of a transaction
@param [Models::Refund] refund contains information to refund
@return [RefundResponse] | [
"Refunds",
"all",
"or",
"part",
"of",
"a",
"transaction"
] | 49b0e3845e442dff58466c06cef01b5f8f037990 | https://github.com/eWAYPayment/eway-rapid-ruby/blob/49b0e3845e442dff58466c06cef01b5f8f037990/lib/eway_rapid/rapid_client.rb#L146-L161 |
23,509 | eWAYPayment/eway-rapid-ruby | lib/eway_rapid/rapid_client.rb | EwayRapid.RapidClient.create_customer | def create_customer(payment_method, customer)
unless get_valid?
return make_response_with_exception(Exceptions::APIKeyInvalidException.new('API key, password or Rapid endpoint missing or invalid'), CreateCustomerResponse)
end
begin
case payment_method
when Enums::PaymentMethod::DIRECT
url = @web_url + Constants::DIRECT_PAYMENT_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::CustomerProcess::CustDirectPaymentMsgProcess.create_request(customer)
response = Message::CustomerProcess::CustDirectPaymentMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::CustomerProcess::CustDirectPaymentMsgProcess.make_result(response)
when Enums::PaymentMethod::RESPONSIVE_SHARED
url = @web_url + Constants::RESPONSIVE_SHARED_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::CustomerProcess::CustResponsiveSharedMsgProcess.create_request(customer)
response = Message::CustomerProcess::CustResponsiveSharedMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::CustomerProcess::CustResponsiveSharedMsgProcess.make_result(response)
when Enums::PaymentMethod::TRANSPARENT_REDIRECT
url = @web_url + Constants::TRANSPARENT_REDIRECT_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::CustomerProcess::CustTransparentRedirectMsgProcess.create_request(customer)
response = Message::CustomerProcess::CustTransparentRedirectMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::CustomerProcess::CustTransparentRedirectMsgProcess.make_result(response)
else
make_response_with_exception(Exceptions::ParameterInvalidException.new('Unsupported payment type'), CreateCustomerResponse)
end
rescue => e
@logger.error(e.to_s) if @logger
make_response_with_exception(e, CreateCustomerResponse)
end
end | ruby | def create_customer(payment_method, customer)
unless get_valid?
return make_response_with_exception(Exceptions::APIKeyInvalidException.new('API key, password or Rapid endpoint missing or invalid'), CreateCustomerResponse)
end
begin
case payment_method
when Enums::PaymentMethod::DIRECT
url = @web_url + Constants::DIRECT_PAYMENT_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::CustomerProcess::CustDirectPaymentMsgProcess.create_request(customer)
response = Message::CustomerProcess::CustDirectPaymentMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::CustomerProcess::CustDirectPaymentMsgProcess.make_result(response)
when Enums::PaymentMethod::RESPONSIVE_SHARED
url = @web_url + Constants::RESPONSIVE_SHARED_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::CustomerProcess::CustResponsiveSharedMsgProcess.create_request(customer)
response = Message::CustomerProcess::CustResponsiveSharedMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::CustomerProcess::CustResponsiveSharedMsgProcess.make_result(response)
when Enums::PaymentMethod::TRANSPARENT_REDIRECT
url = @web_url + Constants::TRANSPARENT_REDIRECT_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::CustomerProcess::CustTransparentRedirectMsgProcess.create_request(customer)
response = Message::CustomerProcess::CustTransparentRedirectMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::CustomerProcess::CustTransparentRedirectMsgProcess.make_result(response)
else
make_response_with_exception(Exceptions::ParameterInvalidException.new('Unsupported payment type'), CreateCustomerResponse)
end
rescue => e
@logger.error(e.to_s) if @logger
make_response_with_exception(e, CreateCustomerResponse)
end
end | [
"def",
"create_customer",
"(",
"payment_method",
",",
"customer",
")",
"unless",
"get_valid?",
"return",
"make_response_with_exception",
"(",
"Exceptions",
"::",
"APIKeyInvalidException",
".",
"new",
"(",
"'API key, password or Rapid endpoint missing or invalid'",
")",
",",
"CreateCustomerResponse",
")",
"end",
"begin",
"case",
"payment_method",
"when",
"Enums",
"::",
"PaymentMethod",
"::",
"DIRECT",
"url",
"=",
"@web_url",
"+",
"Constants",
"::",
"DIRECT_PAYMENT_METHOD_NAME",
"+",
"Constants",
"::",
"JSON_SUFFIX",
"request",
"=",
"Message",
"::",
"CustomerProcess",
"::",
"CustDirectPaymentMsgProcess",
".",
"create_request",
"(",
"customer",
")",
"response",
"=",
"Message",
"::",
"CustomerProcess",
"::",
"CustDirectPaymentMsgProcess",
".",
"send_request",
"(",
"url",
",",
"@api_key",
",",
"@password",
",",
"@version",
",",
"request",
")",
"Message",
"::",
"CustomerProcess",
"::",
"CustDirectPaymentMsgProcess",
".",
"make_result",
"(",
"response",
")",
"when",
"Enums",
"::",
"PaymentMethod",
"::",
"RESPONSIVE_SHARED",
"url",
"=",
"@web_url",
"+",
"Constants",
"::",
"RESPONSIVE_SHARED_METHOD_NAME",
"+",
"Constants",
"::",
"JSON_SUFFIX",
"request",
"=",
"Message",
"::",
"CustomerProcess",
"::",
"CustResponsiveSharedMsgProcess",
".",
"create_request",
"(",
"customer",
")",
"response",
"=",
"Message",
"::",
"CustomerProcess",
"::",
"CustResponsiveSharedMsgProcess",
".",
"send_request",
"(",
"url",
",",
"@api_key",
",",
"@password",
",",
"@version",
",",
"request",
")",
"Message",
"::",
"CustomerProcess",
"::",
"CustResponsiveSharedMsgProcess",
".",
"make_result",
"(",
"response",
")",
"when",
"Enums",
"::",
"PaymentMethod",
"::",
"TRANSPARENT_REDIRECT",
"url",
"=",
"@web_url",
"+",
"Constants",
"::",
"TRANSPARENT_REDIRECT_METHOD_NAME",
"+",
"Constants",
"::",
"JSON_SUFFIX",
"request",
"=",
"Message",
"::",
"CustomerProcess",
"::",
"CustTransparentRedirectMsgProcess",
".",
"create_request",
"(",
"customer",
")",
"response",
"=",
"Message",
"::",
"CustomerProcess",
"::",
"CustTransparentRedirectMsgProcess",
".",
"send_request",
"(",
"url",
",",
"@api_key",
",",
"@password",
",",
"@version",
",",
"request",
")",
"Message",
"::",
"CustomerProcess",
"::",
"CustTransparentRedirectMsgProcess",
".",
"make_result",
"(",
"response",
")",
"else",
"make_response_with_exception",
"(",
"Exceptions",
"::",
"ParameterInvalidException",
".",
"new",
"(",
"'Unsupported payment type'",
")",
",",
"CreateCustomerResponse",
")",
"end",
"rescue",
"=>",
"e",
"@logger",
".",
"error",
"(",
"e",
".",
"to_s",
")",
"if",
"@logger",
"make_response_with_exception",
"(",
"e",
",",
"CreateCustomerResponse",
")",
"end",
"end"
] | Creates a token customer to store card details in the secure eWAY Vault
for charging later
@param [Enums::PaymentMethod] payment_method Describes where the card details will be coming from for this transaction (Direct, Responsive Shared, Transparent Redirect etc).
@param [Models::Customer] customer The customer's details
@return [CreateCustomerResponse] | [
"Creates",
"a",
"token",
"customer",
"to",
"store",
"card",
"details",
"in",
"the",
"secure",
"eWAY",
"Vault",
"for",
"charging",
"later"
] | 49b0e3845e442dff58466c06cef01b5f8f037990 | https://github.com/eWAYPayment/eway-rapid-ruby/blob/49b0e3845e442dff58466c06cef01b5f8f037990/lib/eway_rapid/rapid_client.rb#L189-L220 |
23,510 | eWAYPayment/eway-rapid-ruby | lib/eway_rapid/rapid_client.rb | EwayRapid.RapidClient.update_customer | def update_customer(payment_method, customer)
unless get_valid?
return make_response_with_exception(Exceptions::APIKeyInvalidException.new('API key, password or Rapid endpoint missing or invalid'), CreateCustomerResponse)
end
begin
case payment_method
when Enums::PaymentMethod::DIRECT
url = @web_url + Constants::DIRECT_PAYMENT_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::CustomerProcess::CustDirectUpdateMsgProcess.create_request(customer)
response = Message::CustomerProcess::CustDirectUpdateMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::CustomerProcess::CustDirectUpdateMsgProcess.make_result(response)
when Enums::PaymentMethod::RESPONSIVE_SHARED
url = @web_url + Constants::RESPONSIVE_SHARED_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::CustomerProcess::CustResponsiveUpdateMsgProcess.create_request(customer)
response = Message::CustomerProcess::CustResponsiveUpdateMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::CustomerProcess::CustResponsiveUpdateMsgProcess.make_result(response)
when Enums::PaymentMethod::TRANSPARENT_REDIRECT
url = @web_url + Constants::TRANSPARENT_REDIRECT_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::CustomerProcess::CustTransparentUpdateMsgProcess.create_request(customer)
response = Message::CustomerProcess::CustTransparentUpdateMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::CustomerProcess::CustTransparentUpdateMsgProcess.make_result(response)
else
return make_response_with_exception(Exceptions::ParameterInvalidException.new('Unsupported payment type'), CreateCustomerResponse)
end
rescue => e
@logger.error(e.to_s) if @logger
make_response_with_exception(e, CreateCustomerResponse)
end
end | ruby | def update_customer(payment_method, customer)
unless get_valid?
return make_response_with_exception(Exceptions::APIKeyInvalidException.new('API key, password or Rapid endpoint missing or invalid'), CreateCustomerResponse)
end
begin
case payment_method
when Enums::PaymentMethod::DIRECT
url = @web_url + Constants::DIRECT_PAYMENT_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::CustomerProcess::CustDirectUpdateMsgProcess.create_request(customer)
response = Message::CustomerProcess::CustDirectUpdateMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::CustomerProcess::CustDirectUpdateMsgProcess.make_result(response)
when Enums::PaymentMethod::RESPONSIVE_SHARED
url = @web_url + Constants::RESPONSIVE_SHARED_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::CustomerProcess::CustResponsiveUpdateMsgProcess.create_request(customer)
response = Message::CustomerProcess::CustResponsiveUpdateMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::CustomerProcess::CustResponsiveUpdateMsgProcess.make_result(response)
when Enums::PaymentMethod::TRANSPARENT_REDIRECT
url = @web_url + Constants::TRANSPARENT_REDIRECT_METHOD_NAME + Constants::JSON_SUFFIX
request = Message::CustomerProcess::CustTransparentUpdateMsgProcess.create_request(customer)
response = Message::CustomerProcess::CustTransparentUpdateMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::CustomerProcess::CustTransparentUpdateMsgProcess.make_result(response)
else
return make_response_with_exception(Exceptions::ParameterInvalidException.new('Unsupported payment type'), CreateCustomerResponse)
end
rescue => e
@logger.error(e.to_s) if @logger
make_response_with_exception(e, CreateCustomerResponse)
end
end | [
"def",
"update_customer",
"(",
"payment_method",
",",
"customer",
")",
"unless",
"get_valid?",
"return",
"make_response_with_exception",
"(",
"Exceptions",
"::",
"APIKeyInvalidException",
".",
"new",
"(",
"'API key, password or Rapid endpoint missing or invalid'",
")",
",",
"CreateCustomerResponse",
")",
"end",
"begin",
"case",
"payment_method",
"when",
"Enums",
"::",
"PaymentMethod",
"::",
"DIRECT",
"url",
"=",
"@web_url",
"+",
"Constants",
"::",
"DIRECT_PAYMENT_METHOD_NAME",
"+",
"Constants",
"::",
"JSON_SUFFIX",
"request",
"=",
"Message",
"::",
"CustomerProcess",
"::",
"CustDirectUpdateMsgProcess",
".",
"create_request",
"(",
"customer",
")",
"response",
"=",
"Message",
"::",
"CustomerProcess",
"::",
"CustDirectUpdateMsgProcess",
".",
"send_request",
"(",
"url",
",",
"@api_key",
",",
"@password",
",",
"@version",
",",
"request",
")",
"Message",
"::",
"CustomerProcess",
"::",
"CustDirectUpdateMsgProcess",
".",
"make_result",
"(",
"response",
")",
"when",
"Enums",
"::",
"PaymentMethod",
"::",
"RESPONSIVE_SHARED",
"url",
"=",
"@web_url",
"+",
"Constants",
"::",
"RESPONSIVE_SHARED_METHOD_NAME",
"+",
"Constants",
"::",
"JSON_SUFFIX",
"request",
"=",
"Message",
"::",
"CustomerProcess",
"::",
"CustResponsiveUpdateMsgProcess",
".",
"create_request",
"(",
"customer",
")",
"response",
"=",
"Message",
"::",
"CustomerProcess",
"::",
"CustResponsiveUpdateMsgProcess",
".",
"send_request",
"(",
"url",
",",
"@api_key",
",",
"@password",
",",
"@version",
",",
"request",
")",
"Message",
"::",
"CustomerProcess",
"::",
"CustResponsiveUpdateMsgProcess",
".",
"make_result",
"(",
"response",
")",
"when",
"Enums",
"::",
"PaymentMethod",
"::",
"TRANSPARENT_REDIRECT",
"url",
"=",
"@web_url",
"+",
"Constants",
"::",
"TRANSPARENT_REDIRECT_METHOD_NAME",
"+",
"Constants",
"::",
"JSON_SUFFIX",
"request",
"=",
"Message",
"::",
"CustomerProcess",
"::",
"CustTransparentUpdateMsgProcess",
".",
"create_request",
"(",
"customer",
")",
"response",
"=",
"Message",
"::",
"CustomerProcess",
"::",
"CustTransparentUpdateMsgProcess",
".",
"send_request",
"(",
"url",
",",
"@api_key",
",",
"@password",
",",
"@version",
",",
"request",
")",
"Message",
"::",
"CustomerProcess",
"::",
"CustTransparentUpdateMsgProcess",
".",
"make_result",
"(",
"response",
")",
"else",
"return",
"make_response_with_exception",
"(",
"Exceptions",
"::",
"ParameterInvalidException",
".",
"new",
"(",
"'Unsupported payment type'",
")",
",",
"CreateCustomerResponse",
")",
"end",
"rescue",
"=>",
"e",
"@logger",
".",
"error",
"(",
"e",
".",
"to_s",
")",
"if",
"@logger",
"make_response_with_exception",
"(",
"e",
",",
"CreateCustomerResponse",
")",
"end",
"end"
] | Updates an existing token customer for the merchant in their eWAY account.
@param [Enums::PaymentMethod] payment_method Describes where the card details will be coming from for this transaction (Direct, Responsive Shared, Transparent Redirect etc).
@param [Models::Customer] customer The customer's details
@return [CreateCustomerResponse] | [
"Updates",
"an",
"existing",
"token",
"customer",
"for",
"the",
"merchant",
"in",
"their",
"eWAY",
"account",
"."
] | 49b0e3845e442dff58466c06cef01b5f8f037990 | https://github.com/eWAYPayment/eway-rapid-ruby/blob/49b0e3845e442dff58466c06cef01b5f8f037990/lib/eway_rapid/rapid_client.rb#L227-L257 |
23,511 | eWAYPayment/eway-rapid-ruby | lib/eway_rapid/rapid_client.rb | EwayRapid.RapidClient.query_customer | def query_customer(token_customer_id)
@logger.debug('Query customer with id:' + token_customer_id.to_s) if @logger
unless @is_valid
return make_response_with_exception(Exceptions::APIKeyInvalidException.new('API key, password or Rapid endpoint missing or invalid'), QueryCustomerResponse)
end
begin
url = @web_url + Constants::DIRECT_CUSTOMER_SEARCH_METHOD + Constants::JSON_SUFFIX
url = URI.encode(url)
request = Message::CustomerProcess::QueryCustomerMsgProcess.create_request(token_customer_id.to_s)
response = Message::CustomerProcess::QueryCustomerMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::CustomerProcess::QueryCustomerMsgProcess.make_result(response)
rescue => e
@logger.error(e.to_s) if @logger
make_response_with_exception(e, QueryCustomerResponse)
end
end | ruby | def query_customer(token_customer_id)
@logger.debug('Query customer with id:' + token_customer_id.to_s) if @logger
unless @is_valid
return make_response_with_exception(Exceptions::APIKeyInvalidException.new('API key, password or Rapid endpoint missing or invalid'), QueryCustomerResponse)
end
begin
url = @web_url + Constants::DIRECT_CUSTOMER_SEARCH_METHOD + Constants::JSON_SUFFIX
url = URI.encode(url)
request = Message::CustomerProcess::QueryCustomerMsgProcess.create_request(token_customer_id.to_s)
response = Message::CustomerProcess::QueryCustomerMsgProcess.send_request(url, @api_key, @password, @version, request)
Message::CustomerProcess::QueryCustomerMsgProcess.make_result(response)
rescue => e
@logger.error(e.to_s) if @logger
make_response_with_exception(e, QueryCustomerResponse)
end
end | [
"def",
"query_customer",
"(",
"token_customer_id",
")",
"@logger",
".",
"debug",
"(",
"'Query customer with id:'",
"+",
"token_customer_id",
".",
"to_s",
")",
"if",
"@logger",
"unless",
"@is_valid",
"return",
"make_response_with_exception",
"(",
"Exceptions",
"::",
"APIKeyInvalidException",
".",
"new",
"(",
"'API key, password or Rapid endpoint missing or invalid'",
")",
",",
"QueryCustomerResponse",
")",
"end",
"begin",
"url",
"=",
"@web_url",
"+",
"Constants",
"::",
"DIRECT_CUSTOMER_SEARCH_METHOD",
"+",
"Constants",
"::",
"JSON_SUFFIX",
"url",
"=",
"URI",
".",
"encode",
"(",
"url",
")",
"request",
"=",
"Message",
"::",
"CustomerProcess",
"::",
"QueryCustomerMsgProcess",
".",
"create_request",
"(",
"token_customer_id",
".",
"to_s",
")",
"response",
"=",
"Message",
"::",
"CustomerProcess",
"::",
"QueryCustomerMsgProcess",
".",
"send_request",
"(",
"url",
",",
"@api_key",
",",
"@password",
",",
"@version",
",",
"request",
")",
"Message",
"::",
"CustomerProcess",
"::",
"QueryCustomerMsgProcess",
".",
"make_result",
"(",
"response",
")",
"rescue",
"=>",
"e",
"@logger",
".",
"error",
"(",
"e",
".",
"to_s",
")",
"if",
"@logger",
"make_response_with_exception",
"(",
"e",
",",
"QueryCustomerResponse",
")",
"end",
"end"
] | Returns the details of a Token Customer. This includes the masked card information
for displaying in a UI
@param [Integer] token_customer_id eWAY Token Customer ID to look up.
@return [QueryCustomerResponse] | [
"Returns",
"the",
"details",
"of",
"a",
"Token",
"Customer",
".",
"This",
"includes",
"the",
"masked",
"card",
"information",
"for",
"displaying",
"in",
"a",
"UI"
] | 49b0e3845e442dff58466c06cef01b5f8f037990 | https://github.com/eWAYPayment/eway-rapid-ruby/blob/49b0e3845e442dff58466c06cef01b5f8f037990/lib/eway_rapid/rapid_client.rb#L264-L280 |
23,512 | eWAYPayment/eway-rapid-ruby | lib/eway_rapid/rapid_client.rb | EwayRapid.RapidClient.settlement_search | def settlement_search(search_request)
unless @is_valid
return make_response_with_exception(Exceptions::APIKeyInvalidException.new('API key, password or Rapid endpoint missing or invalid'), QueryCustomerResponse)
end
begin
request = Message::TransactionProcess::SettlementSearchMsgProcess.create_request(search_request)
url = @web_url + Constants::SETTLEMENT_SEARCH_METHOD + request
response = Message::TransactionProcess::SettlementSearchMsgProcess.send_request(url, @api_key, @password, @version)
Message::TransactionProcess::SettlementSearchMsgProcess.make_result(response)
rescue => e
@logger.error(e.to_s) if @logger
make_response_with_exception(e, SettlementSearchResponse)
end
end | ruby | def settlement_search(search_request)
unless @is_valid
return make_response_with_exception(Exceptions::APIKeyInvalidException.new('API key, password or Rapid endpoint missing or invalid'), QueryCustomerResponse)
end
begin
request = Message::TransactionProcess::SettlementSearchMsgProcess.create_request(search_request)
url = @web_url + Constants::SETTLEMENT_SEARCH_METHOD + request
response = Message::TransactionProcess::SettlementSearchMsgProcess.send_request(url, @api_key, @password, @version)
Message::TransactionProcess::SettlementSearchMsgProcess.make_result(response)
rescue => e
@logger.error(e.to_s) if @logger
make_response_with_exception(e, SettlementSearchResponse)
end
end | [
"def",
"settlement_search",
"(",
"search_request",
")",
"unless",
"@is_valid",
"return",
"make_response_with_exception",
"(",
"Exceptions",
"::",
"APIKeyInvalidException",
".",
"new",
"(",
"'API key, password or Rapid endpoint missing or invalid'",
")",
",",
"QueryCustomerResponse",
")",
"end",
"begin",
"request",
"=",
"Message",
"::",
"TransactionProcess",
"::",
"SettlementSearchMsgProcess",
".",
"create_request",
"(",
"search_request",
")",
"url",
"=",
"@web_url",
"+",
"Constants",
"::",
"SETTLEMENT_SEARCH_METHOD",
"+",
"request",
"response",
"=",
"Message",
"::",
"TransactionProcess",
"::",
"SettlementSearchMsgProcess",
".",
"send_request",
"(",
"url",
",",
"@api_key",
",",
"@password",
",",
"@version",
")",
"Message",
"::",
"TransactionProcess",
"::",
"SettlementSearchMsgProcess",
".",
"make_result",
"(",
"response",
")",
"rescue",
"=>",
"e",
"@logger",
".",
"error",
"(",
"e",
".",
"to_s",
")",
"if",
"@logger",
"make_response_with_exception",
"(",
"e",
",",
"SettlementSearchResponse",
")",
"end",
"end"
] | Performs a search of settlements
@param [SettlementSearch]
@return [SettlementSearchResponse] | [
"Performs",
"a",
"search",
"of",
"settlements"
] | 49b0e3845e442dff58466c06cef01b5f8f037990 | https://github.com/eWAYPayment/eway-rapid-ruby/blob/49b0e3845e442dff58466c06cef01b5f8f037990/lib/eway_rapid/rapid_client.rb#L286-L302 |
23,513 | eWAYPayment/eway-rapid-ruby | lib/eway_rapid/rapid_client.rb | EwayRapid.RapidClient.query_transaction_with_path | def query_transaction_with_path(request, request_path)
unless @is_valid
return make_response_with_exception(Exceptions::APIKeyInvalidException.new('API key, password or Rapid endpoint missing or invalid'), QueryTransactionResponse)
end
begin
if request.nil? || request == ''
url = @web_url + request_path + '/' + '0'
else
url = @web_url + request_path + '/' + request
end
url = URI.encode(url)
response = Message::TransactionProcess::TransQueryMsgProcess.process_post_msg(url, @api_key, @password, @version)
Message::TransactionProcess::TransQueryMsgProcess.make_result(response)
rescue => e
@logger.error(e.to_s) if @logger
make_response_with_exception(e, QueryTransactionResponse)
end
end | ruby | def query_transaction_with_path(request, request_path)
unless @is_valid
return make_response_with_exception(Exceptions::APIKeyInvalidException.new('API key, password or Rapid endpoint missing or invalid'), QueryTransactionResponse)
end
begin
if request.nil? || request == ''
url = @web_url + request_path + '/' + '0'
else
url = @web_url + request_path + '/' + request
end
url = URI.encode(url)
response = Message::TransactionProcess::TransQueryMsgProcess.process_post_msg(url, @api_key, @password, @version)
Message::TransactionProcess::TransQueryMsgProcess.make_result(response)
rescue => e
@logger.error(e.to_s) if @logger
make_response_with_exception(e, QueryTransactionResponse)
end
end | [
"def",
"query_transaction_with_path",
"(",
"request",
",",
"request_path",
")",
"unless",
"@is_valid",
"return",
"make_response_with_exception",
"(",
"Exceptions",
"::",
"APIKeyInvalidException",
".",
"new",
"(",
"'API key, password or Rapid endpoint missing or invalid'",
")",
",",
"QueryTransactionResponse",
")",
"end",
"begin",
"if",
"request",
".",
"nil?",
"||",
"request",
"==",
"''",
"url",
"=",
"@web_url",
"+",
"request_path",
"+",
"'/'",
"+",
"'0'",
"else",
"url",
"=",
"@web_url",
"+",
"request_path",
"+",
"'/'",
"+",
"request",
"end",
"url",
"=",
"URI",
".",
"encode",
"(",
"url",
")",
"response",
"=",
"Message",
"::",
"TransactionProcess",
"::",
"TransQueryMsgProcess",
".",
"process_post_msg",
"(",
"url",
",",
"@api_key",
",",
"@password",
",",
"@version",
")",
"Message",
"::",
"TransactionProcess",
"::",
"TransQueryMsgProcess",
".",
"make_result",
"(",
"response",
")",
"rescue",
"=>",
"e",
"@logger",
".",
"error",
"(",
"e",
".",
"to_s",
")",
"if",
"@logger",
"make_response_with_exception",
"(",
"e",
",",
"QueryTransactionResponse",
")",
"end",
"end"
] | Perform a transaction query with the given path
@param [String] request the transaction identifier to query
@param [String] request_path the path to use for the query
@return [QueryTransactionResponse] | [
"Perform",
"a",
"transaction",
"query",
"with",
"the",
"given",
"path"
] | 49b0e3845e442dff58466c06cef01b5f8f037990 | https://github.com/eWAYPayment/eway-rapid-ruby/blob/49b0e3845e442dff58466c06cef01b5f8f037990/lib/eway_rapid/rapid_client.rb#L334-L352 |
23,514 | eWAYPayment/eway-rapid-ruby | lib/eway_rapid/rapid_client.rb | EwayRapid.RapidClient.validate_api_param | def validate_api_param
set_valid(true)
if @api_key.nil? || @api_key.empty? || @password.nil? || @password.empty?
add_error_code(Constants::API_KEY_INVALID_ERROR_CODE)
set_valid(false)
end
if @rapid_endpoint.nil? || @rapid_endpoint.empty?
add_error_code(Constants::LIBRARY_NOT_HAVE_ENDPOINT_ERROR_CODE)
set_valid(false)
end
if @is_valid
begin
parser_endpoint_to_web_url
unless @list_error.nil?
@list_error.clear
end
set_valid(true)
@logger.info "Initiate client using [#{@web_url}] successful!" if @logger
rescue => e
@logger.error "Error setting Rapid endpoint #{e.backtrace.inspect}" if @logger
set_valid(false)
add_error_code(Constants::LIBRARY_NOT_HAVE_ENDPOINT_ERROR_CODE)
end
else
@logger.warn 'Invalid parameter passed to Rapid client' if @logger
end
end | ruby | def validate_api_param
set_valid(true)
if @api_key.nil? || @api_key.empty? || @password.nil? || @password.empty?
add_error_code(Constants::API_KEY_INVALID_ERROR_CODE)
set_valid(false)
end
if @rapid_endpoint.nil? || @rapid_endpoint.empty?
add_error_code(Constants::LIBRARY_NOT_HAVE_ENDPOINT_ERROR_CODE)
set_valid(false)
end
if @is_valid
begin
parser_endpoint_to_web_url
unless @list_error.nil?
@list_error.clear
end
set_valid(true)
@logger.info "Initiate client using [#{@web_url}] successful!" if @logger
rescue => e
@logger.error "Error setting Rapid endpoint #{e.backtrace.inspect}" if @logger
set_valid(false)
add_error_code(Constants::LIBRARY_NOT_HAVE_ENDPOINT_ERROR_CODE)
end
else
@logger.warn 'Invalid parameter passed to Rapid client' if @logger
end
end | [
"def",
"validate_api_param",
"set_valid",
"(",
"true",
")",
"if",
"@api_key",
".",
"nil?",
"||",
"@api_key",
".",
"empty?",
"||",
"@password",
".",
"nil?",
"||",
"@password",
".",
"empty?",
"add_error_code",
"(",
"Constants",
"::",
"API_KEY_INVALID_ERROR_CODE",
")",
"set_valid",
"(",
"false",
")",
"end",
"if",
"@rapid_endpoint",
".",
"nil?",
"||",
"@rapid_endpoint",
".",
"empty?",
"add_error_code",
"(",
"Constants",
"::",
"LIBRARY_NOT_HAVE_ENDPOINT_ERROR_CODE",
")",
"set_valid",
"(",
"false",
")",
"end",
"if",
"@is_valid",
"begin",
"parser_endpoint_to_web_url",
"unless",
"@list_error",
".",
"nil?",
"@list_error",
".",
"clear",
"end",
"set_valid",
"(",
"true",
")",
"@logger",
".",
"info",
"\"Initiate client using [#{@web_url}] successful!\"",
"if",
"@logger",
"rescue",
"=>",
"e",
"@logger",
".",
"error",
"\"Error setting Rapid endpoint #{e.backtrace.inspect}\"",
"if",
"@logger",
"set_valid",
"(",
"false",
")",
"add_error_code",
"(",
"Constants",
"::",
"LIBRARY_NOT_HAVE_ENDPOINT_ERROR_CODE",
")",
"end",
"else",
"@logger",
".",
"warn",
"'Invalid parameter passed to Rapid client'",
"if",
"@logger",
"end",
"end"
] | Validates the Rapid API key, password and endpoint | [
"Validates",
"the",
"Rapid",
"API",
"key",
"password",
"and",
"endpoint"
] | 49b0e3845e442dff58466c06cef01b5f8f037990 | https://github.com/eWAYPayment/eway-rapid-ruby/blob/49b0e3845e442dff58466c06cef01b5f8f037990/lib/eway_rapid/rapid_client.rb#L375-L401 |
23,515 | eWAYPayment/eway-rapid-ruby | lib/eway_rapid/rapid_client.rb | EwayRapid.RapidClient.parser_endpoint_to_web_url | def parser_endpoint_to_web_url
# @type [String]
prop_name = nil
if Constants::RAPID_ENDPOINT_PRODUCTION.casecmp(@rapid_endpoint).zero?
prop_name = Constants::GLOBAL_RAPID_PRODUCTION_REST_URL_PARAM
elsif Constants::RAPID_ENDPOINT_SANDBOX.casecmp(@rapid_endpoint).zero?
prop_name = Constants::GLOBAL_RAPID_SANDBOX_REST_URL_PARAM
end
if prop_name.nil?
set_web_url(@rapid_endpoint)
else
property_array = YAML.load_file(File.join(File.dirname(__FILE__), 'resources', 'rapid-api.yml'))
property_array.each do |h|
if prop_name.casecmp(h.keys.first).zero?
set_web_url(h[h.keys.first])
end
end
if @web_url.nil?
fail Exception, "The endpoint #{prop_name} is invalid."
end
end
# verify_endpoint_url(@web_url) # this is unreliable
end | ruby | def parser_endpoint_to_web_url
# @type [String]
prop_name = nil
if Constants::RAPID_ENDPOINT_PRODUCTION.casecmp(@rapid_endpoint).zero?
prop_name = Constants::GLOBAL_RAPID_PRODUCTION_REST_URL_PARAM
elsif Constants::RAPID_ENDPOINT_SANDBOX.casecmp(@rapid_endpoint).zero?
prop_name = Constants::GLOBAL_RAPID_SANDBOX_REST_URL_PARAM
end
if prop_name.nil?
set_web_url(@rapid_endpoint)
else
property_array = YAML.load_file(File.join(File.dirname(__FILE__), 'resources', 'rapid-api.yml'))
property_array.each do |h|
if prop_name.casecmp(h.keys.first).zero?
set_web_url(h[h.keys.first])
end
end
if @web_url.nil?
fail Exception, "The endpoint #{prop_name} is invalid."
end
end
# verify_endpoint_url(@web_url) # this is unreliable
end | [
"def",
"parser_endpoint_to_web_url",
"# @type [String]",
"prop_name",
"=",
"nil",
"if",
"Constants",
"::",
"RAPID_ENDPOINT_PRODUCTION",
".",
"casecmp",
"(",
"@rapid_endpoint",
")",
".",
"zero?",
"prop_name",
"=",
"Constants",
"::",
"GLOBAL_RAPID_PRODUCTION_REST_URL_PARAM",
"elsif",
"Constants",
"::",
"RAPID_ENDPOINT_SANDBOX",
".",
"casecmp",
"(",
"@rapid_endpoint",
")",
".",
"zero?",
"prop_name",
"=",
"Constants",
"::",
"GLOBAL_RAPID_SANDBOX_REST_URL_PARAM",
"end",
"if",
"prop_name",
".",
"nil?",
"set_web_url",
"(",
"@rapid_endpoint",
")",
"else",
"property_array",
"=",
"YAML",
".",
"load_file",
"(",
"File",
".",
"join",
"(",
"File",
".",
"dirname",
"(",
"__FILE__",
")",
",",
"'resources'",
",",
"'rapid-api.yml'",
")",
")",
"property_array",
".",
"each",
"do",
"|",
"h",
"|",
"if",
"prop_name",
".",
"casecmp",
"(",
"h",
".",
"keys",
".",
"first",
")",
".",
"zero?",
"set_web_url",
"(",
"h",
"[",
"h",
".",
"keys",
".",
"first",
"]",
")",
"end",
"end",
"if",
"@web_url",
".",
"nil?",
"fail",
"Exception",
",",
"\"The endpoint #{prop_name} is invalid.\"",
"end",
"end",
"# verify_endpoint_url(@web_url) # this is unreliable",
"end"
] | Converts an endpoint string to a URL | [
"Converts",
"an",
"endpoint",
"string",
"to",
"a",
"URL"
] | 49b0e3845e442dff58466c06cef01b5f8f037990 | https://github.com/eWAYPayment/eway-rapid-ruby/blob/49b0e3845e442dff58466c06cef01b5f8f037990/lib/eway_rapid/rapid_client.rb#L404-L426 |
23,516 | eWAYPayment/eway-rapid-ruby | lib/eway_rapid/rapid_client.rb | EwayRapid.RapidClient.verify_endpoint_url | def verify_endpoint_url(web_url)
begin
resource = RestClient::Resource.new web_url
resource.get
rescue RestClient::Exception => e
if e.http_code == 404
set_valid(false)
end
end
end | ruby | def verify_endpoint_url(web_url)
begin
resource = RestClient::Resource.new web_url
resource.get
rescue RestClient::Exception => e
if e.http_code == 404
set_valid(false)
end
end
end | [
"def",
"verify_endpoint_url",
"(",
"web_url",
")",
"begin",
"resource",
"=",
"RestClient",
"::",
"Resource",
".",
"new",
"web_url",
"resource",
".",
"get",
"rescue",
"RestClient",
"::",
"Exception",
"=>",
"e",
"if",
"e",
".",
"http_code",
"==",
"404",
"set_valid",
"(",
"false",
")",
"end",
"end",
"end"
] | Checks the Rapid endpoint url
@param [String] web_url | [
"Checks",
"the",
"Rapid",
"endpoint",
"url"
] | 49b0e3845e442dff58466c06cef01b5f8f037990 | https://github.com/eWAYPayment/eway-rapid-ruby/blob/49b0e3845e442dff58466c06cef01b5f8f037990/lib/eway_rapid/rapid_client.rb#L431-L440 |
23,517 | wepay/Ruby-SDK | lib/wepay.rb | WePay.Client.call | def call(call, access_token = false, params = {}, risk_token = false, client_ip = false)
path = call.start_with?('/') ? call : call.prepend('/')
url = URI.parse(api_endpoint + path)
call = Net::HTTP::Post.new(url.path, {
'Content-Type' => 'application/json',
'User-Agent' => 'WePay Ruby SDK'
})
unless params.empty?
call.body = params.to_json
end
if access_token then call.add_field('Authorization', "Bearer #{access_token}"); end
if @api_version then call.add_field('Api-Version', @api_version); end
if risk_token then call.add_field('WePay-Risk-Token', risk_token); end
if client_ip then call.add_field('Client-IP', client_ip); end
make_request(call, url)
end | ruby | def call(call, access_token = false, params = {}, risk_token = false, client_ip = false)
path = call.start_with?('/') ? call : call.prepend('/')
url = URI.parse(api_endpoint + path)
call = Net::HTTP::Post.new(url.path, {
'Content-Type' => 'application/json',
'User-Agent' => 'WePay Ruby SDK'
})
unless params.empty?
call.body = params.to_json
end
if access_token then call.add_field('Authorization', "Bearer #{access_token}"); end
if @api_version then call.add_field('Api-Version', @api_version); end
if risk_token then call.add_field('WePay-Risk-Token', risk_token); end
if client_ip then call.add_field('Client-IP', client_ip); end
make_request(call, url)
end | [
"def",
"call",
"(",
"call",
",",
"access_token",
"=",
"false",
",",
"params",
"=",
"{",
"}",
",",
"risk_token",
"=",
"false",
",",
"client_ip",
"=",
"false",
")",
"path",
"=",
"call",
".",
"start_with?",
"(",
"'/'",
")",
"?",
"call",
":",
"call",
".",
"prepend",
"(",
"'/'",
")",
"url",
"=",
"URI",
".",
"parse",
"(",
"api_endpoint",
"+",
"path",
")",
"call",
"=",
"Net",
"::",
"HTTP",
"::",
"Post",
".",
"new",
"(",
"url",
".",
"path",
",",
"{",
"'Content-Type'",
"=>",
"'application/json'",
",",
"'User-Agent'",
"=>",
"'WePay Ruby SDK'",
"}",
")",
"unless",
"params",
".",
"empty?",
"call",
".",
"body",
"=",
"params",
".",
"to_json",
"end",
"if",
"access_token",
"then",
"call",
".",
"add_field",
"(",
"'Authorization'",
",",
"\"Bearer #{access_token}\"",
")",
";",
"end",
"if",
"@api_version",
"then",
"call",
".",
"add_field",
"(",
"'Api-Version'",
",",
"@api_version",
")",
";",
"end",
"if",
"risk_token",
"then",
"call",
".",
"add_field",
"(",
"'WePay-Risk-Token'",
",",
"risk_token",
")",
";",
"end",
"if",
"client_ip",
"then",
"call",
".",
"add_field",
"(",
"'Client-IP'",
",",
"client_ip",
")",
";",
"end",
"make_request",
"(",
"call",
",",
"url",
")",
"end"
] | Execute a call to the WePay API. | [
"Execute",
"a",
"call",
"to",
"the",
"WePay",
"API",
"."
] | ebb6d27ac6eeb00362c2fe044709317f3d7162d8 | https://github.com/wepay/Ruby-SDK/blob/ebb6d27ac6eeb00362c2fe044709317f3d7162d8/lib/wepay.rb#L59-L78 |
23,518 | wepay/Ruby-SDK | lib/wepay.rb | WePay.Client.make_request | def make_request(call, url)
request = Net::HTTP.new(url.host, url.port)
request.read_timeout = 30
request.use_ssl = true
response = request.start { |http| http.request(call) }
JSON.parse(response.body)
end | ruby | def make_request(call, url)
request = Net::HTTP.new(url.host, url.port)
request.read_timeout = 30
request.use_ssl = true
response = request.start { |http| http.request(call) }
JSON.parse(response.body)
end | [
"def",
"make_request",
"(",
"call",
",",
"url",
")",
"request",
"=",
"Net",
"::",
"HTTP",
".",
"new",
"(",
"url",
".",
"host",
",",
"url",
".",
"port",
")",
"request",
".",
"read_timeout",
"=",
"30",
"request",
".",
"use_ssl",
"=",
"true",
"response",
"=",
"request",
".",
"start",
"{",
"|",
"http",
"|",
"http",
".",
"request",
"(",
"call",
")",
"}",
"JSON",
".",
"parse",
"(",
"response",
".",
"body",
")",
"end"
] | Make the HTTP request to the endpoint. | [
"Make",
"the",
"HTTP",
"request",
"to",
"the",
"endpoint",
"."
] | ebb6d27ac6eeb00362c2fe044709317f3d7162d8 | https://github.com/wepay/Ruby-SDK/blob/ebb6d27ac6eeb00362c2fe044709317f3d7162d8/lib/wepay.rb#L119-L126 |
23,519 | terry90/rails_api_benchmark | lib/rails_api_benchmark.rb | RailsApiBenchmark.Configuration.all | def all
instance_variables.inject({}) do |h, v|
var = v.to_s.sub('@', '')
h.merge(var.to_sym => send(var))
end
end | ruby | def all
instance_variables.inject({}) do |h, v|
var = v.to_s.sub('@', '')
h.merge(var.to_sym => send(var))
end
end | [
"def",
"all",
"instance_variables",
".",
"inject",
"(",
"{",
"}",
")",
"do",
"|",
"h",
",",
"v",
"|",
"var",
"=",
"v",
".",
"to_s",
".",
"sub",
"(",
"'@'",
",",
"''",
")",
"h",
".",
"merge",
"(",
"var",
".",
"to_sym",
"=>",
"send",
"(",
"var",
")",
")",
"end",
"end"
] | Default values, INSANE. Must be refactored
Maybe create a yaml or json file to import for default values | [
"Default",
"values",
"INSANE",
".",
"Must",
"be",
"refactored",
"Maybe",
"create",
"a",
"yaml",
"or",
"json",
"file",
"to",
"import",
"for",
"default",
"values"
] | 2991765ff639b2efdf4aa1a56587247ed5ee22d0 | https://github.com/terry90/rails_api_benchmark/blob/2991765ff639b2efdf4aa1a56587247ed5ee22d0/lib/rails_api_benchmark.rb#L50-L55 |
23,520 | manorie/textoken | lib/textoken/searcher.rb | Textoken.Searcher.match_keys | def match_keys
values.each do |v|
Textoken.expression_err("#{v}: is not permitted.") unless yaml.key?(v)
add_regexps(yaml[v])
end
end | ruby | def match_keys
values.each do |v|
Textoken.expression_err("#{v}: is not permitted.") unless yaml.key?(v)
add_regexps(yaml[v])
end
end | [
"def",
"match_keys",
"values",
".",
"each",
"do",
"|",
"v",
"|",
"Textoken",
".",
"expression_err",
"(",
"\"#{v}: is not permitted.\"",
")",
"unless",
"yaml",
".",
"key?",
"(",
"v",
")",
"add_regexps",
"(",
"yaml",
"[",
"v",
"]",
")",
"end",
"end"
] | here we do check for option values user supplied
option values has to be declared at option_values.yml | [
"here",
"we",
"do",
"check",
"for",
"option",
"values",
"user",
"supplied",
"option",
"values",
"has",
"to",
"be",
"declared",
"at",
"option_values",
".",
"yml"
] | e66b0c34217e8c3cfab70f1d4e6abf26f876555f | https://github.com/manorie/textoken/blob/e66b0c34217e8c3cfab70f1d4e6abf26f876555f/lib/textoken/searcher.rb#L34-L39 |
23,521 | ekosz/Plex-Ruby | lib/plex-ruby/season.rb | Plex.Season.episode | def episode(number)
episodes.detect { |epi| epi.index.to_i == number.to_i }
end | ruby | def episode(number)
episodes.detect { |epi| epi.index.to_i == number.to_i }
end | [
"def",
"episode",
"(",
"number",
")",
"episodes",
".",
"detect",
"{",
"|",
"epi",
"|",
"epi",
".",
"index",
".",
"to_i",
"==",
"number",
".",
"to_i",
"}",
"end"
] | Select a particular episode
@param [Fixnum, String] episode index number
@return [Episode] episode with the index of number | [
"Select",
"a",
"particular",
"episode"
] | 981dd175d674c74cad7ea8daf8b52c266c12df29 | https://github.com/ekosz/Plex-Ruby/blob/981dd175d674c74cad7ea8daf8b52c266c12df29/lib/plex-ruby/season.rb#L42-L44 |
23,522 | petethepig/marmot | lib/marmot/client.rb | Marmot.Client.convert | def convert input_io, options={}
@exception = nil
#1
iam "Retrieving cookies... ", false do
response = self.class.get '/tools/webfont-generator'
@cookies = (response.headers.get_fields("Set-Cookie") || []).join(";")
fail "Failed to retrieve cookies" if @cookies.empty?
self.class.headers({"Cookie" => @cookies})
@@headers_set = true
response
end unless @@headers_set
#2
iam "Uploading font... " do
response = self.class.post '/uploadify/fontfacegen_uploadify.php', :query => {
"Filedata" => File.new(input_io)
}
@path_data = response.body
@id, @original_filename = @path_data.split("|")
fail "Failed to upload the file. Is it a valid font?" if @id.nil? || @original_filename.nil?
response
end
#3
iam "Confirming upload... " do
response = self.class.post "/tools/insert", :query => {
"original_filename" => @original_filename,
"path_data" => @path_data
}
json = JSON.parse response.body
fail (json["message"] || "Failed to confirm the upload. Is it a valid font?") if !json["name"] || !json["id"]
response
end
#4
iam "Generating webfont... " do
custom_options = options.delete :custom_options
options[:id] = @id
@params = OptionsSanitizer.sanitize(options, custom_options)
logger.debug "HTTP Params:\n#{@params.collect{|k,v| "#{k}: #{v.inspect}" }.join("\n")}"
response = self.class.post "/tools/generate", :query => @params
fail "Failed to generate webfont kit" if !response.body.empty?
response
end
#5
counter = 0
while response = self.class.get("/tools/progress/#{@id}") do
p = JSON.parse(response.body)["progress"].to_i
logger.info "Progress: #{p} "
if p == 100
break
elsif p == 0
fail "Progress timeout" if (counter += 1) > 10
end
sleep 2
end
#6
iam "Downloading fonts... ", false do
response = self.class.post "/tools/download", :query => @params
end
#7
if !options[:output_io]
filename = response.headers["Content-Disposition"].gsub(/attachment; filename=\"(.*)\"/,'\1')
options[:output_io] = File.new(filename, "wb")
end
options[:output_io] << response.response.body
end | ruby | def convert input_io, options={}
@exception = nil
#1
iam "Retrieving cookies... ", false do
response = self.class.get '/tools/webfont-generator'
@cookies = (response.headers.get_fields("Set-Cookie") || []).join(";")
fail "Failed to retrieve cookies" if @cookies.empty?
self.class.headers({"Cookie" => @cookies})
@@headers_set = true
response
end unless @@headers_set
#2
iam "Uploading font... " do
response = self.class.post '/uploadify/fontfacegen_uploadify.php', :query => {
"Filedata" => File.new(input_io)
}
@path_data = response.body
@id, @original_filename = @path_data.split("|")
fail "Failed to upload the file. Is it a valid font?" if @id.nil? || @original_filename.nil?
response
end
#3
iam "Confirming upload... " do
response = self.class.post "/tools/insert", :query => {
"original_filename" => @original_filename,
"path_data" => @path_data
}
json = JSON.parse response.body
fail (json["message"] || "Failed to confirm the upload. Is it a valid font?") if !json["name"] || !json["id"]
response
end
#4
iam "Generating webfont... " do
custom_options = options.delete :custom_options
options[:id] = @id
@params = OptionsSanitizer.sanitize(options, custom_options)
logger.debug "HTTP Params:\n#{@params.collect{|k,v| "#{k}: #{v.inspect}" }.join("\n")}"
response = self.class.post "/tools/generate", :query => @params
fail "Failed to generate webfont kit" if !response.body.empty?
response
end
#5
counter = 0
while response = self.class.get("/tools/progress/#{@id}") do
p = JSON.parse(response.body)["progress"].to_i
logger.info "Progress: #{p} "
if p == 100
break
elsif p == 0
fail "Progress timeout" if (counter += 1) > 10
end
sleep 2
end
#6
iam "Downloading fonts... ", false do
response = self.class.post "/tools/download", :query => @params
end
#7
if !options[:output_io]
filename = response.headers["Content-Disposition"].gsub(/attachment; filename=\"(.*)\"/,'\1')
options[:output_io] = File.new(filename, "wb")
end
options[:output_io] << response.response.body
end | [
"def",
"convert",
"input_io",
",",
"options",
"=",
"{",
"}",
"@exception",
"=",
"nil",
"#1",
"iam",
"\"Retrieving cookies... \"",
",",
"false",
"do",
"response",
"=",
"self",
".",
"class",
".",
"get",
"'/tools/webfont-generator'",
"@cookies",
"=",
"(",
"response",
".",
"headers",
".",
"get_fields",
"(",
"\"Set-Cookie\"",
")",
"||",
"[",
"]",
")",
".",
"join",
"(",
"\";\"",
")",
"fail",
"\"Failed to retrieve cookies\"",
"if",
"@cookies",
".",
"empty?",
"self",
".",
"class",
".",
"headers",
"(",
"{",
"\"Cookie\"",
"=>",
"@cookies",
"}",
")",
"@@headers_set",
"=",
"true",
"response",
"end",
"unless",
"@@headers_set",
"#2",
"iam",
"\"Uploading font... \"",
"do",
"response",
"=",
"self",
".",
"class",
".",
"post",
"'/uploadify/fontfacegen_uploadify.php'",
",",
":query",
"=>",
"{",
"\"Filedata\"",
"=>",
"File",
".",
"new",
"(",
"input_io",
")",
"}",
"@path_data",
"=",
"response",
".",
"body",
"@id",
",",
"@original_filename",
"=",
"@path_data",
".",
"split",
"(",
"\"|\"",
")",
"fail",
"\"Failed to upload the file. Is it a valid font?\"",
"if",
"@id",
".",
"nil?",
"||",
"@original_filename",
".",
"nil?",
"response",
"end",
"#3",
"iam",
"\"Confirming upload... \"",
"do",
"response",
"=",
"self",
".",
"class",
".",
"post",
"\"/tools/insert\"",
",",
":query",
"=>",
"{",
"\"original_filename\"",
"=>",
"@original_filename",
",",
"\"path_data\"",
"=>",
"@path_data",
"}",
"json",
"=",
"JSON",
".",
"parse",
"response",
".",
"body",
"fail",
"(",
"json",
"[",
"\"message\"",
"]",
"||",
"\"Failed to confirm the upload. Is it a valid font?\"",
")",
"if",
"!",
"json",
"[",
"\"name\"",
"]",
"||",
"!",
"json",
"[",
"\"id\"",
"]",
"response",
"end",
"#4",
"iam",
"\"Generating webfont... \"",
"do",
"custom_options",
"=",
"options",
".",
"delete",
":custom_options",
"options",
"[",
":id",
"]",
"=",
"@id",
"@params",
"=",
"OptionsSanitizer",
".",
"sanitize",
"(",
"options",
",",
"custom_options",
")",
"logger",
".",
"debug",
"\"HTTP Params:\\n#{@params.collect{|k,v| \"#{k}: #{v.inspect}\" }.join(\"\\n\")}\"",
"response",
"=",
"self",
".",
"class",
".",
"post",
"\"/tools/generate\"",
",",
":query",
"=>",
"@params",
"fail",
"\"Failed to generate webfont kit\"",
"if",
"!",
"response",
".",
"body",
".",
"empty?",
"response",
"end",
"#5",
"counter",
"=",
"0",
"while",
"response",
"=",
"self",
".",
"class",
".",
"get",
"(",
"\"/tools/progress/#{@id}\"",
")",
"do",
"p",
"=",
"JSON",
".",
"parse",
"(",
"response",
".",
"body",
")",
"[",
"\"progress\"",
"]",
".",
"to_i",
"logger",
".",
"info",
"\"Progress: #{p} \"",
"if",
"p",
"==",
"100",
"break",
"elsif",
"p",
"==",
"0",
"fail",
"\"Progress timeout\"",
"if",
"(",
"counter",
"+=",
"1",
")",
">",
"10",
"end",
"sleep",
"2",
"end",
"#6",
"iam",
"\"Downloading fonts... \"",
",",
"false",
"do",
"response",
"=",
"self",
".",
"class",
".",
"post",
"\"/tools/download\"",
",",
":query",
"=>",
"@params",
"end",
"#7",
"if",
"!",
"options",
"[",
":output_io",
"]",
"filename",
"=",
"response",
".",
"headers",
"[",
"\"Content-Disposition\"",
"]",
".",
"gsub",
"(",
"/",
"\\\"",
"\\\"",
"/",
",",
"'\\1'",
")",
"options",
"[",
":output_io",
"]",
"=",
"File",
".",
"new",
"(",
"filename",
",",
"\"wb\"",
")",
"end",
"options",
"[",
":output_io",
"]",
"<<",
"response",
".",
"response",
".",
"body",
"end"
] | Convert a font file to a webfont kit
@param [String] input_io Input IO. Examples: File.new("font.ttf"), STDOUT
@param [Hash] options Options
@option options
[String] :output_io
Output IO
Default is a File with the name like "webfontkit-20130312-200144.zip"
@option options
[Hash] :custom_options
Options that will bypass sanitization. Make sure you know what you do before trying it out.
@option options [Array or String] :formats
Allowed values are: "ttf", "woff", "svg", "eotz", "eot". Default is ["ttf","woff","svg","eotz"]
@option options
[String] :mode
Generator mode: "optimal", "basic", "expert". Default is "optimal"
@option options
[String] :tt_instructor
Truetype hinting: "default", "keep"
@option options
[Boolean] :fix_vertical_metrics
Rendering option. Fix Vertical Metrics (Normalize across browsers). Default is true
@option options
[Boolean] :fix_gasp
Rendering option. Fix GASP Table (Better DirectWrite Rendering). Default is true
@option options
[Boolean] :remove_kerning
Rendering option. Remove Kerning (Strip kerning data). Default is false
@option options
[Boolean] :add_spaces
Fix missing glyphs option. Fix spaces. Default is true
@option options
[Boolean] :add_hyphens
Fix missing glyphs option. Fix hyphens. Default is true
@option options
[String] :fallback
X-height matching: "none", "arial", "verdana", "trebuchet", "georgia", "times", "courier", "custom"
@option options
[String] :fallback_custom
Custom x-height matching, in percents. Default is "100%". Only applies when :fallback is "custom"
@option options
[Boolean] :webonly
Disable desktop use. Default is false
@option options
[String] :options_subset
Subsetting options: "basic", "advanced", "none". Default is "basic"
@option options
[Array] :subset_range
Custom subsetting options. Only applies when :options_subset is "advanced".
Allowed values are: "macroman", "lowercase", "uppercase", "numbers", "punctuation", "currency",
"typographics", "math", "altpunctuation", "accentedlower", "accentedupper", "diacriticals",
"albanian", "bosnian", "catalan", "croatian", "cyrillic", "czech", "danish", "dutch", "english",
"esperanto", "estonian", "faroese", "french", "german", "greek", "hebrew", "hungarian", "icelandic",
"italian", "latvian", "lithuanian", "malagasy", "maltese", "norwegian", "polish", "portuguese",
"romanian", "serbian", "slovak", "slovenian", "spanish", "swedish", "turkish", "ubasic", "ulatin1",
"ucurrency", "upunctuation", "ulatina", "ulatinb", "ulatinaddl"
@option options
[String] :subset_custom
Single characters. Only applies when :options_subset is "advanced". Default is ""
@option options
[String] :subset_custom_range
Unicode Ranges. Only applies when :options_subset is "advanced".
Comma separated values. Can be single hex values and/or ranges separated with hyphens.
Example: "0021-007E,00E7,00EB,00C7,00CB"
@option options
[Boolean] :base64
CSS option. Base64 encode (Embed font in CSS). Default is false
@option options
[Boolean] :style_link
CSS option. Style link (Family support in CSS). Default is false
@option options
[String] :css_stylesheet
CSS Filename. Default is "stylesheet.css"
@option options
[String] :ot_features
OpenType Options. If the features are available, the generator will fold them into the font.
Allowed values: "onum", "lnum", "tnum", "pnum", "zero", "ss01", "ss02", "ss03", "ss04", "ss05"
@option options
[String] :filename_suffix
Filename suffix. Default is "-webfont"
@option options
[String] :emsquare
Em Square Value. In units of the em square. Default is 2048
@option options
[String] :spacing_adjustment
Adjust Glyph Spacing. In units of the em square. Default is 0
@option options
[Boolean] :agreement
Agreement option. The fonts You're uploading are legally eligible for web embedding. Default is true.
@see http://www.fontsquirrel.com/tools/webfont-generator more info about parameters @ www.fontsquirrel.com
@return [String] | [
"Convert",
"a",
"font",
"file",
"to",
"a",
"webfont",
"kit"
] | dd4877fbe1eb40cbbfe49b3a2d2f143aa6db2c58 | https://github.com/petethepig/marmot/blob/dd4877fbe1eb40cbbfe49b3a2d2f143aa6db2c58/lib/marmot/client.rb#L137-L207 |
23,523 | ekosz/Plex-Ruby | lib/plex-ruby/client.rb | Plex.Client.play_media | def play_media(key, user_agent = nil, http_cookies = nil, view_offset = nil)
if !key.is_a?(String) && key.respond_to?(:key)
key = key.key
end
url = player_url+'/application/playMedia?'
url += "path=#{CGI::escape(server.url+key)}"
url += "&key=#{CGI::escape(key)}"
url += "&userAgent=#{user_agent}" if user_agent
url += "&httpCookies=#{http_cookies}" if http_cookies
url += "&viewOffset=#{view_offset}" if view_offset
ping url
end | ruby | def play_media(key, user_agent = nil, http_cookies = nil, view_offset = nil)
if !key.is_a?(String) && key.respond_to?(:key)
key = key.key
end
url = player_url+'/application/playMedia?'
url += "path=#{CGI::escape(server.url+key)}"
url += "&key=#{CGI::escape(key)}"
url += "&userAgent=#{user_agent}" if user_agent
url += "&httpCookies=#{http_cookies}" if http_cookies
url += "&viewOffset=#{view_offset}" if view_offset
ping url
end | [
"def",
"play_media",
"(",
"key",
",",
"user_agent",
"=",
"nil",
",",
"http_cookies",
"=",
"nil",
",",
"view_offset",
"=",
"nil",
")",
"if",
"!",
"key",
".",
"is_a?",
"(",
"String",
")",
"&&",
"key",
".",
"respond_to?",
"(",
":key",
")",
"key",
"=",
"key",
".",
"key",
"end",
"url",
"=",
"player_url",
"+",
"'/application/playMedia?'",
"url",
"+=",
"\"path=#{CGI::escape(server.url+key)}\"",
"url",
"+=",
"\"&key=#{CGI::escape(key)}\"",
"url",
"+=",
"\"&userAgent=#{user_agent}\"",
"if",
"user_agent",
"url",
"+=",
"\"&httpCookies=#{http_cookies}\"",
"if",
"http_cookies",
"url",
"+=",
"\"&viewOffset=#{view_offset}\"",
"if",
"view_offset",
"ping",
"url",
"end"
] | Plays a video that is in the library
@param [String, Object] the key of the video that we want to play. Or an
Object that responds to :key (see Episode#key) (see Movie#key)
@param [String] no clue what this does, its the Plex Remote Command API though
@param [String] no clue what this does, its the Plex Remote Command API though
@param [String] no clue what this does, its the Plex Remote Command API though
@return [True, nil] true if it worked, nil if something went wrong check
the console for the error message | [
"Plays",
"a",
"video",
"that",
"is",
"in",
"the",
"library"
] | 981dd175d674c74cad7ea8daf8b52c266c12df29 | https://github.com/ekosz/Plex-Ruby/blob/981dd175d674c74cad7ea8daf8b52c266c12df29/lib/plex-ruby/client.rb#L64-L78 |
23,524 | ekosz/Plex-Ruby | lib/plex-ruby/client.rb | Plex.Client.screenshot | def screenshot(width, height, quality)
url = player_url+'/application/screenshot?'
url += "width=#{width}"
url += "&height=#{height}"
url += "&quality=#{quality}"
ping url
end | ruby | def screenshot(width, height, quality)
url = player_url+'/application/screenshot?'
url += "width=#{width}"
url += "&height=#{height}"
url += "&quality=#{quality}"
ping url
end | [
"def",
"screenshot",
"(",
"width",
",",
"height",
",",
"quality",
")",
"url",
"=",
"player_url",
"+",
"'/application/screenshot?'",
"url",
"+=",
"\"width=#{width}\"",
"url",
"+=",
"\"&height=#{height}\"",
"url",
"+=",
"\"&quality=#{quality}\"",
"ping",
"url",
"end"
] | Take a screenshot of whats on the Plex Client
@param [String, Fixnum] width of the screenshot
@param [String, Fixnum] height of the screenshot
@param [String, Fixnum] quality of the screenshot
@return [True, nil] true if it worked, nil if something went wrong check
the console for the error message | [
"Take",
"a",
"screenshot",
"of",
"whats",
"on",
"the",
"Plex",
"Client"
] | 981dd175d674c74cad7ea8daf8b52c266c12df29 | https://github.com/ekosz/Plex-Ruby/blob/981dd175d674c74cad7ea8daf8b52c266c12df29/lib/plex-ruby/client.rb#L87-L94 |
23,525 | ekosz/Plex-Ruby | lib/plex-ruby/show.rb | Plex.Show.season | def season(number)
seasons.detect { |sea| sea.index.to_i == number.to_i }
end | ruby | def season(number)
seasons.detect { |sea| sea.index.to_i == number.to_i }
end | [
"def",
"season",
"(",
"number",
")",
"seasons",
".",
"detect",
"{",
"|",
"sea",
"|",
"sea",
".",
"index",
".",
"to_i",
"==",
"number",
".",
"to_i",
"}",
"end"
] | Select a particular season
@param [Fixnum, String] season index number
@return [Season] season with the index of number | [
"Select",
"a",
"particular",
"season"
] | 981dd175d674c74cad7ea8daf8b52c266c12df29 | https://github.com/ekosz/Plex-Ruby/blob/981dd175d674c74cad7ea8daf8b52c266c12df29/lib/plex-ruby/show.rb#L42-L44 |
23,526 | ekosz/Plex-Ruby | lib/plex-ruby/show.rb | Plex.Show.first_season | def first_season
seasons.inject { |a, b| a.index.to_i < b.index.to_i && a.index.to_i > 0 ? a : b }
end | ruby | def first_season
seasons.inject { |a, b| a.index.to_i < b.index.to_i && a.index.to_i > 0 ? a : b }
end | [
"def",
"first_season",
"seasons",
".",
"inject",
"{",
"|",
"a",
",",
"b",
"|",
"a",
".",
"index",
".",
"to_i",
"<",
"b",
".",
"index",
".",
"to_i",
"&&",
"a",
".",
"index",
".",
"to_i",
">",
"0",
"?",
"a",
":",
"b",
"}",
"end"
] | Selects the first season of this show that is on the Plex Server
Does not select season 0
@return [Season] season with the lowest index (but not 0) | [
"Selects",
"the",
"first",
"season",
"of",
"this",
"show",
"that",
"is",
"on",
"the",
"Plex",
"Server",
"Does",
"not",
"select",
"season",
"0"
] | 981dd175d674c74cad7ea8daf8b52c266c12df29 | https://github.com/ekosz/Plex-Ruby/blob/981dd175d674c74cad7ea8daf8b52c266c12df29/lib/plex-ruby/show.rb#L59-L61 |
23,527 | manorie/textoken | lib/textoken/base.rb | Textoken.Base.tokens | def tokens
options.collection.each do |option|
if @findings.nil?
@findings = option.tokenize(self)
else
@findings &= option.tokenize(self)
end
end
Tokenizer.new(self).tokens
end | ruby | def tokens
options.collection.each do |option|
if @findings.nil?
@findings = option.tokenize(self)
else
@findings &= option.tokenize(self)
end
end
Tokenizer.new(self).tokens
end | [
"def",
"tokens",
"options",
".",
"collection",
".",
"each",
"do",
"|",
"option",
"|",
"if",
"@findings",
".",
"nil?",
"@findings",
"=",
"option",
".",
"tokenize",
"(",
"self",
")",
"else",
"@findings",
"&=",
"option",
".",
"tokenize",
"(",
"self",
")",
"end",
"end",
"Tokenizer",
".",
"new",
"(",
"self",
")",
".",
"tokens",
"end"
] | we do take intersection array of results
returning from multiple options | [
"we",
"do",
"take",
"intersection",
"array",
"of",
"results",
"returning",
"from",
"multiple",
"options"
] | e66b0c34217e8c3cfab70f1d4e6abf26f876555f | https://github.com/manorie/textoken/blob/e66b0c34217e8c3cfab70f1d4e6abf26f876555f/lib/textoken/base.rb#L15-L25 |
23,528 | veny/orientdb4r | lib/orientdb4r/rest/client.rb | Orientdb4r.RestClient.gremlin | def gremlin(gremlin)
raise ArgumentError, 'gremlin query is blank' if blank? gremlin
response = call_server(:method => :post, :uri => "command/#{@database}/gremlin/#{CGI::escape(gremlin)}")
entries = process_response(response) do
raise NotFoundError, 'record not found' if response.body =~ /ORecordNotFoundException/
end
rslt = entries['result']
# mixin all document entries (they have '@class' attribute)
rslt.each { |doc| doc.extend Orientdb4r::DocumentMetadata unless doc['@class'].nil? }
rslt
end | ruby | def gremlin(gremlin)
raise ArgumentError, 'gremlin query is blank' if blank? gremlin
response = call_server(:method => :post, :uri => "command/#{@database}/gremlin/#{CGI::escape(gremlin)}")
entries = process_response(response) do
raise NotFoundError, 'record not found' if response.body =~ /ORecordNotFoundException/
end
rslt = entries['result']
# mixin all document entries (they have '@class' attribute)
rslt.each { |doc| doc.extend Orientdb4r::DocumentMetadata unless doc['@class'].nil? }
rslt
end | [
"def",
"gremlin",
"(",
"gremlin",
")",
"raise",
"ArgumentError",
",",
"'gremlin query is blank'",
"if",
"blank?",
"gremlin",
"response",
"=",
"call_server",
"(",
":method",
"=>",
":post",
",",
":uri",
"=>",
"\"command/#{@database}/gremlin/#{CGI::escape(gremlin)}\"",
")",
"entries",
"=",
"process_response",
"(",
"response",
")",
"do",
"raise",
"NotFoundError",
",",
"'record not found'",
"if",
"response",
".",
"body",
"=~",
"/",
"/",
"end",
"rslt",
"=",
"entries",
"[",
"'result'",
"]",
"# mixin all document entries (they have '@class' attribute)",
"rslt",
".",
"each",
"{",
"|",
"doc",
"|",
"doc",
".",
"extend",
"Orientdb4r",
"::",
"DocumentMetadata",
"unless",
"doc",
"[",
"'@class'",
"]",
".",
"nil?",
"}",
"rslt",
"end"
] | Executes a Gremlin command against the database. | [
"Executes",
"a",
"Gremlin",
"command",
"against",
"the",
"database",
"."
] | d02d0d27e6ed19c5c5ff377a642355f617c785d7 | https://github.com/veny/orientdb4r/blob/d02d0d27e6ed19c5c5ff377a642355f617c785d7/lib/orientdb4r/rest/client.rb#L300-L311 |
23,529 | veny/orientdb4r | lib/orientdb4r/rest/client.rb | Orientdb4r.RestClient.process_response | def process_response(response)
raise ArgumentError, 'response is null' if response.nil?
if block_given?
yield
end
# return code
if 401 == response.code
raise UnauthorizedError, compose_error_message(response)
elsif 500 == response.code
raise ServerError, compose_error_message(response)
elsif 2 != (response.code / 100)
raise OrientdbError, "unexpected return code, code=#{response.code}, body=#{compose_error_message(response)}"
end
content_type = response.headers[:content_type] if connection_library == :restclient
content_type = response.headers['Content-Type'] if connection_library == :excon
content_type ||= 'text/plain'
rslt = case
when content_type.start_with?('text/plain')
response.body
when content_type.start_with?('application/x-gzip')
response.body
when content_type.start_with?('application/json')
::JSON.parse(response.body)
else
raise OrientdbError, "unsuported content type: #{content_type}"
end
rslt
end | ruby | def process_response(response)
raise ArgumentError, 'response is null' if response.nil?
if block_given?
yield
end
# return code
if 401 == response.code
raise UnauthorizedError, compose_error_message(response)
elsif 500 == response.code
raise ServerError, compose_error_message(response)
elsif 2 != (response.code / 100)
raise OrientdbError, "unexpected return code, code=#{response.code}, body=#{compose_error_message(response)}"
end
content_type = response.headers[:content_type] if connection_library == :restclient
content_type = response.headers['Content-Type'] if connection_library == :excon
content_type ||= 'text/plain'
rslt = case
when content_type.start_with?('text/plain')
response.body
when content_type.start_with?('application/x-gzip')
response.body
when content_type.start_with?('application/json')
::JSON.parse(response.body)
else
raise OrientdbError, "unsuported content type: #{content_type}"
end
rslt
end | [
"def",
"process_response",
"(",
"response",
")",
"raise",
"ArgumentError",
",",
"'response is null'",
"if",
"response",
".",
"nil?",
"if",
"block_given?",
"yield",
"end",
"# return code",
"if",
"401",
"==",
"response",
".",
"code",
"raise",
"UnauthorizedError",
",",
"compose_error_message",
"(",
"response",
")",
"elsif",
"500",
"==",
"response",
".",
"code",
"raise",
"ServerError",
",",
"compose_error_message",
"(",
"response",
")",
"elsif",
"2",
"!=",
"(",
"response",
".",
"code",
"/",
"100",
")",
"raise",
"OrientdbError",
",",
"\"unexpected return code, code=#{response.code}, body=#{compose_error_message(response)}\"",
"end",
"content_type",
"=",
"response",
".",
"headers",
"[",
":content_type",
"]",
"if",
"connection_library",
"==",
":restclient",
"content_type",
"=",
"response",
".",
"headers",
"[",
"'Content-Type'",
"]",
"if",
"connection_library",
"==",
":excon",
"content_type",
"||=",
"'text/plain'",
"rslt",
"=",
"case",
"when",
"content_type",
".",
"start_with?",
"(",
"'text/plain'",
")",
"response",
".",
"body",
"when",
"content_type",
".",
"start_with?",
"(",
"'application/x-gzip'",
")",
"response",
".",
"body",
"when",
"content_type",
".",
"start_with?",
"(",
"'application/json'",
")",
"::",
"JSON",
".",
"parse",
"(",
"response",
".",
"body",
")",
"else",
"raise",
"OrientdbError",
",",
"\"unsuported content type: #{content_type}\"",
"end",
"rslt",
"end"
] | Processes a HTTP response. | [
"Processes",
"a",
"HTTP",
"response",
"."
] | d02d0d27e6ed19c5c5ff377a642355f617c785d7 | https://github.com/veny/orientdb4r/blob/d02d0d27e6ed19c5c5ff377a642355f617c785d7/lib/orientdb4r/rest/client.rb#L417-L450 |
23,530 | veny/orientdb4r | lib/orientdb4r/rest/client.rb | Orientdb4r.RestClient.compose_error_message | def compose_error_message(http_response, max_len=200)
msg = http_response.body.gsub("\n", ' ')
msg = "#{msg[0..max_len]} ..." if msg.size > max_len
msg
end | ruby | def compose_error_message(http_response, max_len=200)
msg = http_response.body.gsub("\n", ' ')
msg = "#{msg[0..max_len]} ..." if msg.size > max_len
msg
end | [
"def",
"compose_error_message",
"(",
"http_response",
",",
"max_len",
"=",
"200",
")",
"msg",
"=",
"http_response",
".",
"body",
".",
"gsub",
"(",
"\"\\n\"",
",",
"' '",
")",
"msg",
"=",
"\"#{msg[0..max_len]} ...\"",
"if",
"msg",
".",
"size",
">",
"max_len",
"msg",
"end"
] | Composes message of an error raised if the HTTP response doesn't
correspond with expectation. | [
"Composes",
"message",
"of",
"an",
"error",
"raised",
"if",
"the",
"HTTP",
"response",
"doesn",
"t",
"correspond",
"with",
"expectation",
"."
] | d02d0d27e6ed19c5c5ff377a642355f617c785d7 | https://github.com/veny/orientdb4r/blob/d02d0d27e6ed19c5c5ff377a642355f617c785d7/lib/orientdb4r/rest/client.rb#L456-L460 |
23,531 | blambeau/wlang | lib/wlang/dialect.rb | WLang.Dialect.dialects_for | def dialects_for(symbols)
info = self.class.tag_dispatching_name(symbols, "_diatag")
raise ArgumentError, "No tag for #{symbols}" unless respond_to?(info)
send(info)
end | ruby | def dialects_for(symbols)
info = self.class.tag_dispatching_name(symbols, "_diatag")
raise ArgumentError, "No tag for #{symbols}" unless respond_to?(info)
send(info)
end | [
"def",
"dialects_for",
"(",
"symbols",
")",
"info",
"=",
"self",
".",
"class",
".",
"tag_dispatching_name",
"(",
"symbols",
",",
"\"_diatag\"",
")",
"raise",
"ArgumentError",
",",
"\"No tag for #{symbols}\"",
"unless",
"respond_to?",
"(",
"info",
")",
"send",
"(",
"info",
")",
"end"
] | Returns the dialects used to parse the blocks associated with `symbols`, as
previously installed by `define_tag_method`. | [
"Returns",
"the",
"dialects",
"used",
"to",
"parse",
"the",
"blocks",
"associated",
"with",
"symbols",
"as",
"previously",
"installed",
"by",
"define_tag_method",
"."
] | 6e45f0c2ae2c8ff27accfab42e4af8ce6d1ff051 | https://github.com/blambeau/wlang/blob/6e45f0c2ae2c8ff27accfab42e4af8ce6d1ff051/lib/wlang/dialect.rb#L120-L124 |
23,532 | blambeau/wlang | lib/wlang/dialect.rb | WLang.Dialect.render | def render(fn, scope = nil, buffer = "")
if scope.nil?
case fn
when String then buffer << fn
when Proc then fn.call(self, buffer)
when Template then fn.call(@scope, buffer)
when TiltTemplate then buffer << fn.render(@scope)
else
raise ArgumentError, "Unable to render `#{fn}`"
end
buffer
else
with_scope(scope){ render(fn, nil, buffer) }
end
end | ruby | def render(fn, scope = nil, buffer = "")
if scope.nil?
case fn
when String then buffer << fn
when Proc then fn.call(self, buffer)
when Template then fn.call(@scope, buffer)
when TiltTemplate then buffer << fn.render(@scope)
else
raise ArgumentError, "Unable to render `#{fn}`"
end
buffer
else
with_scope(scope){ render(fn, nil, buffer) }
end
end | [
"def",
"render",
"(",
"fn",
",",
"scope",
"=",
"nil",
",",
"buffer",
"=",
"\"\"",
")",
"if",
"scope",
".",
"nil?",
"case",
"fn",
"when",
"String",
"then",
"buffer",
"<<",
"fn",
"when",
"Proc",
"then",
"fn",
".",
"call",
"(",
"self",
",",
"buffer",
")",
"when",
"Template",
"then",
"fn",
".",
"call",
"(",
"@scope",
",",
"buffer",
")",
"when",
"TiltTemplate",
"then",
"buffer",
"<<",
"fn",
".",
"render",
"(",
"@scope",
")",
"else",
"raise",
"ArgumentError",
",",
"\"Unable to render `#{fn}`\"",
"end",
"buffer",
"else",
"with_scope",
"(",
"scope",
")",
"{",
"render",
"(",
"fn",
",",
"nil",
",",
"buffer",
")",
"}",
"end",
"end"
] | rendering
Renders `fn` to a `buffer`, optionally extending the current scope.
`fn` can either be a String (immediately pushed on the buffer), a Proc (taken as a
tag block to render further), or a Template (taken as a partial to render in the
current scope).
Is `scope` is specified, the current scope is first branched to use to new one in
priority, then rendering applies and the newly created scope if then poped.
Returns the buffer. | [
"rendering",
"Renders",
"fn",
"to",
"a",
"buffer",
"optionally",
"extending",
"the",
"current",
"scope",
"."
] | 6e45f0c2ae2c8ff27accfab42e4af8ce6d1ff051 | https://github.com/blambeau/wlang/blob/6e45f0c2ae2c8ff27accfab42e4af8ce6d1ff051/lib/wlang/dialect.rb#L139-L153 |
23,533 | blambeau/wlang | lib/wlang/dialect.rb | WLang.Dialect.evaluate | def evaluate(expr, *default, &bl)
case expr
when Symbol, String
catch(:fail) do
return scope.evaluate(expr, self, *default, &bl)
end
raise NameError, "Unable to find `#{expr}` on #{scope}"
else
evaluate(render(expr), *default, &bl)
end
end | ruby | def evaluate(expr, *default, &bl)
case expr
when Symbol, String
catch(:fail) do
return scope.evaluate(expr, self, *default, &bl)
end
raise NameError, "Unable to find `#{expr}` on #{scope}"
else
evaluate(render(expr), *default, &bl)
end
end | [
"def",
"evaluate",
"(",
"expr",
",",
"*",
"default",
",",
"&",
"bl",
")",
"case",
"expr",
"when",
"Symbol",
",",
"String",
"catch",
"(",
":fail",
")",
"do",
"return",
"scope",
".",
"evaluate",
"(",
"expr",
",",
"self",
",",
"default",
",",
"bl",
")",
"end",
"raise",
"NameError",
",",
"\"Unable to find `#{expr}` on #{scope}\"",
"else",
"evaluate",
"(",
"render",
"(",
"expr",
")",
",",
"default",
",",
"bl",
")",
"end",
"end"
] | Evaluates `expr` in the current scope. `expr` can be either
* a Symbol or a String, taken as a dot expression to evaluate
* a Proc or a Template, first rendered and then evaluated
Evaluation is delegated to the scope (@see Scope#evaluate) and the result returned
by this method. | [
"Evaluates",
"expr",
"in",
"the",
"current",
"scope",
".",
"expr",
"can",
"be",
"either"
] | 6e45f0c2ae2c8ff27accfab42e4af8ce6d1ff051 | https://github.com/blambeau/wlang/blob/6e45f0c2ae2c8ff27accfab42e4af8ce6d1ff051/lib/wlang/dialect.rb#L183-L193 |
23,534 | tongueroo/forger | lib/forger/network.rb | Forger.Network.security_group_id | def security_group_id
resp = ec2.describe_security_groups(filters: [
{name: "vpc-id", values: [vpc_id]},
{name: "group-name", values: ["default"]}
])
resp.security_groups.first.group_id
end | ruby | def security_group_id
resp = ec2.describe_security_groups(filters: [
{name: "vpc-id", values: [vpc_id]},
{name: "group-name", values: ["default"]}
])
resp.security_groups.first.group_id
end | [
"def",
"security_group_id",
"resp",
"=",
"ec2",
".",
"describe_security_groups",
"(",
"filters",
":",
"[",
"{",
"name",
":",
"\"vpc-id\"",
",",
"values",
":",
"[",
"vpc_id",
"]",
"}",
",",
"{",
"name",
":",
"\"group-name\"",
",",
"values",
":",
"[",
"\"default\"",
"]",
"}",
"]",
")",
"resp",
".",
"security_groups",
".",
"first",
".",
"group_id",
"end"
] | default security group | [
"default",
"security",
"group"
] | 4146215b144bfd40874dfd0db3ad33ab0cc5f7a9 | https://github.com/tongueroo/forger/blob/4146215b144bfd40874dfd0db3ad33ab0cc5f7a9/lib/forger/network.rb#L39-L45 |
23,535 | bdurand/sunspot_index_queue | lib/sunspot/index_queue.rb | Sunspot.IndexQueue.process | def process
count = 0
loop do
entries = Entry.next_batch!(self)
if entries.nil? || entries.empty?
break if Entry.ready_count(self) == 0
else
batch = Batch.new(self, entries)
if defined?(@batch_handler) && @batch_handler
@batch_handler.call(batch)
else
batch.submit!
end
count += entries.select{|e| e.processed? }.size
end
end
count
end | ruby | def process
count = 0
loop do
entries = Entry.next_batch!(self)
if entries.nil? || entries.empty?
break if Entry.ready_count(self) == 0
else
batch = Batch.new(self, entries)
if defined?(@batch_handler) && @batch_handler
@batch_handler.call(batch)
else
batch.submit!
end
count += entries.select{|e| e.processed? }.size
end
end
count
end | [
"def",
"process",
"count",
"=",
"0",
"loop",
"do",
"entries",
"=",
"Entry",
".",
"next_batch!",
"(",
"self",
")",
"if",
"entries",
".",
"nil?",
"||",
"entries",
".",
"empty?",
"break",
"if",
"Entry",
".",
"ready_count",
"(",
"self",
")",
"==",
"0",
"else",
"batch",
"=",
"Batch",
".",
"new",
"(",
"self",
",",
"entries",
")",
"if",
"defined?",
"(",
"@batch_handler",
")",
"&&",
"@batch_handler",
"@batch_handler",
".",
"call",
"(",
"batch",
")",
"else",
"batch",
".",
"submit!",
"end",
"count",
"+=",
"entries",
".",
"select",
"{",
"|",
"e",
"|",
"e",
".",
"processed?",
"}",
".",
"size",
"end",
"end",
"count",
"end"
] | Process the queue. Exits when there are no more entries to process at the current time.
Returns the number of entries processed.
If any errors are encountered while processing the queue, they will be logged with the errors so they can
be fixed and tried again later. However, if Solr is refusing connections, the processing is stopped right
away and a Sunspot::IndexQueue::SolrNotResponding exception is raised. | [
"Process",
"the",
"queue",
".",
"Exits",
"when",
"there",
"are",
"no",
"more",
"entries",
"to",
"process",
"at",
"the",
"current",
"time",
".",
"Returns",
"the",
"number",
"of",
"entries",
"processed",
"."
] | 11c2846d0f0f6164de3fdde5202089823e7b9d78 | https://github.com/bdurand/sunspot_index_queue/blob/11c2846d0f0f6164de3fdde5202089823e7b9d78/lib/sunspot/index_queue.rb#L138-L155 |
23,536 | veny/orientdb4r | lib/orientdb4r/rest/model.rb | Orientdb4r.HashExtension.get_mandatory_attribute | def get_mandatory_attribute(name)
key = name.to_s
raise ::ArgumentError, "unknown attribute, name=#{key}" unless self.include? key
self[key]
end | ruby | def get_mandatory_attribute(name)
key = name.to_s
raise ::ArgumentError, "unknown attribute, name=#{key}" unless self.include? key
self[key]
end | [
"def",
"get_mandatory_attribute",
"(",
"name",
")",
"key",
"=",
"name",
".",
"to_s",
"raise",
"::",
"ArgumentError",
",",
"\"unknown attribute, name=#{key}\"",
"unless",
"self",
".",
"include?",
"key",
"self",
"[",
"key",
"]",
"end"
] | Gets an attribute value that has to be presented. | [
"Gets",
"an",
"attribute",
"value",
"that",
"has",
"to",
"be",
"presented",
"."
] | d02d0d27e6ed19c5c5ff377a642355f617c785d7 | https://github.com/veny/orientdb4r/blob/d02d0d27e6ed19c5c5ff377a642355f617c785d7/lib/orientdb4r/rest/model.rb#L10-L14 |
23,537 | veny/orientdb4r | lib/orientdb4r/rest/model.rb | Orientdb4r.OClass.property | def property(name)
raise ArgumentError, 'no properties defined on class' if properties.nil?
props = properties.select { |i| i['name'] == name.to_s }
raise ::ArgumentError, "unknown property, name=#{name}" if props.empty?
raise ::ArgumentError, "too many properties found, name=#{name}" if props.size > 1 # just to be sure
props[0]
end | ruby | def property(name)
raise ArgumentError, 'no properties defined on class' if properties.nil?
props = properties.select { |i| i['name'] == name.to_s }
raise ::ArgumentError, "unknown property, name=#{name}" if props.empty?
raise ::ArgumentError, "too many properties found, name=#{name}" if props.size > 1 # just to be sure
props[0]
end | [
"def",
"property",
"(",
"name",
")",
"raise",
"ArgumentError",
",",
"'no properties defined on class'",
"if",
"properties",
".",
"nil?",
"props",
"=",
"properties",
".",
"select",
"{",
"|",
"i",
"|",
"i",
"[",
"'name'",
"]",
"==",
"name",
".",
"to_s",
"}",
"raise",
"::",
"ArgumentError",
",",
"\"unknown property, name=#{name}\"",
"if",
"props",
".",
"empty?",
"raise",
"::",
"ArgumentError",
",",
"\"too many properties found, name=#{name}\"",
"if",
"props",
".",
"size",
">",
"1",
"# just to be sure",
"props",
"[",
"0",
"]",
"end"
] | Gets a property with the given name. | [
"Gets",
"a",
"property",
"with",
"the",
"given",
"name",
"."
] | d02d0d27e6ed19c5c5ff377a642355f617c785d7 | https://github.com/veny/orientdb4r/blob/d02d0d27e6ed19c5c5ff377a642355f617c785d7/lib/orientdb4r/rest/model.rb#L38-L44 |
23,538 | veny/orientdb4r | lib/orientdb4r/utils.rb | Orientdb4r.Utils.blank? | def blank?(str)
str.nil? or (str.is_a? String and str.strip.empty?)
end | ruby | def blank?(str)
str.nil? or (str.is_a? String and str.strip.empty?)
end | [
"def",
"blank?",
"(",
"str",
")",
"str",
".",
"nil?",
"or",
"(",
"str",
".",
"is_a?",
"String",
"and",
"str",
".",
"strip",
".",
"empty?",
")",
"end"
] | Checks if a given string is either 'nil' or empty string. | [
"Checks",
"if",
"a",
"given",
"string",
"is",
"either",
"nil",
"or",
"empty",
"string",
"."
] | d02d0d27e6ed19c5c5ff377a642355f617c785d7 | https://github.com/veny/orientdb4r/blob/d02d0d27e6ed19c5c5ff377a642355f617c785d7/lib/orientdb4r/utils.rb#L39-L41 |
23,539 | tongueroo/forger | lib/forger/template/context.rb | Forger::Template.Context.load_custom_helpers | def load_custom_helpers
Dir.glob("#{Forger.root}/app/helpers/**/*_helper.rb").each do |path|
filename = path.sub(%r{.*/},'').sub('.rb','')
module_name = filename.classify
# Prepend a period so require works FORGER_ROOT is set to a relative path
# without a period.
#
# Example: FORGER_ROOT=tmp/project
first_char = path[0..0]
path = "./#{path}" unless %w[. /].include?(first_char)
require path
self.class.send :include, module_name.constantize
end
end | ruby | def load_custom_helpers
Dir.glob("#{Forger.root}/app/helpers/**/*_helper.rb").each do |path|
filename = path.sub(%r{.*/},'').sub('.rb','')
module_name = filename.classify
# Prepend a period so require works FORGER_ROOT is set to a relative path
# without a period.
#
# Example: FORGER_ROOT=tmp/project
first_char = path[0..0]
path = "./#{path}" unless %w[. /].include?(first_char)
require path
self.class.send :include, module_name.constantize
end
end | [
"def",
"load_custom_helpers",
"Dir",
".",
"glob",
"(",
"\"#{Forger.root}/app/helpers/**/*_helper.rb\"",
")",
".",
"each",
"do",
"|",
"path",
"|",
"filename",
"=",
"path",
".",
"sub",
"(",
"%r{",
"}",
",",
"''",
")",
".",
"sub",
"(",
"'.rb'",
",",
"''",
")",
"module_name",
"=",
"filename",
".",
"classify",
"# Prepend a period so require works FORGER_ROOT is set to a relative path",
"# without a period.",
"#",
"# Example: FORGER_ROOT=tmp/project",
"first_char",
"=",
"path",
"[",
"0",
"..",
"0",
"]",
"path",
"=",
"\"./#{path}\"",
"unless",
"%w[",
".",
"/",
"]",
".",
"include?",
"(",
"first_char",
")",
"require",
"path",
"self",
".",
"class",
".",
"send",
":include",
",",
"module_name",
".",
"constantize",
"end",
"end"
] | Load custom helper methods from project | [
"Load",
"custom",
"helper",
"methods",
"from",
"project"
] | 4146215b144bfd40874dfd0db3ad33ab0cc5f7a9 | https://github.com/tongueroo/forger/blob/4146215b144bfd40874dfd0db3ad33ab0cc5f7a9/lib/forger/template/context.rb#L16-L30 |
23,540 | XOlator/wayback_gem | lib/wayback/base.rb | Wayback.Base.attrs | def attrs
@attrs.inject({}) do |attrs, (key, value)|
attrs.merge!(key => respond_to?(key) ? send(key) : value)
end
end | ruby | def attrs
@attrs.inject({}) do |attrs, (key, value)|
attrs.merge!(key => respond_to?(key) ? send(key) : value)
end
end | [
"def",
"attrs",
"@attrs",
".",
"inject",
"(",
"{",
"}",
")",
"do",
"|",
"attrs",
",",
"(",
"key",
",",
"value",
")",
"|",
"attrs",
".",
"merge!",
"(",
"key",
"=>",
"respond_to?",
"(",
"key",
")",
"?",
"send",
"(",
"key",
")",
":",
"value",
")",
"end",
"end"
] | Retrieve the attributes of an object
@return [Hash] | [
"Retrieve",
"the",
"attributes",
"of",
"an",
"object"
] | 1f4cdf3e8d023f34abffbce7ff46bc11b2ab8073 | https://github.com/XOlator/wayback_gem/blob/1f4cdf3e8d023f34abffbce7ff46bc11b2ab8073/lib/wayback/base.rb#L95-L99 |
23,541 | veny/orientdb4r | lib/orientdb4r/client.rb | Orientdb4r.Client.database_exists? | def database_exists?(options)
rslt = true
begin
get_database options
rescue OrientdbError
rslt = false
end
rslt
end | ruby | def database_exists?(options)
rslt = true
begin
get_database options
rescue OrientdbError
rslt = false
end
rslt
end | [
"def",
"database_exists?",
"(",
"options",
")",
"rslt",
"=",
"true",
"begin",
"get_database",
"options",
"rescue",
"OrientdbError",
"rslt",
"=",
"false",
"end",
"rslt",
"end"
] | Checks existence of a given database.
Client has not to be connected to see databases suitable to connect. | [
"Checks",
"existence",
"of",
"a",
"given",
"database",
".",
"Client",
"has",
"not",
"to",
"be",
"connected",
"to",
"see",
"databases",
"suitable",
"to",
"connect",
"."
] | d02d0d27e6ed19c5c5ff377a642355f617c785d7 | https://github.com/veny/orientdb4r/blob/d02d0d27e6ed19c5c5ff377a642355f617c785d7/lib/orientdb4r/client.rb#L92-L100 |
23,542 | veny/orientdb4r | lib/orientdb4r/client.rb | Orientdb4r.Client.class_exists? | def class_exists?(name)
rslt = true
begin
get_class name
rescue OrientdbError => e
raise e if e.is_a? ConnectionError and e.message == 'not connected' # workaround for AOP2 (unable to decorate already existing methods)
rslt = false
end
rslt
end | ruby | def class_exists?(name)
rslt = true
begin
get_class name
rescue OrientdbError => e
raise e if e.is_a? ConnectionError and e.message == 'not connected' # workaround for AOP2 (unable to decorate already existing methods)
rslt = false
end
rslt
end | [
"def",
"class_exists?",
"(",
"name",
")",
"rslt",
"=",
"true",
"begin",
"get_class",
"name",
"rescue",
"OrientdbError",
"=>",
"e",
"raise",
"e",
"if",
"e",
".",
"is_a?",
"ConnectionError",
"and",
"e",
".",
"message",
"==",
"'not connected'",
"# workaround for AOP2 (unable to decorate already existing methods)",
"rslt",
"=",
"false",
"end",
"rslt",
"end"
] | Checks existence of a given class. | [
"Checks",
"existence",
"of",
"a",
"given",
"class",
"."
] | d02d0d27e6ed19c5c5ff377a642355f617c785d7 | https://github.com/veny/orientdb4r/blob/d02d0d27e6ed19c5c5ff377a642355f617c785d7/lib/orientdb4r/client.rb#L208-L217 |
23,543 | veny/orientdb4r | lib/orientdb4r/client.rb | Orientdb4r.Client.drop_class | def drop_class(name, options={})
raise ArgumentError, 'class name is blank' if blank?(name)
# :mode=>:strict forbids to drop a class that is a super class for other one
opt_pattern = { :mode => :nil }
verify_options(options, opt_pattern)
if :strict == options[:mode]
response = get_database
children = response['classes'].select { |i| i['superClass'] == name }
unless children.empty?
raise OrientdbError, "class is super-class, cannot be deleted, name=#{name}"
end
end
command "DROP CLASS #{name}"
end | ruby | def drop_class(name, options={})
raise ArgumentError, 'class name is blank' if blank?(name)
# :mode=>:strict forbids to drop a class that is a super class for other one
opt_pattern = { :mode => :nil }
verify_options(options, opt_pattern)
if :strict == options[:mode]
response = get_database
children = response['classes'].select { |i| i['superClass'] == name }
unless children.empty?
raise OrientdbError, "class is super-class, cannot be deleted, name=#{name}"
end
end
command "DROP CLASS #{name}"
end | [
"def",
"drop_class",
"(",
"name",
",",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'class name is blank'",
"if",
"blank?",
"(",
"name",
")",
"# :mode=>:strict forbids to drop a class that is a super class for other one",
"opt_pattern",
"=",
"{",
":mode",
"=>",
":nil",
"}",
"verify_options",
"(",
"options",
",",
"opt_pattern",
")",
"if",
":strict",
"==",
"options",
"[",
":mode",
"]",
"response",
"=",
"get_database",
"children",
"=",
"response",
"[",
"'classes'",
"]",
".",
"select",
"{",
"|",
"i",
"|",
"i",
"[",
"'superClass'",
"]",
"==",
"name",
"}",
"unless",
"children",
".",
"empty?",
"raise",
"OrientdbError",
",",
"\"class is super-class, cannot be deleted, name=#{name}\"",
"end",
"end",
"command",
"\"DROP CLASS #{name}\"",
"end"
] | Removes a class from the schema. | [
"Removes",
"a",
"class",
"from",
"the",
"schema",
"."
] | d02d0d27e6ed19c5c5ff377a642355f617c785d7 | https://github.com/veny/orientdb4r/blob/d02d0d27e6ed19c5c5ff377a642355f617c785d7/lib/orientdb4r/client.rb#L222-L237 |
23,544 | veny/orientdb4r | lib/orientdb4r/client.rb | Orientdb4r.Client.create_property | def create_property(clazz, property, type, options={})
raise ArgumentError, "class name is blank" if blank?(clazz)
raise ArgumentError, "property name is blank" if blank?(property)
opt_pattern = {
:mandatory => :optional , :notnull => :optional, :min => :optional, :max => :optional,
:readonly => :optional, :linked_class => :optional
}
verify_options(options, opt_pattern)
cmd = "CREATE PROPERTY #{clazz}.#{property} #{type.to_s}"
# link?
if [:link, :linklist, :linkset, :linkmap].include? type.to_s.downcase.to_sym
raise ArgumentError, "defined linked-type, but not linked-class" unless options.include? :linked_class
cmd << " #{options[:linked_class]}"
end
command cmd
# ALTER PROPERTY ...
options.delete :linked_class # it's not option for ALTER
unless options.empty?
options.each do |k,v|
command "ALTER PROPERTY #{clazz}.#{property} #{k.to_s.upcase} #{v}"
end
end
end | ruby | def create_property(clazz, property, type, options={})
raise ArgumentError, "class name is blank" if blank?(clazz)
raise ArgumentError, "property name is blank" if blank?(property)
opt_pattern = {
:mandatory => :optional , :notnull => :optional, :min => :optional, :max => :optional,
:readonly => :optional, :linked_class => :optional
}
verify_options(options, opt_pattern)
cmd = "CREATE PROPERTY #{clazz}.#{property} #{type.to_s}"
# link?
if [:link, :linklist, :linkset, :linkmap].include? type.to_s.downcase.to_sym
raise ArgumentError, "defined linked-type, but not linked-class" unless options.include? :linked_class
cmd << " #{options[:linked_class]}"
end
command cmd
# ALTER PROPERTY ...
options.delete :linked_class # it's not option for ALTER
unless options.empty?
options.each do |k,v|
command "ALTER PROPERTY #{clazz}.#{property} #{k.to_s.upcase} #{v}"
end
end
end | [
"def",
"create_property",
"(",
"clazz",
",",
"property",
",",
"type",
",",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"\"class name is blank\"",
"if",
"blank?",
"(",
"clazz",
")",
"raise",
"ArgumentError",
",",
"\"property name is blank\"",
"if",
"blank?",
"(",
"property",
")",
"opt_pattern",
"=",
"{",
":mandatory",
"=>",
":optional",
",",
":notnull",
"=>",
":optional",
",",
":min",
"=>",
":optional",
",",
":max",
"=>",
":optional",
",",
":readonly",
"=>",
":optional",
",",
":linked_class",
"=>",
":optional",
"}",
"verify_options",
"(",
"options",
",",
"opt_pattern",
")",
"cmd",
"=",
"\"CREATE PROPERTY #{clazz}.#{property} #{type.to_s}\"",
"# link?",
"if",
"[",
":link",
",",
":linklist",
",",
":linkset",
",",
":linkmap",
"]",
".",
"include?",
"type",
".",
"to_s",
".",
"downcase",
".",
"to_sym",
"raise",
"ArgumentError",
",",
"\"defined linked-type, but not linked-class\"",
"unless",
"options",
".",
"include?",
":linked_class",
"cmd",
"<<",
"\" #{options[:linked_class]}\"",
"end",
"command",
"cmd",
"# ALTER PROPERTY ...",
"options",
".",
"delete",
":linked_class",
"# it's not option for ALTER",
"unless",
"options",
".",
"empty?",
"options",
".",
"each",
"do",
"|",
"k",
",",
"v",
"|",
"command",
"\"ALTER PROPERTY #{clazz}.#{property} #{k.to_s.upcase} #{v}\"",
"end",
"end",
"end"
] | Creates a new property in the schema.
You need to create the class before. | [
"Creates",
"a",
"new",
"property",
"in",
"the",
"schema",
".",
"You",
"need",
"to",
"create",
"the",
"class",
"before",
"."
] | d02d0d27e6ed19c5c5ff377a642355f617c785d7 | https://github.com/veny/orientdb4r/blob/d02d0d27e6ed19c5c5ff377a642355f617c785d7/lib/orientdb4r/client.rb#L243-L267 |
23,545 | veny/orientdb4r | lib/orientdb4r/client.rb | Orientdb4r.Client.time_around | def time_around(&block)
start = Time.now
rslt = block.call
query_log("#{aop_context[:class].name}##{aop_context[:method]}", "elapsed time = #{Time.now - start} [s]")
rslt
end | ruby | def time_around(&block)
start = Time.now
rslt = block.call
query_log("#{aop_context[:class].name}##{aop_context[:method]}", "elapsed time = #{Time.now - start} [s]")
rslt
end | [
"def",
"time_around",
"(",
"&",
"block",
")",
"start",
"=",
"Time",
".",
"now",
"rslt",
"=",
"block",
".",
"call",
"query_log",
"(",
"\"#{aop_context[:class].name}##{aop_context[:method]}\"",
",",
"\"elapsed time = #{Time.now - start} [s]\"",
")",
"rslt",
"end"
] | Around advice to meassure and print the method time. | [
"Around",
"advice",
"to",
"meassure",
"and",
"print",
"the",
"method",
"time",
"."
] | d02d0d27e6ed19c5c5ff377a642355f617c785d7 | https://github.com/veny/orientdb4r/blob/d02d0d27e6ed19c5c5ff377a642355f617c785d7/lib/orientdb4r/client.rb#L350-L355 |
23,546 | fromAtoB/awesome_xml | lib/awesome_xml/class_methods.rb | AwesomeXML.ClassMethods.constant_node | def constant_node(name, value, options = {})
attr_reader name.to_sym
define_method("parse_#{name}".to_sym) do
instance_variable_set("@#{name}", value)
end
register(name, options[:private])
end | ruby | def constant_node(name, value, options = {})
attr_reader name.to_sym
define_method("parse_#{name}".to_sym) do
instance_variable_set("@#{name}", value)
end
register(name, options[:private])
end | [
"def",
"constant_node",
"(",
"name",
",",
"value",
",",
"options",
"=",
"{",
"}",
")",
"attr_reader",
"name",
".",
"to_sym",
"define_method",
"(",
"\"parse_#{name}\"",
".",
"to_sym",
")",
"do",
"instance_variable_set",
"(",
"\"@#{name}\"",
",",
"value",
")",
"end",
"register",
"(",
"name",
",",
"options",
"[",
":private",
"]",
")",
"end"
] | Defines a method on your class returning a constant. | [
"Defines",
"a",
"method",
"on",
"your",
"class",
"returning",
"a",
"constant",
"."
] | 4011f0553cd0a62579f5ef4eae6d9ce64142aff0 | https://github.com/fromAtoB/awesome_xml/blob/4011f0553cd0a62579f5ef4eae6d9ce64142aff0/lib/awesome_xml/class_methods.rb#L31-L37 |
23,547 | fromAtoB/awesome_xml | lib/awesome_xml/class_methods.rb | AwesomeXML.ClassMethods.node | def node(name, type, options = {}, &block)
attr_reader name.to_sym
options[:local_context] = @local_context
xpath = NodeXPath.new(name, options).xpath
define_method("parse_#{name}".to_sym) do
evaluate_args = [xpath, AwesomeXML::Type.for(type, self.class.name), options]
instance_variable_set(
"@#{name}",
evaluate_nodes(*evaluate_args, &block)
)
end
register(name, options[:private])
end | ruby | def node(name, type, options = {}, &block)
attr_reader name.to_sym
options[:local_context] = @local_context
xpath = NodeXPath.new(name, options).xpath
define_method("parse_#{name}".to_sym) do
evaluate_args = [xpath, AwesomeXML::Type.for(type, self.class.name), options]
instance_variable_set(
"@#{name}",
evaluate_nodes(*evaluate_args, &block)
)
end
register(name, options[:private])
end | [
"def",
"node",
"(",
"name",
",",
"type",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"attr_reader",
"name",
".",
"to_sym",
"options",
"[",
":local_context",
"]",
"=",
"@local_context",
"xpath",
"=",
"NodeXPath",
".",
"new",
"(",
"name",
",",
"options",
")",
".",
"xpath",
"define_method",
"(",
"\"parse_#{name}\"",
".",
"to_sym",
")",
"do",
"evaluate_args",
"=",
"[",
"xpath",
",",
"AwesomeXML",
"::",
"Type",
".",
"for",
"(",
"type",
",",
"self",
".",
"class",
".",
"name",
")",
",",
"options",
"]",
"instance_variable_set",
"(",
"\"@#{name}\"",
",",
"evaluate_nodes",
"(",
"evaluate_args",
",",
"block",
")",
")",
"end",
"register",
"(",
"name",
",",
"options",
"[",
":private",
"]",
")",
"end"
] | Defines a method on your class returning a parsed value | [
"Defines",
"a",
"method",
"on",
"your",
"class",
"returning",
"a",
"parsed",
"value"
] | 4011f0553cd0a62579f5ef4eae6d9ce64142aff0 | https://github.com/fromAtoB/awesome_xml/blob/4011f0553cd0a62579f5ef4eae6d9ce64142aff0/lib/awesome_xml/class_methods.rb#L47-L59 |
23,548 | davidesantangelo/webinspector | lib/web_inspector/inspector.rb | WebInspector.Inspector.validate_url_domain | def validate_url_domain(u)
# Enforce a few bare standards before proceeding
u = "#{u}"
u = "/" if u.empty?
begin
# Look for evidence of a host. If this is a relative link
# like '/contact', add the page host.
domained_url = @host + u unless (u.split("/").first || "").match(/(\:|\.)/)
domained_url ||= u
# http the URL if it is missing
httpped_url = "http://" + domained_url unless domained_url[0..3] == 'http'
httpped_url ||= domained_url
# Make sure the URL parses
uri = URI.parse(httpped_url)
# Make sure the URL passes ICANN rules.
# The PublicSuffix object splits the domain and subdomain
# (unlike URI), which allows more liberal URL matching.
return PublicSuffix.parse(uri.host)
rescue URI::InvalidURIError, PublicSuffix::DomainInvalid
return false
end
end | ruby | def validate_url_domain(u)
# Enforce a few bare standards before proceeding
u = "#{u}"
u = "/" if u.empty?
begin
# Look for evidence of a host. If this is a relative link
# like '/contact', add the page host.
domained_url = @host + u unless (u.split("/").first || "").match(/(\:|\.)/)
domained_url ||= u
# http the URL if it is missing
httpped_url = "http://" + domained_url unless domained_url[0..3] == 'http'
httpped_url ||= domained_url
# Make sure the URL parses
uri = URI.parse(httpped_url)
# Make sure the URL passes ICANN rules.
# The PublicSuffix object splits the domain and subdomain
# (unlike URI), which allows more liberal URL matching.
return PublicSuffix.parse(uri.host)
rescue URI::InvalidURIError, PublicSuffix::DomainInvalid
return false
end
end | [
"def",
"validate_url_domain",
"(",
"u",
")",
"# Enforce a few bare standards before proceeding",
"u",
"=",
"\"#{u}\"",
"u",
"=",
"\"/\"",
"if",
"u",
".",
"empty?",
"begin",
"# Look for evidence of a host. If this is a relative link",
"# like '/contact', add the page host.",
"domained_url",
"=",
"@host",
"+",
"u",
"unless",
"(",
"u",
".",
"split",
"(",
"\"/\"",
")",
".",
"first",
"||",
"\"\"",
")",
".",
"match",
"(",
"/",
"\\:",
"\\.",
"/",
")",
"domained_url",
"||=",
"u",
"# http the URL if it is missing",
"httpped_url",
"=",
"\"http://\"",
"+",
"domained_url",
"unless",
"domained_url",
"[",
"0",
"..",
"3",
"]",
"==",
"'http'",
"httpped_url",
"||=",
"domained_url",
"# Make sure the URL parses",
"uri",
"=",
"URI",
".",
"parse",
"(",
"httpped_url",
")",
"# Make sure the URL passes ICANN rules.",
"# The PublicSuffix object splits the domain and subdomain",
"# (unlike URI), which allows more liberal URL matching.",
"return",
"PublicSuffix",
".",
"parse",
"(",
"uri",
".",
"host",
")",
"rescue",
"URI",
"::",
"InvalidURIError",
",",
"PublicSuffix",
"::",
"DomainInvalid",
"return",
"false",
"end",
"end"
] | Normalize and validate the URLs on the page for comparison | [
"Normalize",
"and",
"validate",
"the",
"URLs",
"on",
"the",
"page",
"for",
"comparison"
] | 430f4e74d7a4977736b99fd0989c5acfd3a57b1d | https://github.com/davidesantangelo/webinspector/blob/430f4e74d7a4977736b99fd0989c5acfd3a57b1d/lib/web_inspector/inspector.rb#L79-L104 |
23,549 | Antondomashnev/danger-missed_localizable_strings | lib/missed_localizable_strings/plugin.rb | Danger.DangerMissedLocalizableStrings.check_localizable_omissions | def check_localizable_omissions
localizable_files = not_deleted_localizable_files
keys_by_file = extract_keys_from_files(localizable_files)
entries = localizable_strings_missed_entries(keys_by_file)
print_missed_entries entries unless entries.empty?
end | ruby | def check_localizable_omissions
localizable_files = not_deleted_localizable_files
keys_by_file = extract_keys_from_files(localizable_files)
entries = localizable_strings_missed_entries(keys_by_file)
print_missed_entries entries unless entries.empty?
end | [
"def",
"check_localizable_omissions",
"localizable_files",
"=",
"not_deleted_localizable_files",
"keys_by_file",
"=",
"extract_keys_from_files",
"(",
"localizable_files",
")",
"entries",
"=",
"localizable_strings_missed_entries",
"(",
"keys_by_file",
")",
"print_missed_entries",
"entries",
"unless",
"entries",
".",
"empty?",
"end"
] | Checks whether there are any missed entries in
all Localizable.strings from PR's changeset
files and prints out any found entries.
@return [void] | [
"Checks",
"whether",
"there",
"are",
"any",
"missed",
"entries",
"in",
"all",
"Localizable",
".",
"strings",
"from",
"PR",
"s",
"changeset",
"files",
"and",
"prints",
"out",
"any",
"found",
"entries",
"."
] | 5f149ff97616a3bce53522842685e29571075b97 | https://github.com/Antondomashnev/danger-missed_localizable_strings/blob/5f149ff97616a3bce53522842685e29571075b97/lib/missed_localizable_strings/plugin.rb#L24-L29 |
23,550 | Antondomashnev/danger-missed_localizable_strings | lib/missed_localizable_strings/plugin.rb | Danger.DangerMissedLocalizableStrings.extract_keys_from_files | def extract_keys_from_files(localizable_files)
keys_from_file = {}
localizable_files.each do |file|
lines = File.readlines(file)
# Grab just the keys, we don't need the translation
keys = lines.map { |e| e.split("=").first }
# Filter newlines and comments
keys = keys.select do |e|
e != "\n" && !e.start_with?("/*") && !e.start_with?("//")
end
keys_from_file[file] = keys
end
keys_from_file
end | ruby | def extract_keys_from_files(localizable_files)
keys_from_file = {}
localizable_files.each do |file|
lines = File.readlines(file)
# Grab just the keys, we don't need the translation
keys = lines.map { |e| e.split("=").first }
# Filter newlines and comments
keys = keys.select do |e|
e != "\n" && !e.start_with?("/*") && !e.start_with?("//")
end
keys_from_file[file] = keys
end
keys_from_file
end | [
"def",
"extract_keys_from_files",
"(",
"localizable_files",
")",
"keys_from_file",
"=",
"{",
"}",
"localizable_files",
".",
"each",
"do",
"|",
"file",
"|",
"lines",
"=",
"File",
".",
"readlines",
"(",
"file",
")",
"# Grab just the keys, we don't need the translation",
"keys",
"=",
"lines",
".",
"map",
"{",
"|",
"e",
"|",
"e",
".",
"split",
"(",
"\"=\"",
")",
".",
"first",
"}",
"# Filter newlines and comments",
"keys",
"=",
"keys",
".",
"select",
"do",
"|",
"e",
"|",
"e",
"!=",
"\"\\n\"",
"&&",
"!",
"e",
".",
"start_with?",
"(",
"\"/*\"",
")",
"&&",
"!",
"e",
".",
"start_with?",
"(",
"\"//\"",
")",
"end",
"keys_from_file",
"[",
"file",
"]",
"=",
"keys",
"end",
"keys_from_file",
"end"
] | A hash with keyes - Localizable.strings file and
values - modified keys from file | [
"A",
"hash",
"with",
"keyes",
"-",
"Localizable",
".",
"strings",
"file",
"and",
"values",
"-",
"modified",
"keys",
"from",
"file"
] | 5f149ff97616a3bce53522842685e29571075b97 | https://github.com/Antondomashnev/danger-missed_localizable_strings/blob/5f149ff97616a3bce53522842685e29571075b97/lib/missed_localizable_strings/plugin.rb#L82-L96 |
23,551 | caseyscarborough/omdbapi | lib/omdbapi/client.rb | OMDB.Client.title | def title(title, options = {})
options.merge!(title: title)
params = build_params(options)
get '/', params
end | ruby | def title(title, options = {})
options.merge!(title: title)
params = build_params(options)
get '/', params
end | [
"def",
"title",
"(",
"title",
",",
"options",
"=",
"{",
"}",
")",
"options",
".",
"merge!",
"(",
"title",
":",
"title",
")",
"params",
"=",
"build_params",
"(",
"options",
")",
"get",
"'/'",
",",
"params",
"end"
] | Retrieves a movie or show based on its title.
@param title [String] The title of the movie or show.
@param options [Hash] Options for the title, plot or year.
@option options [Integer] :year The year of the movie.
@option options [String] :plot 'short' (default), 'full'
@option options [Integer] :season The season to retrieve.
@option options [Integer] :episode The episode to retrieve. Requires the season parameter.
@option options [Boolean] :tomatoes Include Rotten Tomatoes ratings.
@return [Hash]
@example
OMDB.title('Game of Thrones') | [
"Retrieves",
"a",
"movie",
"or",
"show",
"based",
"on",
"its",
"title",
"."
] | 3061e8edc8aed5ed1f278b1162b1461fb53893be | https://github.com/caseyscarborough/omdbapi/blob/3061e8edc8aed5ed1f278b1162b1461fb53893be/lib/omdbapi/client.rb#L23-L27 |
23,552 | caseyscarborough/omdbapi | lib/omdbapi/client.rb | OMDB.Client.id | def id(imdb_id, options = {})
options.merge!(id: imdb_id)
params = build_params(options)
get '/', params
end | ruby | def id(imdb_id, options = {})
options.merge!(id: imdb_id)
params = build_params(options)
get '/', params
end | [
"def",
"id",
"(",
"imdb_id",
",",
"options",
"=",
"{",
"}",
")",
"options",
".",
"merge!",
"(",
"id",
":",
"imdb_id",
")",
"params",
"=",
"build_params",
"(",
"options",
")",
"get",
"'/'",
",",
"params",
"end"
] | Retrieves a movie or show based on its IMDb ID.
@param imdb_id [String] The IMDb ID of the movie or show.
@option options [Boolean] :tomatoes Include Rotten Tomatoes ratings.
@return [Hash]
@example
OMDB.id('tt0944947') | [
"Retrieves",
"a",
"movie",
"or",
"show",
"based",
"on",
"its",
"IMDb",
"ID",
"."
] | 3061e8edc8aed5ed1f278b1162b1461fb53893be | https://github.com/caseyscarborough/omdbapi/blob/3061e8edc8aed5ed1f278b1162b1461fb53893be/lib/omdbapi/client.rb#L36-L40 |
23,553 | caseyscarborough/omdbapi | lib/omdbapi/client.rb | OMDB.Client.search | def search(title)
results = get '/', { s: title }
if results[:search]
# Return the title if there is only one result, otherwise return the seach results
search = results.search
search.size == 1 ? title(search[0].title) : search
else
results
end
end | ruby | def search(title)
results = get '/', { s: title }
if results[:search]
# Return the title if there is only one result, otherwise return the seach results
search = results.search
search.size == 1 ? title(search[0].title) : search
else
results
end
end | [
"def",
"search",
"(",
"title",
")",
"results",
"=",
"get",
"'/'",
",",
"{",
"s",
":",
"title",
"}",
"if",
"results",
"[",
":search",
"]",
"# Return the title if there is only one result, otherwise return the seach results",
"search",
"=",
"results",
".",
"search",
"search",
".",
"size",
"==",
"1",
"?",
"title",
"(",
"search",
"[",
"0",
"]",
".",
"title",
")",
":",
"search",
"else",
"results",
"end",
"end"
] | Search for a movie by its title.
@param title [String] The title of the movie or show to search for.
@return [Array, Hash]
@example
OMDB.find('Star Wars') | [
"Search",
"for",
"a",
"movie",
"by",
"its",
"title",
"."
] | 3061e8edc8aed5ed1f278b1162b1461fb53893be | https://github.com/caseyscarborough/omdbapi/blob/3061e8edc8aed5ed1f278b1162b1461fb53893be/lib/omdbapi/client.rb#L48-L57 |
23,554 | caseyscarborough/omdbapi | lib/omdbapi/client.rb | OMDB.Client.convert_hash_keys | def convert_hash_keys(value)
case value
when Array
value.map { |v| convert_hash_keys(v) }
when Hash
Hash[value.map { |k, v| [k.to_snake_case.to_sym, convert_hash_keys(v)] }]
else
value
end
end | ruby | def convert_hash_keys(value)
case value
when Array
value.map { |v| convert_hash_keys(v) }
when Hash
Hash[value.map { |k, v| [k.to_snake_case.to_sym, convert_hash_keys(v)] }]
else
value
end
end | [
"def",
"convert_hash_keys",
"(",
"value",
")",
"case",
"value",
"when",
"Array",
"value",
".",
"map",
"{",
"|",
"v",
"|",
"convert_hash_keys",
"(",
"v",
")",
"}",
"when",
"Hash",
"Hash",
"[",
"value",
".",
"map",
"{",
"|",
"k",
",",
"v",
"|",
"[",
"k",
".",
"to_snake_case",
".",
"to_sym",
",",
"convert_hash_keys",
"(",
"v",
")",
"]",
"}",
"]",
"else",
"value",
"end",
"end"
] | Performs a method on all hash keys.
@param value [Array, Hash, Object]
@return [Array, Hash, Object] | [
"Performs",
"a",
"method",
"on",
"all",
"hash",
"keys",
"."
] | 3061e8edc8aed5ed1f278b1162b1461fb53893be | https://github.com/caseyscarborough/omdbapi/blob/3061e8edc8aed5ed1f278b1162b1461fb53893be/lib/omdbapi/client.rb#L67-L76 |
23,555 | caseyscarborough/omdbapi | lib/omdbapi/client.rb | OMDB.Client.build_params | def build_params(options)
params = {}
params[:t] = options[:title] if options[:title]
params[:i] = options[:id] if options[:id]
params[:y] = options[:year] if options[:year]
params[:plot] = options[:plot] if options[:plot]
params[:season] = options[:season] if options[:season]
params[:episode] = options[:episode] if options[:episode]
params[:type] = options[:type] if options[:type]
params[:tomatoes] = options[:tomatoes] if options[:tomatoes]
params
end | ruby | def build_params(options)
params = {}
params[:t] = options[:title] if options[:title]
params[:i] = options[:id] if options[:id]
params[:y] = options[:year] if options[:year]
params[:plot] = options[:plot] if options[:plot]
params[:season] = options[:season] if options[:season]
params[:episode] = options[:episode] if options[:episode]
params[:type] = options[:type] if options[:type]
params[:tomatoes] = options[:tomatoes] if options[:tomatoes]
params
end | [
"def",
"build_params",
"(",
"options",
")",
"params",
"=",
"{",
"}",
"params",
"[",
":t",
"]",
"=",
"options",
"[",
":title",
"]",
"if",
"options",
"[",
":title",
"]",
"params",
"[",
":i",
"]",
"=",
"options",
"[",
":id",
"]",
"if",
"options",
"[",
":id",
"]",
"params",
"[",
":y",
"]",
"=",
"options",
"[",
":year",
"]",
"if",
"options",
"[",
":year",
"]",
"params",
"[",
":plot",
"]",
"=",
"options",
"[",
":plot",
"]",
"if",
"options",
"[",
":plot",
"]",
"params",
"[",
":season",
"]",
"=",
"options",
"[",
":season",
"]",
"if",
"options",
"[",
":season",
"]",
"params",
"[",
":episode",
"]",
"=",
"options",
"[",
":episode",
"]",
"if",
"options",
"[",
":episode",
"]",
"params",
"[",
":type",
"]",
"=",
"options",
"[",
":type",
"]",
"if",
"options",
"[",
":type",
"]",
"params",
"[",
":tomatoes",
"]",
"=",
"options",
"[",
":tomatoes",
"]",
"if",
"options",
"[",
":tomatoes",
"]",
"params",
"end"
] | Build parameters for a request.
@param options [Hash] The optional parameters.
@return [Hash] | [
"Build",
"parameters",
"for",
"a",
"request",
"."
] | 3061e8edc8aed5ed1f278b1162b1461fb53893be | https://github.com/caseyscarborough/omdbapi/blob/3061e8edc8aed5ed1f278b1162b1461fb53893be/lib/omdbapi/client.rb#L82-L93 |
23,556 | veny/orientdb4r | lib/orientdb4r/rest/restclient_node.rb | Orientdb4r.RestClientNode.transform_error2_response | def transform_error2_response(error)
response = ["#{error.message}: #{error.http_body}", error.http_code]
def response.body
self[0]
end
def response.code
self[1]
end
response
end | ruby | def transform_error2_response(error)
response = ["#{error.message}: #{error.http_body}", error.http_code]
def response.body
self[0]
end
def response.code
self[1]
end
response
end | [
"def",
"transform_error2_response",
"(",
"error",
")",
"response",
"=",
"[",
"\"#{error.message}: #{error.http_body}\"",
",",
"error",
".",
"http_code",
"]",
"def",
"response",
".",
"body",
"self",
"[",
"0",
"]",
"end",
"def",
"response",
".",
"code",
"self",
"[",
"1",
"]",
"end",
"response",
"end"
] | Fakes an error thrown by the library into a response object with methods
'code' and 'body'. | [
"Fakes",
"an",
"error",
"thrown",
"by",
"the",
"library",
"into",
"a",
"response",
"object",
"with",
"methods",
"code",
"and",
"body",
"."
] | d02d0d27e6ed19c5c5ff377a642355f617c785d7 | https://github.com/veny/orientdb4r/blob/d02d0d27e6ed19c5c5ff377a642355f617c785d7/lib/orientdb4r/rest/restclient_node.rb#L64-L73 |
23,557 | veny/orientdb4r | lib/orientdb4r/rest/excon_node.rb | Orientdb4r.ExconNode.connection | def connection
return @connection unless @connection.nil?
options = {}
options[:proxy] = proxy unless proxy.nil?
options[:scheme], options[:host], options[:port]=url.scan(/(.*):\/\/(.*):([0-9]*)/).first
@connection ||= Excon::Connection.new(options)
#:read_timeout => self.class.read_timeout,
#:write_timeout => self.class.write_timeout,
#:connect_timeout => self.class.connect_timeout
end | ruby | def connection
return @connection unless @connection.nil?
options = {}
options[:proxy] = proxy unless proxy.nil?
options[:scheme], options[:host], options[:port]=url.scan(/(.*):\/\/(.*):([0-9]*)/).first
@connection ||= Excon::Connection.new(options)
#:read_timeout => self.class.read_timeout,
#:write_timeout => self.class.write_timeout,
#:connect_timeout => self.class.connect_timeout
end | [
"def",
"connection",
"return",
"@connection",
"unless",
"@connection",
".",
"nil?",
"options",
"=",
"{",
"}",
"options",
"[",
":proxy",
"]",
"=",
"proxy",
"unless",
"proxy",
".",
"nil?",
"options",
"[",
":scheme",
"]",
",",
"options",
"[",
":host",
"]",
",",
"options",
"[",
":port",
"]",
"=",
"url",
".",
"scan",
"(",
"/",
"\\/",
"\\/",
"/",
")",
".",
"first",
"@connection",
"||=",
"Excon",
"::",
"Connection",
".",
"new",
"(",
"options",
")",
"#:read_timeout => self.class.read_timeout,",
"#:write_timeout => self.class.write_timeout,",
"#:connect_timeout => self.class.connect_timeout",
"end"
] | Gets Excon connection. | [
"Gets",
"Excon",
"connection",
"."
] | d02d0d27e6ed19c5c5ff377a642355f617c785d7 | https://github.com/veny/orientdb4r/blob/d02d0d27e6ed19c5c5ff377a642355f617c785d7/lib/orientdb4r/rest/excon_node.rb#L83-L94 |
23,558 | veny/orientdb4r | lib/orientdb4r/rest/excon_node.rb | Orientdb4r.ExconNode.headers | def headers(options)
rslt = {'Authorization' => basic_auth_header(options[:user], options[:password])}
rslt['Cookie'] = "#{SESSION_COOKIE_NAME}=#{session_id}" if !session_id.nil? and !options[:no_session]
rslt['Content-Type'] = options[:content_type] if options.include? :content_type
rslt['User-Agent'] = user_agent unless user_agent.nil?
rslt
end | ruby | def headers(options)
rslt = {'Authorization' => basic_auth_header(options[:user], options[:password])}
rslt['Cookie'] = "#{SESSION_COOKIE_NAME}=#{session_id}" if !session_id.nil? and !options[:no_session]
rslt['Content-Type'] = options[:content_type] if options.include? :content_type
rslt['User-Agent'] = user_agent unless user_agent.nil?
rslt
end | [
"def",
"headers",
"(",
"options",
")",
"rslt",
"=",
"{",
"'Authorization'",
"=>",
"basic_auth_header",
"(",
"options",
"[",
":user",
"]",
",",
"options",
"[",
":password",
"]",
")",
"}",
"rslt",
"[",
"'Cookie'",
"]",
"=",
"\"#{SESSION_COOKIE_NAME}=#{session_id}\"",
"if",
"!",
"session_id",
".",
"nil?",
"and",
"!",
"options",
"[",
":no_session",
"]",
"rslt",
"[",
"'Content-Type'",
"]",
"=",
"options",
"[",
":content_type",
"]",
"if",
"options",
".",
"include?",
":content_type",
"rslt",
"[",
"'User-Agent'",
"]",
"=",
"user_agent",
"unless",
"user_agent",
".",
"nil?",
"rslt",
"end"
] | Get request headers prepared with session ID and Basic Auth. | [
"Get",
"request",
"headers",
"prepared",
"with",
"session",
"ID",
"and",
"Basic",
"Auth",
"."
] | d02d0d27e6ed19c5c5ff377a642355f617c785d7 | https://github.com/veny/orientdb4r/blob/d02d0d27e6ed19c5c5ff377a642355f617c785d7/lib/orientdb4r/rest/excon_node.rb#L98-L104 |
23,559 | OSC/ood_appkit | lib/ood_appkit/configuration.rb | OodAppkit.Configuration.set_default_configuration | def set_default_configuration
ActiveSupport::Deprecation.warn("The environment variable RAILS_DATAROOT will be deprecated in an upcoming release, please use OOD_DATAROOT instead.") if ENV['RAILS_DATAROOT']
self.dataroot = ENV['OOD_DATAROOT'] || ENV['RAILS_DATAROOT']
self.dataroot ||= "~/#{ENV['OOD_PORTAL'] || "ondemand"}/data/#{ENV['APP_TOKEN']}" if ENV['APP_TOKEN']
# Add markdown template support
self.markdown = Redcarpet::Markdown.new(
Redcarpet::Render::HTML,
autolink: true,
tables: true,
strikethrough: true,
fenced_code_blocks: true,
no_intra_emphasis: true
)
# Initialize URL handlers for system apps
self.public = Urls::Public.new(
title: ENV['OOD_PUBLIC_TITLE'] || 'Public Assets',
base_url: ENV['OOD_PUBLIC_URL'] || '/public'
)
self.dashboard = Urls::Dashboard.new(
title: ENV['OOD_DASHBOARD_TITLE'] || 'Open OnDemand',
base_url: ENV['OOD_DASHBOARD_URL'] || '/pun/sys/dashboard'
)
self.shell = Urls::Shell.new(
title: ENV['OOD_SHELL_TITLE'] || 'Shell',
base_url: ENV['OOD_SHELL_URL'] || '/pun/sys/shell'
)
self.files = Urls::Files.new(
title: ENV['OOD_FILES_TITLE'] || 'Files',
base_url: ENV['OOD_FILES_URL'] || '/pun/sys/files'
)
self.editor = Urls::Editor.new(
title: ENV['OOD_EDITOR_TITLE'] || 'Editor',
base_url: ENV['OOD_EDITOR_URL'] || '/pun/sys/file-editor'
)
# Add routes for useful features
self.routes = OpenStruct.new(
files_rack_app: true,
wiki: true
)
# Override Bootstrap SASS variables
self.bootstrap = OpenStruct.new(
navbar_inverse_bg: '#53565a',
navbar_inverse_link_color: '#fff',
navbar_inverse_color: '$navbar-inverse-link-color',
navbar_inverse_link_hover_color: 'darken($navbar-inverse-link-color, 20%)',
navbar_inverse_brand_color: '$navbar-inverse-link-color',
navbar_inverse_brand_hover_color: '$navbar-inverse-link-hover-color'
)
ENV.each {|k, v| /^BOOTSTRAP_(?<name>.+)$/ =~ k ? self.bootstrap[name.downcase] = v : nil}
self.enable_log_formatter = ::Rails.env.production?
end | ruby | def set_default_configuration
ActiveSupport::Deprecation.warn("The environment variable RAILS_DATAROOT will be deprecated in an upcoming release, please use OOD_DATAROOT instead.") if ENV['RAILS_DATAROOT']
self.dataroot = ENV['OOD_DATAROOT'] || ENV['RAILS_DATAROOT']
self.dataroot ||= "~/#{ENV['OOD_PORTAL'] || "ondemand"}/data/#{ENV['APP_TOKEN']}" if ENV['APP_TOKEN']
# Add markdown template support
self.markdown = Redcarpet::Markdown.new(
Redcarpet::Render::HTML,
autolink: true,
tables: true,
strikethrough: true,
fenced_code_blocks: true,
no_intra_emphasis: true
)
# Initialize URL handlers for system apps
self.public = Urls::Public.new(
title: ENV['OOD_PUBLIC_TITLE'] || 'Public Assets',
base_url: ENV['OOD_PUBLIC_URL'] || '/public'
)
self.dashboard = Urls::Dashboard.new(
title: ENV['OOD_DASHBOARD_TITLE'] || 'Open OnDemand',
base_url: ENV['OOD_DASHBOARD_URL'] || '/pun/sys/dashboard'
)
self.shell = Urls::Shell.new(
title: ENV['OOD_SHELL_TITLE'] || 'Shell',
base_url: ENV['OOD_SHELL_URL'] || '/pun/sys/shell'
)
self.files = Urls::Files.new(
title: ENV['OOD_FILES_TITLE'] || 'Files',
base_url: ENV['OOD_FILES_URL'] || '/pun/sys/files'
)
self.editor = Urls::Editor.new(
title: ENV['OOD_EDITOR_TITLE'] || 'Editor',
base_url: ENV['OOD_EDITOR_URL'] || '/pun/sys/file-editor'
)
# Add routes for useful features
self.routes = OpenStruct.new(
files_rack_app: true,
wiki: true
)
# Override Bootstrap SASS variables
self.bootstrap = OpenStruct.new(
navbar_inverse_bg: '#53565a',
navbar_inverse_link_color: '#fff',
navbar_inverse_color: '$navbar-inverse-link-color',
navbar_inverse_link_hover_color: 'darken($navbar-inverse-link-color, 20%)',
navbar_inverse_brand_color: '$navbar-inverse-link-color',
navbar_inverse_brand_hover_color: '$navbar-inverse-link-hover-color'
)
ENV.each {|k, v| /^BOOTSTRAP_(?<name>.+)$/ =~ k ? self.bootstrap[name.downcase] = v : nil}
self.enable_log_formatter = ::Rails.env.production?
end | [
"def",
"set_default_configuration",
"ActiveSupport",
"::",
"Deprecation",
".",
"warn",
"(",
"\"The environment variable RAILS_DATAROOT will be deprecated in an upcoming release, please use OOD_DATAROOT instead.\"",
")",
"if",
"ENV",
"[",
"'RAILS_DATAROOT'",
"]",
"self",
".",
"dataroot",
"=",
"ENV",
"[",
"'OOD_DATAROOT'",
"]",
"||",
"ENV",
"[",
"'RAILS_DATAROOT'",
"]",
"self",
".",
"dataroot",
"||=",
"\"~/#{ENV['OOD_PORTAL'] || \"ondemand\"}/data/#{ENV['APP_TOKEN']}\"",
"if",
"ENV",
"[",
"'APP_TOKEN'",
"]",
"# Add markdown template support",
"self",
".",
"markdown",
"=",
"Redcarpet",
"::",
"Markdown",
".",
"new",
"(",
"Redcarpet",
"::",
"Render",
"::",
"HTML",
",",
"autolink",
":",
"true",
",",
"tables",
":",
"true",
",",
"strikethrough",
":",
"true",
",",
"fenced_code_blocks",
":",
"true",
",",
"no_intra_emphasis",
":",
"true",
")",
"# Initialize URL handlers for system apps",
"self",
".",
"public",
"=",
"Urls",
"::",
"Public",
".",
"new",
"(",
"title",
":",
"ENV",
"[",
"'OOD_PUBLIC_TITLE'",
"]",
"||",
"'Public Assets'",
",",
"base_url",
":",
"ENV",
"[",
"'OOD_PUBLIC_URL'",
"]",
"||",
"'/public'",
")",
"self",
".",
"dashboard",
"=",
"Urls",
"::",
"Dashboard",
".",
"new",
"(",
"title",
":",
"ENV",
"[",
"'OOD_DASHBOARD_TITLE'",
"]",
"||",
"'Open OnDemand'",
",",
"base_url",
":",
"ENV",
"[",
"'OOD_DASHBOARD_URL'",
"]",
"||",
"'/pun/sys/dashboard'",
")",
"self",
".",
"shell",
"=",
"Urls",
"::",
"Shell",
".",
"new",
"(",
"title",
":",
"ENV",
"[",
"'OOD_SHELL_TITLE'",
"]",
"||",
"'Shell'",
",",
"base_url",
":",
"ENV",
"[",
"'OOD_SHELL_URL'",
"]",
"||",
"'/pun/sys/shell'",
")",
"self",
".",
"files",
"=",
"Urls",
"::",
"Files",
".",
"new",
"(",
"title",
":",
"ENV",
"[",
"'OOD_FILES_TITLE'",
"]",
"||",
"'Files'",
",",
"base_url",
":",
"ENV",
"[",
"'OOD_FILES_URL'",
"]",
"||",
"'/pun/sys/files'",
")",
"self",
".",
"editor",
"=",
"Urls",
"::",
"Editor",
".",
"new",
"(",
"title",
":",
"ENV",
"[",
"'OOD_EDITOR_TITLE'",
"]",
"||",
"'Editor'",
",",
"base_url",
":",
"ENV",
"[",
"'OOD_EDITOR_URL'",
"]",
"||",
"'/pun/sys/file-editor'",
")",
"# Add routes for useful features",
"self",
".",
"routes",
"=",
"OpenStruct",
".",
"new",
"(",
"files_rack_app",
":",
"true",
",",
"wiki",
":",
"true",
")",
"# Override Bootstrap SASS variables",
"self",
".",
"bootstrap",
"=",
"OpenStruct",
".",
"new",
"(",
"navbar_inverse_bg",
":",
"'#53565a'",
",",
"navbar_inverse_link_color",
":",
"'#fff'",
",",
"navbar_inverse_color",
":",
"'$navbar-inverse-link-color'",
",",
"navbar_inverse_link_hover_color",
":",
"'darken($navbar-inverse-link-color, 20%)'",
",",
"navbar_inverse_brand_color",
":",
"'$navbar-inverse-link-color'",
",",
"navbar_inverse_brand_hover_color",
":",
"'$navbar-inverse-link-hover-color'",
")",
"ENV",
".",
"each",
"{",
"|",
"k",
",",
"v",
"|",
"/",
"/",
"=~",
"k",
"?",
"self",
".",
"bootstrap",
"[",
"name",
".",
"downcase",
"]",
"=",
"v",
":",
"nil",
"}",
"self",
".",
"enable_log_formatter",
"=",
"::",
"Rails",
".",
"env",
".",
"production?",
"end"
] | Sets the default configuration for this object.
@return [void] | [
"Sets",
"the",
"default",
"configuration",
"for",
"this",
"object",
"."
] | ea1435d4bbff47cd1786f84096f415441089a7f5 | https://github.com/OSC/ood_appkit/blob/ea1435d4bbff47cd1786f84096f415441089a7f5/lib/ood_appkit/configuration.rb#L68-L123 |
23,560 | OSC/ood_appkit | lib/ood_appkit/configuration.rb | OodAppkit.Configuration.parse_clusters | def parse_clusters(config)
OodCore::Clusters.load_file(config || '/etc/ood/config/clusters.d')
rescue OodCore::ConfigurationNotFound
OodCore::Clusters.new([])
end | ruby | def parse_clusters(config)
OodCore::Clusters.load_file(config || '/etc/ood/config/clusters.d')
rescue OodCore::ConfigurationNotFound
OodCore::Clusters.new([])
end | [
"def",
"parse_clusters",
"(",
"config",
")",
"OodCore",
"::",
"Clusters",
".",
"load_file",
"(",
"config",
"||",
"'/etc/ood/config/clusters.d'",
")",
"rescue",
"OodCore",
"::",
"ConfigurationNotFound",
"OodCore",
"::",
"Clusters",
".",
"new",
"(",
"[",
"]",
")",
"end"
] | Read in cluster config and parse it | [
"Read",
"in",
"cluster",
"config",
"and",
"parse",
"it"
] | ea1435d4bbff47cd1786f84096f415441089a7f5 | https://github.com/OSC/ood_appkit/blob/ea1435d4bbff47cd1786f84096f415441089a7f5/lib/ood_appkit/configuration.rb#L127-L131 |
23,561 | limarka/pandoc_abnt | lib/pandoc_abnt/quadro_filter.rb | PandocAbnt.QuadroFilter.convert_to_latex | def convert_to_latex(node)
latex_code = nil
Open3.popen3("pandoc -f json -t latex --wrap=none") {|stdin, stdout, stderr, wait_thr|
stdin.write(node.to_json)
stdin.close # stdin, stdout and stderr should be closed explicitly in this form.
latex_code = stdout.read
pid = wait_thr.pid # pid of the started process.
exit_status = wait_thr.value # Process::Status object returned.
}
latex_code
end | ruby | def convert_to_latex(node)
latex_code = nil
Open3.popen3("pandoc -f json -t latex --wrap=none") {|stdin, stdout, stderr, wait_thr|
stdin.write(node.to_json)
stdin.close # stdin, stdout and stderr should be closed explicitly in this form.
latex_code = stdout.read
pid = wait_thr.pid # pid of the started process.
exit_status = wait_thr.value # Process::Status object returned.
}
latex_code
end | [
"def",
"convert_to_latex",
"(",
"node",
")",
"latex_code",
"=",
"nil",
"Open3",
".",
"popen3",
"(",
"\"pandoc -f json -t latex --wrap=none\"",
")",
"{",
"|",
"stdin",
",",
"stdout",
",",
"stderr",
",",
"wait_thr",
"|",
"stdin",
".",
"write",
"(",
"node",
".",
"to_json",
")",
"stdin",
".",
"close",
"# stdin, stdout and stderr should be closed explicitly in this form.",
"latex_code",
"=",
"stdout",
".",
"read",
"pid",
"=",
"wait_thr",
".",
"pid",
"# pid of the started process.",
"exit_status",
"=",
"wait_thr",
".",
"value",
"# Process::Status object returned.",
"}",
"latex_code",
"end"
] | Converte node para latex | [
"Converte",
"node",
"para",
"latex"
] | fe623465b4956db6cddfe6cffffa0cd8ed445a18 | https://github.com/limarka/pandoc_abnt/blob/fe623465b4956db6cddfe6cffffa0cd8ed445a18/lib/pandoc_abnt/quadro_filter.rb#L108-L119 |
23,562 | mguymon/naether | src/main/ruby/naether/maven.rb | Naether.Maven.dependencies | def dependencies( scopes = nil)
if scopes
unless scopes.is_a? Array
scopes = [scopes]
end
end
if Naether.platform == 'java'
if scopes.nil?
deps = @project.getDependenciesNotation()
else
deps = @project.getDependenciesNotation( scopes )
end
elsif scopes
list = Naether::Java.convert_to_java_list( scopes )
deps = @project._invoke('getDependenciesNotation', 'Ljava.util.List;', list)
else
deps = @project.getDependenciesNotation()
end
Naether::Java.convert_to_ruby_array( deps, true )
end | ruby | def dependencies( scopes = nil)
if scopes
unless scopes.is_a? Array
scopes = [scopes]
end
end
if Naether.platform == 'java'
if scopes.nil?
deps = @project.getDependenciesNotation()
else
deps = @project.getDependenciesNotation( scopes )
end
elsif scopes
list = Naether::Java.convert_to_java_list( scopes )
deps = @project._invoke('getDependenciesNotation', 'Ljava.util.List;', list)
else
deps = @project.getDependenciesNotation()
end
Naether::Java.convert_to_ruby_array( deps, true )
end | [
"def",
"dependencies",
"(",
"scopes",
"=",
"nil",
")",
"if",
"scopes",
"unless",
"scopes",
".",
"is_a?",
"Array",
"scopes",
"=",
"[",
"scopes",
"]",
"end",
"end",
"if",
"Naether",
".",
"platform",
"==",
"'java'",
"if",
"scopes",
".",
"nil?",
"deps",
"=",
"@project",
".",
"getDependenciesNotation",
"(",
")",
"else",
"deps",
"=",
"@project",
".",
"getDependenciesNotation",
"(",
"scopes",
")",
"end",
"elsif",
"scopes",
"list",
"=",
"Naether",
"::",
"Java",
".",
"convert_to_java_list",
"(",
"scopes",
")",
"deps",
"=",
"@project",
".",
"_invoke",
"(",
"'getDependenciesNotation'",
",",
"'Ljava.util.List;'",
",",
"list",
")",
"else",
"deps",
"=",
"@project",
".",
"getDependenciesNotation",
"(",
")",
"end",
"Naether",
"::",
"Java",
".",
"convert_to_ruby_array",
"(",
"deps",
",",
"true",
")",
"end"
] | Get dependences for Project as notations
@param [Array<String>] scopes valid options are compile,test,runtime | [
"Get",
"dependences",
"for",
"Project",
"as",
"notations"
] | 218d8fd36c0b8b6e16d66e5715975570b4560ec4 | https://github.com/mguymon/naether/blob/218d8fd36c0b8b6e16d66e5715975570b4560ec4/src/main/ruby/naether/maven.rb#L71-L95 |
23,563 | mguymon/naether | src/main/ruby/naether/maven.rb | Naether.Maven.invoke | def invoke( *opts )
#defaults
config = {
# Checks ENV for maven home, otherwise defaults /usr/share/maven
# XXX: Reuse Eng.getMavenHome?
:maven_home => ENV['maven.home'] || ENV['MAVEN_HOME'] || '/usr/share/maven',
:local_repo => File.expand_path('~/.m2/repository')
}
if opts.last.is_a? Hash
config = config.merge( opts.pop )
end
goals = opts
pom = @project.getPomFile().getAbsolutePath()
invoker = Naether::Java.create("com.tobedevoured.naether.maven.Invoker", config[:local_repo], config[:maven_home] )
java_list = Naether::Java.convert_to_java_list(goals)
if Naether.platform == 'java'
invoker.execute( pom, java_list )
else
invoker._invoke('execute', 'Ljava.lang.String;Ljava.util.List;', pom, java_list)
end
end | ruby | def invoke( *opts )
#defaults
config = {
# Checks ENV for maven home, otherwise defaults /usr/share/maven
# XXX: Reuse Eng.getMavenHome?
:maven_home => ENV['maven.home'] || ENV['MAVEN_HOME'] || '/usr/share/maven',
:local_repo => File.expand_path('~/.m2/repository')
}
if opts.last.is_a? Hash
config = config.merge( opts.pop )
end
goals = opts
pom = @project.getPomFile().getAbsolutePath()
invoker = Naether::Java.create("com.tobedevoured.naether.maven.Invoker", config[:local_repo], config[:maven_home] )
java_list = Naether::Java.convert_to_java_list(goals)
if Naether.platform == 'java'
invoker.execute( pom, java_list )
else
invoker._invoke('execute', 'Ljava.lang.String;Ljava.util.List;', pom, java_list)
end
end | [
"def",
"invoke",
"(",
"*",
"opts",
")",
"#defaults",
"config",
"=",
"{",
"# Checks ENV for maven home, otherwise defaults /usr/share/maven",
"# XXX: Reuse Eng.getMavenHome?",
":maven_home",
"=>",
"ENV",
"[",
"'maven.home'",
"]",
"||",
"ENV",
"[",
"'MAVEN_HOME'",
"]",
"||",
"'/usr/share/maven'",
",",
":local_repo",
"=>",
"File",
".",
"expand_path",
"(",
"'~/.m2/repository'",
")",
"}",
"if",
"opts",
".",
"last",
".",
"is_a?",
"Hash",
"config",
"=",
"config",
".",
"merge",
"(",
"opts",
".",
"pop",
")",
"end",
"goals",
"=",
"opts",
"pom",
"=",
"@project",
".",
"getPomFile",
"(",
")",
".",
"getAbsolutePath",
"(",
")",
"invoker",
"=",
"Naether",
"::",
"Java",
".",
"create",
"(",
"\"com.tobedevoured.naether.maven.Invoker\"",
",",
"config",
"[",
":local_repo",
"]",
",",
"config",
"[",
":maven_home",
"]",
")",
"java_list",
"=",
"Naether",
"::",
"Java",
".",
"convert_to_java_list",
"(",
"goals",
")",
"if",
"Naether",
".",
"platform",
"==",
"'java'",
"invoker",
".",
"execute",
"(",
"pom",
",",
"java_list",
")",
"else",
"invoker",
".",
"_invoke",
"(",
"'execute'",
",",
"'Ljava.lang.String;Ljava.util.List;'",
",",
"pom",
",",
"java_list",
")",
"end",
"end"
] | Invoke a Maven goal
@params [Array] Goals names | [
"Invoke",
"a",
"Maven",
"goal"
] | 218d8fd36c0b8b6e16d66e5715975570b4560ec4 | https://github.com/mguymon/naether/blob/218d8fd36c0b8b6e16d66e5715975570b4560ec4/src/main/ruby/naether/maven.rb#L152-L176 |
23,564 | abenari/rbovirt | lib/rbovirt.rb | OVIRT.Client.api_version | def api_version
return @api_version unless @api_version.nil?
xml = http_get("/")/'/api/product_info/version'
major = (xml/'version').first[:major]
minor = (xml/'version').first[:minor]
build = (xml/'version').first[:build]
revision = (xml/'version').first[:revision]
@api_version = "#{major}.#{minor}.#{build}.#{revision}"
end | ruby | def api_version
return @api_version unless @api_version.nil?
xml = http_get("/")/'/api/product_info/version'
major = (xml/'version').first[:major]
minor = (xml/'version').first[:minor]
build = (xml/'version').first[:build]
revision = (xml/'version').first[:revision]
@api_version = "#{major}.#{minor}.#{build}.#{revision}"
end | [
"def",
"api_version",
"return",
"@api_version",
"unless",
"@api_version",
".",
"nil?",
"xml",
"=",
"http_get",
"(",
"\"/\"",
")",
"/",
"'/api/product_info/version'",
"major",
"=",
"(",
"xml",
"/",
"'version'",
")",
".",
"first",
"[",
":major",
"]",
"minor",
"=",
"(",
"xml",
"/",
"'version'",
")",
".",
"first",
"[",
":minor",
"]",
"build",
"=",
"(",
"xml",
"/",
"'version'",
")",
".",
"first",
"[",
":build",
"]",
"revision",
"=",
"(",
"xml",
"/",
"'version'",
")",
".",
"first",
"[",
":revision",
"]",
"@api_version",
"=",
"\"#{major}.#{minor}.#{build}.#{revision}\"",
"end"
] | Construct a new ovirt client class.
mandatory parameters
username, password, api_entrypoint - for example 'me@internal', 'secret', 'https://example.com/api'
optional parameters
datacenter_id, cluster_id and filtered_api can be sent in this order for backward
compatibility, or as a hash in the 4th parameter.
datacenter_id - setting the datacenter at initialization will add a default scope to any subsequent call
to the client to the specified datacenter.
cluster_id - setting the cluster at initialization will add a default scope to any subsequent call
to the client to the specified cluster.
filtered_api - when set to false (default) will use ovirt administrator api, else it will use the user
api mode. | [
"Construct",
"a",
"new",
"ovirt",
"client",
"class",
".",
"mandatory",
"parameters",
"username",
"password",
"api_entrypoint",
"-",
"for",
"example",
"me"
] | e88ffd2ef7470c164a34dd4229cbb8f5a7257265 | https://github.com/abenari/rbovirt/blob/e88ffd2ef7470c164a34dd4229cbb8f5a7257265/lib/rbovirt.rb#L86-L94 |
23,565 | south37/rucc | lib/rucc/gen.rb | Rucc.Gen.emit_builtin_reg_class | def emit_builtin_reg_class(node)
arg = node.args[0]
Util.assert!{ arg.ty.kind == Kind::PTR }
ty = arg.ty.ptr
if ty.kind == Kind::STRUCT
emit("mov $2, #eax")
elsif Type.is_flotype(ty)
emit("mov $1, #eax")
else
emit("mov $0, #eax")
end
end | ruby | def emit_builtin_reg_class(node)
arg = node.args[0]
Util.assert!{ arg.ty.kind == Kind::PTR }
ty = arg.ty.ptr
if ty.kind == Kind::STRUCT
emit("mov $2, #eax")
elsif Type.is_flotype(ty)
emit("mov $1, #eax")
else
emit("mov $0, #eax")
end
end | [
"def",
"emit_builtin_reg_class",
"(",
"node",
")",
"arg",
"=",
"node",
".",
"args",
"[",
"0",
"]",
"Util",
".",
"assert!",
"{",
"arg",
".",
"ty",
".",
"kind",
"==",
"Kind",
"::",
"PTR",
"}",
"ty",
"=",
"arg",
".",
"ty",
".",
"ptr",
"if",
"ty",
".",
"kind",
"==",
"Kind",
"::",
"STRUCT",
"emit",
"(",
"\"mov $2, #eax\"",
")",
"elsif",
"Type",
".",
"is_flotype",
"(",
"ty",
")",
"emit",
"(",
"\"mov $1, #eax\"",
")",
"else",
"emit",
"(",
"\"mov $0, #eax\"",
")",
"end",
"end"
] | Set the register class for parameter passing to RAX.
0 is INTEGER, 1 is SSE, 2 is MEMORY.
@param [Node] node | [
"Set",
"the",
"register",
"class",
"for",
"parameter",
"passing",
"to",
"RAX",
".",
"0",
"is",
"INTEGER",
"1",
"is",
"SSE",
"2",
"is",
"MEMORY",
"."
] | 11743d10eb2fcf0834b4f4a34bb5b8a109b32558 | https://github.com/south37/rucc/blob/11743d10eb2fcf0834b4f4a34bb5b8a109b32558/lib/rucc/gen.rb#L1240-L1251 |
23,566 | BookingSync/synced | lib/synced/model.rb | Synced.Model.synced | def synced(strategy: :updated_since, **options)
options.assert_valid_keys(:associations, :data_key, :fields, :globalized_attributes,
:id_key, :include, :initial_sync_since, :local_attributes, :mapper, :only_updated,
:remove, :auto_paginate, :transaction_per_page, :delegate_attributes, :query_params,
:timestamp_strategy, :handle_processed_objects_proc, :tolerance, :endpoint)
class_attribute :synced_id_key, :synced_data_key,
:synced_local_attributes, :synced_associations, :synced_only_updated,
:synced_mapper, :synced_remove, :synced_include, :synced_fields, :synced_auto_paginate, :synced_transaction_per_page,
:synced_globalized_attributes, :synced_initial_sync_since, :synced_delegate_attributes,
:synced_query_params, :synced_timestamp_strategy, :synced_strategy, :synced_handle_processed_objects_proc,
:synced_tolerance, :synced_endpoint
self.synced_strategy = strategy
self.synced_id_key = options.fetch(:id_key, :synced_id)
self.synced_data_key = options.fetch(:data_key) { synced_column_presence(:synced_data) }
self.synced_local_attributes = options.fetch(:local_attributes, [])
self.synced_associations = options.fetch(:associations, [])
self.synced_only_updated = options.fetch(:only_updated, synced_strategy == :updated_since)
self.synced_mapper = options.fetch(:mapper, nil)
self.synced_remove = options.fetch(:remove, false)
self.synced_include = options.fetch(:include, [])
self.synced_fields = options.fetch(:fields, [])
self.synced_globalized_attributes = options.fetch(:globalized_attributes,
[])
self.synced_initial_sync_since = options.fetch(:initial_sync_since,
nil)
self.synced_delegate_attributes = options.fetch(:delegate_attributes, [])
self.synced_query_params = options.fetch(:query_params, {})
self.synced_timestamp_strategy = options.fetch(:timestamp_strategy, nil)
self.synced_auto_paginate = options.fetch(:auto_paginate, true)
self.synced_transaction_per_page = options.fetch(:transaction_per_page, false)
self.synced_handle_processed_objects_proc = options.fetch(:handle_processed_objects_proc, nil)
self.synced_tolerance = options.fetch(:tolerance, 0).to_i.abs
self.synced_endpoint = options.fetch(:endpoint) { self.to_s.tableize }
include Synced::DelegateAttributes
include Synced::HasSyncedData
end | ruby | def synced(strategy: :updated_since, **options)
options.assert_valid_keys(:associations, :data_key, :fields, :globalized_attributes,
:id_key, :include, :initial_sync_since, :local_attributes, :mapper, :only_updated,
:remove, :auto_paginate, :transaction_per_page, :delegate_attributes, :query_params,
:timestamp_strategy, :handle_processed_objects_proc, :tolerance, :endpoint)
class_attribute :synced_id_key, :synced_data_key,
:synced_local_attributes, :synced_associations, :synced_only_updated,
:synced_mapper, :synced_remove, :synced_include, :synced_fields, :synced_auto_paginate, :synced_transaction_per_page,
:synced_globalized_attributes, :synced_initial_sync_since, :synced_delegate_attributes,
:synced_query_params, :synced_timestamp_strategy, :synced_strategy, :synced_handle_processed_objects_proc,
:synced_tolerance, :synced_endpoint
self.synced_strategy = strategy
self.synced_id_key = options.fetch(:id_key, :synced_id)
self.synced_data_key = options.fetch(:data_key) { synced_column_presence(:synced_data) }
self.synced_local_attributes = options.fetch(:local_attributes, [])
self.synced_associations = options.fetch(:associations, [])
self.synced_only_updated = options.fetch(:only_updated, synced_strategy == :updated_since)
self.synced_mapper = options.fetch(:mapper, nil)
self.synced_remove = options.fetch(:remove, false)
self.synced_include = options.fetch(:include, [])
self.synced_fields = options.fetch(:fields, [])
self.synced_globalized_attributes = options.fetch(:globalized_attributes,
[])
self.synced_initial_sync_since = options.fetch(:initial_sync_since,
nil)
self.synced_delegate_attributes = options.fetch(:delegate_attributes, [])
self.synced_query_params = options.fetch(:query_params, {})
self.synced_timestamp_strategy = options.fetch(:timestamp_strategy, nil)
self.synced_auto_paginate = options.fetch(:auto_paginate, true)
self.synced_transaction_per_page = options.fetch(:transaction_per_page, false)
self.synced_handle_processed_objects_proc = options.fetch(:handle_processed_objects_proc, nil)
self.synced_tolerance = options.fetch(:tolerance, 0).to_i.abs
self.synced_endpoint = options.fetch(:endpoint) { self.to_s.tableize }
include Synced::DelegateAttributes
include Synced::HasSyncedData
end | [
"def",
"synced",
"(",
"strategy",
":",
":updated_since",
",",
"**",
"options",
")",
"options",
".",
"assert_valid_keys",
"(",
":associations",
",",
":data_key",
",",
":fields",
",",
":globalized_attributes",
",",
":id_key",
",",
":include",
",",
":initial_sync_since",
",",
":local_attributes",
",",
":mapper",
",",
":only_updated",
",",
":remove",
",",
":auto_paginate",
",",
":transaction_per_page",
",",
":delegate_attributes",
",",
":query_params",
",",
":timestamp_strategy",
",",
":handle_processed_objects_proc",
",",
":tolerance",
",",
":endpoint",
")",
"class_attribute",
":synced_id_key",
",",
":synced_data_key",
",",
":synced_local_attributes",
",",
":synced_associations",
",",
":synced_only_updated",
",",
":synced_mapper",
",",
":synced_remove",
",",
":synced_include",
",",
":synced_fields",
",",
":synced_auto_paginate",
",",
":synced_transaction_per_page",
",",
":synced_globalized_attributes",
",",
":synced_initial_sync_since",
",",
":synced_delegate_attributes",
",",
":synced_query_params",
",",
":synced_timestamp_strategy",
",",
":synced_strategy",
",",
":synced_handle_processed_objects_proc",
",",
":synced_tolerance",
",",
":synced_endpoint",
"self",
".",
"synced_strategy",
"=",
"strategy",
"self",
".",
"synced_id_key",
"=",
"options",
".",
"fetch",
"(",
":id_key",
",",
":synced_id",
")",
"self",
".",
"synced_data_key",
"=",
"options",
".",
"fetch",
"(",
":data_key",
")",
"{",
"synced_column_presence",
"(",
":synced_data",
")",
"}",
"self",
".",
"synced_local_attributes",
"=",
"options",
".",
"fetch",
"(",
":local_attributes",
",",
"[",
"]",
")",
"self",
".",
"synced_associations",
"=",
"options",
".",
"fetch",
"(",
":associations",
",",
"[",
"]",
")",
"self",
".",
"synced_only_updated",
"=",
"options",
".",
"fetch",
"(",
":only_updated",
",",
"synced_strategy",
"==",
":updated_since",
")",
"self",
".",
"synced_mapper",
"=",
"options",
".",
"fetch",
"(",
":mapper",
",",
"nil",
")",
"self",
".",
"synced_remove",
"=",
"options",
".",
"fetch",
"(",
":remove",
",",
"false",
")",
"self",
".",
"synced_include",
"=",
"options",
".",
"fetch",
"(",
":include",
",",
"[",
"]",
")",
"self",
".",
"synced_fields",
"=",
"options",
".",
"fetch",
"(",
":fields",
",",
"[",
"]",
")",
"self",
".",
"synced_globalized_attributes",
"=",
"options",
".",
"fetch",
"(",
":globalized_attributes",
",",
"[",
"]",
")",
"self",
".",
"synced_initial_sync_since",
"=",
"options",
".",
"fetch",
"(",
":initial_sync_since",
",",
"nil",
")",
"self",
".",
"synced_delegate_attributes",
"=",
"options",
".",
"fetch",
"(",
":delegate_attributes",
",",
"[",
"]",
")",
"self",
".",
"synced_query_params",
"=",
"options",
".",
"fetch",
"(",
":query_params",
",",
"{",
"}",
")",
"self",
".",
"synced_timestamp_strategy",
"=",
"options",
".",
"fetch",
"(",
":timestamp_strategy",
",",
"nil",
")",
"self",
".",
"synced_auto_paginate",
"=",
"options",
".",
"fetch",
"(",
":auto_paginate",
",",
"true",
")",
"self",
".",
"synced_transaction_per_page",
"=",
"options",
".",
"fetch",
"(",
":transaction_per_page",
",",
"false",
")",
"self",
".",
"synced_handle_processed_objects_proc",
"=",
"options",
".",
"fetch",
"(",
":handle_processed_objects_proc",
",",
"nil",
")",
"self",
".",
"synced_tolerance",
"=",
"options",
".",
"fetch",
"(",
":tolerance",
",",
"0",
")",
".",
"to_i",
".",
"abs",
"self",
".",
"synced_endpoint",
"=",
"options",
".",
"fetch",
"(",
":endpoint",
")",
"{",
"self",
".",
"to_s",
".",
"tableize",
"}",
"include",
"Synced",
"::",
"DelegateAttributes",
"include",
"Synced",
"::",
"HasSyncedData",
"end"
] | Enables synced for ActiveRecord model.
@param options [Hash] Configuration options for synced. They are inherited
by subclasses, but can be overwritten in the subclass.
@option options [Symbol] strategy: synchronization strategy, one of :full, :updated_since, :check.
Defaults to :updated_since
@option options [Symbol] id_key: attribute name under which
remote object's ID is stored, default is :synced_id.
@option options [Boolean] only_updated: If true requests to API will take
advantage of updated_since param and fetch only created/changed/deleted
remote objects
@option options [Symbol] data_key: attribute name under which remote
object's data is stored.
@option options [Array|Hash] local_attributes: Array of attributes in the remote
object which will be mapped to local object attributes.
@option options [Boolean|Symbol] remove: If it's true all local objects
within current scope which are not present in the remote array will be
destroyed.
If only_updated is enabled, ids of objects to be deleted will be taken
from the meta part. By default if cancel_at column is present, all
missing local objects will be canceled with cancel_all,
if it's missing, all will be destroyed with destroy_all.
You can also force method to remove local objects by passing it
to remove: :mark_as_missing.
@option options [Array|Hash] globalized_attributes: A list of attributes
which will be mapped with their translations.
@option options [Time|Proc] initial_sync_since: A point in time from which
objects will be synchronized on first synchronization.
Works only for partial (updated_since param) synchronizations.
@option options [Array|Hash] delegate_attributes: Given attributes will be defined
on synchronized object and delegated to synced_data Hash
@option options [Hash] query_params: Given attributes and their values
which will be passed to api client to perform search
@option options [Boolean] auto_paginate: If true (default) will fetch and save all
records at once. If false will fetch and save records in batches.
@option options transaction_per_page [Boolean]: If false (default) all fetched records
will be persisted within single transaction. If true the transaction will be per page
of fetched records
@option options [Proc] handle_processed_objects_proc: Proc taking one argument (persisted remote objects).
Called after persisting remote objects (once in case of auto_paginate, after each batch
when paginating with block).
@option options [Integer] tolerance: amount of seconds subtracted from last_request timestamp.
Used to ensure records are up to date in case request has been made in the middle of transaction.
Defaults to 0. | [
"Enables",
"synced",
"for",
"ActiveRecord",
"model",
"."
] | 4a79eee67497c7b7954b0a8dd6ac832fa06c112b | https://github.com/BookingSync/synced/blob/4a79eee67497c7b7954b0a8dd6ac832fa06c112b/lib/synced/model.rb#L49-L84 |
23,567 | BookingSync/synced | lib/synced/model.rb | Synced.Model.synchronize | def synchronize(scope: scope_from_relation, strategy: synced_strategy, **options)
options.assert_valid_keys(:api, :fields, :include, :remote, :remove, :query_params, :association_sync, :auto_paginate, :transaction_per_page)
options[:remove] = synced_remove unless options.has_key?(:remove)
options[:include] = Array.wrap(synced_include) unless options.has_key?(:include)
options[:fields] = Array.wrap(synced_fields) unless options.has_key?(:fields)
options[:query_params] = synced_query_params unless options.has_key?(:query_params)
options[:auto_paginate] = synced_auto_paginate unless options.has_key?(:auto_paginate)
options[:transaction_per_page] = synced_transaction_per_page unless options.has_key?(:transaction_per_page)
options.merge!({
scope: scope,
strategy: strategy,
id_key: synced_id_key,
synced_data_key: synced_data_key,
data_key: synced_data_key,
local_attributes: synced_local_attributes,
associations: synced_associations,
only_updated: synced_only_updated,
mapper: synced_mapper,
globalized_attributes: synced_globalized_attributes,
initial_sync_since: synced_initial_sync_since,
timestamp_strategy: synced_timestamp_strategy,
handle_processed_objects_proc: synced_handle_processed_objects_proc,
tolerance: synced_tolerance,
synced_endpoint: synced_endpoint
})
Synced::Synchronizer.new(self, options).perform
end | ruby | def synchronize(scope: scope_from_relation, strategy: synced_strategy, **options)
options.assert_valid_keys(:api, :fields, :include, :remote, :remove, :query_params, :association_sync, :auto_paginate, :transaction_per_page)
options[:remove] = synced_remove unless options.has_key?(:remove)
options[:include] = Array.wrap(synced_include) unless options.has_key?(:include)
options[:fields] = Array.wrap(synced_fields) unless options.has_key?(:fields)
options[:query_params] = synced_query_params unless options.has_key?(:query_params)
options[:auto_paginate] = synced_auto_paginate unless options.has_key?(:auto_paginate)
options[:transaction_per_page] = synced_transaction_per_page unless options.has_key?(:transaction_per_page)
options.merge!({
scope: scope,
strategy: strategy,
id_key: synced_id_key,
synced_data_key: synced_data_key,
data_key: synced_data_key,
local_attributes: synced_local_attributes,
associations: synced_associations,
only_updated: synced_only_updated,
mapper: synced_mapper,
globalized_attributes: synced_globalized_attributes,
initial_sync_since: synced_initial_sync_since,
timestamp_strategy: synced_timestamp_strategy,
handle_processed_objects_proc: synced_handle_processed_objects_proc,
tolerance: synced_tolerance,
synced_endpoint: synced_endpoint
})
Synced::Synchronizer.new(self, options).perform
end | [
"def",
"synchronize",
"(",
"scope",
":",
"scope_from_relation",
",",
"strategy",
":",
"synced_strategy",
",",
"**",
"options",
")",
"options",
".",
"assert_valid_keys",
"(",
":api",
",",
":fields",
",",
":include",
",",
":remote",
",",
":remove",
",",
":query_params",
",",
":association_sync",
",",
":auto_paginate",
",",
":transaction_per_page",
")",
"options",
"[",
":remove",
"]",
"=",
"synced_remove",
"unless",
"options",
".",
"has_key?",
"(",
":remove",
")",
"options",
"[",
":include",
"]",
"=",
"Array",
".",
"wrap",
"(",
"synced_include",
")",
"unless",
"options",
".",
"has_key?",
"(",
":include",
")",
"options",
"[",
":fields",
"]",
"=",
"Array",
".",
"wrap",
"(",
"synced_fields",
")",
"unless",
"options",
".",
"has_key?",
"(",
":fields",
")",
"options",
"[",
":query_params",
"]",
"=",
"synced_query_params",
"unless",
"options",
".",
"has_key?",
"(",
":query_params",
")",
"options",
"[",
":auto_paginate",
"]",
"=",
"synced_auto_paginate",
"unless",
"options",
".",
"has_key?",
"(",
":auto_paginate",
")",
"options",
"[",
":transaction_per_page",
"]",
"=",
"synced_transaction_per_page",
"unless",
"options",
".",
"has_key?",
"(",
":transaction_per_page",
")",
"options",
".",
"merge!",
"(",
"{",
"scope",
":",
"scope",
",",
"strategy",
":",
"strategy",
",",
"id_key",
":",
"synced_id_key",
",",
"synced_data_key",
":",
"synced_data_key",
",",
"data_key",
":",
"synced_data_key",
",",
"local_attributes",
":",
"synced_local_attributes",
",",
"associations",
":",
"synced_associations",
",",
"only_updated",
":",
"synced_only_updated",
",",
"mapper",
":",
"synced_mapper",
",",
"globalized_attributes",
":",
"synced_globalized_attributes",
",",
"initial_sync_since",
":",
"synced_initial_sync_since",
",",
"timestamp_strategy",
":",
"synced_timestamp_strategy",
",",
"handle_processed_objects_proc",
":",
"synced_handle_processed_objects_proc",
",",
"tolerance",
":",
"synced_tolerance",
",",
"synced_endpoint",
":",
"synced_endpoint",
"}",
")",
"Synced",
"::",
"Synchronizer",
".",
"new",
"(",
"self",
",",
"options",
")",
".",
"perform",
"end"
] | Performs synchronization of given remote objects to local database.
@param remote [Array] - Remote objects to be synchronized with local db. If
it's nil then synchronizer will make request on it's own.
@param model_class [Class] - ActiveRecord model class to which remote objects
will be synchronized.
@param scope [ActiveRecord::Base] - Within this object scope local objects
will be synchronized. By default it's model_class. Can be infered from active record association scope.
@param remove [Boolean] - If it's true all local objects within
current scope which are not present in the remote array will be destroyed.
If only_updated is enabled, ids of objects to be deleted will be taken
from the meta part. By default if cancel_at column is present, all
missing local objects will be canceled with cancel_all,
if it's missing, all will be destroyed with destroy_all.
You can also force method to remove local objects by passing it
to remove: :mark_as_missing. This option can be defined in the model
and then overwritten in the synchronize method.
@param auto_paginate [Boolean] - If true (default) will fetch and save all
records at once. If false will fetch and save records in batches.
@param transaction_per_page [Boolean] - If false (default) all fetched records
will be persisted within single transaction. If true the transaction will be per page
of fetched records
@param api [BookingSync::API::Client] - API client to be used for fetching
remote objects
@example Synchronizing amenities
Amenity.synchronize(remote: [remote_amenity1, remote_amenity2])
@example Synchronizing rentals within given website. This will
create/remove/update rentals only within website.
It requires relation website.rentals to exist.
website.rentals.synchronize(remote: remote_rentals) | [
"Performs",
"synchronization",
"of",
"given",
"remote",
"objects",
"to",
"local",
"database",
"."
] | 4a79eee67497c7b7954b0a8dd6ac832fa06c112b | https://github.com/BookingSync/synced/blob/4a79eee67497c7b7954b0a8dd6ac832fa06c112b/lib/synced/model.rb#L120-L146 |
23,568 | BookingSync/synced | lib/synced/model.rb | Synced.Model.reset_synced | def reset_synced(scope: scope_from_relation)
options = {
scope: scope,
strategy: synced_strategy,
only_updated: synced_only_updated,
initial_sync_since: synced_initial_sync_since,
timestamp_strategy: synced_timestamp_strategy,
synced_endpoint: synced_endpoint
}
Synced::Synchronizer.new(self, options).reset_synced
end | ruby | def reset_synced(scope: scope_from_relation)
options = {
scope: scope,
strategy: synced_strategy,
only_updated: synced_only_updated,
initial_sync_since: synced_initial_sync_since,
timestamp_strategy: synced_timestamp_strategy,
synced_endpoint: synced_endpoint
}
Synced::Synchronizer.new(self, options).reset_synced
end | [
"def",
"reset_synced",
"(",
"scope",
":",
"scope_from_relation",
")",
"options",
"=",
"{",
"scope",
":",
"scope",
",",
"strategy",
":",
"synced_strategy",
",",
"only_updated",
":",
"synced_only_updated",
",",
"initial_sync_since",
":",
"synced_initial_sync_since",
",",
"timestamp_strategy",
":",
"synced_timestamp_strategy",
",",
"synced_endpoint",
":",
"synced_endpoint",
"}",
"Synced",
"::",
"Synchronizer",
".",
"new",
"(",
"self",
",",
"options",
")",
".",
"reset_synced",
"end"
] | Reset last sync timestamp for given scope, this forces synced to sync
all the records on the next sync. Useful for cases when you add
a new column to be synced and you use updated since strategy for faster
synchronization. | [
"Reset",
"last",
"sync",
"timestamp",
"for",
"given",
"scope",
"this",
"forces",
"synced",
"to",
"sync",
"all",
"the",
"records",
"on",
"the",
"next",
"sync",
".",
"Useful",
"for",
"cases",
"when",
"you",
"add",
"a",
"new",
"column",
"to",
"be",
"synced",
"and",
"you",
"use",
"updated",
"since",
"strategy",
"for",
"faster",
"synchronization",
"."
] | 4a79eee67497c7b7954b0a8dd6ac832fa06c112b | https://github.com/BookingSync/synced/blob/4a79eee67497c7b7954b0a8dd6ac832fa06c112b/lib/synced/model.rb#L152-L162 |
23,569 | mguymon/naether | src/main/ruby/naether/runtime.rb | Naether.Runtime.add_remote_repository | def add_remote_repository( url, username = nil, password = nil )
if username
@resolver.addRemoteRepositoryByUrl( url, username, password )
else
@resolver.addRemoteRepositoryByUrl( url )
end
end | ruby | def add_remote_repository( url, username = nil, password = nil )
if username
@resolver.addRemoteRepositoryByUrl( url, username, password )
else
@resolver.addRemoteRepositoryByUrl( url )
end
end | [
"def",
"add_remote_repository",
"(",
"url",
",",
"username",
"=",
"nil",
",",
"password",
"=",
"nil",
")",
"if",
"username",
"@resolver",
".",
"addRemoteRepositoryByUrl",
"(",
"url",
",",
"username",
",",
"password",
")",
"else",
"@resolver",
".",
"addRemoteRepositoryByUrl",
"(",
"url",
")",
"end",
"end"
] | Add remote repository
@param [String] url of remote repo
@param [String] username optional
@param [String] password optioanl | [
"Add",
"remote",
"repository"
] | 218d8fd36c0b8b6e16d66e5715975570b4560ec4 | https://github.com/mguymon/naether/blob/218d8fd36c0b8b6e16d66e5715975570b4560ec4/src/main/ruby/naether/runtime.rb#L46-L52 |
23,570 | mguymon/naether | src/main/ruby/naether/runtime.rb | Naether.Runtime.build_artifacts= | def build_artifacts=( artifacts )
@resolver.clearBuildArtifacts()
unless artifacts.is_a? Array
artifacts = [artifacts]
end
artifacts.each do |artifact|
# Hash of notation => path or notation => { :path =>, :pom => }
if artifact.is_a? Hash
notation, opts = artifact.shift
if opts.is_a? Hash
@resolver.add_build_artifact( notation, opts[:path], opts[:pom] )
else
@resolver.add_build_artifact( notation, opts )
end
else
raise "invalid build_artifacts format"
end
end
end | ruby | def build_artifacts=( artifacts )
@resolver.clearBuildArtifacts()
unless artifacts.is_a? Array
artifacts = [artifacts]
end
artifacts.each do |artifact|
# Hash of notation => path or notation => { :path =>, :pom => }
if artifact.is_a? Hash
notation, opts = artifact.shift
if opts.is_a? Hash
@resolver.add_build_artifact( notation, opts[:path], opts[:pom] )
else
@resolver.add_build_artifact( notation, opts )
end
else
raise "invalid build_artifacts format"
end
end
end | [
"def",
"build_artifacts",
"=",
"(",
"artifacts",
")",
"@resolver",
".",
"clearBuildArtifacts",
"(",
")",
"unless",
"artifacts",
".",
"is_a?",
"Array",
"artifacts",
"=",
"[",
"artifacts",
"]",
"end",
"artifacts",
".",
"each",
"do",
"|",
"artifact",
"|",
"# Hash of notation => path or notation => { :path =>, :pom => }",
"if",
"artifact",
".",
"is_a?",
"Hash",
"notation",
",",
"opts",
"=",
"artifact",
".",
"shift",
"if",
"opts",
".",
"is_a?",
"Hash",
"@resolver",
".",
"add_build_artifact",
"(",
"notation",
",",
"opts",
"[",
":path",
"]",
",",
"opts",
"[",
":pom",
"]",
")",
"else",
"@resolver",
".",
"add_build_artifact",
"(",
"notation",
",",
"opts",
")",
"end",
"else",
"raise",
"\"invalid build_artifacts format\"",
"end",
"end",
"end"
] | Set local Build Artifacts, that will be used in the Dependency Resolution
@param [Array<Hash>] artifacts of Hashs with { notation => path } or { notation => { :path => path, :pom => pom_path } | [
"Set",
"local",
"Build",
"Artifacts",
"that",
"will",
"be",
"used",
"in",
"the",
"Dependency",
"Resolution"
] | 218d8fd36c0b8b6e16d66e5715975570b4560ec4 | https://github.com/mguymon/naether/blob/218d8fd36c0b8b6e16d66e5715975570b4560ec4/src/main/ruby/naether/runtime.rb#L98-L121 |
23,571 | mguymon/naether | src/main/ruby/naether/runtime.rb | Naether.Runtime.add_pom_dependencies | def add_pom_dependencies( pom_path, scopes=['compile'] )
if Naether.platform == 'java'
@resolver.addDependencies( pom_path, scopes )
else
list = Naether::Java.convert_to_java_list( scopes )
@resolver._invoke( 'addDependencies', 'Ljava.lang.String;Ljava.util.List;', pom_path, list )
end
end | ruby | def add_pom_dependencies( pom_path, scopes=['compile'] )
if Naether.platform == 'java'
@resolver.addDependencies( pom_path, scopes )
else
list = Naether::Java.convert_to_java_list( scopes )
@resolver._invoke( 'addDependencies', 'Ljava.lang.String;Ljava.util.List;', pom_path, list )
end
end | [
"def",
"add_pom_dependencies",
"(",
"pom_path",
",",
"scopes",
"=",
"[",
"'compile'",
"]",
")",
"if",
"Naether",
".",
"platform",
"==",
"'java'",
"@resolver",
".",
"addDependencies",
"(",
"pom_path",
",",
"scopes",
")",
"else",
"list",
"=",
"Naether",
"::",
"Java",
".",
"convert_to_java_list",
"(",
"scopes",
")",
"@resolver",
".",
"_invoke",
"(",
"'addDependencies'",
",",
"'Ljava.lang.String;Ljava.util.List;'",
",",
"pom_path",
",",
"list",
")",
"end",
"end"
] | Add dependencies from a Maven POM
@param [String] pom_path
@param [Array<String>] scopes valid options are compile,test,runtime | [
"Add",
"dependencies",
"from",
"a",
"Maven",
"POM"
] | 218d8fd36c0b8b6e16d66e5715975570b4560ec4 | https://github.com/mguymon/naether/blob/218d8fd36c0b8b6e16d66e5715975570b4560ec4/src/main/ruby/naether/runtime.rb#L145-L152 |
23,572 | mguymon/naether | src/main/ruby/naether/runtime.rb | Naether.Runtime.dependencies= | def dependencies=(dependencies)
@resolver.clearDependencies()
unless dependencies.is_a? Array
dependencies = [dependencies]
end
dependencies.each do |dependent|
# Hash of notation => scope
if dependent.is_a? Hash
key = dependent.keys.first
# Add pom dependencies with scopes
if key =~ /\.xml$/i
scopes = nil
if dependent[key].is_a? Array
scopes = dependent[key]
else
scopes = [dependent[key]]
end
add_pom_dependencies( key, scopes )
# Add a dependency notation with scopes
else
add_notation_dependency( key, dependent[key] )
end
elsif dependent.is_a? String
# Add pom dependencies with default scopes
if dependent =~ /\.xml$/i
add_pom_dependencies( dependent )
# Add a dependency notation with compile scope
else
add_notation_dependency( dependent, 'compile' )
end
# Add an Aether dependency
else
add_dependency( dependent )
end
end
end | ruby | def dependencies=(dependencies)
@resolver.clearDependencies()
unless dependencies.is_a? Array
dependencies = [dependencies]
end
dependencies.each do |dependent|
# Hash of notation => scope
if dependent.is_a? Hash
key = dependent.keys.first
# Add pom dependencies with scopes
if key =~ /\.xml$/i
scopes = nil
if dependent[key].is_a? Array
scopes = dependent[key]
else
scopes = [dependent[key]]
end
add_pom_dependencies( key, scopes )
# Add a dependency notation with scopes
else
add_notation_dependency( key, dependent[key] )
end
elsif dependent.is_a? String
# Add pom dependencies with default scopes
if dependent =~ /\.xml$/i
add_pom_dependencies( dependent )
# Add a dependency notation with compile scope
else
add_notation_dependency( dependent, 'compile' )
end
# Add an Aether dependency
else
add_dependency( dependent )
end
end
end | [
"def",
"dependencies",
"=",
"(",
"dependencies",
")",
"@resolver",
".",
"clearDependencies",
"(",
")",
"unless",
"dependencies",
".",
"is_a?",
"Array",
"dependencies",
"=",
"[",
"dependencies",
"]",
"end",
"dependencies",
".",
"each",
"do",
"|",
"dependent",
"|",
"# Hash of notation => scope",
"if",
"dependent",
".",
"is_a?",
"Hash",
"key",
"=",
"dependent",
".",
"keys",
".",
"first",
"# Add pom dependencies with scopes",
"if",
"key",
"=~",
"/",
"\\.",
"/i",
"scopes",
"=",
"nil",
"if",
"dependent",
"[",
"key",
"]",
".",
"is_a?",
"Array",
"scopes",
"=",
"dependent",
"[",
"key",
"]",
"else",
"scopes",
"=",
"[",
"dependent",
"[",
"key",
"]",
"]",
"end",
"add_pom_dependencies",
"(",
"key",
",",
"scopes",
")",
"# Add a dependency notation with scopes",
"else",
"add_notation_dependency",
"(",
"key",
",",
"dependent",
"[",
"key",
"]",
")",
"end",
"elsif",
"dependent",
".",
"is_a?",
"String",
"# Add pom dependencies with default scopes",
"if",
"dependent",
"=~",
"/",
"\\.",
"/i",
"add_pom_dependencies",
"(",
"dependent",
")",
"# Add a dependency notation with compile scope",
"else",
"add_notation_dependency",
"(",
"dependent",
",",
"'compile'",
")",
"end",
"# Add an Aether dependency",
"else",
"add_dependency",
"(",
"dependent",
")",
"end",
"end",
"end"
] | Set the dependencies
The dependencies param takes an [Array] of mixed dependencies:
* [String] Artifact notation, such as groupId:artifactId:version, e.g. 'junit:junit:4.7'
* [Hash] of a single artifaction notation => scope - { 'junit:junit:4.7' => 'test' }
* [String] path to a local pom - 'lib/pom.xml'
* [Hash] of a single path to a local pom => scope - { 'lib/pom.xml' => ['compile','test'] }
@param [Array] dependencies
@see https://github.com/mguymon/naether/wiki/Notations | [
"Set",
"the",
"dependencies"
] | 218d8fd36c0b8b6e16d66e5715975570b4560ec4 | https://github.com/mguymon/naether/blob/218d8fd36c0b8b6e16d66e5715975570b4560ec4/src/main/ruby/naether/runtime.rb#L176-L220 |
23,573 | mguymon/naether | src/main/ruby/naether/runtime.rb | Naether.Runtime.dependencies_graph | def dependencies_graph(nodes=nil)
nodes = @resolver.getDependenciesGraph() unless nodes
graph = {}
if Naether.platform == 'java'
nodes.each do |k,v|
deps = dependencies_graph(v)
graph[k] = Naether::Java.convert_to_ruby_hash( deps )
end
else
iterator = nodes.entrySet().iterator();
while iterator.hasNext()
entry = iterator.next()
deps = dependencies_graph(entry.getValue())
graph[entry.getKey().toString()] = Naether::Java.convert_to_ruby_hash( deps )
end
end
graph
end | ruby | def dependencies_graph(nodes=nil)
nodes = @resolver.getDependenciesGraph() unless nodes
graph = {}
if Naether.platform == 'java'
nodes.each do |k,v|
deps = dependencies_graph(v)
graph[k] = Naether::Java.convert_to_ruby_hash( deps )
end
else
iterator = nodes.entrySet().iterator();
while iterator.hasNext()
entry = iterator.next()
deps = dependencies_graph(entry.getValue())
graph[entry.getKey().toString()] = Naether::Java.convert_to_ruby_hash( deps )
end
end
graph
end | [
"def",
"dependencies_graph",
"(",
"nodes",
"=",
"nil",
")",
"nodes",
"=",
"@resolver",
".",
"getDependenciesGraph",
"(",
")",
"unless",
"nodes",
"graph",
"=",
"{",
"}",
"if",
"Naether",
".",
"platform",
"==",
"'java'",
"nodes",
".",
"each",
"do",
"|",
"k",
",",
"v",
"|",
"deps",
"=",
"dependencies_graph",
"(",
"v",
")",
"graph",
"[",
"k",
"]",
"=",
"Naether",
"::",
"Java",
".",
"convert_to_ruby_hash",
"(",
"deps",
")",
"end",
"else",
"iterator",
"=",
"nodes",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"iterator",
".",
"hasNext",
"(",
")",
"entry",
"=",
"iterator",
".",
"next",
"(",
")",
"deps",
"=",
"dependencies_graph",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
"graph",
"[",
"entry",
".",
"getKey",
"(",
")",
".",
"toString",
"(",
")",
"]",
"=",
"Naether",
"::",
"Java",
".",
"convert_to_ruby_hash",
"(",
"deps",
")",
"end",
"end",
"graph",
"end"
] | Dependencies as a Graph of nested Hashes
@return [Hash] | [
"Dependencies",
"as",
"a",
"Graph",
"of",
"nested",
"Hashes"
] | 218d8fd36c0b8b6e16d66e5715975570b4560ec4 | https://github.com/mguymon/naether/blob/218d8fd36c0b8b6e16d66e5715975570b4560ec4/src/main/ruby/naether/runtime.rb#L254-L273 |
23,574 | mguymon/naether | src/main/ruby/naether/runtime.rb | Naether.Runtime.load_dependencies_to_classpath | def load_dependencies_to_classpath
jars = dependencies_classpath.split(File::PATH_SEPARATOR)
Naether::Java.load_jars(jars)
jars
end | ruby | def load_dependencies_to_classpath
jars = dependencies_classpath.split(File::PATH_SEPARATOR)
Naether::Java.load_jars(jars)
jars
end | [
"def",
"load_dependencies_to_classpath",
"jars",
"=",
"dependencies_classpath",
".",
"split",
"(",
"File",
"::",
"PATH_SEPARATOR",
")",
"Naether",
"::",
"Java",
".",
"load_jars",
"(",
"jars",
")",
"jars",
"end"
] | Load dependencies to Classpath
@return [Array] of loaded jars | [
"Load",
"dependencies",
"to",
"Classpath"
] | 218d8fd36c0b8b6e16d66e5715975570b4560ec4 | https://github.com/mguymon/naether/blob/218d8fd36c0b8b6e16d66e5715975570b4560ec4/src/main/ruby/naether/runtime.rb#L278-L283 |
23,575 | mguymon/naether | src/main/ruby/naether/runtime.rb | Naether.Runtime.to_local_paths | def to_local_paths( notations )
if Naether.platform == 'java'
Naether::Java.convert_to_ruby_array(
Naether::Java.exec_static_method(
'com.tobedevoured.naether.util.Notation',
'getLocalPaths',
[local_repo_path, notations ],
['java.lang.String', 'java.util.List'] ) )
else
paths = Naether::Java.exec_static_method(
'com.tobedevoured.naether.util.Notation',
'getLocalPaths',
[local_repo_path, Naether::Java.convert_to_java_list(notations) ],
['java.lang.String', 'java.util.List'] )
Naether::Java.convert_to_ruby_array( paths, true )
end
end | ruby | def to_local_paths( notations )
if Naether.platform == 'java'
Naether::Java.convert_to_ruby_array(
Naether::Java.exec_static_method(
'com.tobedevoured.naether.util.Notation',
'getLocalPaths',
[local_repo_path, notations ],
['java.lang.String', 'java.util.List'] ) )
else
paths = Naether::Java.exec_static_method(
'com.tobedevoured.naether.util.Notation',
'getLocalPaths',
[local_repo_path, Naether::Java.convert_to_java_list(notations) ],
['java.lang.String', 'java.util.List'] )
Naether::Java.convert_to_ruby_array( paths, true )
end
end | [
"def",
"to_local_paths",
"(",
"notations",
")",
"if",
"Naether",
".",
"platform",
"==",
"'java'",
"Naether",
"::",
"Java",
".",
"convert_to_ruby_array",
"(",
"Naether",
"::",
"Java",
".",
"exec_static_method",
"(",
"'com.tobedevoured.naether.util.Notation'",
",",
"'getLocalPaths'",
",",
"[",
"local_repo_path",
",",
"notations",
"]",
",",
"[",
"'java.lang.String'",
",",
"'java.util.List'",
"]",
")",
")",
"else",
"paths",
"=",
"Naether",
"::",
"Java",
".",
"exec_static_method",
"(",
"'com.tobedevoured.naether.util.Notation'",
",",
"'getLocalPaths'",
",",
"[",
"local_repo_path",
",",
"Naether",
"::",
"Java",
".",
"convert_to_java_list",
"(",
"notations",
")",
"]",
",",
"[",
"'java.lang.String'",
",",
"'java.util.List'",
"]",
")",
"Naether",
"::",
"Java",
".",
"convert_to_ruby_array",
"(",
"paths",
",",
"true",
")",
"end",
"end"
] | Convert notations to local paths of artifacts
@param [Array<String>] notations
@return [Array<String>] of paths to artifacts
@see https://github.com/mguymon/naether/wiki/Notations | [
"Convert",
"notations",
"to",
"local",
"paths",
"of",
"artifacts"
] | 218d8fd36c0b8b6e16d66e5715975570b4560ec4 | https://github.com/mguymon/naether/blob/218d8fd36c0b8b6e16d66e5715975570b4560ec4/src/main/ruby/naether/runtime.rb#L308-L325 |
23,576 | mguymon/naether | src/main/ruby/naether/runtime.rb | Naether.Runtime.deploy_artifact | def deploy_artifact( notation, file_path, url, opts = {} )
artifact = Naether::Java.create( "com.tobedevoured.naether.deploy.DeployArtifact" )
artifact.setRemoteRepo( url )
artifact.setNotation( notation )
artifact.setFilePath( file_path )
if opts[:pom_path]
artifact.setPomPath( opts[:pom_path] )
end
if opts[:username] || opts[:pub_key]
artifact.setAuth(opts[:username], opts[:password], opts[:pub_key], opts[:pub_key_passphrase] )
end
if Naether.platform == 'java'
@resolver.deployArtifact(artifact)
else
@resolver._invoke( 'deployArtifact', 'Lcom.tobedevoured.naether.deploy.DeployArtifact;', artifact )
end
end | ruby | def deploy_artifact( notation, file_path, url, opts = {} )
artifact = Naether::Java.create( "com.tobedevoured.naether.deploy.DeployArtifact" )
artifact.setRemoteRepo( url )
artifact.setNotation( notation )
artifact.setFilePath( file_path )
if opts[:pom_path]
artifact.setPomPath( opts[:pom_path] )
end
if opts[:username] || opts[:pub_key]
artifact.setAuth(opts[:username], opts[:password], opts[:pub_key], opts[:pub_key_passphrase] )
end
if Naether.platform == 'java'
@resolver.deployArtifact(artifact)
else
@resolver._invoke( 'deployArtifact', 'Lcom.tobedevoured.naether.deploy.DeployArtifact;', artifact )
end
end | [
"def",
"deploy_artifact",
"(",
"notation",
",",
"file_path",
",",
"url",
",",
"opts",
"=",
"{",
"}",
")",
"artifact",
"=",
"Naether",
"::",
"Java",
".",
"create",
"(",
"\"com.tobedevoured.naether.deploy.DeployArtifact\"",
")",
"artifact",
".",
"setRemoteRepo",
"(",
"url",
")",
"artifact",
".",
"setNotation",
"(",
"notation",
")",
"artifact",
".",
"setFilePath",
"(",
"file_path",
")",
"if",
"opts",
"[",
":pom_path",
"]",
"artifact",
".",
"setPomPath",
"(",
"opts",
"[",
":pom_path",
"]",
")",
"end",
"if",
"opts",
"[",
":username",
"]",
"||",
"opts",
"[",
":pub_key",
"]",
"artifact",
".",
"setAuth",
"(",
"opts",
"[",
":username",
"]",
",",
"opts",
"[",
":password",
"]",
",",
"opts",
"[",
":pub_key",
"]",
",",
"opts",
"[",
":pub_key_passphrase",
"]",
")",
"end",
"if",
"Naether",
".",
"platform",
"==",
"'java'",
"@resolver",
".",
"deployArtifact",
"(",
"artifact",
")",
"else",
"@resolver",
".",
"_invoke",
"(",
"'deployArtifact'",
",",
"'Lcom.tobedevoured.naether.deploy.DeployArtifact;'",
",",
"artifact",
")",
"end",
"end"
] | Deploy artifact to remote repo url
@param [String] notation
@param [String] file_path to artifact to deploy
@param [String] url to deploy to
@param [Hash] opts
@option opts [String] :pom_path path to pom.xml
@option opts [String] :username for optional auth
@option opts [String] :password for optional auth
@option opts [String] :pub_key for optional auth
@option opts [String] :pub_key_passphrase for optional auth | [
"Deploy",
"artifact",
"to",
"remote",
"repo",
"url"
] | 218d8fd36c0b8b6e16d66e5715975570b4560ec4 | https://github.com/mguymon/naether/blob/218d8fd36c0b8b6e16d66e5715975570b4560ec4/src/main/ruby/naether/runtime.rb#L364-L382 |
23,577 | south37/rucc | lib/rucc/parser.rb | Rucc.Parser.read_int_sval | def read_int_sval(s)
s = s.downcase
if s.match(/^[+-]?0x/)
return s.to_i(16)
end
if s.match(/^[+-]?0b/)
return s.to_i(2)
end
if s.match(/^[+-]?0/)
return s.to_i(8)
end
s.to_i(10)
end | ruby | def read_int_sval(s)
s = s.downcase
if s.match(/^[+-]?0x/)
return s.to_i(16)
end
if s.match(/^[+-]?0b/)
return s.to_i(2)
end
if s.match(/^[+-]?0/)
return s.to_i(8)
end
s.to_i(10)
end | [
"def",
"read_int_sval",
"(",
"s",
")",
"s",
"=",
"s",
".",
"downcase",
"if",
"s",
".",
"match",
"(",
"/",
"/",
")",
"return",
"s",
".",
"to_i",
"(",
"16",
")",
"end",
"if",
"s",
".",
"match",
"(",
"/",
"/",
")",
"return",
"s",
".",
"to_i",
"(",
"2",
")",
"end",
"if",
"s",
".",
"match",
"(",
"/",
"/",
")",
"return",
"s",
".",
"to_i",
"(",
"8",
")",
"end",
"s",
".",
"to_i",
"(",
"10",
")",
"end"
] | Max of long
@param [s]
@return [Integer] | [
"Max",
"of",
"long"
] | 11743d10eb2fcf0834b4f4a34bb5b8a109b32558 | https://github.com/south37/rucc/blob/11743d10eb2fcf0834b4f4a34bb5b8a109b32558/lib/rucc/parser.rb#L299-L311 |
23,578 | BookingSync/synced | lib/synced/attributes_as_hash.rb | Synced.AttributesAsHash.synced_attributes_as_hash | def synced_attributes_as_hash(attributes)
return attributes if attributes.is_a?(Hash)
Hash[Array.wrap(attributes).map { |name| [name, name] }]
end | ruby | def synced_attributes_as_hash(attributes)
return attributes if attributes.is_a?(Hash)
Hash[Array.wrap(attributes).map { |name| [name, name] }]
end | [
"def",
"synced_attributes_as_hash",
"(",
"attributes",
")",
"return",
"attributes",
"if",
"attributes",
".",
"is_a?",
"(",
"Hash",
")",
"Hash",
"[",
"Array",
".",
"wrap",
"(",
"attributes",
")",
".",
"map",
"{",
"|",
"name",
"|",
"[",
"name",
",",
"name",
"]",
"}",
"]",
"end"
] | On a Hash returns the same Hash
On an Array returns a Hash with identical corresponding keys and values
Used for mapping local - remote attributes | [
"On",
"a",
"Hash",
"returns",
"the",
"same",
"Hash",
"On",
"an",
"Array",
"returns",
"a",
"Hash",
"with",
"identical",
"corresponding",
"keys",
"and",
"values",
"Used",
"for",
"mapping",
"local",
"-",
"remote",
"attributes"
] | 4a79eee67497c7b7954b0a8dd6ac832fa06c112b | https://github.com/BookingSync/synced/blob/4a79eee67497c7b7954b0a8dd6ac832fa06c112b/lib/synced/attributes_as_hash.rb#L6-L9 |
23,579 | south37/rucc | lib/rucc/engine.rb | Rucc.Engine.read_from_string | def read_from_string(buf)
@lexer.stream_stash([FileIO.new(StringIO.new(buf), "-")])
parse.each do |toplevel_ast|
@gen.emit_toplevel(toplevel_ast)
end
@lexer.stream_unstash
end | ruby | def read_from_string(buf)
@lexer.stream_stash([FileIO.new(StringIO.new(buf), "-")])
parse.each do |toplevel_ast|
@gen.emit_toplevel(toplevel_ast)
end
@lexer.stream_unstash
end | [
"def",
"read_from_string",
"(",
"buf",
")",
"@lexer",
".",
"stream_stash",
"(",
"[",
"FileIO",
".",
"new",
"(",
"StringIO",
".",
"new",
"(",
"buf",
")",
",",
"\"-\"",
")",
"]",
")",
"parse",
".",
"each",
"do",
"|",
"toplevel_ast",
"|",
"@gen",
".",
"emit_toplevel",
"(",
"toplevel_ast",
")",
"end",
"@lexer",
".",
"stream_unstash",
"end"
] | Reads from a string as if the string is a content of input file.
Convenient for evaluating small string snippet contaiing preprocessor macros.
@param [String] buf | [
"Reads",
"from",
"a",
"string",
"as",
"if",
"the",
"string",
"is",
"a",
"content",
"of",
"input",
"file",
".",
"Convenient",
"for",
"evaluating",
"small",
"string",
"snippet",
"contaiing",
"preprocessor",
"macros",
"."
] | 11743d10eb2fcf0834b4f4a34bb5b8a109b32558 | https://github.com/south37/rucc/blob/11743d10eb2fcf0834b4f4a34bb5b8a109b32558/lib/rucc/engine.rb#L130-L136 |
23,580 | infinitetoken/barcodes | lib/barcodes/exec.rb | Barcodes.Exec.run | def run
begin
unless self.symbology.nil?
unless self.options[:ascii]
Barcodes::Renderer::Pdf.new(Barcodes.create(self.symbology, self.options)).render(self.target)
else
Barcodes::Renderer::Ascii.new(Barcodes.create(self.symbology, self.options)).render(self.target)
end
end
rescue Exception => e
puts e.message
end
end | ruby | def run
begin
unless self.symbology.nil?
unless self.options[:ascii]
Barcodes::Renderer::Pdf.new(Barcodes.create(self.symbology, self.options)).render(self.target)
else
Barcodes::Renderer::Ascii.new(Barcodes.create(self.symbology, self.options)).render(self.target)
end
end
rescue Exception => e
puts e.message
end
end | [
"def",
"run",
"begin",
"unless",
"self",
".",
"symbology",
".",
"nil?",
"unless",
"self",
".",
"options",
"[",
":ascii",
"]",
"Barcodes",
"::",
"Renderer",
"::",
"Pdf",
".",
"new",
"(",
"Barcodes",
".",
"create",
"(",
"self",
".",
"symbology",
",",
"self",
".",
"options",
")",
")",
".",
"render",
"(",
"self",
".",
"target",
")",
"else",
"Barcodes",
"::",
"Renderer",
"::",
"Ascii",
".",
"new",
"(",
"Barcodes",
".",
"create",
"(",
"self",
".",
"symbology",
",",
"self",
".",
"options",
")",
")",
".",
"render",
"(",
"self",
".",
"target",
")",
"end",
"end",
"rescue",
"Exception",
"=>",
"e",
"puts",
"e",
".",
"message",
"end",
"end"
] | Creates a new instance with given command line arguments and options
Runs the command and renders barcode | [
"Creates",
"a",
"new",
"instance",
"with",
"given",
"command",
"line",
"arguments",
"and",
"options",
"Runs",
"the",
"command",
"and",
"renders",
"barcode"
] | 76a0bda4f5afca246ef040ea96f92044366efc39 | https://github.com/infinitetoken/barcodes/blob/76a0bda4f5afca246ef040ea96f92044366efc39/lib/barcodes/exec.rb#L42-L54 |
23,581 | infinitetoken/barcodes | lib/barcodes/exec.rb | Barcodes.Exec._init_parser | def _init_parser
@parser ||= OptionParser.new do |opts|
opts.banner = "Usage: barcodes [OPTIONS] symbology target"
opts.separator ""
opts.on('-D', '--data [DATA]', 'The barcode data to encode (0123456789)') { |v| @options[:data] = v ||= '0123456789' }
opts.on('-s', '--start_character [START_CHARACTER]', 'The barcode start character if applicable') { |v| @options[:start_character] = v ||= '' }
opts.on('-e', '--stop_character [STOP_CHARACTER]', 'The barcode stop character if applicable') { |v| @options[:stop_character] = v ||= '' }
opts.on('-W', '--bar_width [BAR_WIDTH]', 'The barcode bar width in mils (20)') { |v| @options[:bar_width] = v.to_i ||= 20 }
opts.on('-H', '--bar_height [BAR_HEIGHT]', 'The barcode bar height in mils (1000)') { |v| @options[:bar_height] = v.to_i ||= 1000 }
opts.on('-c', '--caption_height [CAPTION_HEIGHT]', 'The barcode caption height in mils (180)') { |v| @options[:caption_height] = v.to_i ||= 180 }
opts.on('-p', '--caption_size [CAPTION_SIZE]', 'The caption font size in mils (167)') { |v| @options[:font_size] = v.to_f ||= 167 }
opts.on('-A', '--alpha [ALPHA]', 'The barcode transparency (1.0)') { |v| @options[:alpha] = v.to_f ||= 1.0 }
opts.on('-O', '--color [COLOR]', 'The barcode color in hex (000000)') { |v| @options[:color] = v ||= '000000' }
opts.on('-a', '--captioned', 'Render barcode caption (true)') { |v| @options[:captioned] = v ||= true }
opts.on('-i', '--ascii', 'Render barcode as ASCII string (false)') { |v| @options[:ascii] = v ||= false }
opts.on('-v', '--version') { puts self._version; exit }
opts.on('-h', '--help') { puts opts; exit }
opts.separator ""
end
end | ruby | def _init_parser
@parser ||= OptionParser.new do |opts|
opts.banner = "Usage: barcodes [OPTIONS] symbology target"
opts.separator ""
opts.on('-D', '--data [DATA]', 'The barcode data to encode (0123456789)') { |v| @options[:data] = v ||= '0123456789' }
opts.on('-s', '--start_character [START_CHARACTER]', 'The barcode start character if applicable') { |v| @options[:start_character] = v ||= '' }
opts.on('-e', '--stop_character [STOP_CHARACTER]', 'The barcode stop character if applicable') { |v| @options[:stop_character] = v ||= '' }
opts.on('-W', '--bar_width [BAR_WIDTH]', 'The barcode bar width in mils (20)') { |v| @options[:bar_width] = v.to_i ||= 20 }
opts.on('-H', '--bar_height [BAR_HEIGHT]', 'The barcode bar height in mils (1000)') { |v| @options[:bar_height] = v.to_i ||= 1000 }
opts.on('-c', '--caption_height [CAPTION_HEIGHT]', 'The barcode caption height in mils (180)') { |v| @options[:caption_height] = v.to_i ||= 180 }
opts.on('-p', '--caption_size [CAPTION_SIZE]', 'The caption font size in mils (167)') { |v| @options[:font_size] = v.to_f ||= 167 }
opts.on('-A', '--alpha [ALPHA]', 'The barcode transparency (1.0)') { |v| @options[:alpha] = v.to_f ||= 1.0 }
opts.on('-O', '--color [COLOR]', 'The barcode color in hex (000000)') { |v| @options[:color] = v ||= '000000' }
opts.on('-a', '--captioned', 'Render barcode caption (true)') { |v| @options[:captioned] = v ||= true }
opts.on('-i', '--ascii', 'Render barcode as ASCII string (false)') { |v| @options[:ascii] = v ||= false }
opts.on('-v', '--version') { puts self._version; exit }
opts.on('-h', '--help') { puts opts; exit }
opts.separator ""
end
end | [
"def",
"_init_parser",
"@parser",
"||=",
"OptionParser",
".",
"new",
"do",
"|",
"opts",
"|",
"opts",
".",
"banner",
"=",
"\"Usage: barcodes [OPTIONS] symbology target\"",
"opts",
".",
"separator",
"\"\"",
"opts",
".",
"on",
"(",
"'-D'",
",",
"'--data [DATA]'",
",",
"'The barcode data to encode (0123456789)'",
")",
"{",
"|",
"v",
"|",
"@options",
"[",
":data",
"]",
"=",
"v",
"||=",
"'0123456789'",
"}",
"opts",
".",
"on",
"(",
"'-s'",
",",
"'--start_character [START_CHARACTER]'",
",",
"'The barcode start character if applicable'",
")",
"{",
"|",
"v",
"|",
"@options",
"[",
":start_character",
"]",
"=",
"v",
"||=",
"''",
"}",
"opts",
".",
"on",
"(",
"'-e'",
",",
"'--stop_character [STOP_CHARACTER]'",
",",
"'The barcode stop character if applicable'",
")",
"{",
"|",
"v",
"|",
"@options",
"[",
":stop_character",
"]",
"=",
"v",
"||=",
"''",
"}",
"opts",
".",
"on",
"(",
"'-W'",
",",
"'--bar_width [BAR_WIDTH]'",
",",
"'The barcode bar width in mils (20)'",
")",
"{",
"|",
"v",
"|",
"@options",
"[",
":bar_width",
"]",
"=",
"v",
".",
"to_i",
"||=",
"20",
"}",
"opts",
".",
"on",
"(",
"'-H'",
",",
"'--bar_height [BAR_HEIGHT]'",
",",
"'The barcode bar height in mils (1000)'",
")",
"{",
"|",
"v",
"|",
"@options",
"[",
":bar_height",
"]",
"=",
"v",
".",
"to_i",
"||=",
"1000",
"}",
"opts",
".",
"on",
"(",
"'-c'",
",",
"'--caption_height [CAPTION_HEIGHT]'",
",",
"'The barcode caption height in mils (180)'",
")",
"{",
"|",
"v",
"|",
"@options",
"[",
":caption_height",
"]",
"=",
"v",
".",
"to_i",
"||=",
"180",
"}",
"opts",
".",
"on",
"(",
"'-p'",
",",
"'--caption_size [CAPTION_SIZE]'",
",",
"'The caption font size in mils (167)'",
")",
"{",
"|",
"v",
"|",
"@options",
"[",
":font_size",
"]",
"=",
"v",
".",
"to_f",
"||=",
"167",
"}",
"opts",
".",
"on",
"(",
"'-A'",
",",
"'--alpha [ALPHA]'",
",",
"'The barcode transparency (1.0)'",
")",
"{",
"|",
"v",
"|",
"@options",
"[",
":alpha",
"]",
"=",
"v",
".",
"to_f",
"||=",
"1.0",
"}",
"opts",
".",
"on",
"(",
"'-O'",
",",
"'--color [COLOR]'",
",",
"'The barcode color in hex (000000)'",
")",
"{",
"|",
"v",
"|",
"@options",
"[",
":color",
"]",
"=",
"v",
"||=",
"'000000'",
"}",
"opts",
".",
"on",
"(",
"'-a'",
",",
"'--captioned'",
",",
"'Render barcode caption (true)'",
")",
"{",
"|",
"v",
"|",
"@options",
"[",
":captioned",
"]",
"=",
"v",
"||=",
"true",
"}",
"opts",
".",
"on",
"(",
"'-i'",
",",
"'--ascii'",
",",
"'Render barcode as ASCII string (false)'",
")",
"{",
"|",
"v",
"|",
"@options",
"[",
":ascii",
"]",
"=",
"v",
"||=",
"false",
"}",
"opts",
".",
"on",
"(",
"'-v'",
",",
"'--version'",
")",
"{",
"puts",
"self",
".",
"_version",
";",
"exit",
"}",
"opts",
".",
"on",
"(",
"'-h'",
",",
"'--help'",
")",
"{",
"puts",
"opts",
";",
"exit",
"}",
"opts",
".",
"separator",
"\"\"",
"end",
"end"
] | Initializes the option parser instance | [
"Initializes",
"the",
"option",
"parser",
"instance"
] | 76a0bda4f5afca246ef040ea96f92044366efc39 | https://github.com/infinitetoken/barcodes/blob/76a0bda4f5afca246ef040ea96f92044366efc39/lib/barcodes/exec.rb#L59-L78 |
23,582 | infinitetoken/barcodes | lib/barcodes/exec.rb | Barcodes.Exec._parse! | def _parse!
begin
self.parser.parse!(self.argv)
rescue
puts self.parser.help
exit 1
end
@symbology = self.argv.shift
@target = self.argv.shift
end | ruby | def _parse!
begin
self.parser.parse!(self.argv)
rescue
puts self.parser.help
exit 1
end
@symbology = self.argv.shift
@target = self.argv.shift
end | [
"def",
"_parse!",
"begin",
"self",
".",
"parser",
".",
"parse!",
"(",
"self",
".",
"argv",
")",
"rescue",
"puts",
"self",
".",
"parser",
".",
"help",
"exit",
"1",
"end",
"@symbology",
"=",
"self",
".",
"argv",
".",
"shift",
"@target",
"=",
"self",
".",
"argv",
".",
"shift",
"end"
] | Parses the command line arguments | [
"Parses",
"the",
"command",
"line",
"arguments"
] | 76a0bda4f5afca246ef040ea96f92044366efc39 | https://github.com/infinitetoken/barcodes/blob/76a0bda4f5afca246ef040ea96f92044366efc39/lib/barcodes/exec.rb#L81-L92 |
23,583 | ruby-ore/ore | lib/ore/cli.rb | Ore.CLI.list | def list
print_template = lambda { |path|
puts " #{File.basename(path)}"
}
say "Builtin templates:", :green
Config.builtin_templates(&print_template)
say "Installed templates:", :green
Config.installed_templates(&print_template)
end | ruby | def list
print_template = lambda { |path|
puts " #{File.basename(path)}"
}
say "Builtin templates:", :green
Config.builtin_templates(&print_template)
say "Installed templates:", :green
Config.installed_templates(&print_template)
end | [
"def",
"list",
"print_template",
"=",
"lambda",
"{",
"|",
"path",
"|",
"puts",
"\" #{File.basename(path)}\"",
"}",
"say",
"\"Builtin templates:\"",
",",
":green",
"Config",
".",
"builtin_templates",
"(",
"print_template",
")",
"say",
"\"Installed templates:\"",
",",
":green",
"Config",
".",
"installed_templates",
"(",
"print_template",
")",
"end"
] | Lists builtin and installed templates. | [
"Lists",
"builtin",
"and",
"installed",
"templates",
"."
] | 585c98027771fd118041e90bb38295983d67166c | https://github.com/ruby-ore/ore/blob/585c98027771fd118041e90bb38295983d67166c/lib/ore/cli.rb#L24-L34 |
23,584 | ruby-ore/ore | lib/ore/cli.rb | Ore.CLI.remove | def remove(name)
name = File.basename(name)
path = File.join(Config::TEMPLATES_DIR,name)
unless File.exists?(path)
say "Unknown template: #{name}", :red
exit -1
end
FileUtils.rm_rf(path)
end | ruby | def remove(name)
name = File.basename(name)
path = File.join(Config::TEMPLATES_DIR,name)
unless File.exists?(path)
say "Unknown template: #{name}", :red
exit -1
end
FileUtils.rm_rf(path)
end | [
"def",
"remove",
"(",
"name",
")",
"name",
"=",
"File",
".",
"basename",
"(",
"name",
")",
"path",
"=",
"File",
".",
"join",
"(",
"Config",
"::",
"TEMPLATES_DIR",
",",
"name",
")",
"unless",
"File",
".",
"exists?",
"(",
"path",
")",
"say",
"\"Unknown template: #{name}\"",
",",
":red",
"exit",
"-",
"1",
"end",
"FileUtils",
".",
"rm_rf",
"(",
"path",
")",
"end"
] | Removes a previously installed template.
@param [String] name
The name of the template to remove. | [
"Removes",
"a",
"previously",
"installed",
"template",
"."
] | 585c98027771fd118041e90bb38295983d67166c | https://github.com/ruby-ore/ore/blob/585c98027771fd118041e90bb38295983d67166c/lib/ore/cli.rb#L82-L92 |
23,585 | ruby-ore/ore | lib/ore/generator.rb | Ore.Generator.generate | def generate
self.destination_root = path
enable_templates!
initialize_variables!
extend Template::Helpers::MARKUP.fetch(@markup)
unless options.quiet?
say "Generating #{self.destination_root}", :green
end
generate_directories!
generate_files!
initialize_scm!
end | ruby | def generate
self.destination_root = path
enable_templates!
initialize_variables!
extend Template::Helpers::MARKUP.fetch(@markup)
unless options.quiet?
say "Generating #{self.destination_root}", :green
end
generate_directories!
generate_files!
initialize_scm!
end | [
"def",
"generate",
"self",
".",
"destination_root",
"=",
"path",
"enable_templates!",
"initialize_variables!",
"extend",
"Template",
"::",
"Helpers",
"::",
"MARKUP",
".",
"fetch",
"(",
"@markup",
")",
"unless",
"options",
".",
"quiet?",
"say",
"\"Generating #{self.destination_root}\"",
",",
":green",
"end",
"generate_directories!",
"generate_files!",
"initialize_scm!",
"end"
] | Generates a new project. | [
"Generates",
"a",
"new",
"project",
"."
] | 585c98027771fd118041e90bb38295983d67166c | https://github.com/ruby-ore/ore/blob/585c98027771fd118041e90bb38295983d67166c/lib/ore/generator.rb#L90-L105 |
23,586 | ruby-ore/ore | lib/ore/generator.rb | Ore.Generator.enable_template | def enable_template(name)
name = name.to_sym
return false if @enabled_templates.include?(name)
unless (template_dir = Template.templates[name])
say "Unknown template #{name}", :red
exit -1
end
new_template = Template::Directory.new(template_dir)
# mark the template as enabled
@enabled_templates << name
# enable any other templates
new_template.enable.each do |sub_template|
enable_template(sub_template)
end
# append the new template to the end of the list,
# to override previously loaded templates
@templates << new_template
# add the template directory to the source-paths
self.source_paths << new_template.path
return true
end | ruby | def enable_template(name)
name = name.to_sym
return false if @enabled_templates.include?(name)
unless (template_dir = Template.templates[name])
say "Unknown template #{name}", :red
exit -1
end
new_template = Template::Directory.new(template_dir)
# mark the template as enabled
@enabled_templates << name
# enable any other templates
new_template.enable.each do |sub_template|
enable_template(sub_template)
end
# append the new template to the end of the list,
# to override previously loaded templates
@templates << new_template
# add the template directory to the source-paths
self.source_paths << new_template.path
return true
end | [
"def",
"enable_template",
"(",
"name",
")",
"name",
"=",
"name",
".",
"to_sym",
"return",
"false",
"if",
"@enabled_templates",
".",
"include?",
"(",
"name",
")",
"unless",
"(",
"template_dir",
"=",
"Template",
".",
"templates",
"[",
"name",
"]",
")",
"say",
"\"Unknown template #{name}\"",
",",
":red",
"exit",
"-",
"1",
"end",
"new_template",
"=",
"Template",
"::",
"Directory",
".",
"new",
"(",
"template_dir",
")",
"# mark the template as enabled",
"@enabled_templates",
"<<",
"name",
"# enable any other templates",
"new_template",
".",
"enable",
".",
"each",
"do",
"|",
"sub_template",
"|",
"enable_template",
"(",
"sub_template",
")",
"end",
"# append the new template to the end of the list,",
"# to override previously loaded templates",
"@templates",
"<<",
"new_template",
"# add the template directory to the source-paths",
"self",
".",
"source_paths",
"<<",
"new_template",
".",
"path",
"return",
"true",
"end"
] | Enables a template, adding it to the generator.
@param [Symbol, String] name
The name of the template to add.
@since 0.4.0 | [
"Enables",
"a",
"template",
"adding",
"it",
"to",
"the",
"generator",
"."
] | 585c98027771fd118041e90bb38295983d67166c | https://github.com/ruby-ore/ore/blob/585c98027771fd118041e90bb38295983d67166c/lib/ore/generator.rb#L117-L144 |
23,587 | ruby-ore/ore | lib/ore/generator.rb | Ore.Generator.disable_template | def disable_template(name)
name = name.to_sym
return false if @disabled_templates.include?(name)
if (template_dir = Template.templates[name])
source_paths.delete(template_dir)
@templates.delete_if { |template| template.path == template_dir }
@enabled_templates.delete(name)
end
@disabled_templates << name
return true
end | ruby | def disable_template(name)
name = name.to_sym
return false if @disabled_templates.include?(name)
if (template_dir = Template.templates[name])
source_paths.delete(template_dir)
@templates.delete_if { |template| template.path == template_dir }
@enabled_templates.delete(name)
end
@disabled_templates << name
return true
end | [
"def",
"disable_template",
"(",
"name",
")",
"name",
"=",
"name",
".",
"to_sym",
"return",
"false",
"if",
"@disabled_templates",
".",
"include?",
"(",
"name",
")",
"if",
"(",
"template_dir",
"=",
"Template",
".",
"templates",
"[",
"name",
"]",
")",
"source_paths",
".",
"delete",
"(",
"template_dir",
")",
"@templates",
".",
"delete_if",
"{",
"|",
"template",
"|",
"template",
".",
"path",
"==",
"template_dir",
"}",
"@enabled_templates",
".",
"delete",
"(",
"name",
")",
"end",
"@disabled_templates",
"<<",
"name",
"return",
"true",
"end"
] | Disables a template in the generator.
@param [Symbol, String] name
The name of the template.
@since 0.4.0 | [
"Disables",
"a",
"template",
"in",
"the",
"generator",
"."
] | 585c98027771fd118041e90bb38295983d67166c | https://github.com/ruby-ore/ore/blob/585c98027771fd118041e90bb38295983d67166c/lib/ore/generator.rb#L154-L168 |
23,588 | ruby-ore/ore | lib/ore/generator.rb | Ore.Generator.enable_templates! | def enable_templates!
@templates = []
@enabled_templates = Set[]
@disabled_templates = Set[]
enable_template :gem
# enable the default templates first
Options::DEFAULT_TEMPLATES.each do |name|
if (Template.template?(name) && options[name])
enable_template(name)
end
end
# enable the templates specified by option
options.each do |name,value|
if (Template.template?(name) && value)
enable_template(name)
end
end
# enable any additionally specified templates
options.templates.each { |name| enable_template(name) }
# disable any previously enabled templates
@templates.reverse_each do |template|
template.disable.each { |name| disable_template(name) }
end
end | ruby | def enable_templates!
@templates = []
@enabled_templates = Set[]
@disabled_templates = Set[]
enable_template :gem
# enable the default templates first
Options::DEFAULT_TEMPLATES.each do |name|
if (Template.template?(name) && options[name])
enable_template(name)
end
end
# enable the templates specified by option
options.each do |name,value|
if (Template.template?(name) && value)
enable_template(name)
end
end
# enable any additionally specified templates
options.templates.each { |name| enable_template(name) }
# disable any previously enabled templates
@templates.reverse_each do |template|
template.disable.each { |name| disable_template(name) }
end
end | [
"def",
"enable_templates!",
"@templates",
"=",
"[",
"]",
"@enabled_templates",
"=",
"Set",
"[",
"]",
"@disabled_templates",
"=",
"Set",
"[",
"]",
"enable_template",
":gem",
"# enable the default templates first",
"Options",
"::",
"DEFAULT_TEMPLATES",
".",
"each",
"do",
"|",
"name",
"|",
"if",
"(",
"Template",
".",
"template?",
"(",
"name",
")",
"&&",
"options",
"[",
"name",
"]",
")",
"enable_template",
"(",
"name",
")",
"end",
"end",
"# enable the templates specified by option",
"options",
".",
"each",
"do",
"|",
"name",
",",
"value",
"|",
"if",
"(",
"Template",
".",
"template?",
"(",
"name",
")",
"&&",
"value",
")",
"enable_template",
"(",
"name",
")",
"end",
"end",
"# enable any additionally specified templates",
"options",
".",
"templates",
".",
"each",
"{",
"|",
"name",
"|",
"enable_template",
"(",
"name",
")",
"}",
"# disable any previously enabled templates",
"@templates",
".",
"reverse_each",
"do",
"|",
"template",
"|",
"template",
".",
"disable",
".",
"each",
"{",
"|",
"name",
"|",
"disable_template",
"(",
"name",
")",
"}",
"end",
"end"
] | Enables templates. | [
"Enables",
"templates",
"."
] | 585c98027771fd118041e90bb38295983d67166c | https://github.com/ruby-ore/ore/blob/585c98027771fd118041e90bb38295983d67166c/lib/ore/generator.rb#L173-L201 |
23,589 | ruby-ore/ore | lib/ore/generator.rb | Ore.Generator.initialize_variables! | def initialize_variables!
@root = destination_root
@project_dir = File.basename(@root)
@name = (options.name || @project_dir)
@scm = if File.directory?(File.join(@root,'.git')) then :git
elsif File.directory?(File.join(@root,'.hg')) then :hg
elsif File.directory?(File.join(@root,'.svn')) then :svn
elsif options.hg? then :hg
elsif options.git? then :git
end
case @scm
when :git
@scm_user = `git config user.name`.chomp
@scm_email = `git config user.email`.chomp
@github_user = `git config github.user`.chomp
when :hg
user_email = `hg showconfig ui.username`.chomp
user_email.scan(/([^<]+)\s+<([^>]+)>/) do |(user,email)|
@scm_user, @scm_email = user, email
end
end
@modules = modules_of(@name)
@module_depth = @modules.length
@module = @modules.last
@namespace = options.namespace || namespace_of(@name)
@namespace_dirs = namespace_dirs_of(@name)
@namespace_path = namespace_path_of(@name)
@namespace_dir = @namespace_dirs.last
@version = options.version
@summary = options.summary
@description = options.description
@authors = if options.author || options.author
[*options.author, *options.authors]
else
[@scm_user || ENV['USERNAME'] || ENV['USER'].capitalize]
end
@author = @authors.first
@email = (options.email || @scm_email)
@safe_email = @email.sub('@',' at ') if @email
@homepage = if options.homepage
options.homepage
elsif !(@github_user.nil? || @github_user.empty?)
"https://github.com/#{@github_user}/#{@name}#readme"
else
"https://rubygems.org/gems/#{@name}"
end
@uri = URI(@homepage)
@bug_tracker = case @uri.host
when 'github.com'
"https://#{@uri.host}#{@uri.path}/issues"
end
@markup = if options.markdown? then :markdown
elsif options.textile? then :textile
elsif options.markup? then options.markup.to_sym
end
@markup_ext = Template::Markup::EXT.fetch(@markup) do
say "Unknown markup: #{@markup}", :red
exit -1
end
@date = Date.today
@year = @date.year
@month = @date.month
@day = @date.day
@ignore = SortedSet[]
@dependencies = {}
@development_dependencies = {}
@templates.each do |template|
@ignore.merge(template.ignore)
@dependencies.merge!(template.dependencies)
@development_dependencies.merge!(template.development_dependencies)
template.variables.each do |name,value|
instance_variable_set("@#{name}",value)
end
end
@generated_dirs = {}
@generated_files = {}
end | ruby | def initialize_variables!
@root = destination_root
@project_dir = File.basename(@root)
@name = (options.name || @project_dir)
@scm = if File.directory?(File.join(@root,'.git')) then :git
elsif File.directory?(File.join(@root,'.hg')) then :hg
elsif File.directory?(File.join(@root,'.svn')) then :svn
elsif options.hg? then :hg
elsif options.git? then :git
end
case @scm
when :git
@scm_user = `git config user.name`.chomp
@scm_email = `git config user.email`.chomp
@github_user = `git config github.user`.chomp
when :hg
user_email = `hg showconfig ui.username`.chomp
user_email.scan(/([^<]+)\s+<([^>]+)>/) do |(user,email)|
@scm_user, @scm_email = user, email
end
end
@modules = modules_of(@name)
@module_depth = @modules.length
@module = @modules.last
@namespace = options.namespace || namespace_of(@name)
@namespace_dirs = namespace_dirs_of(@name)
@namespace_path = namespace_path_of(@name)
@namespace_dir = @namespace_dirs.last
@version = options.version
@summary = options.summary
@description = options.description
@authors = if options.author || options.author
[*options.author, *options.authors]
else
[@scm_user || ENV['USERNAME'] || ENV['USER'].capitalize]
end
@author = @authors.first
@email = (options.email || @scm_email)
@safe_email = @email.sub('@',' at ') if @email
@homepage = if options.homepage
options.homepage
elsif !(@github_user.nil? || @github_user.empty?)
"https://github.com/#{@github_user}/#{@name}#readme"
else
"https://rubygems.org/gems/#{@name}"
end
@uri = URI(@homepage)
@bug_tracker = case @uri.host
when 'github.com'
"https://#{@uri.host}#{@uri.path}/issues"
end
@markup = if options.markdown? then :markdown
elsif options.textile? then :textile
elsif options.markup? then options.markup.to_sym
end
@markup_ext = Template::Markup::EXT.fetch(@markup) do
say "Unknown markup: #{@markup}", :red
exit -1
end
@date = Date.today
@year = @date.year
@month = @date.month
@day = @date.day
@ignore = SortedSet[]
@dependencies = {}
@development_dependencies = {}
@templates.each do |template|
@ignore.merge(template.ignore)
@dependencies.merge!(template.dependencies)
@development_dependencies.merge!(template.development_dependencies)
template.variables.each do |name,value|
instance_variable_set("@#{name}",value)
end
end
@generated_dirs = {}
@generated_files = {}
end | [
"def",
"initialize_variables!",
"@root",
"=",
"destination_root",
"@project_dir",
"=",
"File",
".",
"basename",
"(",
"@root",
")",
"@name",
"=",
"(",
"options",
".",
"name",
"||",
"@project_dir",
")",
"@scm",
"=",
"if",
"File",
".",
"directory?",
"(",
"File",
".",
"join",
"(",
"@root",
",",
"'.git'",
")",
")",
"then",
":git",
"elsif",
"File",
".",
"directory?",
"(",
"File",
".",
"join",
"(",
"@root",
",",
"'.hg'",
")",
")",
"then",
":hg",
"elsif",
"File",
".",
"directory?",
"(",
"File",
".",
"join",
"(",
"@root",
",",
"'.svn'",
")",
")",
"then",
":svn",
"elsif",
"options",
".",
"hg?",
"then",
":hg",
"elsif",
"options",
".",
"git?",
"then",
":git",
"end",
"case",
"@scm",
"when",
":git",
"@scm_user",
"=",
"`",
"`",
".",
"chomp",
"@scm_email",
"=",
"`",
"`",
".",
"chomp",
"@github_user",
"=",
"`",
"`",
".",
"chomp",
"when",
":hg",
"user_email",
"=",
"`",
"`",
".",
"chomp",
"user_email",
".",
"scan",
"(",
"/",
"\\s",
"/",
")",
"do",
"|",
"(",
"user",
",",
"email",
")",
"|",
"@scm_user",
",",
"@scm_email",
"=",
"user",
",",
"email",
"end",
"end",
"@modules",
"=",
"modules_of",
"(",
"@name",
")",
"@module_depth",
"=",
"@modules",
".",
"length",
"@module",
"=",
"@modules",
".",
"last",
"@namespace",
"=",
"options",
".",
"namespace",
"||",
"namespace_of",
"(",
"@name",
")",
"@namespace_dirs",
"=",
"namespace_dirs_of",
"(",
"@name",
")",
"@namespace_path",
"=",
"namespace_path_of",
"(",
"@name",
")",
"@namespace_dir",
"=",
"@namespace_dirs",
".",
"last",
"@version",
"=",
"options",
".",
"version",
"@summary",
"=",
"options",
".",
"summary",
"@description",
"=",
"options",
".",
"description",
"@authors",
"=",
"if",
"options",
".",
"author",
"||",
"options",
".",
"author",
"[",
"options",
".",
"author",
",",
"options",
".",
"authors",
"]",
"else",
"[",
"@scm_user",
"||",
"ENV",
"[",
"'USERNAME'",
"]",
"||",
"ENV",
"[",
"'USER'",
"]",
".",
"capitalize",
"]",
"end",
"@author",
"=",
"@authors",
".",
"first",
"@email",
"=",
"(",
"options",
".",
"email",
"||",
"@scm_email",
")",
"@safe_email",
"=",
"@email",
".",
"sub",
"(",
"'@'",
",",
"' at '",
")",
"if",
"@email",
"@homepage",
"=",
"if",
"options",
".",
"homepage",
"options",
".",
"homepage",
"elsif",
"!",
"(",
"@github_user",
".",
"nil?",
"||",
"@github_user",
".",
"empty?",
")",
"\"https://github.com/#{@github_user}/#{@name}#readme\"",
"else",
"\"https://rubygems.org/gems/#{@name}\"",
"end",
"@uri",
"=",
"URI",
"(",
"@homepage",
")",
"@bug_tracker",
"=",
"case",
"@uri",
".",
"host",
"when",
"'github.com'",
"\"https://#{@uri.host}#{@uri.path}/issues\"",
"end",
"@markup",
"=",
"if",
"options",
".",
"markdown?",
"then",
":markdown",
"elsif",
"options",
".",
"textile?",
"then",
":textile",
"elsif",
"options",
".",
"markup?",
"then",
"options",
".",
"markup",
".",
"to_sym",
"end",
"@markup_ext",
"=",
"Template",
"::",
"Markup",
"::",
"EXT",
".",
"fetch",
"(",
"@markup",
")",
"do",
"say",
"\"Unknown markup: #{@markup}\"",
",",
":red",
"exit",
"-",
"1",
"end",
"@date",
"=",
"Date",
".",
"today",
"@year",
"=",
"@date",
".",
"year",
"@month",
"=",
"@date",
".",
"month",
"@day",
"=",
"@date",
".",
"day",
"@ignore",
"=",
"SortedSet",
"[",
"]",
"@dependencies",
"=",
"{",
"}",
"@development_dependencies",
"=",
"{",
"}",
"@templates",
".",
"each",
"do",
"|",
"template",
"|",
"@ignore",
".",
"merge",
"(",
"template",
".",
"ignore",
")",
"@dependencies",
".",
"merge!",
"(",
"template",
".",
"dependencies",
")",
"@development_dependencies",
".",
"merge!",
"(",
"template",
".",
"development_dependencies",
")",
"template",
".",
"variables",
".",
"each",
"do",
"|",
"name",
",",
"value",
"|",
"instance_variable_set",
"(",
"\"@#{name}\"",
",",
"value",
")",
"end",
"end",
"@generated_dirs",
"=",
"{",
"}",
"@generated_files",
"=",
"{",
"}",
"end"
] | Initializes variables for the templates. | [
"Initializes",
"variables",
"for",
"the",
"templates",
"."
] | 585c98027771fd118041e90bb38295983d67166c | https://github.com/ruby-ore/ore/blob/585c98027771fd118041e90bb38295983d67166c/lib/ore/generator.rb#L206-L299 |
23,590 | ruby-ore/ore | lib/ore/generator.rb | Ore.Generator.generate_files! | def generate_files!
# iterate through the templates in reverse, so files in the templates
# loaded last override the previously templates.
@templates.reverse_each do |template|
# copy in the static files first
template.each_file(@markup) do |dest,file|
generate_file dest, file
end
# then render the templates
template.each_template(@markup) do |dest,file|
generate_file dest, file, template: true
end
end
@generated_files.each_value do |path|
dir = path.split(File::SEPARATOR,2).first
if dir == 'bin'
chmod path, 0755
end
end
end | ruby | def generate_files!
# iterate through the templates in reverse, so files in the templates
# loaded last override the previously templates.
@templates.reverse_each do |template|
# copy in the static files first
template.each_file(@markup) do |dest,file|
generate_file dest, file
end
# then render the templates
template.each_template(@markup) do |dest,file|
generate_file dest, file, template: true
end
end
@generated_files.each_value do |path|
dir = path.split(File::SEPARATOR,2).first
if dir == 'bin'
chmod path, 0755
end
end
end | [
"def",
"generate_files!",
"# iterate through the templates in reverse, so files in the templates",
"# loaded last override the previously templates.",
"@templates",
".",
"reverse_each",
"do",
"|",
"template",
"|",
"# copy in the static files first",
"template",
".",
"each_file",
"(",
"@markup",
")",
"do",
"|",
"dest",
",",
"file",
"|",
"generate_file",
"dest",
",",
"file",
"end",
"# then render the templates",
"template",
".",
"each_template",
"(",
"@markup",
")",
"do",
"|",
"dest",
",",
"file",
"|",
"generate_file",
"dest",
",",
"file",
",",
"template",
":",
"true",
"end",
"end",
"@generated_files",
".",
"each_value",
"do",
"|",
"path",
"|",
"dir",
"=",
"path",
".",
"split",
"(",
"File",
"::",
"SEPARATOR",
",",
"2",
")",
".",
"first",
"if",
"dir",
"==",
"'bin'",
"chmod",
"path",
",",
"0755",
"end",
"end",
"end"
] | Copies static files and renders templates in the template directories. | [
"Copies",
"static",
"files",
"and",
"renders",
"templates",
"in",
"the",
"template",
"directories",
"."
] | 585c98027771fd118041e90bb38295983d67166c | https://github.com/ruby-ore/ore/blob/585c98027771fd118041e90bb38295983d67166c/lib/ore/generator.rb#L315-L337 |
23,591 | ruby-ore/ore | lib/ore/generator.rb | Ore.Generator.initialize_scm! | def initialize_scm!
in_root do
case @scm
when :git
unless File.directory?('.git')
run 'git init'
run 'git add .'
run 'git commit -m "Initial commit."'
end
when :hg
unless File.directory?('.hg')
run 'hg init'
run 'hg add .'
run 'hg commit -m "Initial commit."'
end
when :svn
@ignore.each do |pattern|
run "svn propset svn:ignore #{pattern.dump}"
end
run 'svn add .'
run 'svn commit -m "Initial commit."'
end
end
end | ruby | def initialize_scm!
in_root do
case @scm
when :git
unless File.directory?('.git')
run 'git init'
run 'git add .'
run 'git commit -m "Initial commit."'
end
when :hg
unless File.directory?('.hg')
run 'hg init'
run 'hg add .'
run 'hg commit -m "Initial commit."'
end
when :svn
@ignore.each do |pattern|
run "svn propset svn:ignore #{pattern.dump}"
end
run 'svn add .'
run 'svn commit -m "Initial commit."'
end
end
end | [
"def",
"initialize_scm!",
"in_root",
"do",
"case",
"@scm",
"when",
":git",
"unless",
"File",
".",
"directory?",
"(",
"'.git'",
")",
"run",
"'git init'",
"run",
"'git add .'",
"run",
"'git commit -m \"Initial commit.\"'",
"end",
"when",
":hg",
"unless",
"File",
".",
"directory?",
"(",
"'.hg'",
")",
"run",
"'hg init'",
"run",
"'hg add .'",
"run",
"'hg commit -m \"Initial commit.\"'",
"end",
"when",
":svn",
"@ignore",
".",
"each",
"do",
"|",
"pattern",
"|",
"run",
"\"svn propset svn:ignore #{pattern.dump}\"",
"end",
"run",
"'svn add .'",
"run",
"'svn commit -m \"Initial commit.\"'",
"end",
"end",
"end"
] | Initializes the project repository and commits all files.
@since 0.10.0 | [
"Initializes",
"the",
"project",
"repository",
"and",
"commits",
"all",
"files",
"."
] | 585c98027771fd118041e90bb38295983d67166c | https://github.com/ruby-ore/ore/blob/585c98027771fd118041e90bb38295983d67166c/lib/ore/generator.rb#L344-L368 |
23,592 | octopress/deploy | lib/octopress-deploy.rb | Octopress.Deploy.init_config | def init_config(options={})
options = options.to_symbol_keys
if !options[:method]
abort "Please provide a deployment method. e.g. #{METHODS.keys}"
end
@options = DEFAULT_OPTIONS.deep_merge(options)
write_config
check_gitignore
end | ruby | def init_config(options={})
options = options.to_symbol_keys
if !options[:method]
abort "Please provide a deployment method. e.g. #{METHODS.keys}"
end
@options = DEFAULT_OPTIONS.deep_merge(options)
write_config
check_gitignore
end | [
"def",
"init_config",
"(",
"options",
"=",
"{",
"}",
")",
"options",
"=",
"options",
".",
"to_symbol_keys",
"if",
"!",
"options",
"[",
":method",
"]",
"abort",
"\"Please provide a deployment method. e.g. #{METHODS.keys}\"",
"end",
"@options",
"=",
"DEFAULT_OPTIONS",
".",
"deep_merge",
"(",
"options",
")",
"write_config",
"check_gitignore",
"end"
] | Create a config file | [
"Create",
"a",
"config",
"file"
] | 662485f5ba8f66e0cbfe4a3ee1f2844dee4c6d59 | https://github.com/octopress/deploy/blob/662485f5ba8f66e0cbfe4a3ee1f2844dee4c6d59/lib/octopress-deploy.rb#L92-L102 |
23,593 | maetl/calyx | lib/calyx/grammar.rb | Calyx.Grammar.generate_result | def generate_result(*args)
start_symbol, rules_map = map_default_args(*args)
Result.new(@registry.evaluate(start_symbol, rules_map))
end | ruby | def generate_result(*args)
start_symbol, rules_map = map_default_args(*args)
Result.new(@registry.evaluate(start_symbol, rules_map))
end | [
"def",
"generate_result",
"(",
"*",
"args",
")",
"start_symbol",
",",
"rules_map",
"=",
"map_default_args",
"(",
"args",
")",
"Result",
".",
"new",
"(",
"@registry",
".",
"evaluate",
"(",
"start_symbol",
",",
"rules_map",
")",
")",
"end"
] | Produces a generated result from evaluating the grammar.
@see Calyx::Result
@overload generate_result(start_symbol)
@param [Symbol] start_symbol
@overload generate_result(rules_map)
@param [Hash] rules_map
@overload generate_result(start_symbol, rules_map)
@param [Symbol] start_symbol
@param [Hash] rules_map
@return [Calyx::Result] | [
"Produces",
"a",
"generated",
"result",
"from",
"evaluating",
"the",
"grammar",
"."
] | 5011cd4b948792bdfd22ae1d3eaac9ff529e3861 | https://github.com/maetl/calyx/blob/5011cd4b948792bdfd22ae1d3eaac9ff529e3861/lib/calyx/grammar.rb#L175-L179 |
23,594 | cloudfoundry-attic/vcap-services-base | lib/base/job/snapshot.rb | VCAP::Services::Base::AsyncJob.Snapshot.service_snapshots | def service_snapshots(service_id)
return unless service_id
res = client.hgetall(redis_key(service_id))
res.values.map{|v| Yajl::Parser.parse(v)}
end | ruby | def service_snapshots(service_id)
return unless service_id
res = client.hgetall(redis_key(service_id))
res.values.map{|v| Yajl::Parser.parse(v)}
end | [
"def",
"service_snapshots",
"(",
"service_id",
")",
"return",
"unless",
"service_id",
"res",
"=",
"client",
".",
"hgetall",
"(",
"redis_key",
"(",
"service_id",
")",
")",
"res",
".",
"values",
".",
"map",
"{",
"|",
"v",
"|",
"Yajl",
"::",
"Parser",
".",
"parse",
"(",
"v",
")",
"}",
"end"
] | Get all snapshots related to a service instance | [
"Get",
"all",
"snapshots",
"related",
"to",
"a",
"service",
"instance"
] | bde81300391cb27e1c531148d15bde696ebf4da0 | https://github.com/cloudfoundry-attic/vcap-services-base/blob/bde81300391cb27e1c531148d15bde696ebf4da0/lib/base/job/snapshot.rb#L38-L42 |
23,595 | cloudfoundry-attic/vcap-services-base | lib/base/job/snapshot.rb | VCAP::Services::Base::AsyncJob.Snapshot.snapshot_details | def snapshot_details(service_id, snapshot_id)
return unless service_id && snapshot_id
res = client.hget(redis_key(service_id), snapshot_id)
raise ServiceError.new(ServiceError::NOT_FOUND, "snapshot #{snapshot_id}") unless res
Yajl::Parser.parse(res)
end | ruby | def snapshot_details(service_id, snapshot_id)
return unless service_id && snapshot_id
res = client.hget(redis_key(service_id), snapshot_id)
raise ServiceError.new(ServiceError::NOT_FOUND, "snapshot #{snapshot_id}") unless res
Yajl::Parser.parse(res)
end | [
"def",
"snapshot_details",
"(",
"service_id",
",",
"snapshot_id",
")",
"return",
"unless",
"service_id",
"&&",
"snapshot_id",
"res",
"=",
"client",
".",
"hget",
"(",
"redis_key",
"(",
"service_id",
")",
",",
"snapshot_id",
")",
"raise",
"ServiceError",
".",
"new",
"(",
"ServiceError",
"::",
"NOT_FOUND",
",",
"\"snapshot #{snapshot_id}\"",
")",
"unless",
"res",
"Yajl",
"::",
"Parser",
".",
"parse",
"(",
"res",
")",
"end"
] | Get detail information for a single snapshot | [
"Get",
"detail",
"information",
"for",
"a",
"single",
"snapshot"
] | bde81300391cb27e1c531148d15bde696ebf4da0 | https://github.com/cloudfoundry-attic/vcap-services-base/blob/bde81300391cb27e1c531148d15bde696ebf4da0/lib/base/job/snapshot.rb#L53-L58 |
23,596 | cloudfoundry-attic/vcap-services-base | lib/base/job/snapshot.rb | VCAP::Services::Base::AsyncJob.Snapshot.filter_keys | def filter_keys(snapshot)
return unless snapshot.is_a? Hash
snapshot.select {|k,v| FILTER_KEYS.include? k.to_s}
end | ruby | def filter_keys(snapshot)
return unless snapshot.is_a? Hash
snapshot.select {|k,v| FILTER_KEYS.include? k.to_s}
end | [
"def",
"filter_keys",
"(",
"snapshot",
")",
"return",
"unless",
"snapshot",
".",
"is_a?",
"Hash",
"snapshot",
".",
"select",
"{",
"|",
"k",
",",
"v",
"|",
"FILTER_KEYS",
".",
"include?",
"k",
".",
"to_s",
"}",
"end"
] | filter internal keys of a given snapshot object, return a new snapshot object in canonical format | [
"filter",
"internal",
"keys",
"of",
"a",
"given",
"snapshot",
"object",
"return",
"a",
"new",
"snapshot",
"object",
"in",
"canonical",
"format"
] | bde81300391cb27e1c531148d15bde696ebf4da0 | https://github.com/cloudfoundry-attic/vcap-services-base/blob/bde81300391cb27e1c531148d15bde696ebf4da0/lib/base/job/snapshot.rb#L61-L64 |
23,597 | ruby-ore/ore | lib/ore/actions.rb | Ore.Actions.generate_dir | def generate_dir(dest)
return if @generated_dirs.has_key?(dest)
path = interpolate(dest)
empty_directory path
@generated_dirs[dest] = path
return path
end | ruby | def generate_dir(dest)
return if @generated_dirs.has_key?(dest)
path = interpolate(dest)
empty_directory path
@generated_dirs[dest] = path
return path
end | [
"def",
"generate_dir",
"(",
"dest",
")",
"return",
"if",
"@generated_dirs",
".",
"has_key?",
"(",
"dest",
")",
"path",
"=",
"interpolate",
"(",
"dest",
")",
"empty_directory",
"path",
"@generated_dirs",
"[",
"dest",
"]",
"=",
"path",
"return",
"path",
"end"
] | Generates an empty directory.
@param [String] dest
The uninterpolated destination path.
@return [String]
The destination path of the directory.
@since 0.7.1 | [
"Generates",
"an",
"empty",
"directory",
"."
] | 585c98027771fd118041e90bb38295983d67166c | https://github.com/ruby-ore/ore/blob/585c98027771fd118041e90bb38295983d67166c/lib/ore/actions.rb#L38-L46 |
23,598 | ruby-ore/ore | lib/ore/actions.rb | Ore.Actions.generate_file | def generate_file(dest,file,options={})
return if @generated_files.has_key?(dest)
path = interpolate(dest)
if options[:template]
@current_template_dir = File.dirname(dest)
template file, path
@current_template_dir = nil
else
copy_file file, path
end
@generated_files[dest] = path
return path
end | ruby | def generate_file(dest,file,options={})
return if @generated_files.has_key?(dest)
path = interpolate(dest)
if options[:template]
@current_template_dir = File.dirname(dest)
template file, path
@current_template_dir = nil
else
copy_file file, path
end
@generated_files[dest] = path
return path
end | [
"def",
"generate_file",
"(",
"dest",
",",
"file",
",",
"options",
"=",
"{",
"}",
")",
"return",
"if",
"@generated_files",
".",
"has_key?",
"(",
"dest",
")",
"path",
"=",
"interpolate",
"(",
"dest",
")",
"if",
"options",
"[",
":template",
"]",
"@current_template_dir",
"=",
"File",
".",
"dirname",
"(",
"dest",
")",
"template",
"file",
",",
"path",
"@current_template_dir",
"=",
"nil",
"else",
"copy_file",
"file",
",",
"path",
"end",
"@generated_files",
"[",
"dest",
"]",
"=",
"path",
"return",
"path",
"end"
] | Generates a file.
@param [String] dest
The uninterpolated destination path.
@param [String] file
The source file or template.
@param [Hash] options
Additional options.
@option options [Boolean] :template
Specifies that the file is a template, and should be rendered.
@return [String]
The destination path of the file.
@since 0.7.1 | [
"Generates",
"a",
"file",
"."
] | 585c98027771fd118041e90bb38295983d67166c | https://github.com/ruby-ore/ore/blob/585c98027771fd118041e90bb38295983d67166c/lib/ore/actions.rb#L68-L83 |
23,599 | instructure/moodle2cc | lib/moodle2cc/moodle2converter/migrator.rb | Moodle2CC::Moodle2Converter.Migrator.convert_assessments | def convert_assessments(quizzes, choices, feedbacks, questionnaires)
assessment_converter = Moodle2CC::Moodle2Converter::AssessmentConverter.new
assessments = []
assessments += quizzes.map { |quiz| assessment_converter.convert_quiz(quiz) }
assessments += choices.map { |choice| assessment_converter.convert_choice(choice) }
assessments += feedbacks.map { |feedback| assessment_converter.convert_feedback(feedback) }
assessments += questionnaires.map { |questionnaire| assessment_converter.convert_questionnaire(questionnaire) }
assessments
end | ruby | def convert_assessments(quizzes, choices, feedbacks, questionnaires)
assessment_converter = Moodle2CC::Moodle2Converter::AssessmentConverter.new
assessments = []
assessments += quizzes.map { |quiz| assessment_converter.convert_quiz(quiz) }
assessments += choices.map { |choice| assessment_converter.convert_choice(choice) }
assessments += feedbacks.map { |feedback| assessment_converter.convert_feedback(feedback) }
assessments += questionnaires.map { |questionnaire| assessment_converter.convert_questionnaire(questionnaire) }
assessments
end | [
"def",
"convert_assessments",
"(",
"quizzes",
",",
"choices",
",",
"feedbacks",
",",
"questionnaires",
")",
"assessment_converter",
"=",
"Moodle2CC",
"::",
"Moodle2Converter",
"::",
"AssessmentConverter",
".",
"new",
"assessments",
"=",
"[",
"]",
"assessments",
"+=",
"quizzes",
".",
"map",
"{",
"|",
"quiz",
"|",
"assessment_converter",
".",
"convert_quiz",
"(",
"quiz",
")",
"}",
"assessments",
"+=",
"choices",
".",
"map",
"{",
"|",
"choice",
"|",
"assessment_converter",
".",
"convert_choice",
"(",
"choice",
")",
"}",
"assessments",
"+=",
"feedbacks",
".",
"map",
"{",
"|",
"feedback",
"|",
"assessment_converter",
".",
"convert_feedback",
"(",
"feedback",
")",
"}",
"assessments",
"+=",
"questionnaires",
".",
"map",
"{",
"|",
"questionnaire",
"|",
"assessment_converter",
".",
"convert_questionnaire",
"(",
"questionnaire",
")",
"}",
"assessments",
"end"
] | convert quizzes to assessments | [
"convert",
"quizzes",
"to",
"assessments"
] | cdb1666a76b22e87e8853d4045e31439244cce4b | https://github.com/instructure/moodle2cc/blob/cdb1666a76b22e87e8853d4045e31439244cce4b/lib/moodle2cc/moodle2converter/migrator.rb#L114-L122 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.