id int32 0 24.9k | repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 |
|---|---|---|---|---|---|---|---|---|---|---|---|
4,900 | donaldpiret/github-pivotal-flow | lib/github_pivotal_flow/configuration.rb | GithubPivotalFlow.Configuration.api_token | def api_token
api_token = @options[:api_token] || Git.get_config(KEY_API_TOKEN, :inherited)
if api_token.blank?
api_token = ask('Pivotal API Token (found at https://www.pivotaltracker.com/profile): ').strip
Git.set_config(KEY_API_TOKEN, api_token, :local) unless api_token.blank?
put... | ruby | def api_token
api_token = @options[:api_token] || Git.get_config(KEY_API_TOKEN, :inherited)
if api_token.blank?
api_token = ask('Pivotal API Token (found at https://www.pivotaltracker.com/profile): ').strip
Git.set_config(KEY_API_TOKEN, api_token, :local) unless api_token.blank?
put... | [
"def",
"api_token",
"api_token",
"=",
"@options",
"[",
":api_token",
"]",
"||",
"Git",
".",
"get_config",
"(",
"KEY_API_TOKEN",
",",
":inherited",
")",
"if",
"api_token",
".",
"blank?",
"api_token",
"=",
"ask",
"(",
"'Pivotal API Token (found at https://www.pivotalt... | Returns the user's Pivotal Tracker API token. If this token has not been
configured, prompts the user for the value. The value is checked for in
the _inherited_ Git configuration, but is stored in the _global_ Git
configuration so that it can be used across multiple repositories.
@return [String] The user's Pivo... | [
"Returns",
"the",
"user",
"s",
"Pivotal",
"Tracker",
"API",
"token",
".",
"If",
"this",
"token",
"has",
"not",
"been",
"configured",
"prompts",
"the",
"user",
"for",
"the",
"value",
".",
"The",
"value",
"is",
"checked",
"for",
"in",
"the",
"_inherited_",
... | 676436950b691f57ad793a9023a4765ab9420dd0 | https://github.com/donaldpiret/github-pivotal-flow/blob/676436950b691f57ad793a9023a4765ab9420dd0/lib/github_pivotal_flow/configuration.rb#L43-L53 |
4,901 | donaldpiret/github-pivotal-flow | lib/github_pivotal_flow/configuration.rb | GithubPivotalFlow.Configuration.project_id | def project_id
project_id = @options[:project_id] || Git.get_config(KEY_PROJECT_ID, :inherited)
if project_id.empty?
project_id = choose do |menu|
menu.prompt = 'Choose project associated with this repository: '
PivotalTracker::Project.all.sort_by { |project| project.name }.eac... | ruby | def project_id
project_id = @options[:project_id] || Git.get_config(KEY_PROJECT_ID, :inherited)
if project_id.empty?
project_id = choose do |menu|
menu.prompt = 'Choose project associated with this repository: '
PivotalTracker::Project.all.sort_by { |project| project.name }.eac... | [
"def",
"project_id",
"project_id",
"=",
"@options",
"[",
":project_id",
"]",
"||",
"Git",
".",
"get_config",
"(",
"KEY_PROJECT_ID",
",",
":inherited",
")",
"if",
"project_id",
".",
"empty?",
"project_id",
"=",
"choose",
"do",
"|",
"menu",
"|",
"menu",
".",
... | Returns the Pivotal Tracker project id for this repository. If this id
has not been configuration, prompts the user for the value. The value is
checked for in the _inherited_ Git configuration, but is stored in the
_local_ Git configuration so that it is specific to this repository.
@return [String] The reposito... | [
"Returns",
"the",
"Pivotal",
"Tracker",
"project",
"id",
"for",
"this",
"repository",
".",
"If",
"this",
"id",
"has",
"not",
"been",
"configuration",
"prompts",
"the",
"user",
"for",
"the",
"value",
".",
"The",
"value",
"is",
"checked",
"for",
"in",
"the",... | 676436950b691f57ad793a9023a4765ab9420dd0 | https://github.com/donaldpiret/github-pivotal-flow/blob/676436950b691f57ad793a9023a4765ab9420dd0/lib/github_pivotal_flow/configuration.rb#L79-L96 |
4,902 | donaldpiret/github-pivotal-flow | lib/github_pivotal_flow/configuration.rb | GithubPivotalFlow.Configuration.story | def story
return @story if @story
story_id = Git.get_config(KEY_STORY_ID, :branch)
if story_id.blank? && (matchdata = /^[a-z0-9_\-]+\/(\d+)(-[a-z0-9_\-]+)?$/i.match(Git.current_branch))
story_id = matchdata[1]
Git.set_config(KEY_STORY_ID, story_id, :branch) unless story_id.blank?
... | ruby | def story
return @story if @story
story_id = Git.get_config(KEY_STORY_ID, :branch)
if story_id.blank? && (matchdata = /^[a-z0-9_\-]+\/(\d+)(-[a-z0-9_\-]+)?$/i.match(Git.current_branch))
story_id = matchdata[1]
Git.set_config(KEY_STORY_ID, story_id, :branch) unless story_id.blank?
... | [
"def",
"story",
"return",
"@story",
"if",
"@story",
"story_id",
"=",
"Git",
".",
"get_config",
"(",
"KEY_STORY_ID",
",",
":branch",
")",
"if",
"story_id",
".",
"blank?",
"&&",
"(",
"matchdata",
"=",
"/",
"\\-",
"\\/",
"\\d",
"\\-",
"/i",
".",
"match",
... | Returns the story associated with the branch
@return [Story] the story associated with the current development branch | [
"Returns",
"the",
"story",
"associated",
"with",
"the",
"branch"
] | 676436950b691f57ad793a9023a4765ab9420dd0 | https://github.com/donaldpiret/github-pivotal-flow/blob/676436950b691f57ad793a9023a4765ab9420dd0/lib/github_pivotal_flow/configuration.rb#L105-L118 |
4,903 | donaldpiret/github-pivotal-flow | lib/github_pivotal_flow/configuration.rb | GithubPivotalFlow.Configuration.ask_github_password | def ask_github_password(username = nil)
username ||= github_username
print "Github password for #{username} (never stored): "
if $stdin.tty?
password = askpass
puts ''
password
else
# in testing
$stdin.gets.chomp
end
rescue Interrupt
abort
... | ruby | def ask_github_password(username = nil)
username ||= github_username
print "Github password for #{username} (never stored): "
if $stdin.tty?
password = askpass
puts ''
password
else
# in testing
$stdin.gets.chomp
end
rescue Interrupt
abort
... | [
"def",
"ask_github_password",
"(",
"username",
"=",
"nil",
")",
"username",
"||=",
"github_username",
"print",
"\"Github password for #{username} (never stored): \"",
"if",
"$stdin",
".",
"tty?",
"password",
"=",
"askpass",
"puts",
"''",
"password",
"else",
"# in testin... | special prompt that has hidden input | [
"special",
"prompt",
"that",
"has",
"hidden",
"input"
] | 676436950b691f57ad793a9023a4765ab9420dd0 | https://github.com/donaldpiret/github-pivotal-flow/blob/676436950b691f57ad793a9023a4765ab9420dd0/lib/github_pivotal_flow/configuration.rb#L260-L273 |
4,904 | payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/payment_processor.rb | PaynetEasy::PaynetEasyApi.PaymentProcessor.execute_query | def execute_query(query_name, payment_transaction)
query = query(query_name)
begin
request = query.create_request payment_transaction
response = make_request request
query.process_response payment_transaction, response
rescue Exception => error
handle_exception error, ... | ruby | def execute_query(query_name, payment_transaction)
query = query(query_name)
begin
request = query.create_request payment_transaction
response = make_request request
query.process_response payment_transaction, response
rescue Exception => error
handle_exception error, ... | [
"def",
"execute_query",
"(",
"query_name",
",",
"payment_transaction",
")",
"query",
"=",
"query",
"(",
"query_name",
")",
"begin",
"request",
"=",
"query",
".",
"create_request",
"payment_transaction",
"response",
"=",
"make_request",
"request",
"query",
".",
"pr... | Executes payment API query
@param query_name [String] Payment API query name
@param payment_transaction [PaymentTransaction] Payment transaction for processing
@return [Response] Query response | [
"Executes",
"payment",
"API",
"query"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/payment_processor.rb#L62-L77 |
4,905 | payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/payment_processor.rb | PaynetEasy::PaynetEasyApi.PaymentProcessor.process_paynet_easy_callback | def process_paynet_easy_callback(callback_response, payment_transaction)
begin
callback(callback_response.type).process_callback(payment_transaction, callback_response)
rescue Exception => error
handle_exception error, payment_transaction, callback_response
return
end
ha... | ruby | def process_paynet_easy_callback(callback_response, payment_transaction)
begin
callback(callback_response.type).process_callback(payment_transaction, callback_response)
rescue Exception => error
handle_exception error, payment_transaction, callback_response
return
end
ha... | [
"def",
"process_paynet_easy_callback",
"(",
"callback_response",
",",
"payment_transaction",
")",
"begin",
"callback",
"(",
"callback_response",
".",
"type",
")",
".",
"process_callback",
"(",
"payment_transaction",
",",
"callback_response",
")",
"rescue",
"Exception",
... | Executes payment gateway processor for PaynetEasy payment callback
@param callback_response [CallbackResponse] Callback object with data from payment gateway
@param payment_transaction [PaymentTransaction] Payment transaction for processing
@return [CallbackResponse] ... | [
"Executes",
"payment",
"gateway",
"processor",
"for",
"PaynetEasy",
"payment",
"callback"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/payment_processor.rb#L96-L107 |
4,906 | kyohei8/inoreader-api | lib/inoreader/api/app.rb | InoreaderApi.Api.login | def login(un, pw)
response_body = Helper.auth_request un, pw
auth_token = Hash[*response_body.split.collect { |i| i.split('=') }.flatten]['Auth']
raise InoreaderApi::InoreaderApiError.new 'Bad Authentication' if auth_token.nil?
auth_token
rescue => e
raise InoreaderApi::InoreaderApiErr... | ruby | def login(un, pw)
response_body = Helper.auth_request un, pw
auth_token = Hash[*response_body.split.collect { |i| i.split('=') }.flatten]['Auth']
raise InoreaderApi::InoreaderApiError.new 'Bad Authentication' if auth_token.nil?
auth_token
rescue => e
raise InoreaderApi::InoreaderApiErr... | [
"def",
"login",
"(",
"un",
",",
"pw",
")",
"response_body",
"=",
"Helper",
".",
"auth_request",
"un",
",",
"pw",
"auth_token",
"=",
"Hash",
"[",
"response_body",
".",
"split",
".",
"collect",
"{",
"|",
"i",
"|",
"i",
".",
"split",
"(",
"'='",
")",
... | Authenticate, to return authToken
@param un username or Email
@param pw Password
@return Hash
if success
{
:auth_token => xxxxxxxx
} | [
"Authenticate",
"to",
"return",
"authToken"
] | 4b894dc0fe3a663df5cf1bab0081aee616ac0305 | https://github.com/kyohei8/inoreader-api/blob/4b894dc0fe3a663df5cf1bab0081aee616ac0305/lib/inoreader/api/app.rb#L219-L226 |
4,907 | imanel/libwebsocket | lib/libwebsocket/frame.rb | LibWebSocket.Frame.to_s | def to_s
ary = ["\x00", @buffer.dup, "\xff"]
ary.collect{ |s| s.force_encoding('UTF-8') if s.respond_to?(:force_encoding) }
return ary.join
end | ruby | def to_s
ary = ["\x00", @buffer.dup, "\xff"]
ary.collect{ |s| s.force_encoding('UTF-8') if s.respond_to?(:force_encoding) }
return ary.join
end | [
"def",
"to_s",
"ary",
"=",
"[",
"\"\\x00\"",
",",
"@buffer",
".",
"dup",
",",
"\"\\xff\"",
"]",
"ary",
".",
"collect",
"{",
"|",
"s",
"|",
"s",
".",
"force_encoding",
"(",
"'UTF-8'",
")",
"if",
"s",
".",
"respond_to?",
"(",
":force_encoding",
")",
"}... | Construct a WebSocket frame.
@example
frame = LibWebSocket::Frame.new('foo')
frame.to_s # => \x00foo\xff | [
"Construct",
"a",
"WebSocket",
"frame",
"."
] | 3e071439246f5a2c306e16fefc772d2f6f716f6b | https://github.com/imanel/libwebsocket/blob/3e071439246f5a2c306e16fefc772d2f6f716f6b/lib/libwebsocket/frame.rb#L59-L65 |
4,908 | tpope/ldaptic | lib/ldaptic/methods.rb | Ldaptic.Methods.add | def add(dn, attributes)
attributes = normalize_attributes(attributes)
log_dispatch(:add, dn, attributes)
adapter.add(dn, attributes)
end | ruby | def add(dn, attributes)
attributes = normalize_attributes(attributes)
log_dispatch(:add, dn, attributes)
adapter.add(dn, attributes)
end | [
"def",
"add",
"(",
"dn",
",",
"attributes",
")",
"attributes",
"=",
"normalize_attributes",
"(",
"attributes",
")",
"log_dispatch",
"(",
":add",
",",
"dn",
",",
"attributes",
")",
"adapter",
".",
"add",
"(",
"dn",
",",
"attributes",
")",
"end"
] | Performs an LDAP add. | [
"Performs",
"an",
"LDAP",
"add",
"."
] | 159a39464e9f5a05c0145db2b21cb256ef859612 | https://github.com/tpope/ldaptic/blob/159a39464e9f5a05c0145db2b21cb256ef859612/lib/ldaptic/methods.rb#L251-L255 |
4,909 | tpope/ldaptic | lib/ldaptic/methods.rb | Ldaptic.Methods.modify | def modify(dn, attributes)
if attributes.kind_of?(Hash)
attributes = normalize_attributes(attributes)
else
attributes = attributes.map do |(action, key, values)|
[action, Ldaptic.encode(key), values.respond_to?(:before_type_cast) ? values.before_type_cast : [values].flatten.compact... | ruby | def modify(dn, attributes)
if attributes.kind_of?(Hash)
attributes = normalize_attributes(attributes)
else
attributes = attributes.map do |(action, key, values)|
[action, Ldaptic.encode(key), values.respond_to?(:before_type_cast) ? values.before_type_cast : [values].flatten.compact... | [
"def",
"modify",
"(",
"dn",
",",
"attributes",
")",
"if",
"attributes",
".",
"kind_of?",
"(",
"Hash",
")",
"attributes",
"=",
"normalize_attributes",
"(",
"attributes",
")",
"else",
"attributes",
"=",
"attributes",
".",
"map",
"do",
"|",
"(",
"action",
","... | Performs an LDAP modify. | [
"Performs",
"an",
"LDAP",
"modify",
"."
] | 159a39464e9f5a05c0145db2b21cb256ef859612 | https://github.com/tpope/ldaptic/blob/159a39464e9f5a05c0145db2b21cb256ef859612/lib/ldaptic/methods.rb#L258-L268 |
4,910 | tpope/ldaptic | lib/ldaptic/methods.rb | Ldaptic.Methods.rename | def rename(dn, new_rdn, delete_old, *args)
log_dispatch(:rename, dn, new_rdn, delete_old, *args)
adapter.rename(dn, new_rdn.to_str, delete_old, *args)
end | ruby | def rename(dn, new_rdn, delete_old, *args)
log_dispatch(:rename, dn, new_rdn, delete_old, *args)
adapter.rename(dn, new_rdn.to_str, delete_old, *args)
end | [
"def",
"rename",
"(",
"dn",
",",
"new_rdn",
",",
"delete_old",
",",
"*",
"args",
")",
"log_dispatch",
"(",
":rename",
",",
"dn",
",",
"new_rdn",
",",
"delete_old",
",",
"args",
")",
"adapter",
".",
"rename",
"(",
"dn",
",",
"new_rdn",
".",
"to_str",
... | Performs an LDAP modrdn. | [
"Performs",
"an",
"LDAP",
"modrdn",
"."
] | 159a39464e9f5a05c0145db2b21cb256ef859612 | https://github.com/tpope/ldaptic/blob/159a39464e9f5a05c0145db2b21cb256ef859612/lib/ldaptic/methods.rb#L277-L280 |
4,911 | tpope/ldaptic | lib/ldaptic/methods.rb | Ldaptic.Methods.compare | def compare(dn, key, value)
log_dispatch(:compare, dn, key, value)
adapter.compare(dn, Ldaptic.encode(key), Ldaptic.encode(value))
end | ruby | def compare(dn, key, value)
log_dispatch(:compare, dn, key, value)
adapter.compare(dn, Ldaptic.encode(key), Ldaptic.encode(value))
end | [
"def",
"compare",
"(",
"dn",
",",
"key",
",",
"value",
")",
"log_dispatch",
"(",
":compare",
",",
"dn",
",",
"key",
",",
"value",
")",
"adapter",
".",
"compare",
"(",
"dn",
",",
"Ldaptic",
".",
"encode",
"(",
"key",
")",
",",
"Ldaptic",
".",
"encod... | Performs an LDAP compare. | [
"Performs",
"an",
"LDAP",
"compare",
"."
] | 159a39464e9f5a05c0145db2b21cb256ef859612 | https://github.com/tpope/ldaptic/blob/159a39464e9f5a05c0145db2b21cb256ef859612/lib/ldaptic/methods.rb#L283-L286 |
4,912 | ronyv89/skydrive | lib/skydrive/operations.rb | Skydrive.Operations.upload | def upload folder_path, filename, file, options={}
response = put("/#{folder_path}/files/#{filename}", file.read, options)
end | ruby | def upload folder_path, filename, file, options={}
response = put("/#{folder_path}/files/#{filename}", file.read, options)
end | [
"def",
"upload",
"folder_path",
",",
"filename",
",",
"file",
",",
"options",
"=",
"{",
"}",
"response",
"=",
"put",
"(",
"\"/#{folder_path}/files/#{filename}\"",
",",
"file",
".",
"read",
",",
"options",
")",
"end"
] | Upload a file
@param [String] folder_path Either 'me/skydrive' or FOLDER_ID(id of the parent folder)
@param [String] filename Name of the new file
@param [File] The actual file to be uploaded
@param [Hash] options Any additional options to be passed
@option options [Boolean] :overwrite whether to overwrite the fil... | [
"Upload",
"a",
"file"
] | 6cf7b692f64c6f00a81bc7ca6fffca3020244072 | https://github.com/ronyv89/skydrive/blob/6cf7b692f64c6f00a81bc7ca6fffca3020244072/lib/skydrive/operations.rb#L189-L191 |
4,913 | mamantoha/freshdesk_api_client_rb | lib/freshdesk_api/configuration.rb | FreshdeskAPI.Configuration.options | def options
{
headers: {
accept: :json,
content_type: :json,
accept_encoding: 'gzip ,deflate',
user_agent: "FreshdeskAPI API #{FreshdeskAPI::VERSION}"
},
read_timeout: nil,
open_timeout: nil,
base_url: @base_url
}.merge(client_o... | ruby | def options
{
headers: {
accept: :json,
content_type: :json,
accept_encoding: 'gzip ,deflate',
user_agent: "FreshdeskAPI API #{FreshdeskAPI::VERSION}"
},
read_timeout: nil,
open_timeout: nil,
base_url: @base_url
}.merge(client_o... | [
"def",
"options",
"{",
"headers",
":",
"{",
"accept",
":",
":json",
",",
"content_type",
":",
":json",
",",
"accept_encoding",
":",
"'gzip ,deflate'",
",",
"user_agent",
":",
"\"FreshdeskAPI API #{FreshdeskAPI::VERSION}\"",
"}",
",",
"read_timeout",
":",
"nil",
",... | Sets accept and user_agent headers, and url
@return [Hash] RestClient-formatted hash of options. | [
"Sets",
"accept",
"and",
"user_agent",
"headers",
"and",
"url"
] | 74367fe0dd31bd269197b3f419412ef600031e62 | https://github.com/mamantoha/freshdesk_api_client_rb/blob/74367fe0dd31bd269197b3f419412ef600031e62/lib/freshdesk_api/configuration.rb#L39-L51 |
4,914 | payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.create_request | def create_request(payment_transaction)
validate_payment_transaction payment_transaction
request = payment_transaction_to_request payment_transaction
request.api_method = @api_method
request.end_point = payment_transaction.query_config.end_point
request.gateway_url = payment_transacti... | ruby | def create_request(payment_transaction)
validate_payment_transaction payment_transaction
request = payment_transaction_to_request payment_transaction
request.api_method = @api_method
request.end_point = payment_transaction.query_config.end_point
request.gateway_url = payment_transacti... | [
"def",
"create_request",
"(",
"payment_transaction",
")",
"validate_payment_transaction",
"payment_transaction",
"request",
"=",
"payment_transaction_to_request",
"payment_transaction",
"request",
".",
"api_method",
"=",
"@api_method",
"request",
".",
"end_point",
"=",
"payme... | Create API gateway request from payment transaction data
@param payment_transaction [PaymentTransaction] Payment transaction for query
@return [Request] Request object | [
"Create",
"API",
"gateway",
"request",
"from",
"payment",
"transaction",
"data"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L45-L61 |
4,915 | payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.process_response | def process_response(payment_transaction, response)
if response.processing? || response.approved?
validate = :validate_response_on_success
update = :update_payment_transaction_on_success
else
validate = :validate_response_on_error
update = :update_payment_transaction_on_e... | ruby | def process_response(payment_transaction, response)
if response.processing? || response.approved?
validate = :validate_response_on_success
update = :update_payment_transaction_on_success
else
validate = :validate_response_on_error
update = :update_payment_transaction_on_e... | [
"def",
"process_response",
"(",
"payment_transaction",
",",
"response",
")",
"if",
"response",
".",
"processing?",
"||",
"response",
".",
"approved?",
"validate",
"=",
":validate_response_on_success",
"update",
"=",
":update_payment_transaction_on_success",
"else",
"valid... | Process API gateway response and update payment transaction
@param payment_transaction [PaymentTransaction] Payment transaction for update
@param response [Response] API gateway response
@return [Response] API gateway response | [
"Process",
"API",
"gateway",
"response",
"and",
"update",
"payment",
"transaction"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L69-L94 |
4,916 | payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.validate_payment_transaction | def validate_payment_transaction(payment_transaction)
validate_query_config payment_transaction
error_message = ''
missed_fields = []
invalid_fields = []
request_fields_definition.each do |field_name, property_path, is_field_required, validation_rule|
field_value = PropertyA... | ruby | def validate_payment_transaction(payment_transaction)
validate_query_config payment_transaction
error_message = ''
missed_fields = []
invalid_fields = []
request_fields_definition.each do |field_name, property_path, is_field_required, validation_rule|
field_value = PropertyA... | [
"def",
"validate_payment_transaction",
"(",
"payment_transaction",
")",
"validate_query_config",
"payment_transaction",
"error_message",
"=",
"''",
"missed_fields",
"=",
"[",
"]",
"invalid_fields",
"=",
"[",
"]",
"request_fields_definition",
".",
"each",
"do",
"|",
"fie... | Validates payment transaction before request constructing
@param payment_transaction [PaymentTransaction] Payment transaction for validation | [
"Validates",
"payment",
"transaction",
"before",
"request",
"constructing"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L101-L133 |
4,917 | payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.payment_transaction_to_request | def payment_transaction_to_request(payment_transaction)
request_fields = {}
request_fields_definition.each do |field_name, property_path, _|
field_value = PropertyAccessor.get_value payment_transaction, property_path
if field_value
request_fields[field_name] = field_value
... | ruby | def payment_transaction_to_request(payment_transaction)
request_fields = {}
request_fields_definition.each do |field_name, property_path, _|
field_value = PropertyAccessor.get_value payment_transaction, property_path
if field_value
request_fields[field_name] = field_value
... | [
"def",
"payment_transaction_to_request",
"(",
"payment_transaction",
")",
"request_fields",
"=",
"{",
"}",
"request_fields_definition",
".",
"each",
"do",
"|",
"field_name",
",",
"property_path",
",",
"_",
"|",
"field_value",
"=",
"PropertyAccessor",
".",
"get_value",... | Creates request from payment transaction
@param payment_transaction [PaymentTransaction] Payment transaction for request constructing
@return [Request] Request object | [
"Creates",
"request",
"from",
"payment",
"transaction"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L140-L152 |
4,918 | payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.validate_response_on_success | def validate_response_on_success(payment_transaction, response)
if response.type != success_response_type
raise ValidationError, "Response type '#{response.type}' does " +
"not match success response type '#{success_response_type}'"
end
missed_fields = []
... | ruby | def validate_response_on_success(payment_transaction, response)
if response.type != success_response_type
raise ValidationError, "Response type '#{response.type}' does " +
"not match success response type '#{success_response_type}'"
end
missed_fields = []
... | [
"def",
"validate_response_on_success",
"(",
"payment_transaction",
",",
"response",
")",
"if",
"response",
".",
"type",
"!=",
"success_response_type",
"raise",
"ValidationError",
",",
"\"Response type '#{response.type}' does \"",
"+",
"\"not match success response type '#{success... | Validates response before payment transaction updating
if payment transaction is processing or approved
@param payment_transaction [PaymentTransaction] Payment transaction
@param response [Response] Response for validating | [
"Validates",
"response",
"before",
"payment",
"transaction",
"updating",
"if",
"payment",
"transaction",
"is",
"processing",
"or",
"approved"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L175-L192 |
4,919 | payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.validate_response_on_error | def validate_response_on_error(payment_transaction, response)
unless [success_response_type, 'error', 'validation-error'].include? response.type
raise ValidationError, "Unknown response type '#{response.type}'"
end
validate_client_id payment_transaction, response
end | ruby | def validate_response_on_error(payment_transaction, response)
unless [success_response_type, 'error', 'validation-error'].include? response.type
raise ValidationError, "Unknown response type '#{response.type}'"
end
validate_client_id payment_transaction, response
end | [
"def",
"validate_response_on_error",
"(",
"payment_transaction",
",",
"response",
")",
"unless",
"[",
"success_response_type",
",",
"'error'",
",",
"'validation-error'",
"]",
".",
"include?",
"response",
".",
"type",
"raise",
"ValidationError",
",",
"\"Unknown response ... | Validates response before payment transaction updating
if payment transaction is not processing or approved
@param payment_transaction [PaymentTransaction] Payment transaction
@param response [Response] Response for validating | [
"Validates",
"response",
"before",
"payment",
"transaction",
"updating",
"if",
"payment",
"transaction",
"is",
"not",
"processing",
"or",
"approved"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L199-L205 |
4,920 | payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.update_payment_transaction_on_success | def update_payment_transaction_on_success(payment_transaction, response)
payment_transaction.status = response.status
set_paynet_id payment_transaction, response
end | ruby | def update_payment_transaction_on_success(payment_transaction, response)
payment_transaction.status = response.status
set_paynet_id payment_transaction, response
end | [
"def",
"update_payment_transaction_on_success",
"(",
"payment_transaction",
",",
"response",
")",
"payment_transaction",
".",
"status",
"=",
"response",
".",
"status",
"set_paynet_id",
"payment_transaction",
",",
"response",
"end"
] | Updates payment transaction by query response data
if payment transaction is processing or approved
@param payment_transaction [PaymentTransaction] Payment transaction
@param response [Response] Response for payment transaction updating | [
"Updates",
"payment",
"transaction",
"by",
"query",
"response",
"data",
"if",
"payment",
"transaction",
"is",
"processing",
"or",
"approved"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L212-L215 |
4,921 | payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.update_payment_transaction_on_error | def update_payment_transaction_on_error(payment_transaction, response)
if response.declined?
payment_transaction.status = response.status
else
payment_transaction.status = PaymentTransaction::STATUS_ERROR
end
payment_transaction.add_error response.error
set_paynet_id payme... | ruby | def update_payment_transaction_on_error(payment_transaction, response)
if response.declined?
payment_transaction.status = response.status
else
payment_transaction.status = PaymentTransaction::STATUS_ERROR
end
payment_transaction.add_error response.error
set_paynet_id payme... | [
"def",
"update_payment_transaction_on_error",
"(",
"payment_transaction",
",",
"response",
")",
"if",
"response",
".",
"declined?",
"payment_transaction",
".",
"status",
"=",
"response",
".",
"status",
"else",
"payment_transaction",
".",
"status",
"=",
"PaymentTransacti... | Updates payment transaction by query response data
if payment transaction is not processing or approved
@param payment_transaction [PaymentTransaction] Payment transaction
@param response [Response] Response for payment transaction updating | [
"Updates",
"payment",
"transaction",
"by",
"query",
"response",
"data",
"if",
"payment",
"transaction",
"is",
"not",
"processing",
"or",
"approved"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L222-L231 |
4,922 | payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.validate_query_definition | def validate_query_definition
raise RuntimeError, 'You must configure @request_fields_definition' if request_fields_definition.empty?
raise RuntimeError, 'You must configure @signature_definition' if signature_definition.empty?
raise RuntimeError, 'You must configure @response_fields_definition... | ruby | def validate_query_definition
raise RuntimeError, 'You must configure @request_fields_definition' if request_fields_definition.empty?
raise RuntimeError, 'You must configure @signature_definition' if signature_definition.empty?
raise RuntimeError, 'You must configure @response_fields_definition... | [
"def",
"validate_query_definition",
"raise",
"RuntimeError",
",",
"'You must configure @request_fields_definition'",
"if",
"request_fields_definition",
".",
"empty?",
"raise",
"RuntimeError",
",",
"'You must configure @signature_definition'",
"if",
"signature_definition",
".",
"emp... | Validates query object definition | [
"Validates",
"query",
"object",
"definition"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L243-L248 |
4,923 | payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.validate_client_id | def validate_client_id(payment_transaction, response)
payment_id = payment_transaction.payment.client_id
response_id = response.payment_client_id
if response_id && payment_id.to_s != response_id.to_s # Different types with equal values must pass validation
raise ValidationError, "Response ... | ruby | def validate_client_id(payment_transaction, response)
payment_id = payment_transaction.payment.client_id
response_id = response.payment_client_id
if response_id && payment_id.to_s != response_id.to_s # Different types with equal values must pass validation
raise ValidationError, "Response ... | [
"def",
"validate_client_id",
"(",
"payment_transaction",
",",
"response",
")",
"payment_id",
"=",
"payment_transaction",
".",
"payment",
".",
"client_id",
"response_id",
"=",
"response",
".",
"payment_client_id",
"if",
"response_id",
"&&",
"payment_id",
".",
"to_s",
... | Check, is payment transaction client order id and query response client order id equal or not.
@param payment_transaction [PaymentTransaction] Payment transaction for update
@param response [Response] API gateway response | [
"Check",
"is",
"payment",
"transaction",
"client",
"order",
"id",
"and",
"query",
"response",
"client",
"order",
"id",
"equal",
"or",
"not",
"."
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L254-L261 |
4,924 | payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/query/prototype/query.rb | PaynetEasy::PaynetEasyApi::Query::Prototype.Query.set_paynet_id | def set_paynet_id(payment_transaction, response)
if response.payment_paynet_id
payment_transaction.payment.paynet_id = response.payment_paynet_id
end
end | ruby | def set_paynet_id(payment_transaction, response)
if response.payment_paynet_id
payment_transaction.payment.paynet_id = response.payment_paynet_id
end
end | [
"def",
"set_paynet_id",
"(",
"payment_transaction",
",",
"response",
")",
"if",
"response",
".",
"payment_paynet_id",
"payment_transaction",
".",
"payment",
".",
"paynet_id",
"=",
"response",
".",
"payment_paynet_id",
"end",
"end"
] | Set PaynetEasy payment id to payment transaction Payment
@param payment_transaction [PaymentTransaction] Payment transaction for update
@param response [Response] API gateway response | [
"Set",
"PaynetEasy",
"payment",
"id",
"to",
"payment",
"transaction",
"Payment"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/query/prototype/query.rb#L267-L271 |
4,925 | grempe/opensecrets | lib/opensecrets.rb | OpenSecrets.Candidate.summary | def summary(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
options.merge!({:method => 'candSummary'})
self.class.get("/", :query => options)
end | ruby | def summary(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
options.merge!({:method => 'candSummary'})
self.class.get("/", :query => options)
end | [
"def",
"summary",
"(",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'You must provide a :cid option'",
"if",
"options",
"[",
":cid",
"]",
".",
"nil?",
"||",
"options",
"[",
":cid",
"]",
".",
"empty?",
"options",
".",
"merge!",
"(",
"{",
... | Provides summary fundraising information for specified politician.
See : http://www.opensecrets.org/api/?method=candSummary&output=doc
@option options [String] :cid ("") a CRP CandidateID
@option options [optional, String] :cycle ("") blank values returns current cycle. | [
"Provides",
"summary",
"fundraising",
"information",
"for",
"specified",
"politician",
"."
] | 2f507e214de716ce7b23831e056160b1384bff78 | https://github.com/grempe/opensecrets/blob/2f507e214de716ce7b23831e056160b1384bff78/lib/opensecrets.rb#L66-L70 |
4,926 | grempe/opensecrets | lib/opensecrets.rb | OpenSecrets.Candidate.contributors | def contributors(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
options.merge!({:method => 'candContrib'})
self.class.get("/", :query => options)
end | ruby | def contributors(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
options.merge!({:method => 'candContrib'})
self.class.get("/", :query => options)
end | [
"def",
"contributors",
"(",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'You must provide a :cid option'",
"if",
"options",
"[",
":cid",
"]",
".",
"nil?",
"||",
"options",
"[",
":cid",
"]",
".",
"empty?",
"options",
".",
"merge!",
"(",
"... | Provides the top organizations contributing to specified politician.
See : http://www.opensecrets.org/api/?method=candContrib&output=doc
@option options [String] :cid ("") a CRP CandidateID
@option options [optional, String] :cycle ("") 2008 or 2010. | [
"Provides",
"the",
"top",
"organizations",
"contributing",
"to",
"specified",
"politician",
"."
] | 2f507e214de716ce7b23831e056160b1384bff78 | https://github.com/grempe/opensecrets/blob/2f507e214de716ce7b23831e056160b1384bff78/lib/opensecrets.rb#L79-L83 |
4,927 | grempe/opensecrets | lib/opensecrets.rb | OpenSecrets.Candidate.industries | def industries(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
options.merge!({:method => 'candIndustry'})
self.class.get("/", :query => options)
end | ruby | def industries(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
options.merge!({:method => 'candIndustry'})
self.class.get("/", :query => options)
end | [
"def",
"industries",
"(",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'You must provide a :cid option'",
"if",
"options",
"[",
":cid",
"]",
".",
"nil?",
"||",
"options",
"[",
":cid",
"]",
".",
"empty?",
"options",
".",
"merge!",
"(",
"{"... | Provides the top industries contributing to a specified politician.
See : http://www.opensecrets.org/api/?method=candIndustry&output=doc
@option options [String] :cid ("") a CRP CandidateID
@option options [optional, String] :cycle ("") blank values returns current cycle. | [
"Provides",
"the",
"top",
"industries",
"contributing",
"to",
"a",
"specified",
"politician",
"."
] | 2f507e214de716ce7b23831e056160b1384bff78 | https://github.com/grempe/opensecrets/blob/2f507e214de716ce7b23831e056160b1384bff78/lib/opensecrets.rb#L92-L96 |
4,928 | grempe/opensecrets | lib/opensecrets.rb | OpenSecrets.Candidate.contributions_by_industry | def contributions_by_industry(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
raise ArgumentError, 'You must provide a :ind option' if options[:ind].nil? || options[:ind].empty?
options.merge!({:method => 'CandIndByInd'})
self.cla... | ruby | def contributions_by_industry(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
raise ArgumentError, 'You must provide a :ind option' if options[:ind].nil? || options[:ind].empty?
options.merge!({:method => 'CandIndByInd'})
self.cla... | [
"def",
"contributions_by_industry",
"(",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'You must provide a :cid option'",
"if",
"options",
"[",
":cid",
"]",
".",
"nil?",
"||",
"options",
"[",
":cid",
"]",
".",
"empty?",
"raise",
"ArgumentError",... | Provides total contributed to specified candidate from specified industry for specified cycle.
See : http://www.opensecrets.org/api/?method=candIndByInd&output=doc
@option options [String] :cid ("") a CRP CandidateID
@option options [String] :ind ("") a a 3-character industry code
@option options [optional, Strin... | [
"Provides",
"total",
"contributed",
"to",
"specified",
"candidate",
"from",
"specified",
"industry",
"for",
"specified",
"cycle",
"."
] | 2f507e214de716ce7b23831e056160b1384bff78 | https://github.com/grempe/opensecrets/blob/2f507e214de716ce7b23831e056160b1384bff78/lib/opensecrets.rb#L106-L111 |
4,929 | grempe/opensecrets | lib/opensecrets.rb | OpenSecrets.Candidate.sector | def sector(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
options.merge!({:method => 'candSector'})
self.class.get("/", :query => options)
end | ruby | def sector(options = {})
raise ArgumentError, 'You must provide a :cid option' if options[:cid].nil? || options[:cid].empty?
options.merge!({:method => 'candSector'})
self.class.get("/", :query => options)
end | [
"def",
"sector",
"(",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'You must provide a :cid option'",
"if",
"options",
"[",
":cid",
"]",
".",
"nil?",
"||",
"options",
"[",
":cid",
"]",
".",
"empty?",
"options",
".",
"merge!",
"(",
"{",
... | Provides sector total of specified politician's receipts.
See : http://www.opensecrets.org/api/?method=candSector&output=doc
@option options [String] :cid ("") a CRP CandidateID
@option options [optional, String] :cycle ("") blank values returns current cycle. | [
"Provides",
"sector",
"total",
"of",
"specified",
"politician",
"s",
"receipts",
"."
] | 2f507e214de716ce7b23831e056160b1384bff78 | https://github.com/grempe/opensecrets/blob/2f507e214de716ce7b23831e056160b1384bff78/lib/opensecrets.rb#L120-L124 |
4,930 | grempe/opensecrets | lib/opensecrets.rb | OpenSecrets.Committee.by_industry | def by_industry(options = {})
raise ArgumentError, 'You must provide a :cmte option' if options[:cmte].nil? || options[:cmte].empty?
raise ArgumentError, 'You must provide a :congno option' if options[:congno].nil? || options[:congno].empty?
raise ArgumentError, 'You must provide a :indus option' if o... | ruby | def by_industry(options = {})
raise ArgumentError, 'You must provide a :cmte option' if options[:cmte].nil? || options[:cmte].empty?
raise ArgumentError, 'You must provide a :congno option' if options[:congno].nil? || options[:congno].empty?
raise ArgumentError, 'You must provide a :indus option' if o... | [
"def",
"by_industry",
"(",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'You must provide a :cmte option'",
"if",
"options",
"[",
":cmte",
"]",
".",
"nil?",
"||",
"options",
"[",
":cmte",
"]",
".",
"empty?",
"raise",
"ArgumentError",
",",
"... | Provides summary fundraising information for a specific committee, industry and Congress number.
See : http://www.opensecrets.org/api/?method=congCmteIndus&output=doc
@option options [String] :cmte ("") Committee ID in CQ format
@option options [String] :congno ("") Congress Number (like 110)
@option options [Str... | [
"Provides",
"summary",
"fundraising",
"information",
"for",
"a",
"specific",
"committee",
"industry",
"and",
"Congress",
"number",
"."
] | 2f507e214de716ce7b23831e056160b1384bff78 | https://github.com/grempe/opensecrets/blob/2f507e214de716ce7b23831e056160b1384bff78/lib/opensecrets.rb#L138-L144 |
4,931 | grempe/opensecrets | lib/opensecrets.rb | OpenSecrets.Organization.get_orgs | def get_orgs(options = {})
raise ArgumentError, 'You must provide a :org option' if options[:org].nil? || options[:org].empty?
options.merge!({:method => 'getOrgs'})
self.class.get("/", :query => options)
end | ruby | def get_orgs(options = {})
raise ArgumentError, 'You must provide a :org option' if options[:org].nil? || options[:org].empty?
options.merge!({:method => 'getOrgs'})
self.class.get("/", :query => options)
end | [
"def",
"get_orgs",
"(",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'You must provide a :org option'",
"if",
"options",
"[",
":org",
"]",
".",
"nil?",
"||",
"options",
"[",
":org",
"]",
".",
"empty?",
"options",
".",
"merge!",
"(",
"{",
... | Look up an organization by name.
See : https://www.opensecrets.org/api/?method=getOrgs&output=doc
@option options [String] :org ("") name or partial name of organization requested | [
"Look",
"up",
"an",
"organization",
"by",
"name",
"."
] | 2f507e214de716ce7b23831e056160b1384bff78 | https://github.com/grempe/opensecrets/blob/2f507e214de716ce7b23831e056160b1384bff78/lib/opensecrets.rb#L156-L160 |
4,932 | grempe/opensecrets | lib/opensecrets.rb | OpenSecrets.Organization.org_summary | def org_summary(options = {})
raise ArgumentError, 'You must provide a :id option' if options[:id].nil? || options[:id].empty?
options.merge!({:method => 'orgSummary'})
self.class.get("/", :query => options)
end | ruby | def org_summary(options = {})
raise ArgumentError, 'You must provide a :id option' if options[:id].nil? || options[:id].empty?
options.merge!({:method => 'orgSummary'})
self.class.get("/", :query => options)
end | [
"def",
"org_summary",
"(",
"options",
"=",
"{",
"}",
")",
"raise",
"ArgumentError",
",",
"'You must provide a :id option'",
"if",
"options",
"[",
":id",
"]",
".",
"nil?",
"||",
"options",
"[",
":id",
"]",
".",
"empty?",
"options",
".",
"merge!",
"(",
"{",
... | Provides summary fundraising information for the specified organization id.
See : https://www.opensecrets.org/api/?method=orgSummary&output=doc
@option options [String] :org ("") CRP orgid (available via 'get_orgs' method) | [
"Provides",
"summary",
"fundraising",
"information",
"for",
"the",
"specified",
"organization",
"id",
"."
] | 2f507e214de716ce7b23831e056160b1384bff78 | https://github.com/grempe/opensecrets/blob/2f507e214de716ce7b23831e056160b1384bff78/lib/opensecrets.rb#L168-L172 |
4,933 | petebrowne/massimo | lib/massimo/config.rb | Massimo.Config.path_for | def path_for(resource_name)
if resource_path = send("#{resource_name}_path")
File.expand_path resource_path
else
File.join source_path, resource_name.to_s
end
end | ruby | def path_for(resource_name)
if resource_path = send("#{resource_name}_path")
File.expand_path resource_path
else
File.join source_path, resource_name.to_s
end
end | [
"def",
"path_for",
"(",
"resource_name",
")",
"if",
"resource_path",
"=",
"send",
"(",
"\"#{resource_name}_path\"",
")",
"File",
".",
"expand_path",
"resource_path",
"else",
"File",
".",
"join",
"source_path",
",",
"resource_name",
".",
"to_s",
"end",
"end"
] | Get a full, expanded path for the given resource name. This is either set
in the configuration or determined dynamically based on the name. | [
"Get",
"a",
"full",
"expanded",
"path",
"for",
"the",
"given",
"resource",
"name",
".",
"This",
"is",
"either",
"set",
"in",
"the",
"configuration",
"or",
"determined",
"dynamically",
"based",
"on",
"the",
"name",
"."
] | c450edc531ad358f011da0a47e5d0bc9a038d911 | https://github.com/petebrowne/massimo/blob/c450edc531ad358f011da0a47e5d0bc9a038d911/lib/massimo/config.rb#L131-L137 |
4,934 | mooreryan/parse_fasta | lib/parse_fasta/seq_file.rb | ParseFasta.SeqFile.get_first_char | def get_first_char fname
if File.exists? fname
begin
f = Zlib::GzipReader.open fname
rescue Zlib::GzipFile::Error
f = File.open fname
end
begin
first_char = f.each.peek[0]
return first_char
ensure
f.close
end
... | ruby | def get_first_char fname
if File.exists? fname
begin
f = Zlib::GzipReader.open fname
rescue Zlib::GzipFile::Error
f = File.open fname
end
begin
first_char = f.each.peek[0]
return first_char
ensure
f.close
end
... | [
"def",
"get_first_char",
"fname",
"if",
"File",
".",
"exists?",
"fname",
"begin",
"f",
"=",
"Zlib",
"::",
"GzipReader",
".",
"open",
"fname",
"rescue",
"Zlib",
"::",
"GzipFile",
"::",
"Error",
"f",
"=",
"File",
".",
"open",
"fname",
"end",
"begin",
"firs... | Get the first char of the file whether it is gzip'd or not. No
need to rewind the stream afterwards. | [
"Get",
"the",
"first",
"char",
"of",
"the",
"file",
"whether",
"it",
"is",
"gzip",
"d",
"or",
"not",
".",
"No",
"need",
"to",
"rewind",
"the",
"stream",
"afterwards",
"."
] | 016272371be668addb29d3c92ec6a5d2e07332ad | https://github.com/mooreryan/parse_fasta/blob/016272371be668addb29d3c92ec6a5d2e07332ad/lib/parse_fasta/seq_file.rb#L214-L234 |
4,935 | donaldpiret/github-pivotal-flow | lib/github_pivotal_flow/github_api.rb | GithubPivotalFlow.GitHubAPI.create_pullrequest | def create_pullrequest options
project = options.fetch(:project)
params = {
:base => options.fetch(:base),
:head => options.fetch(:head)
}
if options[:issue]
params[:issue] = options[:issue]
else
params[:title] = options[:title] if options[:title]
... | ruby | def create_pullrequest options
project = options.fetch(:project)
params = {
:base => options.fetch(:base),
:head => options.fetch(:head)
}
if options[:issue]
params[:issue] = options[:issue]
else
params[:title] = options[:title] if options[:title]
... | [
"def",
"create_pullrequest",
"options",
"project",
"=",
"options",
".",
"fetch",
"(",
":project",
")",
"params",
"=",
"{",
":base",
"=>",
"options",
".",
"fetch",
"(",
":base",
")",
",",
":head",
"=>",
"options",
".",
"fetch",
"(",
":head",
")",
"}",
"... | Returns parsed data from the new pull request. | [
"Returns",
"parsed",
"data",
"from",
"the",
"new",
"pull",
"request",
"."
] | 676436950b691f57ad793a9023a4765ab9420dd0 | https://github.com/donaldpiret/github-pivotal-flow/blob/676436950b691f57ad793a9023a4765ab9420dd0/lib/github_pivotal_flow/github_api.rb#L47-L66 |
4,936 | petebrowne/massimo | lib/massimo/watcher.rb | Massimo.Watcher.process | def process
if config_changed?
Massimo::UI.say 'massimo is reloading your site'
@site.reload
@site.process
Massimo::UI.say 'massimo has built your site', :growl => true
elsif changed?
Massimo::UI.say 'massimo has noticed a change'
@site.process
Massimo... | ruby | def process
if config_changed?
Massimo::UI.say 'massimo is reloading your site'
@site.reload
@site.process
Massimo::UI.say 'massimo has built your site', :growl => true
elsif changed?
Massimo::UI.say 'massimo has noticed a change'
@site.process
Massimo... | [
"def",
"process",
"if",
"config_changed?",
"Massimo",
"::",
"UI",
".",
"say",
"'massimo is reloading your site'",
"@site",
".",
"reload",
"@site",
".",
"process",
"Massimo",
"::",
"UI",
".",
"say",
"'massimo has built your site'",
",",
":growl",
"=>",
"true",
"els... | Processes the Site if any of the files have changed. | [
"Processes",
"the",
"Site",
"if",
"any",
"of",
"the",
"files",
"have",
"changed",
"."
] | c450edc531ad358f011da0a47e5d0bc9a038d911 | https://github.com/petebrowne/massimo/blob/c450edc531ad358f011da0a47e5d0bc9a038d911/lib/massimo/watcher.rb#L29-L40 |
4,937 | fuminori-ido/edgarj | app/helpers/edgarj/field_helper.rb | Edgarj.FieldHelper.draw_form_buttons | def draw_form_buttons(options = {})
content_tag(:table) do
content_tag(:tr) do
# save button
content_tag(:td) do
#cp_bitset = Edgarj::ModelPermission::FlagsBitset
#create_or_update = cp_bitset::CREATE + cp_bitset::UPDATE
tag(:input, {
... | ruby | def draw_form_buttons(options = {})
content_tag(:table) do
content_tag(:tr) do
# save button
content_tag(:td) do
#cp_bitset = Edgarj::ModelPermission::FlagsBitset
#create_or_update = cp_bitset::CREATE + cp_bitset::UPDATE
tag(:input, {
... | [
"def",
"draw_form_buttons",
"(",
"options",
"=",
"{",
"}",
")",
"content_tag",
"(",
":table",
")",
"do",
"content_tag",
"(",
":tr",
")",
"do",
"# save button",
"content_tag",
"(",
":td",
")",
"do",
"#cp_bitset = Edgarj::ModelPermission::FlagsBitset",
"#create_or_upd... | Draw buttons for form.
When no CREATE/UPDATE permission, save button is disabled.
It can be overwritten by options[:save].
When no DELETE permission, delete button is disabled.
It can be overwritten by options[:delete].
options may have:
:save:: html options for 'save' button.
:search_form:: html opt... | [
"Draw",
"buttons",
"for",
"form",
"."
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/field_helper.rb#L18-L73 |
4,938 | fuminori-ido/edgarj | app/helpers/edgarj/field_helper.rb | Edgarj.FieldHelper.draw_field | def draw_field(f, col, options={})
case col.type
when :date
draw_date(f, col, options[:date] || {})
when :datetime
draw_datetime(f, col, options[:datetime] || {})
when :integer
f.text_field(col.name, options[:integer])
else
f.text_field(col.name, options[:te... | ruby | def draw_field(f, col, options={})
case col.type
when :date
draw_date(f, col, options[:date] || {})
when :datetime
draw_datetime(f, col, options[:datetime] || {})
when :integer
f.text_field(col.name, options[:integer])
else
f.text_field(col.name, options[:te... | [
"def",
"draw_field",
"(",
"f",
",",
"col",
",",
"options",
"=",
"{",
"}",
")",
"case",
"col",
".",
"type",
"when",
":date",
"draw_date",
"(",
"f",
",",
"col",
",",
"options",
"[",
":date",
"]",
"||",
"{",
"}",
")",
"when",
":datetime",
"draw_dateti... | draw default field for col.type
options[type] is passed to each rails helper. Following types are
supported:
* :date
* :datetime
* :integer
* :boolean
* :text
=== INPUTS
f:: FormBuilder object
col:: column info returned by AR.columns, or symbol
options:: options hash passed to each helper. | [
"draw",
"default",
"field",
"for",
"col",
".",
"type"
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/field_helper.rb#L122-L133 |
4,939 | fuminori-ido/edgarj | app/helpers/edgarj/field_helper.rb | Edgarj.FieldHelper.draw_datetime | def draw_datetime(f, col_or_sym, options={})
col_name = get_column_name(col_or_sym)
f.text_field(col_name,
value: datetime_fmt(f.object.send(col_name)))
end | ruby | def draw_datetime(f, col_or_sym, options={})
col_name = get_column_name(col_or_sym)
f.text_field(col_name,
value: datetime_fmt(f.object.send(col_name)))
end | [
"def",
"draw_datetime",
"(",
"f",
",",
"col_or_sym",
",",
"options",
"=",
"{",
"}",
")",
"col_name",
"=",
"get_column_name",
"(",
"col_or_sym",
")",
"f",
".",
"text_field",
"(",
"col_name",
",",
"value",
":",
"datetime_fmt",
"(",
"f",
".",
"object",
".",... | draw calendar datetime select
=== INPUTS
f:: Form builder object.
col_or_sym:: column object returned by rec.class.columns, or symbol
options:: passed to calendar_date_select | [
"draw",
"calendar",
"datetime",
"select"
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/field_helper.rb#L165-L169 |
4,940 | fuminori-ido/edgarj | app/helpers/edgarj/field_helper.rb | Edgarj.FieldHelper.draw_address | def draw_address(f, col_or_sym)
address_name = f.object.class.get_belongs_to_name(col_or_sym)
render('edgarj/address',
f: f,
rec: f.object,
address_name: address_name
)
end | ruby | def draw_address(f, col_or_sym)
address_name = f.object.class.get_belongs_to_name(col_or_sym)
render('edgarj/address',
f: f,
rec: f.object,
address_name: address_name
)
end | [
"def",
"draw_address",
"(",
"f",
",",
"col_or_sym",
")",
"address_name",
"=",
"f",
".",
"object",
".",
"class",
".",
"get_belongs_to_name",
"(",
"col_or_sym",
")",
"render",
"(",
"'edgarj/address'",
",",
"f",
":",
"f",
",",
"rec",
":",
"f",
".",
"object"... | draw 'edgarj_address' field
The column, which is declared as 'edgarj_address', can be
drawn by this helper.
=== INPUTS
f:: FormBuilder
col_or_sym:: column object returned by rec.class.columns, or symbol | [
"draw",
"edgarj_address",
"field"
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/field_helper.rb#L179-L186 |
4,941 | fuminori-ido/edgarj | app/helpers/edgarj/field_helper.rb | Edgarj.FieldHelper.draw_bitset | def draw_bitset(f, col, bitset=nil, options={})
html = ''
bitset = model.const_get(col_name.to_s.camelize + 'Bitset') if !bitset
i = 0
id_array_var = sprintf('%s_%s_var', f.object_name, col.name)
ids = []
for flag in bitset.constants do
... | ruby | def draw_bitset(f, col, bitset=nil, options={})
html = ''
bitset = model.const_get(col_name.to_s.camelize + 'Bitset') if !bitset
i = 0
id_array_var = sprintf('%s_%s_var', f.object_name, col.name)
ids = []
for flag in bitset.constants do
... | [
"def",
"draw_bitset",
"(",
"f",
",",
"col",
",",
"bitset",
"=",
"nil",
",",
"options",
"=",
"{",
"}",
")",
"html",
"=",
"''",
"bitset",
"=",
"model",
".",
"const_get",
"(",
"col_name",
".",
"to_s",
".",
"camelize",
"+",
"'Bitset'",
")",
"if",
"!",
... | draw bitset checkboxes.
When model class has integer field (e.g. 'flags') and
Flags module which defines 'bitflag' constant,
model.flags integer column is drawn as bitset checkboxes.
Constant name will be translated by config/locales/*.yml
See ModelPermission for example.
'flags' column value is calculated at c... | [
"draw",
"bitset",
"checkboxes",
"."
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/field_helper.rb#L205-L232 |
4,942 | fuminori-ido/edgarj | app/helpers/edgarj/field_helper.rb | Edgarj.FieldHelper.draw_enum | def draw_enum(f, col_or_sym, enum=nil, options={})
col_name = get_column_name(col_or_sym)
enum = model.const_get(col_name.to_s.camelize) if !enum
sorted_elements = enum.constants.sort{|a,b|
enum.const_get(a) <=> enum.const_get(b)}
op... | ruby | def draw_enum(f, col_or_sym, enum=nil, options={})
col_name = get_column_name(col_or_sym)
enum = model.const_get(col_name.to_s.camelize) if !enum
sorted_elements = enum.constants.sort{|a,b|
enum.const_get(a) <=> enum.const_get(b)}
op... | [
"def",
"draw_enum",
"(",
"f",
",",
"col_or_sym",
",",
"enum",
"=",
"nil",
",",
"options",
"=",
"{",
"}",
")",
"col_name",
"=",
"get_column_name",
"(",
"col_or_sym",
")",
"enum",
"=",
"model",
".",
"const_get",
"(",
"col_name",
".",
"to_s",
".",
"cameli... | draw enum selection.
'Enum' in Edgarj is a module which integer constants are defined.
draw_enum() draws selection rather than simple integer text field.
Selection-option label is I18 supported by AR human_const_name API.
See lib/edgarj/model.rb rdoc.
=== EXAMPLE
Followings draws Question module's Priority sel... | [
"draw",
"enum",
"selection",
"."
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/field_helper.rb#L267-L281 |
4,943 | fuminori-ido/edgarj | app/helpers/edgarj/field_helper.rb | Edgarj.FieldHelper.draw_checkbox | def draw_checkbox(f, id, flag, bitset, id_array_var)
val = f.object.send(:flags) || 0
flag_val = bitset.const_get(flag)
tag(:input,
type: 'checkbox',
id: id,
name: id,
value: flag_val,
onChange: "Edgarj.sum_bitset(#{id_array_var... | ruby | def draw_checkbox(f, id, flag, bitset, id_array_var)
val = f.object.send(:flags) || 0
flag_val = bitset.const_get(flag)
tag(:input,
type: 'checkbox',
id: id,
name: id,
value: flag_val,
onChange: "Edgarj.sum_bitset(#{id_array_var... | [
"def",
"draw_checkbox",
"(",
"f",
",",
"id",
",",
"flag",
",",
"bitset",
",",
"id_array_var",
")",
"val",
"=",
"f",
".",
"object",
".",
"send",
"(",
":flags",
")",
"||",
"0",
"flag_val",
"=",
"bitset",
".",
"const_get",
"(",
"flag",
")",
"tag",
"("... | draw Edgarj flags specific checkbox | [
"draw",
"Edgarj",
"flags",
"specific",
"checkbox"
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/field_helper.rb#L359-L369 |
4,944 | fuminori-ido/edgarj | app/helpers/edgarj/field_helper.rb | Edgarj.FieldHelper.find_col | def find_col(rec, sym)
rec.class.columns.detect{|c| c.name == sym.to_s}
end | ruby | def find_col(rec, sym)
rec.class.columns.detect{|c| c.name == sym.to_s}
end | [
"def",
"find_col",
"(",
"rec",
",",
"sym",
")",
"rec",
".",
"class",
".",
"columns",
".",
"detect",
"{",
"|",
"c",
"|",
"c",
".",
"name",
"==",
"sym",
".",
"to_s",
"}",
"end"
] | find column info from name | [
"find",
"column",
"info",
"from",
"name"
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/field_helper.rb#L372-L374 |
4,945 | fuminori-ido/edgarj | app/helpers/edgarj/field_helper.rb | Edgarj.FieldHelper.button_for_js | def button_for_js(label, js, html_options={})
tag(:input, {type: 'button', value: label, onClick: js}.merge(
html_options))
end | ruby | def button_for_js(label, js, html_options={})
tag(:input, {type: 'button', value: label, onClick: js}.merge(
html_options))
end | [
"def",
"button_for_js",
"(",
"label",
",",
"js",
",",
"html_options",
"=",
"{",
"}",
")",
"tag",
"(",
":input",
",",
"{",
"type",
":",
"'button'",
",",
"value",
":",
"label",
",",
"onClick",
":",
"js",
"}",
".",
"merge",
"(",
"html_options",
")",
"... | replacement of button_to_function to avoid DEPRECATION WARNING.
When the js is called just once, onClick is simpler than
unobtrusive-javascript approach. | [
"replacement",
"of",
"button_to_function",
"to",
"avoid",
"DEPRECATION",
"WARNING",
"."
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/helpers/edgarj/field_helper.rb#L398-L401 |
4,946 | jwoertink/tourets | lib/tourets/utilities.rb | TouRETS.Utilities.map_search_params | def map_search_params(search_params)
Hash[search_params.map {|k, v| [key_map[k], v] }]
end | ruby | def map_search_params(search_params)
Hash[search_params.map {|k, v| [key_map[k], v] }]
end | [
"def",
"map_search_params",
"(",
"search_params",
")",
"Hash",
"[",
"search_params",
".",
"map",
"{",
"|",
"k",
",",
"v",
"|",
"[",
"key_map",
"[",
"k",
"]",
",",
"v",
"]",
"}",
"]",
"end"
] | This takes a hash of search parameters, and modifies
the hash to have the correct key types for the current RETS server | [
"This",
"takes",
"a",
"hash",
"of",
"search",
"parameters",
"and",
"modifies",
"the",
"hash",
"to",
"have",
"the",
"correct",
"key",
"types",
"for",
"the",
"current",
"RETS",
"server"
] | 1cf5b5b061702846d38a261ad256f1641d2553c1 | https://github.com/jwoertink/tourets/blob/1cf5b5b061702846d38a261ad256f1641d2553c1/lib/tourets/utilities.rb#L17-L19 |
4,947 | jwoertink/tourets | lib/tourets/utilities.rb | TouRETS.Utilities.value_map | def value_map(value)
v = case value.class
when Array
value.join(',')
when Range
"#{value.first}-#{value.last}"
when Hash
if value.has_key?(:or)
"|#{value[:or].join(',')}"
elsif value.has_key?(:not)
"~#{value[:not].join(',')}"
end
... | ruby | def value_map(value)
v = case value.class
when Array
value.join(',')
when Range
"#{value.first}-#{value.last}"
when Hash
if value.has_key?(:or)
"|#{value[:or].join(',')}"
elsif value.has_key?(:not)
"~#{value[:not].join(',')}"
end
... | [
"def",
"value_map",
"(",
"value",
")",
"v",
"=",
"case",
"value",
".",
"class",
"when",
"Array",
"value",
".",
"join",
"(",
"','",
")",
"when",
"Range",
"\"#{value.first}-#{value.last}\"",
"when",
"Hash",
"if",
"value",
".",
"has_key?",
"(",
":or",
")",
... | Take values like true and false, convert them to "Y" or "N". make collections into joint strings. | [
"Take",
"values",
"like",
"true",
"and",
"false",
"convert",
"them",
"to",
"Y",
"or",
"N",
".",
"make",
"collections",
"into",
"joint",
"strings",
"."
] | 1cf5b5b061702846d38a261ad256f1641d2553c1 | https://github.com/jwoertink/tourets/blob/1cf5b5b061702846d38a261ad256f1641d2553c1/lib/tourets/utilities.rb#L193-L213 |
4,948 | fuminori-ido/edgarj | lib/edgarj/enum_cache.rb | Edgarj.EnumCache.label | def label(rec, attr, enum = nil)
if !enum
enum = rec.class.const_get(attr.to_s.camelize)
raise(NameError, "wrong constant name #{attr}") if !enum
end
if !@enum_map[enum]
@enum_map[enum] = {}
end
value = rec.attributes[attr.to_s]
if label = @enum_map[enum][valu... | ruby | def label(rec, attr, enum = nil)
if !enum
enum = rec.class.const_get(attr.to_s.camelize)
raise(NameError, "wrong constant name #{attr}") if !enum
end
if !@enum_map[enum]
@enum_map[enum] = {}
end
value = rec.attributes[attr.to_s]
if label = @enum_map[enum][valu... | [
"def",
"label",
"(",
"rec",
",",
"attr",
",",
"enum",
"=",
"nil",
")",
"if",
"!",
"enum",
"enum",
"=",
"rec",
".",
"class",
".",
"const_get",
"(",
"attr",
".",
"to_s",
".",
"camelize",
")",
"raise",
"(",
"NameError",
",",
"\"wrong constant name #{attr}... | return label of 'rec.attr', where attr is enum value. | [
"return",
"label",
"of",
"rec",
".",
"attr",
"where",
"attr",
"is",
"enum",
"value",
"."
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/lib/edgarj/enum_cache.rb#L14-L39 |
4,949 | ndlib/rof | lib/rof/compare_rof.rb | ROF.CompareRof.rights_equal | def rights_equal(rights_attr)
f_rights = Array.wrap(fedora.fetch('rights', {}).fetch(rights_attr, [])).sort
b_rights = Array.wrap(bendo.fetch('rights', {}).fetch(rights_attr, [])).sort
return 0 if f_rights == b_rights
1
end | ruby | def rights_equal(rights_attr)
f_rights = Array.wrap(fedora.fetch('rights', {}).fetch(rights_attr, [])).sort
b_rights = Array.wrap(bendo.fetch('rights', {}).fetch(rights_attr, [])).sort
return 0 if f_rights == b_rights
1
end | [
"def",
"rights_equal",
"(",
"rights_attr",
")",
"f_rights",
"=",
"Array",
".",
"wrap",
"(",
"fedora",
".",
"fetch",
"(",
"'rights'",
",",
"{",
"}",
")",
".",
"fetch",
"(",
"rights_attr",
",",
"[",
"]",
")",
")",
".",
"sort",
"b_rights",
"=",
"Array",... | compare array or element for equivalence | [
"compare",
"array",
"or",
"element",
"for",
"equivalence"
] | 18a8cc009540a868447952eed82de035451025e8 | https://github.com/ndlib/rof/blob/18a8cc009540a868447952eed82de035451025e8/lib/rof/compare_rof.rb#L51-L57 |
4,950 | ndlib/rof | lib/rof/compare_rof.rb | ROF.CompareRof.compare_everything_else | def compare_everything_else
error_count =0
exclude_keys = ['rights', 'rels-ext', 'metadata', 'thumbnail-file']
all_keys_to_check = (bendo.keys + fedora.keys - exclude_keys).uniq
all_keys_to_check.each do |key|
bendo_value = bendo.fetch(key, nil)
fedora_value = fedora.fetch(key, n... | ruby | def compare_everything_else
error_count =0
exclude_keys = ['rights', 'rels-ext', 'metadata', 'thumbnail-file']
all_keys_to_check = (bendo.keys + fedora.keys - exclude_keys).uniq
all_keys_to_check.each do |key|
bendo_value = bendo.fetch(key, nil)
fedora_value = fedora.fetch(key, n... | [
"def",
"compare_everything_else",
"error_count",
"=",
"0",
"exclude_keys",
"=",
"[",
"'rights'",
",",
"'rels-ext'",
",",
"'metadata'",
",",
"'thumbnail-file'",
"]",
"all_keys_to_check",
"=",
"(",
"bendo",
".",
"keys",
"+",
"fedora",
".",
"keys",
"-",
"exclude_ke... | compare what remains | [
"compare",
"what",
"remains"
] | 18a8cc009540a868447952eed82de035451025e8 | https://github.com/ndlib/rof/blob/18a8cc009540a868447952eed82de035451025e8/lib/rof/compare_rof.rb#L95-L109 |
4,951 | ndlib/rof | lib/rof/compare_rof.rb | ROF.CompareRof.normalize_value | def normalize_value(values)
Array.wrap(values).map do |value|
value.is_a?(String) ? value.gsub("\n", "") : value
end
end | ruby | def normalize_value(values)
Array.wrap(values).map do |value|
value.is_a?(String) ? value.gsub("\n", "") : value
end
end | [
"def",
"normalize_value",
"(",
"values",
")",
"Array",
".",
"wrap",
"(",
"values",
")",
".",
"map",
"do",
"|",
"value",
"|",
"value",
".",
"is_a?",
"(",
"String",
")",
"?",
"value",
".",
"gsub",
"(",
"\"\\n\"",
",",
"\"\"",
")",
":",
"value",
"end"... | Because sometimes we have carriage returns and line breaks but we really don't care
@todo Do we care about line breaks? | [
"Because",
"sometimes",
"we",
"have",
"carriage",
"returns",
"and",
"line",
"breaks",
"but",
"we",
"really",
"don",
"t",
"care"
] | 18a8cc009540a868447952eed82de035451025e8 | https://github.com/ndlib/rof/blob/18a8cc009540a868447952eed82de035451025e8/lib/rof/compare_rof.rb#L115-L119 |
4,952 | fuminori-ido/edgarj | app/models/edgarj/search_popup.rb | Edgarj.SearchPopup.conditions | def conditions
return ['1=0'] if !valid?
if @val.blank?
[]
else
# FIXME: assume type is just string
op = '=?'
val = @val
if val =~ /\*$/
op = ' like ?'
val = @val.gsub(/\*/, '%')
end
["#{@col}#{op}", val]
end
end | ruby | def conditions
return ['1=0'] if !valid?
if @val.blank?
[]
else
# FIXME: assume type is just string
op = '=?'
val = @val
if val =~ /\*$/
op = ' like ?'
val = @val.gsub(/\*/, '%')
end
["#{@col}#{op}", val]
end
end | [
"def",
"conditions",
"return",
"[",
"'1=0'",
"]",
"if",
"!",
"valid?",
"if",
"@val",
".",
"blank?",
"[",
"]",
"else",
"# FIXME: assume type is just string",
"op",
"=",
"'=?'",
"val",
"=",
"@val",
"if",
"val",
"=~",
"/",
"\\*",
"/",
"op",
"=",
"' like ?'"... | implement to generate search-conditions | [
"implement",
"to",
"generate",
"search",
"-",
"conditions"
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/models/edgarj/search_popup.rb#L16-L31 |
4,953 | nu7hatch/react | lib/react/runner.rb | React.Runner.start | def start
puts "== Connected to #{redis.client.id}"
puts "== Waiting for commands from `#{options[:queue]}`"
if options[:daemon]
puts "== Daemonizing..."
Daemons.daemonize
end
loop do
begin
cid = redis.blpop(options[:queue], 10)[1]
... | ruby | def start
puts "== Connected to #{redis.client.id}"
puts "== Waiting for commands from `#{options[:queue]}`"
if options[:daemon]
puts "== Daemonizing..."
Daemons.daemonize
end
loop do
begin
cid = redis.blpop(options[:queue], 10)[1]
... | [
"def",
"start",
"puts",
"\"== Connected to #{redis.client.id}\"",
"puts",
"\"== Waiting for commands from `#{options[:queue]}`\"",
"if",
"options",
"[",
":daemon",
"]",
"puts",
"\"== Daemonizing...\"",
"Daemons",
".",
"daemonize",
"end",
"loop",
"do",
"begin",
"cid",
"=",
... | It starts the consumer loop. | [
"It",
"starts",
"the",
"consumer",
"loop",
"."
] | 74a8f7cb83df0e6c2d343172a68f9f30097678b1 | https://github.com/nu7hatch/react/blob/74a8f7cb83df0e6c2d343172a68f9f30097678b1/lib/react/runner.rb#L17-L40 |
4,954 | dvwright/svn_wc | lib/svn_wc.rb | SvnWc.RepoAccess.set_conf | def set_conf(conf)
begin
conf = load_conf(conf)
@svn_user = conf['svn_user']
@svn_pass = conf['svn_pass']
@force_checkout = conf['force_checkout']
@svn_repo_master = conf['svn_repo_master']
@svn_repo_working_copy = conf['svn_re... | ruby | def set_conf(conf)
begin
conf = load_conf(conf)
@svn_user = conf['svn_user']
@svn_pass = conf['svn_pass']
@force_checkout = conf['force_checkout']
@svn_repo_master = conf['svn_repo_master']
@svn_repo_working_copy = conf['svn_re... | [
"def",
"set_conf",
"(",
"conf",
")",
"begin",
"conf",
"=",
"load_conf",
"(",
"conf",
")",
"@svn_user",
"=",
"conf",
"[",
"'svn_user'",
"]",
"@svn_pass",
"=",
"conf",
"[",
"'svn_pass'",
"]",
"@force_checkout",
"=",
"conf",
"[",
"'force_checkout'",
"]",
"@sv... | set config file with abs path | [
"set",
"config",
"file",
"with",
"abs",
"path"
] | f9cda1140d5d101239b104558680c638361c68a4 | https://github.com/dvwright/svn_wc/blob/f9cda1140d5d101239b104558680c638361c68a4/lib/svn_wc.rb#L177-L190 |
4,955 | dvwright/svn_wc | lib/svn_wc.rb | SvnWc.RepoAccess.add | def add(files=[], recurse=true, force=false, no_ignore=false)
# TODO make sure args are what is expected for all methods
raise ArgumentError, 'files is empty' unless files
svn_session() do |svn|
begin
files.each do |ef|
svn.add(ef, recurse, force, no_ignore)
... | ruby | def add(files=[], recurse=true, force=false, no_ignore=false)
# TODO make sure args are what is expected for all methods
raise ArgumentError, 'files is empty' unless files
svn_session() do |svn|
begin
files.each do |ef|
svn.add(ef, recurse, force, no_ignore)
... | [
"def",
"add",
"(",
"files",
"=",
"[",
"]",
",",
"recurse",
"=",
"true",
",",
"force",
"=",
"false",
",",
"no_ignore",
"=",
"false",
")",
"# TODO make sure args are what is expected for all methods",
"raise",
"ArgumentError",
",",
"'files is empty'",
"unless",
"fil... | add entities to the repo
pass a single entry or list of file(s) with fully qualified path,
which must exist,
raises RepoAccessError if something goes wrong
--
"svn/client.rb" Svn::Client
def add(path, recurse=true, force=false, no_ignore=false)
Client.add3(path, recurse, force, no_ignore, self)
end
++ | [
"add",
"entities",
"to",
"the",
"repo"
] | f9cda1140d5d101239b104558680c638361c68a4 | https://github.com/dvwright/svn_wc/blob/f9cda1140d5d101239b104558680c638361c68a4/lib/svn_wc.rb#L284-L302 |
4,956 | dvwright/svn_wc | lib/svn_wc.rb | SvnWc.RepoAccess.delete | def delete(files=[], recurs=false)
svn_session() do |svn|
begin
svn.delete(files)
#rescue Svn::Error::AuthnNoProvider,
# #Svn::Error::WcNotDirectory,
# Svn::Error::ClientModified,
# Svn::Error::SvnError => e
rescue Exception => err
... | ruby | def delete(files=[], recurs=false)
svn_session() do |svn|
begin
svn.delete(files)
#rescue Svn::Error::AuthnNoProvider,
# #Svn::Error::WcNotDirectory,
# Svn::Error::ClientModified,
# Svn::Error::SvnError => e
rescue Exception => err
... | [
"def",
"delete",
"(",
"files",
"=",
"[",
"]",
",",
"recurs",
"=",
"false",
")",
"svn_session",
"(",
")",
"do",
"|",
"svn",
"|",
"begin",
"svn",
".",
"delete",
"(",
"files",
")",
"#rescue Svn::Error::AuthnNoProvider,",
"# #Svn::Error::WcNotDirectory,",
"#... | delete entities from the repository
pass single entity or list of files with fully qualified path,
which must exist,
raises RepoAccessError if something goes wrong | [
"delete",
"entities",
"from",
"the",
"repository"
] | f9cda1140d5d101239b104558680c638361c68a4 | https://github.com/dvwright/svn_wc/blob/f9cda1140d5d101239b104558680c638361c68a4/lib/svn_wc.rb#L313-L325 |
4,957 | dvwright/svn_wc | lib/svn_wc.rb | SvnWc.RepoAccess.commit | def commit(files=[], msg='')
if files and files.empty? or files.nil? then files = self.svn_repo_working_copy end
rev = ''
svn_session(msg) do |svn|
begin
rev = svn.commit(files).revision
#rescue Svn::Error::AuthnNoProvider,
# #Svn::Error::WcNotDirectory,
... | ruby | def commit(files=[], msg='')
if files and files.empty? or files.nil? then files = self.svn_repo_working_copy end
rev = ''
svn_session(msg) do |svn|
begin
rev = svn.commit(files).revision
#rescue Svn::Error::AuthnNoProvider,
# #Svn::Error::WcNotDirectory,
... | [
"def",
"commit",
"(",
"files",
"=",
"[",
"]",
",",
"msg",
"=",
"''",
")",
"if",
"files",
"and",
"files",
".",
"empty?",
"or",
"files",
".",
"nil?",
"then",
"files",
"=",
"self",
".",
"svn_repo_working_copy",
"end",
"rev",
"=",
"''",
"svn_session",
"(... | commit entities to the repository
params single or list of files (full relative path (to repo root) needed)
optional message
raises RepoAccessError if something goes wrong
returns the revision of the commmit | [
"commit",
"entities",
"to",
"the",
"repository"
] | f9cda1140d5d101239b104558680c638361c68a4 | https://github.com/dvwright/svn_wc/blob/f9cda1140d5d101239b104558680c638361c68a4/lib/svn_wc.rb#L340-L357 |
4,958 | dvwright/svn_wc | lib/svn_wc.rb | SvnWc.RepoAccess._pre_update_entries | def _pre_update_entries #:nodoc:
@pre_up_entries = Array.new
@modified_entries = Array.new
list_entries.each do |ent|
##puts "#{ent[:status]} | #{ent[:repo_rev]} | #{ent[:entry_name]}"
e_name = ent[:entry_name]
stat = ent[:status]
if @limit_to_dir_path # limit files re... | ruby | def _pre_update_entries #:nodoc:
@pre_up_entries = Array.new
@modified_entries = Array.new
list_entries.each do |ent|
##puts "#{ent[:status]} | #{ent[:repo_rev]} | #{ent[:entry_name]}"
e_name = ent[:entry_name]
stat = ent[:status]
if @limit_to_dir_path # limit files re... | [
"def",
"_pre_update_entries",
"#:nodoc:",
"@pre_up_entries",
"=",
"Array",
".",
"new",
"@modified_entries",
"=",
"Array",
".",
"new",
"list_entries",
".",
"each",
"do",
"|",
"ent",
"|",
"##puts \"#{ent[:status]} | #{ent[:repo_rev]} | #{ent[:entry_name]}\"",
"e_name",
"=",... | get list of entries before doing an update | [
"get",
"list",
"of",
"entries",
"before",
"doing",
"an",
"update"
] | f9cda1140d5d101239b104558680c638361c68a4 | https://github.com/dvwright/svn_wc/blob/f9cda1140d5d101239b104558680c638361c68a4/lib/svn_wc.rb#L413-L434 |
4,959 | dvwright/svn_wc | lib/svn_wc.rb | SvnWc.RepoAccess._post_update_entries | def _post_update_entries #:nodoc:
post_up_entries = Array.new
list_entries.each { |ent|
if @limit_to_dir_path # limit files returned to this (and subdir's of) dir
fle = File.join(self.svn_repo_working_copy, ent[:entry_name])
next unless fle.include? @limit_to_dir_path
en... | ruby | def _post_update_entries #:nodoc:
post_up_entries = Array.new
list_entries.each { |ent|
if @limit_to_dir_path # limit files returned to this (and subdir's of) dir
fle = File.join(self.svn_repo_working_copy, ent[:entry_name])
next unless fle.include? @limit_to_dir_path
en... | [
"def",
"_post_update_entries",
"#:nodoc:",
"post_up_entries",
"=",
"Array",
".",
"new",
"list_entries",
".",
"each",
"{",
"|",
"ent",
"|",
"if",
"@limit_to_dir_path",
"# limit files returned to this (and subdir's of) dir",
"fle",
"=",
"File",
".",
"join",
"(",
"self",... | get list of entries after doing an update | [
"get",
"list",
"of",
"entries",
"after",
"doing",
"an",
"update"
] | f9cda1140d5d101239b104558680c638361c68a4 | https://github.com/dvwright/svn_wc/blob/f9cda1140d5d101239b104558680c638361c68a4/lib/svn_wc.rb#L440-L464 |
4,960 | dvwright/svn_wc | lib/svn_wc.rb | SvnWc.RepoAccess.revert | def revert(file_path='')
if file_path.empty? then file_path = self.svn_repo_working_copy end
svn_session() { |svn| svn.revert(file_path) }
end | ruby | def revert(file_path='')
if file_path.empty? then file_path = self.svn_repo_working_copy end
svn_session() { |svn| svn.revert(file_path) }
end | [
"def",
"revert",
"(",
"file_path",
"=",
"''",
")",
"if",
"file_path",
".",
"empty?",
"then",
"file_path",
"=",
"self",
".",
"svn_repo_working_copy",
"end",
"svn_session",
"(",
")",
"{",
"|",
"svn",
"|",
"svn",
".",
"revert",
"(",
"file_path",
")",
"}",
... | discard working copy changes, get current repository entry | [
"discard",
"working",
"copy",
"changes",
"get",
"current",
"repository",
"entry"
] | f9cda1140d5d101239b104558680c638361c68a4 | https://github.com/dvwright/svn_wc/blob/f9cda1140d5d101239b104558680c638361c68a4/lib/svn_wc.rb#L821-L824 |
4,961 | petebrowne/massimo | lib/massimo/resource.rb | Massimo.Resource.render | def render
extensions.reverse.inject(content) do |output, ext|
if template_type = Tilt[ext]
template_options = Massimo.config.options_for(ext[1..-1])
template = template_type.new(source_path.to_s, @line, template_options) { output }
template.render(template_scope, tem... | ruby | def render
extensions.reverse.inject(content) do |output, ext|
if template_type = Tilt[ext]
template_options = Massimo.config.options_for(ext[1..-1])
template = template_type.new(source_path.to_s, @line, template_options) { output }
template.render(template_scope, tem... | [
"def",
"render",
"extensions",
".",
"reverse",
".",
"inject",
"(",
"content",
")",
"do",
"|",
"output",
",",
"ext",
"|",
"if",
"template_type",
"=",
"Tilt",
"[",
"ext",
"]",
"template_options",
"=",
"Massimo",
".",
"config",
".",
"options_for",
"(",
"ext... | Runs the content through any necessary filters, templates, etc. | [
"Runs",
"the",
"content",
"through",
"any",
"necessary",
"filters",
"templates",
"etc",
"."
] | c450edc531ad358f011da0a47e5d0bc9a038d911 | https://github.com/petebrowne/massimo/blob/c450edc531ad358f011da0a47e5d0bc9a038d911/lib/massimo/resource.rb#L94-L104 |
4,962 | petebrowne/massimo | lib/massimo/resource.rb | Massimo.Resource.process | def process
FileUtils.mkdir_p(output_path.dirname)
output_path.open('w') do |f|
f.write render
end
end | ruby | def process
FileUtils.mkdir_p(output_path.dirname)
output_path.open('w') do |f|
f.write render
end
end | [
"def",
"process",
"FileUtils",
".",
"mkdir_p",
"(",
"output_path",
".",
"dirname",
")",
"output_path",
".",
"open",
"(",
"'w'",
")",
"do",
"|",
"f",
"|",
"f",
".",
"write",
"render",
"end",
"end"
] | Writes the rendered content to the output file. | [
"Writes",
"the",
"rendered",
"content",
"to",
"the",
"output",
"file",
"."
] | c450edc531ad358f011da0a47e5d0bc9a038d911 | https://github.com/petebrowne/massimo/blob/c450edc531ad358f011da0a47e5d0bc9a038d911/lib/massimo/resource.rb#L107-L112 |
4,963 | galetahub/web_video | lib/web_video/transcoder.rb | WebVideo.Transcoder.convert | def convert(destination, options = {}, &block)
options.symbolize_keys!
process(destination, @source.convert_command, options, &block)
end | ruby | def convert(destination, options = {}, &block)
options.symbolize_keys!
process(destination, @source.convert_command, options, &block)
end | [
"def",
"convert",
"(",
"destination",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"options",
".",
"symbolize_keys!",
"process",
"(",
"destination",
",",
"@source",
".",
"convert_command",
",",
"options",
",",
"block",
")",
"end"
] | Generate new video file
transcoder = WebVideo::Transcoder.new("demo.avi")
begin
transcoder.convert("demo.flv", :resolution => "480x360") do |command|
command << "-ar 22050"
command << "-ab 128k"
command << "-acodec libmp3lame"
command << "-vcodec flv"
command << "-r 25"
command << "... | [
"Generate",
"new",
"video",
"file"
] | a73c10501871ba136302cecad411b1c8f8dbaaf8 | https://github.com/galetahub/web_video/blob/a73c10501871ba136302cecad411b1c8f8dbaaf8/lib/web_video/transcoder.rb#L81-L85 |
4,964 | expectedbehavior/cheddargetter_client_ruby | lib/cheddar_getter/response.rb | CheddarGetter.Response.customer_outstanding_invoices | def customer_outstanding_invoices(code = nil)
now = Time.now
customer_invoices(code).reject do |i|
i[:paidTransactionId] || i[:billingDatetime] > now
end
end | ruby | def customer_outstanding_invoices(code = nil)
now = Time.now
customer_invoices(code).reject do |i|
i[:paidTransactionId] || i[:billingDatetime] > now
end
end | [
"def",
"customer_outstanding_invoices",
"(",
"code",
"=",
"nil",
")",
"now",
"=",
"Time",
".",
"now",
"customer_invoices",
"(",
"code",
")",
".",
"reject",
"do",
"|",
"i",
"|",
"i",
"[",
":paidTransactionId",
"]",
"||",
"i",
"[",
":billingDatetime",
"]",
... | Returns an array of any currently outstanding invoices for the given customer.
code must be provided if this response contains more than one customer. | [
"Returns",
"an",
"array",
"of",
"any",
"currently",
"outstanding",
"invoices",
"for",
"the",
"given",
"customer",
"."
] | f3942d362f031e0c667892099c272737c152cbdf | https://github.com/expectedbehavior/cheddargetter_client_ruby/blob/f3942d362f031e0c667892099c272737c152cbdf/lib/cheddar_getter/response.rb#L180-L185 |
4,965 | expectedbehavior/cheddargetter_client_ruby | lib/cheddar_getter/response.rb | CheddarGetter.Response.customer_item | def customer_item(item_code = nil, code = nil)
sub_item = retrieve_item(customer_subscription(code), :items, item_code)
plan_item = retrieve_item(customer_plan(code), :items, item_code)
return nil unless sub_item && plan_item
item = plan_item.dup
item[:quantity] = sub_item[:quanti... | ruby | def customer_item(item_code = nil, code = nil)
sub_item = retrieve_item(customer_subscription(code), :items, item_code)
plan_item = retrieve_item(customer_plan(code), :items, item_code)
return nil unless sub_item && plan_item
item = plan_item.dup
item[:quantity] = sub_item[:quanti... | [
"def",
"customer_item",
"(",
"item_code",
"=",
"nil",
",",
"code",
"=",
"nil",
")",
"sub_item",
"=",
"retrieve_item",
"(",
"customer_subscription",
"(",
"code",
")",
",",
":items",
",",
"item_code",
")",
"plan_item",
"=",
"retrieve_item",
"(",
"customer_plan",... | Info about the given item for the given customer.
Merges the plan item info with the subscription item info.
item_code must be provided if the customer is on a plan with more than one item.
code must be provided if this response contains more than one customer. | [
"Info",
"about",
"the",
"given",
"item",
"for",
"the",
"given",
"customer",
".",
"Merges",
"the",
"plan",
"item",
"info",
"with",
"the",
"subscription",
"item",
"info",
"."
] | f3942d362f031e0c667892099c272737c152cbdf | https://github.com/expectedbehavior/cheddargetter_client_ruby/blob/f3942d362f031e0c667892099c272737c152cbdf/lib/cheddar_getter/response.rb#L193-L200 |
4,966 | expectedbehavior/cheddargetter_client_ruby | lib/cheddar_getter/response.rb | CheddarGetter.Response.customer_item_quantity_remaining | def customer_item_quantity_remaining(item_code = nil, code = nil)
item = customer_item(item_code, code)
item ? item[:quantityIncluded] - item[:quantity] : 0
end | ruby | def customer_item_quantity_remaining(item_code = nil, code = nil)
item = customer_item(item_code, code)
item ? item[:quantityIncluded] - item[:quantity] : 0
end | [
"def",
"customer_item_quantity_remaining",
"(",
"item_code",
"=",
"nil",
",",
"code",
"=",
"nil",
")",
"item",
"=",
"customer_item",
"(",
"item_code",
",",
"code",
")",
"item",
"?",
"item",
"[",
":quantityIncluded",
"]",
"-",
"item",
"[",
":quantity",
"]",
... | The amount remaining for a given item for a given customer.
item_code must be provided if the customer is on a plan with more than one item.
code must be provided if this response contains more than one customer. | [
"The",
"amount",
"remaining",
"for",
"a",
"given",
"item",
"for",
"a",
"given",
"customer",
"."
] | f3942d362f031e0c667892099c272737c152cbdf | https://github.com/expectedbehavior/cheddargetter_client_ruby/blob/f3942d362f031e0c667892099c272737c152cbdf/lib/cheddar_getter/response.rb#L207-L210 |
4,967 | expectedbehavior/cheddargetter_client_ruby | lib/cheddar_getter/response.rb | CheddarGetter.Response.customer_item_quantity_overage | def customer_item_quantity_overage(item_code = nil, code = nil)
over = -customer_item_quantity_remaining(item_code, code)
over = 0 if over <= 0
over
end | ruby | def customer_item_quantity_overage(item_code = nil, code = nil)
over = -customer_item_quantity_remaining(item_code, code)
over = 0 if over <= 0
over
end | [
"def",
"customer_item_quantity_overage",
"(",
"item_code",
"=",
"nil",
",",
"code",
"=",
"nil",
")",
"over",
"=",
"-",
"customer_item_quantity_remaining",
"(",
"item_code",
",",
"code",
")",
"over",
"=",
"0",
"if",
"over",
"<=",
"0",
"over",
"end"
] | The overage amount for the given item for the given customer. 0 if they are still under their limit.
item_code must be provided if the customer is on a plan with more than one item.
code must be provided if this response contains more than one customer. | [
"The",
"overage",
"amount",
"for",
"the",
"given",
"item",
"for",
"the",
"given",
"customer",
".",
"0",
"if",
"they",
"are",
"still",
"under",
"their",
"limit",
"."
] | f3942d362f031e0c667892099c272737c152cbdf | https://github.com/expectedbehavior/cheddargetter_client_ruby/blob/f3942d362f031e0c667892099c272737c152cbdf/lib/cheddar_getter/response.rb#L217-L221 |
4,968 | expectedbehavior/cheddargetter_client_ruby | lib/cheddar_getter/response.rb | CheddarGetter.Response.customer_item_quantity_overage_cost | def customer_item_quantity_overage_cost(item_code = nil, code = nil)
item = customer_item(item_code, code)
return 0 unless item
overage = customer_item_quantity_overage(item_code, code)
item[:overageAmount] * overage
end | ruby | def customer_item_quantity_overage_cost(item_code = nil, code = nil)
item = customer_item(item_code, code)
return 0 unless item
overage = customer_item_quantity_overage(item_code, code)
item[:overageAmount] * overage
end | [
"def",
"customer_item_quantity_overage_cost",
"(",
"item_code",
"=",
"nil",
",",
"code",
"=",
"nil",
")",
"item",
"=",
"customer_item",
"(",
"item_code",
",",
"code",
")",
"return",
"0",
"unless",
"item",
"overage",
"=",
"customer_item_quantity_overage",
"(",
"i... | The current overage cost for the given item for the given customer.
item_code must be provided if the customer is on a plan with more than one item.
code must be provided if this response contains more than one customer. | [
"The",
"current",
"overage",
"cost",
"for",
"the",
"given",
"item",
"for",
"the",
"given",
"customer",
"."
] | f3942d362f031e0c667892099c272737c152cbdf | https://github.com/expectedbehavior/cheddargetter_client_ruby/blob/f3942d362f031e0c667892099c272737c152cbdf/lib/cheddar_getter/response.rb#L228-L233 |
4,969 | expectedbehavior/cheddargetter_client_ruby | lib/cheddar_getter/response.rb | CheddarGetter.Response.customer_active? | def customer_active?(code = nil)
subscription = customer_subscription(code)
if subscription[:canceledDatetime] && subscription[:canceledDatetime] <= Time.now
false
else
true
end
end | ruby | def customer_active?(code = nil)
subscription = customer_subscription(code)
if subscription[:canceledDatetime] && subscription[:canceledDatetime] <= Time.now
false
else
true
end
end | [
"def",
"customer_active?",
"(",
"code",
"=",
"nil",
")",
"subscription",
"=",
"customer_subscription",
"(",
"code",
")",
"if",
"subscription",
"[",
":canceledDatetime",
"]",
"&&",
"subscription",
"[",
":canceledDatetime",
"]",
"<=",
"Time",
".",
"now",
"false",
... | Get an array representation of a single customer's current subscription
@throws CheddarGetter_Response_Exception if the response type is incompatible or if a $code
is not provided and the response contains more than one customer
@return array | [
"Get",
"an",
"array",
"representation",
"of",
"a",
"single",
"customer",
"s",
"current",
"subscription"
] | f3942d362f031e0c667892099c272737c152cbdf | https://github.com/expectedbehavior/cheddargetter_client_ruby/blob/f3942d362f031e0c667892099c272737c152cbdf/lib/cheddar_getter/response.rb#L247-L254 |
4,970 | expectedbehavior/cheddargetter_client_ruby | lib/cheddar_getter/response.rb | CheddarGetter.Response.customer_waiting_for_paypal? | def customer_waiting_for_paypal?(code = nil)
subscription = customer_subscription(code)
if subscription[:canceledDatetime] && subscription[:canceledDatetime] <= Time.now && subscription[:cancelType] == 'paypal-wait'
true
else
false
end
end | ruby | def customer_waiting_for_paypal?(code = nil)
subscription = customer_subscription(code)
if subscription[:canceledDatetime] && subscription[:canceledDatetime] <= Time.now && subscription[:cancelType] == 'paypal-wait'
true
else
false
end
end | [
"def",
"customer_waiting_for_paypal?",
"(",
"code",
"=",
"nil",
")",
"subscription",
"=",
"customer_subscription",
"(",
"code",
")",
"if",
"subscription",
"[",
":canceledDatetime",
"]",
"&&",
"subscription",
"[",
":canceledDatetime",
"]",
"<=",
"Time",
".",
"now",... | Is this customer's account pending paypal preapproval confirmation? | [
"Is",
"this",
"customer",
"s",
"account",
"pending",
"paypal",
"preapproval",
"confirmation?"
] | f3942d362f031e0c667892099c272737c152cbdf | https://github.com/expectedbehavior/cheddargetter_client_ruby/blob/f3942d362f031e0c667892099c272737c152cbdf/lib/cheddar_getter/response.rb#L257-L264 |
4,971 | kul1/jinda | lib/jinda/gemhelpers.rb | Jinda.GemHelpers.process_controllers | def process_controllers
process_services
modules= Jinda::Module.all
modules.each do |m|
next if controller_exists?(m.code)
puts " Rails generate controller #{m.code}"
end
end | ruby | def process_controllers
process_services
modules= Jinda::Module.all
modules.each do |m|
next if controller_exists?(m.code)
puts " Rails generate controller #{m.code}"
end
end | [
"def",
"process_controllers",
"process_services",
"modules",
"=",
"Jinda",
"::",
"Module",
".",
"all",
"modules",
".",
"each",
"do",
"|",
"m",
"|",
"next",
"if",
"controller_exists?",
"(",
"m",
".",
"code",
")",
"puts",
"\" Rails generate controller #{m.code}\"... | Mock generate controller for test
Otherwise test will call rails g controller | [
"Mock",
"generate",
"controller",
"for",
"test",
"Otherwise",
"test",
"will",
"call",
"rails",
"g",
"controller"
] | 97cbf13fa5f9c8b6afdc50c61fc76a4d21f1d7f6 | https://github.com/kul1/jinda/blob/97cbf13fa5f9c8b6afdc50c61fc76a4d21f1d7f6/lib/jinda/gemhelpers.rb#L19-L26 |
4,972 | fuminori-ido/edgarj | app/controllers/edgarj/rescue_mixin.rb | Edgarj.RescueMixin.edgarj_rescue_sub | def edgarj_rescue_sub(ex, message)
logger.info(
"#{ex.class} #{ex.message} bactrace:\n " +
ex.backtrace.join("\n "))
respond_to do |format|
format.html {
flash[:error] = message
redirect_to top_path
}
format.js {
flash.now[:error... | ruby | def edgarj_rescue_sub(ex, message)
logger.info(
"#{ex.class} #{ex.message} bactrace:\n " +
ex.backtrace.join("\n "))
respond_to do |format|
format.html {
flash[:error] = message
redirect_to top_path
}
format.js {
flash.now[:error... | [
"def",
"edgarj_rescue_sub",
"(",
"ex",
",",
"message",
")",
"logger",
".",
"info",
"(",
"\"#{ex.class} #{ex.message} bactrace:\\n \"",
"+",
"ex",
".",
"backtrace",
".",
"join",
"(",
"\"\\n \"",
")",
")",
"respond_to",
"do",
"|",
"format",
"|",
"format",
".",... | rescue callback sub method to show message by flush on normal http request
or by popup-dialog on Ajax request. | [
"rescue",
"callback",
"sub",
"method",
"to",
"show",
"message",
"by",
"flush",
"on",
"normal",
"http",
"request",
"or",
"by",
"popup",
"-",
"dialog",
"on",
"Ajax",
"request",
"."
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/controllers/edgarj/rescue_mixin.rb#L10-L25 |
4,973 | mamantoha/freshdesk_api_client_rb | lib/freshdesk_api/actions.rb | FreshdeskAPI.Read.find! | def find!(client, options = {})
@client = client # so we can use client.logger in rescue
raise ArgumentError, 'No :id given' unless options[:id]
path = api_url(options) + "/#{options[:id]}"
response = client.make_request!(path, :get)
new(@client).tap do |resource|
resource.attri... | ruby | def find!(client, options = {})
@client = client # so we can use client.logger in rescue
raise ArgumentError, 'No :id given' unless options[:id]
path = api_url(options) + "/#{options[:id]}"
response = client.make_request!(path, :get)
new(@client).tap do |resource|
resource.attri... | [
"def",
"find!",
"(",
"client",
",",
"options",
"=",
"{",
"}",
")",
"@client",
"=",
"client",
"# so we can use client.logger in rescue",
"raise",
"ArgumentError",
",",
"'No :id given'",
"unless",
"options",
"[",
":id",
"]",
"path",
"=",
"api_url",
"(",
"options",... | Finds a resource by an id and any options passed in
@param [Client] client The {Client} object to be used
@param [Hash] option Any additional GET parameters to be added | [
"Finds",
"a",
"resource",
"by",
"an",
"id",
"and",
"any",
"options",
"passed",
"in"
] | 74367fe0dd31bd269197b3f419412ef600031e62 | https://github.com/mamantoha/freshdesk_api_client_rb/blob/74367fe0dd31bd269197b3f419412ef600031e62/lib/freshdesk_api/actions.rb#L20-L32 |
4,974 | mamantoha/freshdesk_api_client_rb | lib/freshdesk_api/actions.rb | FreshdeskAPI.Read.find | def find(client, options = {}, &block)
find!(client, options, &block)
rescue FreshdeskAPI::Error::ClientError
nil
end | ruby | def find(client, options = {}, &block)
find!(client, options, &block)
rescue FreshdeskAPI::Error::ClientError
nil
end | [
"def",
"find",
"(",
"client",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"find!",
"(",
"client",
",",
"options",
",",
"block",
")",
"rescue",
"FreshdeskAPI",
"::",
"Error",
"::",
"ClientError",
"nil",
"end"
] | Finds, returning nil if it fails | [
"Finds",
"returning",
"nil",
"if",
"it",
"fails"
] | 74367fe0dd31bd269197b3f419412ef600031e62 | https://github.com/mamantoha/freshdesk_api_client_rb/blob/74367fe0dd31bd269197b3f419412ef600031e62/lib/freshdesk_api/actions.rb#L35-L39 |
4,975 | code-and-effect/effective_obfuscation | app/models/concerns/acts_as_obfuscated.rb | ActsAsObfuscated.ClassMethods.deobfuscate | def deobfuscate(original, rescue_with_original_id = true)
if original.kind_of?(Array)
return original.map { |value| deobfuscate(value, true) } # Always rescue with original ID
elsif !(original.kind_of?(Integer) || original.kind_of?(String))
return original
end
# Remove any non-d... | ruby | def deobfuscate(original, rescue_with_original_id = true)
if original.kind_of?(Array)
return original.map { |value| deobfuscate(value, true) } # Always rescue with original ID
elsif !(original.kind_of?(Integer) || original.kind_of?(String))
return original
end
# Remove any non-d... | [
"def",
"deobfuscate",
"(",
"original",
",",
"rescue_with_original_id",
"=",
"true",
")",
"if",
"original",
".",
"kind_of?",
"(",
"Array",
")",
"return",
"original",
".",
"map",
"{",
"|",
"value",
"|",
"deobfuscate",
"(",
"value",
",",
"true",
")",
"}",
"... | If rescue_with_original_id is set to true the original ID will be returned when its Obfuscated Id is not found
We use this as the default behaviour on everything except Class.find() | [
"If",
"rescue_with_original_id",
"is",
"set",
"to",
"true",
"the",
"original",
"ID",
"will",
"be",
"returned",
"when",
"its",
"Obfuscated",
"Id",
"is",
"not",
"found"
] | c6e5ec480401448f31c9fb71b496c85c4a7b4685 | https://github.com/code-and-effect/effective_obfuscation/blob/c6e5ec480401448f31c9fb71b496c85c4a7b4685/app/models/concerns/acts_as_obfuscated.rb#L75-L93 |
4,976 | lvxn0va/catarse_stripe | app/controllers/catarse_stripe/payment/stripe_controller.rb | CatarseStripe::Payment.StripeController.callback | def callback
@stripe_user = current_user
code = params[:code]
@response = @client.auth_code.get_token(code, {
:headers => {'Authorization' => "Bearer(::Configuration['stripe_secret_key'])"} #Platform Secret Key
})
#Save PROJECT owner's new keys
@stripe_user.stripe_acces... | ruby | def callback
@stripe_user = current_user
code = params[:code]
@response = @client.auth_code.get_token(code, {
:headers => {'Authorization' => "Bearer(::Configuration['stripe_secret_key'])"} #Platform Secret Key
})
#Save PROJECT owner's new keys
@stripe_user.stripe_acces... | [
"def",
"callback",
"@stripe_user",
"=",
"current_user",
"code",
"=",
"params",
"[",
":code",
"]",
"@response",
"=",
"@client",
".",
"auth_code",
".",
"get_token",
"(",
"code",
",",
"{",
":headers",
"=>",
"{",
"'Authorization'",
"=>",
"\"Bearer(::Configuration['s... | Brings back the authcode from Stripe and makes another call to Stripe to convert to a authtoken | [
"Brings",
"back",
"the",
"authcode",
"from",
"Stripe",
"and",
"makes",
"another",
"call",
"to",
"Stripe",
"to",
"convert",
"to",
"a",
"authtoken"
] | 66b7b0b3e785d3b1c6fa4c0305d78cf99d10a412 | https://github.com/lvxn0va/catarse_stripe/blob/66b7b0b3e785d3b1c6fa4c0305d78cf99d10a412/app/controllers/catarse_stripe/payment/stripe_controller.rb#L31-L52 |
4,977 | datamapper/dm-adjust | lib/dm-adjust/collection.rb | DataMapper.Collection.adjust! | def adjust!(attributes = {}, reload = false)
return true if attributes.empty?
reload_conditions = if reload
model_key = model.key(repository.name)
Query.target_conditions(self, model_key, model_key)
end
adjust_attributes = adjust_attributes(attributes)
repository.adjust(a... | ruby | def adjust!(attributes = {}, reload = false)
return true if attributes.empty?
reload_conditions = if reload
model_key = model.key(repository.name)
Query.target_conditions(self, model_key, model_key)
end
adjust_attributes = adjust_attributes(attributes)
repository.adjust(a... | [
"def",
"adjust!",
"(",
"attributes",
"=",
"{",
"}",
",",
"reload",
"=",
"false",
")",
"return",
"true",
"if",
"attributes",
".",
"empty?",
"reload_conditions",
"=",
"if",
"reload",
"model_key",
"=",
"model",
".",
"key",
"(",
"repository",
".",
"name",
")... | increment or decrement attributes on a collection
@example [Usage]
* People.all.adjust(:salary => +1000)
* Children.all(:age.gte => 18).adjust(:allowance => -100)
@param attributes <Hash> A hash of attributes to adjust, and their adjustment
@param reload <FalseClass,TrueClass> If true, affected objects will ... | [
"increment",
"or",
"decrement",
"attributes",
"on",
"a",
"collection"
] | 17d342755ba937a394af3a1a40fd13a253bc3c9c | https://github.com/datamapper/dm-adjust/blob/17d342755ba937a394af3a1a40fd13a253bc3c9c/lib/dm-adjust/collection.rb#L19-L37 |
4,978 | Kuniri/kuniri | lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb | Languages.FunctionAbstract.add_parameters | def add_parameters(pValue)
unless ((pValue.respond_to?(:has_key?) && pValue.length == 1) ||
pValue.respond_to?(:to_str))
return nil
end
@parameters.push(pValue)
end | ruby | def add_parameters(pValue)
unless ((pValue.respond_to?(:has_key?) && pValue.length == 1) ||
pValue.respond_to?(:to_str))
return nil
end
@parameters.push(pValue)
end | [
"def",
"add_parameters",
"(",
"pValue",
")",
"unless",
"(",
"(",
"pValue",
".",
"respond_to?",
"(",
":has_key?",
")",
"&&",
"pValue",
".",
"length",
"==",
"1",
")",
"||",
"pValue",
".",
"respond_to?",
"(",
":to_str",
")",
")",
"return",
"nil",
"end",
"... | Add parameters inside function.
@param pValue Add a parameter inside function.
@return if pValue is not String or Hash with more than one element.
return nil. | [
"Add",
"parameters",
"inside",
"function",
"."
] | 8b840ab307dc6bec48edd272c732b28c98f93f45 | https://github.com/Kuniri/kuniri/blob/8b840ab307dc6bec48edd272c732b28c98f93f45/lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb#L42-L48 |
4,979 | Kuniri/kuniri | lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb | Languages.FunctionAbstract.add_conditional | def add_conditional(pConditional, pBehaviour = Languages::KEEP_LEVEL)
return nil unless (pConditional.instance_of?Languages::ConditionalData)
add_with_manager(pConditional, 'conditional', pBehaviour)
end | ruby | def add_conditional(pConditional, pBehaviour = Languages::KEEP_LEVEL)
return nil unless (pConditional.instance_of?Languages::ConditionalData)
add_with_manager(pConditional, 'conditional', pBehaviour)
end | [
"def",
"add_conditional",
"(",
"pConditional",
",",
"pBehaviour",
"=",
"Languages",
"::",
"KEEP_LEVEL",
")",
"return",
"nil",
"unless",
"(",
"pConditional",
".",
"instance_of?",
"Languages",
"::",
"ConditionalData",
")",
"add_with_manager",
"(",
"pConditional",
",",... | Add conditional element inside function.
@param pConditional An object of ConditionalData.
@return If pConditional is not an instance of ConditionalData,
return nil. | [
"Add",
"conditional",
"element",
"inside",
"function",
"."
] | 8b840ab307dc6bec48edd272c732b28c98f93f45 | https://github.com/Kuniri/kuniri/blob/8b840ab307dc6bec48edd272c732b28c98f93f45/lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb#L54-L57 |
4,980 | Kuniri/kuniri | lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb | Languages.FunctionAbstract.add_repetition | def add_repetition(pRepetition, pBehaviour = Languages::KEEP_LEVEL)
return nil unless (pRepetition.instance_of?Languages::RepetitionData)
add_with_manager(pRepetition, 'repetition', pBehaviour)
end | ruby | def add_repetition(pRepetition, pBehaviour = Languages::KEEP_LEVEL)
return nil unless (pRepetition.instance_of?Languages::RepetitionData)
add_with_manager(pRepetition, 'repetition', pBehaviour)
end | [
"def",
"add_repetition",
"(",
"pRepetition",
",",
"pBehaviour",
"=",
"Languages",
"::",
"KEEP_LEVEL",
")",
"return",
"nil",
"unless",
"(",
"pRepetition",
".",
"instance_of?",
"Languages",
"::",
"RepetitionData",
")",
"add_with_manager",
"(",
"pRepetition",
",",
"'... | Add repetition element inside function.
@param pRepetition An object of RepetitionData.
@return If pRepetition is not RepetitionData instance return nil. | [
"Add",
"repetition",
"element",
"inside",
"function",
"."
] | 8b840ab307dc6bec48edd272c732b28c98f93f45 | https://github.com/Kuniri/kuniri/blob/8b840ab307dc6bec48edd272c732b28c98f93f45/lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb#L62-L65 |
4,981 | Kuniri/kuniri | lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb | Languages.FunctionAbstract.add_block | def add_block(pBlock, pBehaviour = Languages::KEEP_LEVEL)
return nil unless (pBlock.instance_of?Languages::BlockData)
add_with_manager(pBlock, 'block', pBehaviour)
end | ruby | def add_block(pBlock, pBehaviour = Languages::KEEP_LEVEL)
return nil unless (pBlock.instance_of?Languages::BlockData)
add_with_manager(pBlock, 'block', pBehaviour)
end | [
"def",
"add_block",
"(",
"pBlock",
",",
"pBehaviour",
"=",
"Languages",
"::",
"KEEP_LEVEL",
")",
"return",
"nil",
"unless",
"(",
"pBlock",
".",
"instance_of?",
"Languages",
"::",
"BlockData",
")",
"add_with_manager",
"(",
"pBlock",
",",
"'block'",
",",
"pBehav... | Add block element inside function.
@param pBlock An object of BlockData.
@return If pBlock is not pBlockData instance return nil. | [
"Add",
"block",
"element",
"inside",
"function",
"."
] | 8b840ab307dc6bec48edd272c732b28c98f93f45 | https://github.com/Kuniri/kuniri/blob/8b840ab307dc6bec48edd272c732b28c98f93f45/lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb#L70-L73 |
4,982 | Kuniri/kuniri | lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb | Languages.FunctionAbstract.<< | def <<(fromTo)
return nil unless fromTo.is_a?(Languages::FunctionAbstract)
@name = fromTo.name
@parameters = fromTo.parameters
@managerCondLoopAndBlock = fromTo.managerCondLoopAndBlock
@visibility = fromTo.visibility
@comments = fromTo.comments
@type = @type
end | ruby | def <<(fromTo)
return nil unless fromTo.is_a?(Languages::FunctionAbstract)
@name = fromTo.name
@parameters = fromTo.parameters
@managerCondLoopAndBlock = fromTo.managerCondLoopAndBlock
@visibility = fromTo.visibility
@comments = fromTo.comments
@type = @type
end | [
"def",
"<<",
"(",
"fromTo",
")",
"return",
"nil",
"unless",
"fromTo",
".",
"is_a?",
"(",
"Languages",
"::",
"FunctionAbstract",
")",
"@name",
"=",
"fromTo",
".",
"name",
"@parameters",
"=",
"fromTo",
".",
"parameters",
"@managerCondLoopAndBlock",
"=",
"fromTo"... | Copy elements from an object of FunctionAbstract to specific element
@param fromTo Reference from FunctionAbstract | [
"Copy",
"elements",
"from",
"an",
"object",
"of",
"FunctionAbstract",
"to",
"specific",
"element"
] | 8b840ab307dc6bec48edd272c732b28c98f93f45 | https://github.com/Kuniri/kuniri/blob/8b840ab307dc6bec48edd272c732b28c98f93f45/lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb#L77-L85 |
4,983 | Kuniri/kuniri | lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb | Languages.FunctionAbstract.add_with_manager | def add_with_manager(pElementToAdd, pMetaData, pBehaviour)
case pBehaviour
when Languages::KEEP_LEVEL
@managerCondLoopAndBlock.send("add_#{pMetaData}", pElementToAdd)
when Languages::UP_LEVEL
@managerCondLoopAndBlock.decrease_deep_level
@managerCondLoopAndBlock.send("add_#{pMet... | ruby | def add_with_manager(pElementToAdd, pMetaData, pBehaviour)
case pBehaviour
when Languages::KEEP_LEVEL
@managerCondLoopAndBlock.send("add_#{pMetaData}", pElementToAdd)
when Languages::UP_LEVEL
@managerCondLoopAndBlock.decrease_deep_level
@managerCondLoopAndBlock.send("add_#{pMet... | [
"def",
"add_with_manager",
"(",
"pElementToAdd",
",",
"pMetaData",
",",
"pBehaviour",
")",
"case",
"pBehaviour",
"when",
"Languages",
"::",
"KEEP_LEVEL",
"@managerCondLoopAndBlock",
".",
"send",
"(",
"\"add_#{pMetaData}\"",
",",
"pElementToAdd",
")",
"when",
"Language... | Add to a manager conditional or repetition.
@param pElementToAdd Element wish we want to add.
@param pMetaData String with name for of element we want to add.
@param pBehaviour Flag with behaviour. | [
"Add",
"to",
"a",
"manager",
"conditional",
"or",
"repetition",
"."
] | 8b840ab307dc6bec48edd272c732b28c98f93f45 | https://github.com/Kuniri/kuniri/blob/8b840ab307dc6bec48edd272c732b28c98f93f45/lib/kuniri/language/container_data/structured_and_oo/function_abstract.rb#L93-L104 |
4,984 | news-scraper/news_scraper | lib/news_scraper/extractors_helpers.rb | NewsScraper.ExtractorsHelpers.http_request | def http_request(url)
url = URIParser.new(url).with_scheme
CLI.put_header(url)
CLI.log "Beginning HTTP request for #{url}"
response = HTTParty.get(url, headers: { "User-Agent" => "news-scraper-#{NewsScraper::VERSION}" })
raise ResponseError.new(
error_code: response.code,
... | ruby | def http_request(url)
url = URIParser.new(url).with_scheme
CLI.put_header(url)
CLI.log "Beginning HTTP request for #{url}"
response = HTTParty.get(url, headers: { "User-Agent" => "news-scraper-#{NewsScraper::VERSION}" })
raise ResponseError.new(
error_code: response.code,
... | [
"def",
"http_request",
"(",
"url",
")",
"url",
"=",
"URIParser",
".",
"new",
"(",
"url",
")",
".",
"with_scheme",
"CLI",
".",
"put_header",
"(",
"url",
")",
"CLI",
".",
"log",
"\"Beginning HTTP request for #{url}\"",
"response",
"=",
"HTTParty",
".",
"get",
... | Perform an HTTP request with a standardized response
*Params*
- <code>url</code>: the url on which to perform a get request | [
"Perform",
"an",
"HTTP",
"request",
"with",
"a",
"standardized",
"response"
] | 3ee2ea9590d081ffb8e98120b2e1344dec88a15e | https://github.com/news-scraper/news_scraper/blob/3ee2ea9590d081ffb8e98120b2e1344dec88a15e/lib/news_scraper/extractors_helpers.rb#L8-L29 |
4,985 | PerfectMemory/translator-text | lib/translator_text/client.rb | TranslatorText.Client.detect | def detect(sentences)
results = post(
'/detect',
body: build_sentences(sentences).to_json
)
results.map { |r| Types::DetectionResult.new(r) }
end | ruby | def detect(sentences)
results = post(
'/detect',
body: build_sentences(sentences).to_json
)
results.map { |r| Types::DetectionResult.new(r) }
end | [
"def",
"detect",
"(",
"sentences",
")",
"results",
"=",
"post",
"(",
"'/detect'",
",",
"body",
":",
"build_sentences",
"(",
"sentences",
")",
".",
"to_json",
")",
"results",
".",
"map",
"{",
"|",
"r",
"|",
"Types",
"::",
"DetectionResult",
".",
"new",
... | Identifies the language of a piece of text.
The following limitations apply:
* The array _sentences_ can have at most 100 elements.
* The text value of an array element cannot exceed 10,000 characters including spaces.
* The entire text included in the request cannot exceed 50,000 characters including spaces.
@se... | [
"Identifies",
"the",
"language",
"of",
"a",
"piece",
"of",
"text",
"."
] | 17518d3b0cbda23d2beef1d88c95ba38e21db33e | https://github.com/PerfectMemory/translator-text/blob/17518d3b0cbda23d2beef1d88c95ba38e21db33e/lib/translator_text/client.rb#L52-L59 |
4,986 | jm/literati | lib/literati.rb | Literati.MarkdownRenderer.determine_markdown_renderer | def determine_markdown_renderer
@markdown = if installed?('github/markdown')
GitHubWrapper.new(@content)
elsif installed?('redcarpet/compat')
Markdown.new(@content, :fenced_code, :safelink, :autolink)
elsif installed?('redcarpet')
RedcarpetCompat.new(@content)
elsif insta... | ruby | def determine_markdown_renderer
@markdown = if installed?('github/markdown')
GitHubWrapper.new(@content)
elsif installed?('redcarpet/compat')
Markdown.new(@content, :fenced_code, :safelink, :autolink)
elsif installed?('redcarpet')
RedcarpetCompat.new(@content)
elsif insta... | [
"def",
"determine_markdown_renderer",
"@markdown",
"=",
"if",
"installed?",
"(",
"'github/markdown'",
")",
"GitHubWrapper",
".",
"new",
"(",
"@content",
")",
"elsif",
"installed?",
"(",
"'redcarpet/compat'",
")",
"Markdown",
".",
"new",
"(",
"@content",
",",
":fen... | Create a new compatibility instance.
content - The Markdown content to render. | [
"Create",
"a",
"new",
"compatibility",
"instance",
"."
] | ee2c949ccd015cbc037921213516bae96832716a | https://github.com/jm/literati/blob/ee2c949ccd015cbc037921213516bae96832716a/lib/literati.rb#L32-L48 |
4,987 | jm/literati | lib/literati.rb | Literati.Renderer.to_markdown | def to_markdown
lines = @bare_content.split("\n")
markdown = ""
# Using `while` here so we can alter the collection at will
while current_line = lines.shift
# If we got us some of them bird tracks...
if current_line =~ BIRD_TRACKS_REGEX
# Remove the bird tracks from th... | ruby | def to_markdown
lines = @bare_content.split("\n")
markdown = ""
# Using `while` here so we can alter the collection at will
while current_line = lines.shift
# If we got us some of them bird tracks...
if current_line =~ BIRD_TRACKS_REGEX
# Remove the bird tracks from th... | [
"def",
"to_markdown",
"lines",
"=",
"@bare_content",
".",
"split",
"(",
"\"\\n\"",
")",
"markdown",
"=",
"\"\"",
"# Using `while` here so we can alter the collection at will",
"while",
"current_line",
"=",
"lines",
".",
"shift",
"# If we got us some of them bird tracks...",
... | Initialize a new literate Haskell renderer.
content - The literate Haskell code string
markdowner - The class we'll use to render the HTML (defaults
to our RedCarpet wrapper).
Render the given literate Haskell to a Markdown string.
Returns a Markdown string we can render to HTML. | [
"Initialize",
"a",
"new",
"literate",
"Haskell",
"renderer",
"."
] | ee2c949ccd015cbc037921213516bae96832716a | https://github.com/jm/literati/blob/ee2c949ccd015cbc037921213516bae96832716a/lib/literati.rb#L90-L112 |
4,988 | jm/literati | lib/literati.rb | Literati.Renderer.remove_bird_tracks | def remove_bird_tracks(line)
tracks = line.scan(BIRD_TRACKS_REGEX)[0]
(tracks.first == " ") ? tracks[1] : tracks.join
end | ruby | def remove_bird_tracks(line)
tracks = line.scan(BIRD_TRACKS_REGEX)[0]
(tracks.first == " ") ? tracks[1] : tracks.join
end | [
"def",
"remove_bird_tracks",
"(",
"line",
")",
"tracks",
"=",
"line",
".",
"scan",
"(",
"BIRD_TRACKS_REGEX",
")",
"[",
"0",
"]",
"(",
"tracks",
".",
"first",
"==",
"\" \"",
")",
"?",
"tracks",
"[",
"1",
"]",
":",
"tracks",
".",
"join",
"end"
] | Remove Bird-style comment markers from a line of text.
comment = "> Haskell codes"
remove_bird_tracks(comment)
# => "Haskell codes"
Returns the given line of text sans bird tracks. | [
"Remove",
"Bird",
"-",
"style",
"comment",
"markers",
"from",
"a",
"line",
"of",
"text",
"."
] | ee2c949ccd015cbc037921213516bae96832716a | https://github.com/jm/literati/blob/ee2c949ccd015cbc037921213516bae96832716a/lib/literati.rb#L121-L124 |
4,989 | jm/literati | lib/literati.rb | Literati.Renderer.slurp_remaining_bird_tracks | def slurp_remaining_bird_tracks(lines)
tracked_lines = []
while lines.first =~ BIRD_TRACKS_REGEX
tracked_lines << remove_bird_tracks(lines.shift)
end
if tracked_lines.empty?
""
else
"\n" + tracked_lines.join("\n")
end
end | ruby | def slurp_remaining_bird_tracks(lines)
tracked_lines = []
while lines.first =~ BIRD_TRACKS_REGEX
tracked_lines << remove_bird_tracks(lines.shift)
end
if tracked_lines.empty?
""
else
"\n" + tracked_lines.join("\n")
end
end | [
"def",
"slurp_remaining_bird_tracks",
"(",
"lines",
")",
"tracked_lines",
"=",
"[",
"]",
"while",
"lines",
".",
"first",
"=~",
"BIRD_TRACKS_REGEX",
"tracked_lines",
"<<",
"remove_bird_tracks",
"(",
"lines",
".",
"shift",
")",
"end",
"if",
"tracked_lines",
".",
"... | Given an Array of lines, pulls from the front of the Array
until the next line doesn't match our bird tracks regex.
lines = ["> code", "> code", "", "not code"]
slurp_remaining_bird_tracks(lines)
# => "code\ncode"
Returns the lines mashed into a string separated by a newline. | [
"Given",
"an",
"Array",
"of",
"lines",
"pulls",
"from",
"the",
"front",
"of",
"the",
"Array",
"until",
"the",
"next",
"line",
"doesn",
"t",
"match",
"our",
"bird",
"tracks",
"regex",
"."
] | ee2c949ccd015cbc037921213516bae96832716a | https://github.com/jm/literati/blob/ee2c949ccd015cbc037921213516bae96832716a/lib/literati.rb#L134-L146 |
4,990 | flori/cpu | lib/cpu/usage_sampler.rb | CPU.UsageSampler.sample | def sample
total, @usages = nil, {}
timestamp = Time.now
File.foreach('/proc/stat') do |line|
case line
when /^cpu[^\d]/
next
when CPU
times = $~.captures
processor_id = times[0] = times[0].to_i
(1...times.size).each { |i| times[i] = time... | ruby | def sample
total, @usages = nil, {}
timestamp = Time.now
File.foreach('/proc/stat') do |line|
case line
when /^cpu[^\d]/
next
when CPU
times = $~.captures
processor_id = times[0] = times[0].to_i
(1...times.size).each { |i| times[i] = time... | [
"def",
"sample",
"total",
",",
"@usages",
"=",
"nil",
",",
"{",
"}",
"timestamp",
"=",
"Time",
".",
"now",
"File",
".",
"foreach",
"(",
"'/proc/stat'",
")",
"do",
"|",
"line",
"|",
"case",
"line",
"when",
"/",
"\\d",
"/",
"next",
"when",
"CPU",
"ti... | Take one sample of CPU usage data for every processor in this computer
and store them in the +usages+ attribute. | [
"Take",
"one",
"sample",
"of",
"CPU",
"usage",
"data",
"for",
"every",
"processor",
"in",
"this",
"computer",
"and",
"store",
"them",
"in",
"the",
"+",
"usages",
"+",
"attribute",
"."
] | b1e320c83a6653758b266b02141fc57e5379d1e6 | https://github.com/flori/cpu/blob/b1e320c83a6653758b266b02141fc57e5379d1e6/lib/cpu/usage_sampler.rb#L26-L47 |
4,991 | adamcooke/datey | lib/datey/formatter.rb | Datey.Formatter.include_year_in_dates? | def include_year_in_dates?
if @time.year != Date.today.year
# If the year was in the past, always include the year
return true
end
if @time.year == Date.today.year && @time.month < (Date.today.month - 4)
# If the year is this year, include if it happened more than 6 months
... | ruby | def include_year_in_dates?
if @time.year != Date.today.year
# If the year was in the past, always include the year
return true
end
if @time.year == Date.today.year && @time.month < (Date.today.month - 4)
# If the year is this year, include if it happened more than 6 months
... | [
"def",
"include_year_in_dates?",
"if",
"@time",
".",
"year",
"!=",
"Date",
".",
"today",
".",
"year",
"# If the year was in the past, always include the year",
"return",
"true",
"end",
"if",
"@time",
".",
"year",
"==",
"Date",
".",
"today",
".",
"year",
"&&",
"@... | Should years be included in dates? | [
"Should",
"years",
"be",
"included",
"in",
"dates?"
] | 6bf55aa533f7e17df66b8a188ed6d6e6d17cf06f | https://github.com/adamcooke/datey/blob/6bf55aa533f7e17df66b8a188ed6d6e6d17cf06f/lib/datey/formatter.rb#L103-L114 |
4,992 | payneteasy/ruby-library-payneteasy-api | lib/paynet_easy/paynet_easy_api/transport/gateway_client.rb | PaynetEasy::PaynetEasyApi::Transport.GatewayClient.parse_response | def parse_response(response)
unless response.body
raise ResponseError, 'PaynetEasy response is empty'
end
# Change hash format from {'key' => ['value']} to {'key' => 'value'} in map block
response_fields = Hash[CGI.parse(response.body).map {|key, value| [key, value.first]}]
Respo... | ruby | def parse_response(response)
unless response.body
raise ResponseError, 'PaynetEasy response is empty'
end
# Change hash format from {'key' => ['value']} to {'key' => 'value'} in map block
response_fields = Hash[CGI.parse(response.body).map {|key, value| [key, value.first]}]
Respo... | [
"def",
"parse_response",
"(",
"response",
")",
"unless",
"response",
".",
"body",
"raise",
"ResponseError",
",",
"'PaynetEasy response is empty'",
"end",
"# Change hash format from {'key' => ['value']} to {'key' => 'value'} in map block",
"response_fields",
"=",
"Hash",
"[",
"C... | Parse PaynetEasy response from string to Response object
@param response [HTTPResponse] PaynetEasy response as HTTPResponse
@return [Response] PaynetEasy response as Response | [
"Parse",
"PaynetEasy",
"response",
"from",
"string",
"to",
"Response",
"object"
] | 3200a447829b62e241fdc329f80fddb5f8d68cc0 | https://github.com/payneteasy/ruby-library-payneteasy-api/blob/3200a447829b62e241fdc329f80fddb5f8d68cc0/lib/paynet_easy/paynet_easy_api/transport/gateway_client.rb#L61-L70 |
4,993 | donaldpiret/github-pivotal-flow | lib/github_pivotal_flow/finish.rb | GithubPivotalFlow.Finish.run! | def run!
raise_error_if_development_or_master
story = @configuration.story
fail("Could not find story associated with branch") unless story
story.can_merge?
commit_message = options[:commit_message]
if story.release?
story.merge_release!(commit_message, @options)
else
... | ruby | def run!
raise_error_if_development_or_master
story = @configuration.story
fail("Could not find story associated with branch") unless story
story.can_merge?
commit_message = options[:commit_message]
if story.release?
story.merge_release!(commit_message, @options)
else
... | [
"def",
"run!",
"raise_error_if_development_or_master",
"story",
"=",
"@configuration",
".",
"story",
"fail",
"(",
"\"Could not find story associated with branch\"",
")",
"unless",
"story",
"story",
".",
"can_merge?",
"commit_message",
"=",
"options",
"[",
":commit_message",... | Finishes a Pivotal Tracker story | [
"Finishes",
"a",
"Pivotal",
"Tracker",
"story"
] | 676436950b691f57ad793a9023a4765ab9420dd0 | https://github.com/donaldpiret/github-pivotal-flow/blob/676436950b691f57ad793a9023a4765ab9420dd0/lib/github_pivotal_flow/finish.rb#L6-L18 |
4,994 | jage/elk | lib/elk/sms.rb | Elk.SMS.reload | def reload
response = @client.get("/SMS/#{self.message_id}")
self.set_parameters(Elk::Util.parse_json(response.body))
response.code == 200
end | ruby | def reload
response = @client.get("/SMS/#{self.message_id}")
self.set_parameters(Elk::Util.parse_json(response.body))
response.code == 200
end | [
"def",
"reload",
"response",
"=",
"@client",
".",
"get",
"(",
"\"/SMS/#{self.message_id}\"",
")",
"self",
".",
"set_parameters",
"(",
"Elk",
"::",
"Util",
".",
"parse_json",
"(",
"response",
".",
"body",
")",
")",
"response",
".",
"code",
"==",
"200",
"end... | Reloads a SMS from server | [
"Reloads",
"a",
"SMS",
"from",
"server"
] | 9e28155d1c270d7a21f5c009a4cdff9a0fff0808 | https://github.com/jage/elk/blob/9e28155d1c270d7a21f5c009a4cdff9a0fff0808/lib/elk/sms.rb#L26-L30 |
4,995 | cul/cul_omniauth | app/models/concerns/cul/omniauth/users.rb | Cul::Omniauth::Users.ClassMethods.find_for_provider | def find_for_provider(token, provider)
return nil unless token['uid']
props = {:uid => token['uid'].downcase, provider: provider.downcase}
user = where(props).first
# create new user if necessary
unless user
user = create!(whitelist(props))
# can we add groups or roles here... | ruby | def find_for_provider(token, provider)
return nil unless token['uid']
props = {:uid => token['uid'].downcase, provider: provider.downcase}
user = where(props).first
# create new user if necessary
unless user
user = create!(whitelist(props))
# can we add groups or roles here... | [
"def",
"find_for_provider",
"(",
"token",
",",
"provider",
")",
"return",
"nil",
"unless",
"token",
"[",
"'uid'",
"]",
"props",
"=",
"{",
":uid",
"=>",
"token",
"[",
"'uid'",
"]",
".",
"downcase",
",",
"provider",
":",
"provider",
".",
"downcase",
"}",
... | token is an omniauth hash | [
"token",
"is",
"an",
"omniauth",
"hash"
] | bf40dfe86e246dffbac70e0551b57f7638959a3b | https://github.com/cul/cul_omniauth/blob/bf40dfe86e246dffbac70e0551b57f7638959a3b/app/models/concerns/cul/omniauth/users.rb#L33-L43 |
4,996 | mooreryan/parse_fasta | lib/parse_fasta/record.rb | ParseFasta.Record.to_fastq | def to_fastq opts = {}
if fastq?
"@#{@header}\n#{@seq}\n+#{@desc}\n#{qual}"
else
qual = opts.fetch :qual, "I"
check_qual qual
desc = opts.fetch :desc, ""
qual_str = make_qual_str qual
"@#{@header}\n#{@seq}\n+#{desc}\n#{qual_str}"
end
end | ruby | def to_fastq opts = {}
if fastq?
"@#{@header}\n#{@seq}\n+#{@desc}\n#{qual}"
else
qual = opts.fetch :qual, "I"
check_qual qual
desc = opts.fetch :desc, ""
qual_str = make_qual_str qual
"@#{@header}\n#{@seq}\n+#{desc}\n#{qual_str}"
end
end | [
"def",
"to_fastq",
"opts",
"=",
"{",
"}",
"if",
"fastq?",
"\"@#{@header}\\n#{@seq}\\n+#{@desc}\\n#{qual}\"",
"else",
"qual",
"=",
"opts",
".",
"fetch",
":qual",
",",
"\"I\"",
"check_qual",
"qual",
"desc",
"=",
"opts",
".",
"fetch",
":desc",
",",
"\"\"",
"qual_... | Returns a fastA record ready to print.
If the record is fastA like, the desc and qual can be specified.
@return [String] a printable fastQ sequence record
@example When the record is fastA like, no args
rec = Record.new header: "Apple", seq: "ACTG"
rec.to_fastq #=> "@Apple\nACTG\n+\nIIII"
@example When th... | [
"Returns",
"a",
"fastA",
"record",
"ready",
"to",
"print",
"."
] | 016272371be668addb29d3c92ec6a5d2e07332ad | https://github.com/mooreryan/parse_fasta/blob/016272371be668addb29d3c92ec6a5d2e07332ad/lib/parse_fasta/record.rb#L137-L150 |
4,997 | MattRyder/tableau | lib/tableau/moduleparser.rb | Tableau.ModuleParser.module_info | def module_info
mod, types = parse, Set.new
mod.classes.each { |c| types.add?(c.type) }
return { name: mod.name, code: mod.module_id, types: types }
end | ruby | def module_info
mod, types = parse, Set.new
mod.classes.each { |c| types.add?(c.type) }
return { name: mod.name, code: mod.module_id, types: types }
end | [
"def",
"module_info",
"mod",
",",
"types",
"=",
"parse",
",",
"Set",
".",
"new",
"mod",
".",
"classes",
".",
"each",
"{",
"|",
"c",
"|",
"types",
".",
"add?",
"(",
"c",
".",
"type",
")",
"}",
"return",
"{",
"name",
":",
"mod",
".",
"name",
",",... | Create a new ModuleParser, with an optional module code | [
"Create",
"a",
"new",
"ModuleParser",
"with",
"an",
"optional",
"module",
"code"
] | a313fa88bf165ca66cb564c14abd3e526d6c1494 | https://github.com/MattRyder/tableau/blob/a313fa88bf165ca66cb564c14abd3e526d6c1494/lib/tableau/moduleparser.rb#L21-L26 |
4,998 | fuminori-ido/edgarj | app/controllers/edgarj/edgarj_controller.rb | Edgarj.EdgarjController.create | def create
upsert do
# NOTE: create!() is not used because assign to @record to draw form.
# Otherwise, @record would be in nil so failure at edgarj/_form rendering.
#
# NOTE2: valid? after create() calls validate_on_update. This is not
# an expected behavior. So, new, va... | ruby | def create
upsert do
# NOTE: create!() is not used because assign to @record to draw form.
# Otherwise, @record would be in nil so failure at edgarj/_form rendering.
#
# NOTE2: valid? after create() calls validate_on_update. This is not
# an expected behavior. So, new, va... | [
"def",
"create",
"upsert",
"do",
"# NOTE: create!() is not used because assign to @record to draw form.",
"# Otherwise, @record would be in nil so failure at edgarj/_form rendering.",
"#",
"# NOTE2: valid? after create() calls validate_on_update. This is not",
"# an expected behavior. So, new, val... | save new record
=== Permission
ModelPermission::CREATE on this controller is required. | [
"save",
"new",
"record"
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/controllers/edgarj/edgarj_controller.rb#L134-L151 |
4,999 | fuminori-ido/edgarj | app/controllers/edgarj/edgarj_controller.rb | Edgarj.EdgarjController.show | def show
@record = user_scoped.find(params[:id])
#add_topic_path
respond_to do |format|
format.html {
prepare_list
@search = page_info.record
render :action=>'index'
}
format.js
end
end | ruby | def show
@record = user_scoped.find(params[:id])
#add_topic_path
respond_to do |format|
format.html {
prepare_list
@search = page_info.record
render :action=>'index'
}
format.js
end
end | [
"def",
"show",
"@record",
"=",
"user_scoped",
".",
"find",
"(",
"params",
"[",
":id",
"]",
")",
"#add_topic_path",
"respond_to",
"do",
"|",
"format",
"|",
"format",
".",
"html",
"{",
"prepare_list",
"@search",
"=",
"page_info",
".",
"record",
"render",
":a... | Show detail of one record. Format of html & js should be supported.
=== Permission
ModelPermission::READ on this controller is required. | [
"Show",
"detail",
"of",
"one",
"record",
".",
"Format",
"of",
"html",
"&",
"js",
"should",
"be",
"supported",
"."
] | 1648ab180f1f4adaeea03d54b645f58f3702a2bf | https://github.com/fuminori-ido/edgarj/blob/1648ab180f1f4adaeea03d54b645f58f3702a2bf/app/controllers/edgarj/edgarj_controller.rb#L158-L169 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.