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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
AzureAD/azure-activedirectory-library-for-ruby | lib/adal/cache_driver.rb | ADAL.CacheDriver.resource_specific | def resource_specific(responses, resource)
logger.verbose("Looking through #{responses.size} matching cache " \
"entries for resource #{resource}.")
responses.select { |response| response.resource == resource }
.map(&:token_response).first
end | ruby | def resource_specific(responses, resource)
logger.verbose("Looking through #{responses.size} matching cache " \
"entries for resource #{resource}.")
responses.select { |response| response.resource == resource }
.map(&:token_response).first
end | [
"def",
"resource_specific",
"(",
"responses",
",",
"resource",
")",
"logger",
".",
"verbose",
"(",
"\"Looking through #{responses.size} matching cache \"",
"\"entries for resource #{resource}.\"",
")",
"responses",
".",
"select",
"{",
"|",
"response",
"|",
"response",
"."... | Searches a list of CachedTokenResponses for one that matches the resource.
@param Array[CachedTokenResponse]
@return SuccessResponse|nil | [
"Searches",
"a",
"list",
"of",
"CachedTokenResponses",
"for",
"one",
"that",
"matches",
"the",
"resource",
"."
] | 5d2f2530298a2545ca8caf688eabcd1143ffa304 | https://github.com/AzureAD/azure-activedirectory-library-for-ruby/blob/5d2f2530298a2545ca8caf688eabcd1143ffa304/lib/adal/cache_driver.rb#L136-L141 | train |
AzureAD/azure-activedirectory-library-for-ruby | lib/adal/cache_driver.rb | ADAL.CacheDriver.update_refresh_tokens | def update_refresh_tokens(mrrt)
fail ArgumentError, 'Token must contain an MRRT.' unless mrrt.mrrt?
@token_cache.find.each do |entry|
entry.refresh_token = mrrt.refresh_token if mrrt.can_refresh?(entry)
end
end | ruby | def update_refresh_tokens(mrrt)
fail ArgumentError, 'Token must contain an MRRT.' unless mrrt.mrrt?
@token_cache.find.each do |entry|
entry.refresh_token = mrrt.refresh_token if mrrt.can_refresh?(entry)
end
end | [
"def",
"update_refresh_tokens",
"(",
"mrrt",
")",
"fail",
"ArgumentError",
",",
"'Token must contain an MRRT.'",
"unless",
"mrrt",
".",
"mrrt?",
"@token_cache",
".",
"find",
".",
"each",
"do",
"|",
"entry",
"|",
"entry",
".",
"refresh_token",
"=",
"mrrt",
".",
... | Updates the refresh tokens of all tokens in the cache that match a given
MRRT.
@param CachedTokenResponse mrrt
A new MRRT containing a refresh token to update other matching cache
entries with. | [
"Updates",
"the",
"refresh",
"tokens",
"of",
"all",
"tokens",
"in",
"the",
"cache",
"that",
"match",
"a",
"given",
"MRRT",
"."
] | 5d2f2530298a2545ca8caf688eabcd1143ffa304 | https://github.com/AzureAD/azure-activedirectory-library-for-ruby/blob/5d2f2530298a2545ca8caf688eabcd1143ffa304/lib/adal/cache_driver.rb#L150-L155 | train |
AzureAD/azure-activedirectory-library-for-ruby | lib/adal/cache_driver.rb | ADAL.CacheDriver.validate | def validate(entries)
logger.verbose("Validating #{entries.size} possible cache matches.")
valid_entries = entries.group_by(&:validate)
@token_cache.remove(valid_entries[false] || [])
valid_entries[true] || []
end | ruby | def validate(entries)
logger.verbose("Validating #{entries.size} possible cache matches.")
valid_entries = entries.group_by(&:validate)
@token_cache.remove(valid_entries[false] || [])
valid_entries[true] || []
end | [
"def",
"validate",
"(",
"entries",
")",
"logger",
".",
"verbose",
"(",
"\"Validating #{entries.size} possible cache matches.\"",
")",
"valid_entries",
"=",
"entries",
".",
"group_by",
"(",
"&",
":validate",
")",
"@token_cache",
".",
"remove",
"(",
"valid_entries",
"... | Checks if an array of current cache entries are still valid, attempts to
refresh those that have expired and discards those that cannot be.
@param Array[CachedTokenResponse] entries
The tokens to validate.
@return Array[CachedTokenResponse] | [
"Checks",
"if",
"an",
"array",
"of",
"current",
"cache",
"entries",
"are",
"still",
"valid",
"attempts",
"to",
"refresh",
"those",
"that",
"have",
"expired",
"and",
"discards",
"those",
"that",
"cannot",
"be",
"."
] | 5d2f2530298a2545ca8caf688eabcd1143ffa304 | https://github.com/AzureAD/azure-activedirectory-library-for-ruby/blob/5d2f2530298a2545ca8caf688eabcd1143ffa304/lib/adal/cache_driver.rb#L164-L169 | train |
AzureAD/azure-activedirectory-library-for-ruby | lib/adal/cached_token_response.rb | ADAL.CachedTokenResponse.to_json | def to_json(_ = nil)
JSON.unparse(authority: [authority.host, authority.tenant],
client_id: client_id,
token_response: token_response)
end | ruby | def to_json(_ = nil)
JSON.unparse(authority: [authority.host, authority.tenant],
client_id: client_id,
token_response: token_response)
end | [
"def",
"to_json",
"(",
"_",
"=",
"nil",
")",
"JSON",
".",
"unparse",
"(",
"authority",
":",
"[",
"authority",
".",
"host",
",",
"authority",
".",
"tenant",
"]",
",",
"client_id",
":",
"client_id",
",",
"token_response",
":",
"token_response",
")",
"end"
... | Constructs a new CachedTokenResponse.
@param ClientCredential|ClientAssertion|ClientAssertionCertificate
The credentials of the calling client application.
@param Authority authority
The ADAL::Authority object that the response was retrieved from.
@param SuccessResponse token_response
The token response to... | [
"Constructs",
"a",
"new",
"CachedTokenResponse",
"."
] | 5d2f2530298a2545ca8caf688eabcd1143ffa304 | https://github.com/AzureAD/azure-activedirectory-library-for-ruby/blob/5d2f2530298a2545ca8caf688eabcd1143ffa304/lib/adal/cached_token_response.rb#L61-L65 | train |
AzureAD/azure-activedirectory-library-for-ruby | lib/adal/cached_token_response.rb | ADAL.CachedTokenResponse.can_refresh? | def can_refresh?(other)
mrrt? && (authority == other.authority) &&
(user_info == other.user_info) && (client_id == other.client_id)
end | ruby | def can_refresh?(other)
mrrt? && (authority == other.authority) &&
(user_info == other.user_info) && (client_id == other.client_id)
end | [
"def",
"can_refresh?",
"(",
"other",
")",
"mrrt?",
"&&",
"(",
"authority",
"==",
"other",
".",
"authority",
")",
"&&",
"(",
"user_info",
"==",
"other",
".",
"user_info",
")",
"&&",
"(",
"client_id",
"==",
"other",
".",
"client_id",
")",
"end"
] | Determines if self can be used to refresh other.
@param CachedTokenResponse other
@return Boolean | [
"Determines",
"if",
"self",
"can",
"be",
"used",
"to",
"refresh",
"other",
"."
] | 5d2f2530298a2545ca8caf688eabcd1143ffa304 | https://github.com/AzureAD/azure-activedirectory-library-for-ruby/blob/5d2f2530298a2545ca8caf688eabcd1143ffa304/lib/adal/cached_token_response.rb#L85-L88 | train |
AzureAD/azure-activedirectory-library-for-ruby | lib/adal/cached_token_response.rb | ADAL.CachedTokenResponse.validate | def validate(expiration_buffer_sec = 0)
return true if (Time.now + expiration_buffer_sec).to_i < expires_on
unless refresh_token
logger.verbose('Cached token is almost expired but no refresh token ' \
'is available.')
return false
end
logger.verbose('Cached... | ruby | def validate(expiration_buffer_sec = 0)
return true if (Time.now + expiration_buffer_sec).to_i < expires_on
unless refresh_token
logger.verbose('Cached token is almost expired but no refresh token ' \
'is available.')
return false
end
logger.verbose('Cached... | [
"def",
"validate",
"(",
"expiration_buffer_sec",
"=",
"0",
")",
"return",
"true",
"if",
"(",
"Time",
".",
"now",
"+",
"expiration_buffer_sec",
")",
".",
"to_i",
"<",
"expires_on",
"unless",
"refresh_token",
"logger",
".",
"verbose",
"(",
"'Cached token is almost... | If the access token is within the expiration buffer of expiring, an
attempt will be made to retrieve a new token with the refresh token.
@param Fixnum expiration_buffer_sec
The number of seconds to use as leeway in determining if the token is
expired. A positive buffer will refresh the token early while a nega... | [
"If",
"the",
"access",
"token",
"is",
"within",
"the",
"expiration",
"buffer",
"of",
"expiring",
"an",
"attempt",
"will",
"be",
"made",
"to",
"retrieve",
"a",
"new",
"token",
"with",
"the",
"refresh",
"token",
"."
] | 5d2f2530298a2545ca8caf688eabcd1143ffa304 | https://github.com/AzureAD/azure-activedirectory-library-for-ruby/blob/5d2f2530298a2545ca8caf688eabcd1143ffa304/lib/adal/cached_token_response.rb#L102-L120 | train |
AzureAD/azure-activedirectory-library-for-ruby | lib/adal/cached_token_response.rb | ADAL.CachedTokenResponse.refresh | def refresh(new_resource = resource)
token_response = TokenRequest
.new(authority, @client)
.get_with_refresh_token(refresh_token, new_resource)
if token_response.instance_of? SuccessResponse
token_response.parse_id_token(id_token)
end
token_... | ruby | def refresh(new_resource = resource)
token_response = TokenRequest
.new(authority, @client)
.get_with_refresh_token(refresh_token, new_resource)
if token_response.instance_of? SuccessResponse
token_response.parse_id_token(id_token)
end
token_... | [
"def",
"refresh",
"(",
"new_resource",
"=",
"resource",
")",
"token_response",
"=",
"TokenRequest",
".",
"new",
"(",
"authority",
",",
"@client",
")",
".",
"get_with_refresh_token",
"(",
"refresh_token",
",",
"new_resource",
")",
"if",
"token_response",
".",
"in... | Attempts to refresh the access token for a given resource. Note that you
can call this method with a different resource even if the token is not
an MRRT, but it will fail
@param String resource
The resource that the new access token is beign requested for. Defaults
to using the same resource as the original t... | [
"Attempts",
"to",
"refresh",
"the",
"access",
"token",
"for",
"a",
"given",
"resource",
".",
"Note",
"that",
"you",
"can",
"call",
"this",
"method",
"with",
"a",
"different",
"resource",
"even",
"if",
"the",
"token",
"is",
"not",
"an",
"MRRT",
"but",
"it... | 5d2f2530298a2545ca8caf688eabcd1143ffa304 | https://github.com/AzureAD/azure-activedirectory-library-for-ruby/blob/5d2f2530298a2545ca8caf688eabcd1143ffa304/lib/adal/cached_token_response.rb#L131-L139 | train |
AzureAD/azure-activedirectory-library-for-ruby | lib/adal/util.rb | ADAL.Util.string_hash | def string_hash(hash)
hash.map { |k, v| [k.to_s, v.to_s] }.to_h
end | ruby | def string_hash(hash)
hash.map { |k, v| [k.to_s, v.to_s] }.to_h
end | [
"def",
"string_hash",
"(",
"hash",
")",
"hash",
".",
"map",
"{",
"|",
"k",
",",
"v",
"|",
"[",
"k",
".",
"to_s",
",",
"v",
".",
"to_s",
"]",
"}",
".",
"to_h",
"end"
] | Converts every key and value of a hash to string.
@param Hash
@return Hash | [
"Converts",
"every",
"key",
"and",
"value",
"of",
"a",
"hash",
"to",
"string",
"."
] | 5d2f2530298a2545ca8caf688eabcd1143ffa304 | https://github.com/AzureAD/azure-activedirectory-library-for-ruby/blob/5d2f2530298a2545ca8caf688eabcd1143ffa304/lib/adal/util.rb#L45-L47 | train |
AzureAD/azure-activedirectory-library-for-ruby | lib/adal/memory_cache.rb | ADAL.MemoryCache.add | def add(entries)
entries = Array(entries) # If entries is an array, this is a no-op.
old_size = @entries.size
@entries |= entries
logger.verbose("Added #{entries.size - old_size} new entries to cache.")
end | ruby | def add(entries)
entries = Array(entries) # If entries is an array, this is a no-op.
old_size = @entries.size
@entries |= entries
logger.verbose("Added #{entries.size - old_size} new entries to cache.")
end | [
"def",
"add",
"(",
"entries",
")",
"entries",
"=",
"Array",
"(",
"entries",
")",
"old_size",
"=",
"@entries",
".",
"size",
"@entries",
"|=",
"entries",
"logger",
".",
"verbose",
"(",
"\"Added #{entries.size - old_size} new entries to cache.\"",
")",
"end"
] | Adds an array of objects to the cache.
@param Array
The entries to add.
@return Array
The entries after the addition. | [
"Adds",
"an",
"array",
"of",
"objects",
"to",
"the",
"cache",
"."
] | 5d2f2530298a2545ca8caf688eabcd1143ffa304 | https://github.com/AzureAD/azure-activedirectory-library-for-ruby/blob/5d2f2530298a2545ca8caf688eabcd1143ffa304/lib/adal/memory_cache.rb#L43-L48 | train |
AzureAD/azure-activedirectory-library-for-ruby | lib/adal/oauth_request.rb | ADAL.OAuthRequest.execute | def execute
request = Net::HTTP::Post.new(@endpoint_uri.path)
add_headers(request)
request.body = URI.encode_www_form(string_hash(params))
TokenResponse.parse(http(@endpoint_uri).request(request).body)
end | ruby | def execute
request = Net::HTTP::Post.new(@endpoint_uri.path)
add_headers(request)
request.body = URI.encode_www_form(string_hash(params))
TokenResponse.parse(http(@endpoint_uri).request(request).body)
end | [
"def",
"execute",
"request",
"=",
"Net",
"::",
"HTTP",
"::",
"Post",
".",
"new",
"(",
"@endpoint_uri",
".",
"path",
")",
"add_headers",
"(",
"request",
")",
"request",
".",
"body",
"=",
"URI",
".",
"encode_www_form",
"(",
"string_hash",
"(",
"params",
")... | Requests and waits for a token from the endpoint.
@return TokenResponse | [
"Requests",
"and",
"waits",
"for",
"a",
"token",
"from",
"the",
"endpoint",
"."
] | 5d2f2530298a2545ca8caf688eabcd1143ffa304 | https://github.com/AzureAD/azure-activedirectory-library-for-ruby/blob/5d2f2530298a2545ca8caf688eabcd1143ffa304/lib/adal/oauth_request.rb#L52-L57 | train |
AzureAD/azure-activedirectory-library-for-ruby | lib/adal/oauth_request.rb | ADAL.OAuthRequest.add_headers | def add_headers(request)
return if Logging.correlation_id.nil?
request.add_field(CLIENT_REQUEST_ID.to_s, Logging.correlation_id)
request.add_field(CLIENT_RETURN_CLIENT_REQUEST_ID.to_s, true)
end | ruby | def add_headers(request)
return if Logging.correlation_id.nil?
request.add_field(CLIENT_REQUEST_ID.to_s, Logging.correlation_id)
request.add_field(CLIENT_RETURN_CLIENT_REQUEST_ID.to_s, true)
end | [
"def",
"add_headers",
"(",
"request",
")",
"return",
"if",
"Logging",
".",
"correlation_id",
".",
"nil?",
"request",
".",
"add_field",
"(",
"CLIENT_REQUEST_ID",
".",
"to_s",
",",
"Logging",
".",
"correlation_id",
")",
"request",
".",
"add_field",
"(",
"CLIENT_... | Adds the necessary OAuth headers.
@param Net::HTTPGenericRequest | [
"Adds",
"the",
"necessary",
"OAuth",
"headers",
"."
] | 5d2f2530298a2545ca8caf688eabcd1143ffa304 | https://github.com/AzureAD/azure-activedirectory-library-for-ruby/blob/5d2f2530298a2545ca8caf688eabcd1143ffa304/lib/adal/oauth_request.rb#L65-L69 | train |
castle/ruby-u2f | lib/u2f/u2f.rb | U2F.U2F.authenticate! | def authenticate!(challenge, response, registration_public_key, registration_counter)
# TODO: check that it's the correct key_handle as well
raise NoMatchingRequestError unless challenge == response.client_data.challenge
raise ClientDataTypeError unless response.client_data.authentication?
pem... | ruby | def authenticate!(challenge, response, registration_public_key, registration_counter)
# TODO: check that it's the correct key_handle as well
raise NoMatchingRequestError unless challenge == response.client_data.challenge
raise ClientDataTypeError unless response.client_data.authentication?
pem... | [
"def",
"authenticate!",
"(",
"challenge",
",",
"response",
",",
"registration_public_key",
",",
"registration_counter",
")",
"raise",
"NoMatchingRequestError",
"unless",
"challenge",
"==",
"response",
".",
"client_data",
".",
"challenge",
"raise",
"ClientDataTypeError",
... | Authenticate a response from the U2F device
* *Args*:
- +challenge+:: Challenge string
- +response+:: Response from the U2F device as a +SignResponse+ object
- +registration_public_key+:: Public key of the registered U2F device as binary string
- +registration_counter+:: +Integer+ with the current counter... | [
"Authenticate",
"a",
"response",
"from",
"the",
"U2F",
"device"
] | 1daa303669b589fced6f91c1b5d60cfa5dc14524 | https://github.com/castle/ruby-u2f/blob/1daa303669b589fced6f91c1b5d60cfa5dc14524/lib/u2f/u2f.rb#L49-L64 | train |
castle/ruby-u2f | lib/u2f/u2f.rb | U2F.U2F.register! | def register!(challenges, response)
challenges = [challenges] unless challenges.is_a? Array
challenge = challenges.detect do |chg|
chg == response.client_data.challenge
end
raise UnmatchedChallengeError unless challenge
raise ClientDataTypeError unless response.client_data.regist... | ruby | def register!(challenges, response)
challenges = [challenges] unless challenges.is_a? Array
challenge = challenges.detect do |chg|
chg == response.client_data.challenge
end
raise UnmatchedChallengeError unless challenge
raise ClientDataTypeError unless response.client_data.regist... | [
"def",
"register!",
"(",
"challenges",
",",
"response",
")",
"challenges",
"=",
"[",
"challenges",
"]",
"unless",
"challenges",
".",
"is_a?",
"Array",
"challenge",
"=",
"challenges",
".",
"detect",
"do",
"|",
"chg",
"|",
"chg",
"==",
"response",
".",
"clie... | Authenticate the response from the U2F device when registering
* *Args*:
- +challenges+:: +Array+ of challenge strings
- +response+:: Response of the U2F device as a +RegisterResponse+ object
* *Returns*:
- A +Registration+ object
* *Raises*:
- +UnmatchedChallengeError+:: if the challenge in the respo... | [
"Authenticate",
"the",
"response",
"from",
"the",
"U2F",
"device",
"when",
"registering"
] | 1daa303669b589fced6f91c1b5d60cfa5dc14524 | https://github.com/castle/ruby-u2f/blob/1daa303669b589fced6f91c1b5d60cfa5dc14524/lib/u2f/u2f.rb#L103-L123 | train |
castle/ruby-u2f | lib/u2f/sign_response.rb | U2F.SignResponse.verify | def verify(app_id, public_key_pem)
data = [
::U2F::DIGEST.digest(app_id),
signature_data.byteslice(0, 5),
::U2F::DIGEST.digest(client_data_json)
].join
public_key = OpenSSL::PKey.read(public_key_pem)
begin
public_key.verify(::U2F::DIGEST.new, signature, data)
... | ruby | def verify(app_id, public_key_pem)
data = [
::U2F::DIGEST.digest(app_id),
signature_data.byteslice(0, 5),
::U2F::DIGEST.digest(client_data_json)
].join
public_key = OpenSSL::PKey.read(public_key_pem)
begin
public_key.verify(::U2F::DIGEST.new, signature, data)
... | [
"def",
"verify",
"(",
"app_id",
",",
"public_key_pem",
")",
"data",
"=",
"[",
"::",
"U2F",
"::",
"DIGEST",
".",
"digest",
"(",
"app_id",
")",
",",
"signature_data",
".",
"byteslice",
"(",
"0",
",",
"5",
")",
",",
"::",
"U2F",
"::",
"DIGEST",
".",
"... | Verifies the response against an app id and the public key of the
registered device | [
"Verifies",
"the",
"response",
"against",
"an",
"app",
"id",
"and",
"the",
"public",
"key",
"of",
"the",
"registered",
"device"
] | 1daa303669b589fced6f91c1b5d60cfa5dc14524 | https://github.com/castle/ruby-u2f/blob/1daa303669b589fced6f91c1b5d60cfa5dc14524/lib/u2f/sign_response.rb#L53-L67 | train |
castle/ruby-u2f | lib/u2f/register_response.rb | U2F.RegisterResponse.verify | def verify(app_id)
# Chapter 4.3 in
# http://fidoalliance.org/specs/fido-u2f-raw-message-formats-v1.0-rd-20141008.pdf
data = [
"\x00",
::U2F::DIGEST.digest(app_id),
::U2F::DIGEST.digest(client_data_json),
key_handle_raw,
public_key_raw
].join
begin
... | ruby | def verify(app_id)
# Chapter 4.3 in
# http://fidoalliance.org/specs/fido-u2f-raw-message-formats-v1.0-rd-20141008.pdf
data = [
"\x00",
::U2F::DIGEST.digest(app_id),
::U2F::DIGEST.digest(client_data_json),
key_handle_raw,
public_key_raw
].join
begin
... | [
"def",
"verify",
"(",
"app_id",
")",
"data",
"=",
"[",
"\"\\x00\"",
",",
"::",
"U2F",
"::",
"DIGEST",
".",
"digest",
"(",
"app_id",
")",
",",
"::",
"U2F",
"::",
"DIGEST",
".",
"digest",
"(",
"client_data_json",
")",
",",
"key_handle_raw",
",",
"public_... | Verifies the registration data against the app id | [
"Verifies",
"the",
"registration",
"data",
"against",
"the",
"app",
"id"
] | 1daa303669b589fced6f91c1b5d60cfa5dc14524 | https://github.com/castle/ruby-u2f/blob/1daa303669b589fced6f91c1b5d60cfa5dc14524/lib/u2f/register_response.rb#L92-L108 | train |
castle/ruby-u2f | lib/u2f/fake_u2f.rb | U2F.FakeU2F.register_response | def register_response(challenge, error = false)
if error
JSON.dump(errorCode: 4)
else
client_data_json = client_data(::U2F::ClientData::REGISTRATION_TYP, challenge)
JSON.dump(
registrationData: reg_registration_data(client_data_json),
clientData: ::U2F.urlsafe_enc... | ruby | def register_response(challenge, error = false)
if error
JSON.dump(errorCode: 4)
else
client_data_json = client_data(::U2F::ClientData::REGISTRATION_TYP, challenge)
JSON.dump(
registrationData: reg_registration_data(client_data_json),
clientData: ::U2F.urlsafe_enc... | [
"def",
"register_response",
"(",
"challenge",
",",
"error",
"=",
"false",
")",
"if",
"error",
"JSON",
".",
"dump",
"(",
"errorCode",
":",
"4",
")",
"else",
"client_data_json",
"=",
"client_data",
"(",
"::",
"U2F",
"::",
"ClientData",
"::",
"REGISTRATION_TYP"... | Initialize a new FakeU2F device for use in tests.
app_id - The appId/origin this is being tested against.
options - A Hash of optional parameters (optional).
:counter - The initial counter for this device.
:key_handle - The raw key-handle this device should use.
:cert_subject... | [
"Initialize",
"a",
"new",
"FakeU2F",
"device",
"for",
"use",
"in",
"tests",
"."
] | 1daa303669b589fced6f91c1b5d60cfa5dc14524 | https://github.com/castle/ruby-u2f/blob/1daa303669b589fced6f91c1b5d60cfa5dc14524/lib/u2f/fake_u2f.rb#L33-L43 | train |
castle/ruby-u2f | lib/u2f/fake_u2f.rb | U2F.FakeU2F.sign_response | def sign_response(challenge)
client_data_json = client_data(::U2F::ClientData::AUTHENTICATION_TYP, challenge)
JSON.dump(
clientData: ::U2F.urlsafe_encode64(client_data_json),
keyHandle: ::U2F.urlsafe_encode64(key_handle_raw),
signatureData: auth_signature_data(client_data_json)
... | ruby | def sign_response(challenge)
client_data_json = client_data(::U2F::ClientData::AUTHENTICATION_TYP, challenge)
JSON.dump(
clientData: ::U2F.urlsafe_encode64(client_data_json),
keyHandle: ::U2F.urlsafe_encode64(key_handle_raw),
signatureData: auth_signature_data(client_data_json)
... | [
"def",
"sign_response",
"(",
"challenge",
")",
"client_data_json",
"=",
"client_data",
"(",
"::",
"U2F",
"::",
"ClientData",
"::",
"AUTHENTICATION_TYP",
",",
"challenge",
")",
"JSON",
".",
"dump",
"(",
"clientData",
":",
"::",
"U2F",
".",
"urlsafe_encode64",
"... | A SignResponse hash as returned by the u2f.sign JavaScript API.
challenge - The challenge to sign.
Returns a JSON encoded Hash String. | [
"A",
"SignResponse",
"hash",
"as",
"returned",
"by",
"the",
"u2f",
".",
"sign",
"JavaScript",
"API",
"."
] | 1daa303669b589fced6f91c1b5d60cfa5dc14524 | https://github.com/castle/ruby-u2f/blob/1daa303669b589fced6f91c1b5d60cfa5dc14524/lib/u2f/fake_u2f.rb#L50-L57 | train |
castle/ruby-u2f | lib/u2f/fake_u2f.rb | U2F.FakeU2F.reg_registration_data | def reg_registration_data(client_data_json)
::U2F.urlsafe_encode64(
[
5,
origin_public_key_raw,
key_handle_raw.bytesize,
key_handle_raw,
cert_raw,
reg_signature(client_data_json)
].pack("CA65CA#{key_handle_raw.bytesize}A#{cert_raw.bytesiz... | ruby | def reg_registration_data(client_data_json)
::U2F.urlsafe_encode64(
[
5,
origin_public_key_raw,
key_handle_raw.bytesize,
key_handle_raw,
cert_raw,
reg_signature(client_data_json)
].pack("CA65CA#{key_handle_raw.bytesize}A#{cert_raw.bytesiz... | [
"def",
"reg_registration_data",
"(",
"client_data_json",
")",
"::",
"U2F",
".",
"urlsafe_encode64",
"(",
"[",
"5",
",",
"origin_public_key_raw",
",",
"key_handle_raw",
".",
"bytesize",
",",
"key_handle_raw",
",",
"cert_raw",
",",
"reg_signature",
"(",
"client_data_j... | The registrationData field returns in a RegisterResponse Hash.
client_data_json - The JSON encoded clientData String.
Returns a url-safe base64 encoded binary String. | [
"The",
"registrationData",
"field",
"returns",
"in",
"a",
"RegisterResponse",
"Hash",
"."
] | 1daa303669b589fced6f91c1b5d60cfa5dc14524 | https://github.com/castle/ruby-u2f/blob/1daa303669b589fced6f91c1b5d60cfa5dc14524/lib/u2f/fake_u2f.rb#L82-L93 | train |
castle/ruby-u2f | lib/u2f/fake_u2f.rb | U2F.FakeU2F.reg_signature | def reg_signature(client_data_json)
payload = [
"\x00",
::U2F::DIGEST.digest(app_id),
::U2F::DIGEST.digest(client_data_json),
key_handle_raw,
origin_public_key_raw
].join
cert_key.sign(::U2F::DIGEST.new, payload)
end | ruby | def reg_signature(client_data_json)
payload = [
"\x00",
::U2F::DIGEST.digest(app_id),
::U2F::DIGEST.digest(client_data_json),
key_handle_raw,
origin_public_key_raw
].join
cert_key.sign(::U2F::DIGEST.new, payload)
end | [
"def",
"reg_signature",
"(",
"client_data_json",
")",
"payload",
"=",
"[",
"\"\\x00\"",
",",
"::",
"U2F",
"::",
"DIGEST",
".",
"digest",
"(",
"app_id",
")",
",",
"::",
"U2F",
"::",
"DIGEST",
".",
"digest",
"(",
"client_data_json",
")",
",",
"key_handle_raw... | The signature field of a registrationData field of a RegisterResponse.
client_data_json - The JSON encoded clientData String.
Returns an ECDSA signature String. | [
"The",
"signature",
"field",
"of",
"a",
"registrationData",
"field",
"of",
"a",
"RegisterResponse",
"."
] | 1daa303669b589fced6f91c1b5d60cfa5dc14524 | https://github.com/castle/ruby-u2f/blob/1daa303669b589fced6f91c1b5d60cfa5dc14524/lib/u2f/fake_u2f.rb#L100-L109 | train |
castle/ruby-u2f | lib/u2f/fake_u2f.rb | U2F.FakeU2F.auth_signature | def auth_signature(client_data_json)
data = [
::U2F::DIGEST.digest(app_id),
1, # User present
counter,
::U2F::DIGEST.digest(client_data_json)
].pack('A32CNA32')
origin_key.sign(::U2F::DIGEST.new, data)
end | ruby | def auth_signature(client_data_json)
data = [
::U2F::DIGEST.digest(app_id),
1, # User present
counter,
::U2F::DIGEST.digest(client_data_json)
].pack('A32CNA32')
origin_key.sign(::U2F::DIGEST.new, data)
end | [
"def",
"auth_signature",
"(",
"client_data_json",
")",
"data",
"=",
"[",
"::",
"U2F",
"::",
"DIGEST",
".",
"digest",
"(",
"app_id",
")",
",",
"1",
",",
"counter",
",",
"::",
"U2F",
"::",
"DIGEST",
".",
"digest",
"(",
"client_data_json",
")",
"]",
".",
... | The signature field of a signatureData field of a SignResponse Hash.
client_data_json - The JSON encoded clientData String.
Returns an ECDSA signature String. | [
"The",
"signature",
"field",
"of",
"a",
"signatureData",
"field",
"of",
"a",
"SignResponse",
"Hash",
"."
] | 1daa303669b589fced6f91c1b5d60cfa5dc14524 | https://github.com/castle/ruby-u2f/blob/1daa303669b589fced6f91c1b5d60cfa5dc14524/lib/u2f/fake_u2f.rb#L131-L140 | train |
castle/ruby-u2f | lib/u2f/fake_u2f.rb | U2F.FakeU2F.client_data | def client_data(typ, challenge)
JSON.dump(
challenge: challenge,
origin: app_id,
typ: typ
)
end | ruby | def client_data(typ, challenge)
JSON.dump(
challenge: challenge,
origin: app_id,
typ: typ
)
end | [
"def",
"client_data",
"(",
"typ",
",",
"challenge",
")",
"JSON",
".",
"dump",
"(",
"challenge",
":",
"challenge",
",",
"origin",
":",
"app_id",
",",
"typ",
":",
"typ",
")",
"end"
] | The clientData hash as returned by registration and authentication
responses.
typ - The String value for the 'typ' field.
challenge - The String url-safe base64 encoded challenge parameter.
Returns a JSON encoded Hash String. | [
"The",
"clientData",
"hash",
"as",
"returned",
"by",
"registration",
"and",
"authentication",
"responses",
"."
] | 1daa303669b589fced6f91c1b5d60cfa5dc14524 | https://github.com/castle/ruby-u2f/blob/1daa303669b589fced6f91c1b5d60cfa5dc14524/lib/u2f/fake_u2f.rb#L149-L155 | train |
castle/ruby-u2f | lib/u2f/fake_u2f.rb | U2F.FakeU2F.cert | def cert
@cert ||= OpenSSL::X509::Certificate.new.tap do |c|
c.subject = c.issuer = OpenSSL::X509::Name.parse(cert_subject)
c.not_before = Time.now
c.not_after = Time.now + 365 * 24 * 60 * 60
c.public_key = cert_key
c.serial = 0x1
c.version = 0x0
c.sign cert... | ruby | def cert
@cert ||= OpenSSL::X509::Certificate.new.tap do |c|
c.subject = c.issuer = OpenSSL::X509::Name.parse(cert_subject)
c.not_before = Time.now
c.not_after = Time.now + 365 * 24 * 60 * 60
c.public_key = cert_key
c.serial = 0x1
c.version = 0x0
c.sign cert... | [
"def",
"cert",
"@cert",
"||=",
"OpenSSL",
"::",
"X509",
"::",
"Certificate",
".",
"new",
".",
"tap",
"do",
"|",
"c",
"|",
"c",
".",
"subject",
"=",
"c",
".",
"issuer",
"=",
"OpenSSL",
"::",
"X509",
"::",
"Name",
".",
"parse",
"(",
"cert_subject",
"... | The self-signed device attestation certificate.
Returns a OpenSSL::X509::Certificate instance. | [
"The",
"self",
"-",
"signed",
"device",
"attestation",
"certificate",
"."
] | 1daa303669b589fced6f91c1b5d60cfa5dc14524 | https://github.com/castle/ruby-u2f/blob/1daa303669b589fced6f91c1b5d60cfa5dc14524/lib/u2f/fake_u2f.rb#L167-L177 | train |
jonatas/fast | lib/fast.rb | Fast.Rewriter.replace_on | def replace_on(*types)
types.map do |type|
self.class.send :define_method, "on_#{type}" do |node|
if captures = match?(node) # rubocop:disable Lint/AssignmentInCondition
@match_index += 1
execute_replacement(node, captures)
end
super(node)
end
... | ruby | def replace_on(*types)
types.map do |type|
self.class.send :define_method, "on_#{type}" do |node|
if captures = match?(node) # rubocop:disable Lint/AssignmentInCondition
@match_index += 1
execute_replacement(node, captures)
end
super(node)
end
... | [
"def",
"replace_on",
"(",
"*",
"types",
")",
"types",
".",
"map",
"do",
"|",
"type",
"|",
"self",
".",
"class",
".",
"send",
":define_method",
",",
"\"on_#{type}\"",
"do",
"|",
"node",
"|",
"if",
"captures",
"=",
"match?",
"(",
"node",
")",
"@match_ind... | Generate methods for all affected types.
@see Fast.replace | [
"Generate",
"methods",
"for",
"all",
"affected",
"types",
"."
] | 5d918a5c19327847fbadab6c56035f936458ba70 | https://github.com/jonatas/fast/blob/5d918a5c19327847fbadab6c56035f936458ba70/lib/fast.rb#L268-L278 | train |
jonatas/fast | lib/fast.rb | Fast.Matcher.captures? | def captures?(fast = @fast)
case fast
when Capture then true
when Array then fast.any?(&method(:captures?))
when Find then captures?(fast.token)
end
end | ruby | def captures?(fast = @fast)
case fast
when Capture then true
when Array then fast.any?(&method(:captures?))
when Find then captures?(fast.token)
end
end | [
"def",
"captures?",
"(",
"fast",
"=",
"@fast",
")",
"case",
"fast",
"when",
"Capture",
"then",
"true",
"when",
"Array",
"then",
"fast",
".",
"any?",
"(",
"&",
"method",
"(",
":captures?",
")",
")",
"when",
"Find",
"then",
"captures?",
"(",
"fast",
".",... | Look recursively into @param fast to check if the expression is have
captures.
@return [true] if any sub expression have captures. | [
"Look",
"recursively",
"into"
] | 5d918a5c19327847fbadab6c56035f936458ba70 | https://github.com/jonatas/fast/blob/5d918a5c19327847fbadab6c56035f936458ba70/lib/fast.rb#L686-L692 | train |
jonatas/fast | lib/fast.rb | Fast.Matcher.find_captures | def find_captures(fast = @fast)
return true if fast == @fast && !captures?(fast)
case fast
when Capture then fast.captures
when Array then fast.flat_map(&method(:find_captures)).compact
when Find then find_captures(fast.token)
end
end | ruby | def find_captures(fast = @fast)
return true if fast == @fast && !captures?(fast)
case fast
when Capture then fast.captures
when Array then fast.flat_map(&method(:find_captures)).compact
when Find then find_captures(fast.token)
end
end | [
"def",
"find_captures",
"(",
"fast",
"=",
"@fast",
")",
"return",
"true",
"if",
"fast",
"==",
"@fast",
"&&",
"!",
"captures?",
"(",
"fast",
")",
"case",
"fast",
"when",
"Capture",
"then",
"fast",
".",
"captures",
"when",
"Array",
"then",
"fast",
".",
"... | Find search captures recursively.
@return [Array<Object>] of captures from the expression
@return [true] in case of no captures in the expression
@see Fast::Capture
@see Fast::FindFromArgument | [
"Find",
"search",
"captures",
"recursively",
"."
] | 5d918a5c19327847fbadab6c56035f936458ba70 | https://github.com/jonatas/fast/blob/5d918a5c19327847fbadab6c56035f936458ba70/lib/fast.rb#L700-L708 | train |
jonatas/fast | lib/fast.rb | Fast.Matcher.prepare_arguments | def prepare_arguments(expression, arguments)
case expression
when Array
expression.each do |item|
prepare_arguments(item, arguments)
end
when Fast::FindFromArgument
expression.arguments = arguments
when Fast::Find
prepare_arguments expression.token, argu... | ruby | def prepare_arguments(expression, arguments)
case expression
when Array
expression.each do |item|
prepare_arguments(item, arguments)
end
when Fast::FindFromArgument
expression.arguments = arguments
when Fast::Find
prepare_arguments expression.token, argu... | [
"def",
"prepare_arguments",
"(",
"expression",
",",
"arguments",
")",
"case",
"expression",
"when",
"Array",
"expression",
".",
"each",
"do",
"|",
"item",
"|",
"prepare_arguments",
"(",
"item",
",",
"arguments",
")",
"end",
"when",
"Fast",
"::",
"FindFromArgum... | Prepare arguments case the expression needs to bind extra arguments.
@return [void] | [
"Prepare",
"arguments",
"case",
"the",
"expression",
"needs",
"to",
"bind",
"extra",
"arguments",
"."
] | 5d918a5c19327847fbadab6c56035f936458ba70 | https://github.com/jonatas/fast/blob/5d918a5c19327847fbadab6c56035f936458ba70/lib/fast.rb#L714-L725 | train |
jonatas/fast | lib/fast/experiment.rb | Fast.ExperimentFile.ok_with | def ok_with(combination)
@ok_experiments << combination
return unless combination.is_a?(Array)
combination.each do |element|
@ok_experiments.delete(element)
end
end | ruby | def ok_with(combination)
@ok_experiments << combination
return unless combination.is_a?(Array)
combination.each do |element|
@ok_experiments.delete(element)
end
end | [
"def",
"ok_with",
"(",
"combination",
")",
"@ok_experiments",
"<<",
"combination",
"return",
"unless",
"combination",
".",
"is_a?",
"(",
"Array",
")",
"combination",
".",
"each",
"do",
"|",
"element",
"|",
"@ok_experiments",
".",
"delete",
"(",
"element",
")",... | Keep track of ok experiments depending on the current combination.
It keep the combinations unique removing single replacements after the
first round.
@return void | [
"Keep",
"track",
"of",
"ok",
"experiments",
"depending",
"on",
"the",
"current",
"combination",
".",
"It",
"keep",
"the",
"combinations",
"unique",
"removing",
"single",
"replacements",
"after",
"the",
"first",
"round",
"."
] | 5d918a5c19327847fbadab6c56035f936458ba70 | https://github.com/jonatas/fast/blob/5d918a5c19327847fbadab6c56035f936458ba70/lib/fast/experiment.rb#L273-L280 | train |
jonatas/fast | lib/fast/experiment.rb | Fast.ExperimentFile.run_partial_replacement_with | def run_partial_replacement_with(combination)
content = partial_replace(*combination)
experimental_file = experimental_filename(combination)
File.open(experimental_file, 'w+') { |f| f.puts content }
raise 'No changes were made to the file.' if FileUtils.compare_file(@file, experimental_file)
... | ruby | def run_partial_replacement_with(combination)
content = partial_replace(*combination)
experimental_file = experimental_filename(combination)
File.open(experimental_file, 'w+') { |f| f.puts content }
raise 'No changes were made to the file.' if FileUtils.compare_file(@file, experimental_file)
... | [
"def",
"run_partial_replacement_with",
"(",
"combination",
")",
"content",
"=",
"partial_replace",
"(",
"*",
"combination",
")",
"experimental_file",
"=",
"experimental_filename",
"(",
"combination",
")",
"File",
".",
"open",
"(",
"experimental_file",
",",
"'w+'",
"... | Writes a new file with partial replacements based on the current combination.
Raise error if no changes was made with the given combination indices.
@param [Array<Integer>] combination to be replaced. | [
"Writes",
"a",
"new",
"file",
"with",
"partial",
"replacements",
"based",
"on",
"the",
"current",
"combination",
".",
"Raise",
"error",
"if",
"no",
"changes",
"was",
"made",
"with",
"the",
"given",
"combination",
"indices",
"."
] | 5d918a5c19327847fbadab6c56035f936458ba70 | https://github.com/jonatas/fast/blob/5d918a5c19327847fbadab6c56035f936458ba70/lib/fast/experiment.rb#L366-L383 | train |
gottfrois/link_thumbnailer | lib/link_thumbnailer/grader.rb | LinkThumbnailer.Grader.call | def call
probability = 1.0
graders.each do |lambda|
instance = lambda.call(description)
probability *= instance.call.to_f ** instance.weight
end
probability
end | ruby | def call
probability = 1.0
graders.each do |lambda|
instance = lambda.call(description)
probability *= instance.call.to_f ** instance.weight
end
probability
end | [
"def",
"call",
"probability",
"=",
"1.0",
"graders",
".",
"each",
"do",
"|",
"lambda",
"|",
"instance",
"=",
"lambda",
".",
"call",
"(",
"description",
")",
"probability",
"*=",
"instance",
".",
"call",
".",
"to_f",
"**",
"instance",
".",
"weight",
"end"... | For given description, computes probabilities returned by each graders by multipying them together.
@return [Float] the probability for the given description to be considered good | [
"For",
"given",
"description",
"computes",
"probabilities",
"returned",
"by",
"each",
"graders",
"by",
"multipying",
"them",
"together",
"."
] | 299e6cec1b392ca4134e872acfe76fa82b1ba9a9 | https://github.com/gottfrois/link_thumbnailer/blob/299e6cec1b392ca4134e872acfe76fa82b1ba9a9/lib/link_thumbnailer/grader.rb#L25-L34 | train |
infinitered/ProMotion | lib/ProMotion/table/table.rb | ProMotion.Table.tableView | def tableView(_, viewForHeaderInSection: index)
section = promotion_table_data.section(index)
view = section[:title_view]
view = section[:title_view].new if section[:title_view].respond_to?(:new)
view.on_load if view.respond_to?(:on_load)
view.title = section[:title] if view.respond_to?(:t... | ruby | def tableView(_, viewForHeaderInSection: index)
section = promotion_table_data.section(index)
view = section[:title_view]
view = section[:title_view].new if section[:title_view].respond_to?(:new)
view.on_load if view.respond_to?(:on_load)
view.title = section[:title] if view.respond_to?(:t... | [
"def",
"tableView",
"(",
"_",
",",
"viewForHeaderInSection",
":",
"index",
")",
"section",
"=",
"promotion_table_data",
".",
"section",
"(",
"index",
")",
"view",
"=",
"section",
"[",
":title_view",
"]",
"view",
"=",
"section",
"[",
":title_view",
"]",
".",
... | Section header view methods | [
"Section",
"header",
"view",
"methods"
] | 837d4b1dbdf7fac4ce6dee840223db5a917f0116 | https://github.com/infinitered/ProMotion/blob/837d4b1dbdf7fac4ce6dee840223db5a917f0116/lib/ProMotion/table/table.rb#L288-L295 | train |
infinitered/ProMotion | lib/ProMotion/web/web_screen_module.rb | ProMotion.WebScreenModule.webView | def webView(in_web, shouldStartLoadWithRequest:in_request, navigationType:in_type)
if %w(http https).include?(in_request.URL.scheme)
if self.external_links == true && in_type == UIWebViewNavigationTypeLinkClicked
if defined?(OpenInChromeController)
open_in_chrome in_request
... | ruby | def webView(in_web, shouldStartLoadWithRequest:in_request, navigationType:in_type)
if %w(http https).include?(in_request.URL.scheme)
if self.external_links == true && in_type == UIWebViewNavigationTypeLinkClicked
if defined?(OpenInChromeController)
open_in_chrome in_request
... | [
"def",
"webView",
"(",
"in_web",
",",
"shouldStartLoadWithRequest",
":",
"in_request",
",",
"navigationType",
":",
"in_type",
")",
"if",
"%w(",
"http",
"https",
")",
".",
"include?",
"(",
"in_request",
".",
"URL",
".",
"scheme",
")",
"if",
"self",
".",
"ex... | UIWebViewDelegate Methods - Camelcase | [
"UIWebViewDelegate",
"Methods",
"-",
"Camelcase"
] | 837d4b1dbdf7fac4ce6dee840223db5a917f0116 | https://github.com/infinitered/ProMotion/blob/837d4b1dbdf7fac4ce6dee840223db5a917f0116/lib/ProMotion/web/web_screen_module.rb#L123-L138 | train |
infinitered/ProMotion | lib/ProMotion/ipad/split_screen.rb | ProMotion.SplitScreen.splitViewController | def splitViewController(svc, willHideViewController: vc, withBarButtonItem: button, forPopoverController: _)
button ||= self.displayModeButtonItem if self.respond_to?(:displayModeButtonItem)
return unless button
button.title = @pm_split_screen_button_title || vc.title
svc.detail_screen.navigatio... | ruby | def splitViewController(svc, willHideViewController: vc, withBarButtonItem: button, forPopoverController: _)
button ||= self.displayModeButtonItem if self.respond_to?(:displayModeButtonItem)
return unless button
button.title = @pm_split_screen_button_title || vc.title
svc.detail_screen.navigatio... | [
"def",
"splitViewController",
"(",
"svc",
",",
"willHideViewController",
":",
"vc",
",",
"withBarButtonItem",
":",
"button",
",",
"forPopoverController",
":",
"_",
")",
"button",
"||=",
"self",
".",
"displayModeButtonItem",
"if",
"self",
".",
"respond_to?",
"(",
... | UISplitViewControllerDelegate methods
iOS 7 and below | [
"UISplitViewControllerDelegate",
"methods",
"iOS",
"7",
"and",
"below"
] | 837d4b1dbdf7fac4ce6dee840223db5a917f0116 | https://github.com/infinitered/ProMotion/blob/837d4b1dbdf7fac4ce6dee840223db5a917f0116/lib/ProMotion/ipad/split_screen.rb#L20-L25 | train |
infinitered/ProMotion | lib/ProMotion/ipad/split_screen.rb | ProMotion.SplitScreen.splitViewController | def splitViewController(svc, willChangeToDisplayMode: display_mode)
vc = svc.viewControllers.first
vc = vc.topViewController if vc.respond_to?(:topViewController)
case display_mode
# when UISplitViewControllerDisplayModeAutomatic then do_something?
when UISplitViewControllerDisplayModePrim... | ruby | def splitViewController(svc, willChangeToDisplayMode: display_mode)
vc = svc.viewControllers.first
vc = vc.topViewController if vc.respond_to?(:topViewController)
case display_mode
# when UISplitViewControllerDisplayModeAutomatic then do_something?
when UISplitViewControllerDisplayModePrim... | [
"def",
"splitViewController",
"(",
"svc",
",",
"willChangeToDisplayMode",
":",
"display_mode",
")",
"vc",
"=",
"svc",
".",
"viewControllers",
".",
"first",
"vc",
"=",
"vc",
".",
"topViewController",
"if",
"vc",
".",
"respond_to?",
"(",
":topViewController",
")",... | iOS 8 and above | [
"iOS",
"8",
"and",
"above"
] | 837d4b1dbdf7fac4ce6dee840223db5a917f0116 | https://github.com/infinitered/ProMotion/blob/837d4b1dbdf7fac4ce6dee840223db5a917f0116/lib/ProMotion/ipad/split_screen.rb#L32-L46 | train |
infinitered/ProMotion | lib/ProMotion/styling/styling.rb | ProMotion.Styling.closest_parent | def closest_parent(type, this_view = nil)
this_view ||= view_or_self.superview
while this_view != nil do
return this_view if this_view.is_a? type
this_view = this_view.superview
end
nil
end | ruby | def closest_parent(type, this_view = nil)
this_view ||= view_or_self.superview
while this_view != nil do
return this_view if this_view.is_a? type
this_view = this_view.superview
end
nil
end | [
"def",
"closest_parent",
"(",
"type",
",",
"this_view",
"=",
"nil",
")",
"this_view",
"||=",
"view_or_self",
".",
"superview",
"while",
"this_view",
"!=",
"nil",
"do",
"return",
"this_view",
"if",
"this_view",
".",
"is_a?",
"type",
"this_view",
"=",
"this_view... | iterate up the view hierarchy to find the parent element
of "type" containing this view | [
"iterate",
"up",
"the",
"view",
"hierarchy",
"to",
"find",
"the",
"parent",
"element",
"of",
"type",
"containing",
"this",
"view"
] | 837d4b1dbdf7fac4ce6dee840223db5a917f0116 | https://github.com/infinitered/ProMotion/blob/837d4b1dbdf7fac4ce6dee840223db5a917f0116/lib/ProMotion/styling/styling.rb#L58-L65 | train |
jackc/tod | lib/tod/shift.rb | Tod.Shift.include? | def include?(tod)
second = tod.to_i
second += TimeOfDay::NUM_SECONDS_IN_DAY if second < @range.first
@range.cover?(second)
end | ruby | def include?(tod)
second = tod.to_i
second += TimeOfDay::NUM_SECONDS_IN_DAY if second < @range.first
@range.cover?(second)
end | [
"def",
"include?",
"(",
"tod",
")",
"second",
"=",
"tod",
".",
"to_i",
"second",
"+=",
"TimeOfDay",
"::",
"NUM_SECONDS_IN_DAY",
"if",
"second",
"<",
"@range",
".",
"first",
"@range",
".",
"cover?",
"(",
"second",
")",
"end"
] | Returns true if the time of day is inside the shift, false otherwise. | [
"Returns",
"true",
"if",
"the",
"time",
"of",
"day",
"is",
"inside",
"the",
"shift",
"false",
"otherwise",
"."
] | 14c54f00e056264379484d2d8f55568e327a3b74 | https://github.com/jackc/tod/blob/14c54f00e056264379484d2d8f55568e327a3b74/lib/tod/shift.rb#L28-L32 | train |
jackc/tod | lib/tod/shift.rb | Tod.Shift.overlaps? | def overlaps?(other)
max_seconds = TimeOfDay::NUM_SECONDS_IN_DAY
# Standard case, when Shifts are on the same day
a, b = [self, other].map(&:range).sort_by(&:first)
op = a.exclude_end? ? :> : :>=
return true if a.last.send(op, b.first)
# Special cases, when Shifts span to the next ... | ruby | def overlaps?(other)
max_seconds = TimeOfDay::NUM_SECONDS_IN_DAY
# Standard case, when Shifts are on the same day
a, b = [self, other].map(&:range).sort_by(&:first)
op = a.exclude_end? ? :> : :>=
return true if a.last.send(op, b.first)
# Special cases, when Shifts span to the next ... | [
"def",
"overlaps?",
"(",
"other",
")",
"max_seconds",
"=",
"TimeOfDay",
"::",
"NUM_SECONDS_IN_DAY",
"a",
",",
"b",
"=",
"[",
"self",
",",
"other",
"]",
".",
"map",
"(",
"&",
":range",
")",
".",
"sort_by",
"(",
"&",
":first",
")",
"op",
"=",
"a",
".... | Returns true if ranges overlap, false otherwise. | [
"Returns",
"true",
"if",
"ranges",
"overlap",
"false",
"otherwise",
"."
] | 14c54f00e056264379484d2d8f55568e327a3b74 | https://github.com/jackc/tod/blob/14c54f00e056264379484d2d8f55568e327a3b74/lib/tod/shift.rb#L35-L50 | train |
jackc/tod | lib/tod/time_of_day.rb | Tod.TimeOfDay.round | def round(round_sec = 1)
down = self - (self.to_i % round_sec)
up = down + round_sec
difference_down = self - down
difference_up = up - self
if (difference_down < difference_up)
return down
else
return up
end
end | ruby | def round(round_sec = 1)
down = self - (self.to_i % round_sec)
up = down + round_sec
difference_down = self - down
difference_up = up - self
if (difference_down < difference_up)
return down
else
return up
end
end | [
"def",
"round",
"(",
"round_sec",
"=",
"1",
")",
"down",
"=",
"self",
"-",
"(",
"self",
".",
"to_i",
"%",
"round_sec",
")",
"up",
"=",
"down",
"+",
"round_sec",
"difference_down",
"=",
"self",
"-",
"down",
"difference_up",
"=",
"up",
"-",
"self",
"if... | Rounding to the given nearest number of seconds | [
"Rounding",
"to",
"the",
"given",
"nearest",
"number",
"of",
"seconds"
] | 14c54f00e056264379484d2d8f55568e327a3b74 | https://github.com/jackc/tod/blob/14c54f00e056264379484d2d8f55568e327a3b74/lib/tod/time_of_day.rb#L74-L86 | train |
jackc/tod | lib/tod/time_of_day.rb | Tod.TimeOfDay.- | def -(other)
if other.instance_of?(TimeOfDay)
TimeOfDay.from_second_of_day @second_of_day - other.second_of_day
else
TimeOfDay.from_second_of_day @second_of_day - other
end
end | ruby | def -(other)
if other.instance_of?(TimeOfDay)
TimeOfDay.from_second_of_day @second_of_day - other.second_of_day
else
TimeOfDay.from_second_of_day @second_of_day - other
end
end | [
"def",
"-",
"(",
"other",
")",
"if",
"other",
".",
"instance_of?",
"(",
"TimeOfDay",
")",
"TimeOfDay",
".",
"from_second_of_day",
"@second_of_day",
"-",
"other",
".",
"second_of_day",
"else",
"TimeOfDay",
".",
"from_second_of_day",
"@second_of_day",
"-",
"other",
... | Return a new TimeOfDay num_seconds less than self. It will wrap around
at midnight. | [
"Return",
"a",
"new",
"TimeOfDay",
"num_seconds",
"less",
"than",
"self",
".",
"It",
"will",
"wrap",
"around",
"at",
"midnight",
"."
] | 14c54f00e056264379484d2d8f55568e327a3b74 | https://github.com/jackc/tod/blob/14c54f00e056264379484d2d8f55568e327a3b74/lib/tod/time_of_day.rb#L121-L127 | train |
jackc/tod | lib/tod/time_of_day.rb | Tod.TimeOfDay.on | def on(date, time_zone=Tod::TimeOfDay.time_zone)
time_zone.local date.year, date.month, date.day, @hour, @minute, @second
end | ruby | def on(date, time_zone=Tod::TimeOfDay.time_zone)
time_zone.local date.year, date.month, date.day, @hour, @minute, @second
end | [
"def",
"on",
"(",
"date",
",",
"time_zone",
"=",
"Tod",
"::",
"TimeOfDay",
".",
"time_zone",
")",
"time_zone",
".",
"local",
"date",
".",
"year",
",",
"date",
".",
"month",
",",
"date",
".",
"day",
",",
"@hour",
",",
"@minute",
",",
"@second",
"end"
... | Returns a Time instance on date using self as the time of day
Optional time_zone will build time in that zone | [
"Returns",
"a",
"Time",
"instance",
"on",
"date",
"using",
"self",
"as",
"the",
"time",
"of",
"day",
"Optional",
"time_zone",
"will",
"build",
"time",
"in",
"that",
"zone"
] | 14c54f00e056264379484d2d8f55568e327a3b74 | https://github.com/jackc/tod/blob/14c54f00e056264379484d2d8f55568e327a3b74/lib/tod/time_of_day.rb#L131-L133 | train |
opentracing/opentracing-ruby | lib/opentracing/tracer.rb | OpenTracing.Tracer.extract | def extract(format, carrier)
case format
when OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY, OpenTracing::FORMAT_RACK
return SpanContext::NOOP_INSTANCE
else
warn 'Unknown extract format'
nil
end
end | ruby | def extract(format, carrier)
case format
when OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY, OpenTracing::FORMAT_RACK
return SpanContext::NOOP_INSTANCE
else
warn 'Unknown extract format'
nil
end
end | [
"def",
"extract",
"(",
"format",
",",
"carrier",
")",
"case",
"format",
"when",
"OpenTracing",
"::",
"FORMAT_TEXT_MAP",
",",
"OpenTracing",
"::",
"FORMAT_BINARY",
",",
"OpenTracing",
"::",
"FORMAT_RACK",
"return",
"SpanContext",
"::",
"NOOP_INSTANCE",
"else",
"war... | Extract a SpanContext in the given format from the given carrier.
@param format [OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY, OpenTracing::FORMAT_RACK]
@param carrier [Carrier] A carrier object of the type dictated by the specified `format`
@return [SpanContext, nil] the extracted SpanContext or nil if... | [
"Extract",
"a",
"SpanContext",
"in",
"the",
"given",
"format",
"from",
"the",
"given",
"carrier",
"."
] | 01304d46b6d8322e23bb2962189c0cd14065c886 | https://github.com/opentracing/opentracing-ruby/blob/01304d46b6d8322e23bb2962189c0cd14065c886/lib/opentracing/tracer.rb#L116-L124 | train |
mailboxer/mailboxer | lib/mailboxer/recipient_filter.rb | Mailboxer.RecipientFilter.call | def call
return recipients unless mailable.respond_to?(:conversation)
recipients.each_with_object([]) do |recipient, array|
array << recipient if mailable.conversation.has_subscriber?(recipient)
end
end | ruby | def call
return recipients unless mailable.respond_to?(:conversation)
recipients.each_with_object([]) do |recipient, array|
array << recipient if mailable.conversation.has_subscriber?(recipient)
end
end | [
"def",
"call",
"return",
"recipients",
"unless",
"mailable",
".",
"respond_to?",
"(",
":conversation",
")",
"recipients",
".",
"each_with_object",
"(",
"[",
"]",
")",
"do",
"|",
"recipient",
",",
"array",
"|",
"array",
"<<",
"recipient",
"if",
"mailable",
".... | recipients can be filtered on a conversation basis | [
"recipients",
"can",
"be",
"filtered",
"on",
"a",
"conversation",
"basis"
] | 3e148858879110c3258b46152b11e5bfc514dc04 | https://github.com/mailboxer/mailboxer/blob/3e148858879110c3258b46152b11e5bfc514dc04/lib/mailboxer/recipient_filter.rb#L9-L15 | train |
lassebunk/dynamic_sitemaps | lib/dynamic_sitemaps/index_generator.rb | DynamicSitemaps.IndexGenerator.generate | def generate
sitemaps.group_by(&:folder).each do |folder, sitemaps|
index_path = "#{DynamicSitemaps.temp_path}/#{folder}/#{DynamicSitemaps.index_file_name}"
if !DynamicSitemaps.always_generate_index && sitemaps.count == 1 && sitemaps.first.files.count == 1
file_path = "#{DynamicSitemaps... | ruby | def generate
sitemaps.group_by(&:folder).each do |folder, sitemaps|
index_path = "#{DynamicSitemaps.temp_path}/#{folder}/#{DynamicSitemaps.index_file_name}"
if !DynamicSitemaps.always_generate_index && sitemaps.count == 1 && sitemaps.first.files.count == 1
file_path = "#{DynamicSitemaps... | [
"def",
"generate",
"sitemaps",
".",
"group_by",
"(",
"&",
":folder",
")",
".",
"each",
"do",
"|",
"folder",
",",
"sitemaps",
"|",
"index_path",
"=",
"\"#{DynamicSitemaps.temp_path}/#{folder}/#{DynamicSitemaps.index_file_name}\"",
"if",
"!",
"DynamicSitemaps",
".",
"al... | Array of sitemap results
Initialize the class with an array of SitemapResult | [
"Array",
"of",
"sitemap",
"results",
"Initialize",
"the",
"class",
"with",
"an",
"array",
"of",
"SitemapResult"
] | 37beeba143e8202218ee814056231b0e6974bafb | https://github.com/lassebunk/dynamic_sitemaps/blob/37beeba143e8202218ee814056231b0e6974bafb/lib/dynamic_sitemaps/index_generator.rb#L10-L26 | train |
ianfixes/arduino_ci | lib/arduino_ci/cpp_library.rb | ArduinoCI.CppLibrary.cpp_files_in | def cpp_files_in(some_dir)
raise ArgumentError, 'some_dir is not a Pathname' unless some_dir.is_a? Pathname
return [] unless some_dir.exist? && some_dir.directory?
real = some_dir.realpath
files = Find.find(real).map { |p| Pathname.new(p) }.reject(&:directory?)
cpp = files.select { |path|... | ruby | def cpp_files_in(some_dir)
raise ArgumentError, 'some_dir is not a Pathname' unless some_dir.is_a? Pathname
return [] unless some_dir.exist? && some_dir.directory?
real = some_dir.realpath
files = Find.find(real).map { |p| Pathname.new(p) }.reject(&:directory?)
cpp = files.select { |path|... | [
"def",
"cpp_files_in",
"(",
"some_dir",
")",
"raise",
"ArgumentError",
",",
"'some_dir is not a Pathname'",
"unless",
"some_dir",
".",
"is_a?",
"Pathname",
"return",
"[",
"]",
"unless",
"some_dir",
".",
"exist?",
"&&",
"some_dir",
".",
"directory?",
"real",
"=",
... | Get a list of all CPP source files in a directory and its subdirectories
@param some_dir [Pathname] The directory in which to begin the search
@return [Array<Pathname>] The paths of the found files | [
"Get",
"a",
"list",
"of",
"all",
"CPP",
"source",
"files",
"in",
"a",
"directory",
"and",
"its",
"subdirectories"
] | cb3fe8df14a744b9a3bc5cdc0168f820f78cde57 | https://github.com/ianfixes/arduino_ci/blob/cb3fe8df14a744b9a3bc5cdc0168f820f78cde57/lib/arduino_ci/cpp_library.rb#L139-L148 | train |
ianfixes/arduino_ci | lib/arduino_ci/cpp_library.rb | ArduinoCI.CppLibrary.cpp_files_libraries | def cpp_files_libraries(aux_libraries)
arduino_library_src_dirs(aux_libraries).map { |d| cpp_files_in(d) }.flatten.uniq
end | ruby | def cpp_files_libraries(aux_libraries)
arduino_library_src_dirs(aux_libraries).map { |d| cpp_files_in(d) }.flatten.uniq
end | [
"def",
"cpp_files_libraries",
"(",
"aux_libraries",
")",
"arduino_library_src_dirs",
"(",
"aux_libraries",
")",
".",
"map",
"{",
"|",
"d",
"|",
"cpp_files_in",
"(",
"d",
")",
"}",
".",
"flatten",
".",
"uniq",
"end"
] | CPP files that are part of the 3rd-party libraries we're including
@param [Array<String>] aux_libraries
@return [Array<Pathname>] | [
"CPP",
"files",
"that",
"are",
"part",
"of",
"the",
"3rd",
"-",
"party",
"libraries",
"we",
"re",
"including"
] | cb3fe8df14a744b9a3bc5cdc0168f820f78cde57 | https://github.com/ianfixes/arduino_ci/blob/cb3fe8df14a744b9a3bc5cdc0168f820f78cde57/lib/arduino_ci/cpp_library.rb#L171-L173 | train |
ianfixes/arduino_ci | lib/arduino_ci/cpp_library.rb | ArduinoCI.CppLibrary.header_dirs | def header_dirs
real = @base_dir.realpath
all_files = Find.find(real).map { |f| Pathname.new(f) }.reject(&:directory?)
unbundled = all_files.reject { |path| vendor_bundle?(path) }
files = unbundled.select { |path| HPP_EXTENSIONS.include?(path.extname.downcase) }
files.map(&:dirname).uniq
... | ruby | def header_dirs
real = @base_dir.realpath
all_files = Find.find(real).map { |f| Pathname.new(f) }.reject(&:directory?)
unbundled = all_files.reject { |path| vendor_bundle?(path) }
files = unbundled.select { |path| HPP_EXTENSIONS.include?(path.extname.downcase) }
files.map(&:dirname).uniq
... | [
"def",
"header_dirs",
"real",
"=",
"@base_dir",
".",
"realpath",
"all_files",
"=",
"Find",
".",
"find",
"(",
"real",
")",
".",
"map",
"{",
"|",
"f",
"|",
"Pathname",
".",
"new",
"(",
"f",
")",
"}",
".",
"reject",
"(",
"&",
":directory?",
")",
"unbu... | Find all directories in the project library that include C++ header files
@return [Array<Pathname>] | [
"Find",
"all",
"directories",
"in",
"the",
"project",
"library",
"that",
"include",
"C",
"++",
"header",
"files"
] | cb3fe8df14a744b9a3bc5cdc0168f820f78cde57 | https://github.com/ianfixes/arduino_ci/blob/cb3fe8df14a744b9a3bc5cdc0168f820f78cde57/lib/arduino_ci/cpp_library.rb#L189-L195 | train |
ianfixes/arduino_ci | lib/arduino_ci/cpp_library.rb | ArduinoCI.CppLibrary.run_gcc | def run_gcc(gcc_binary, *args, **kwargs)
full_args = [gcc_binary] + args
@last_cmd = " $ #{full_args.join(' ')}"
ret = Host.run_and_capture(*full_args, **kwargs)
@last_err = ret[:err]
@last_out = ret[:out]
ret[:success]
end | ruby | def run_gcc(gcc_binary, *args, **kwargs)
full_args = [gcc_binary] + args
@last_cmd = " $ #{full_args.join(' ')}"
ret = Host.run_and_capture(*full_args, **kwargs)
@last_err = ret[:err]
@last_out = ret[:out]
ret[:success]
end | [
"def",
"run_gcc",
"(",
"gcc_binary",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
"full_args",
"=",
"[",
"gcc_binary",
"]",
"+",
"args",
"@last_cmd",
"=",
"\" $ #{full_args.join(' ')}\"",
"ret",
"=",
"Host",
".",
"run_and_capture",
"(",
"*",
"full_args",
",",... | wrapper for the GCC command | [
"wrapper",
"for",
"the",
"GCC",
"command"
] | cb3fe8df14a744b9a3bc5cdc0168f820f78cde57 | https://github.com/ianfixes/arduino_ci/blob/cb3fe8df14a744b9a3bc5cdc0168f820f78cde57/lib/arduino_ci/cpp_library.rb#L198-L205 | train |
ianfixes/arduino_ci | lib/arduino_ci/cpp_library.rb | ArduinoCI.CppLibrary.arduino_library_src_dirs | def arduino_library_src_dirs(aux_libraries)
# Pull in all possible places that headers could live, according to the spec:
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification
# TODO: be smart and implement library spec (library.properties, etc)?
subdirs = ["", "src", ... | ruby | def arduino_library_src_dirs(aux_libraries)
# Pull in all possible places that headers could live, according to the spec:
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification
# TODO: be smart and implement library spec (library.properties, etc)?
subdirs = ["", "src", ... | [
"def",
"arduino_library_src_dirs",
"(",
"aux_libraries",
")",
"subdirs",
"=",
"[",
"\"\"",
",",
"\"src\"",
",",
"\"utility\"",
"]",
"all_aux_include_dirs_nested",
"=",
"aux_libraries",
".",
"map",
"do",
"|",
"libdir",
"|",
"subdirs",
".",
"map",
"{",
"|",
"sub... | Arduino library directories containing sources
@return [Array<Pathname>] | [
"Arduino",
"library",
"directories",
"containing",
"sources"
] | cb3fe8df14a744b9a3bc5cdc0168f820f78cde57 | https://github.com/ianfixes/arduino_ci/blob/cb3fe8df14a744b9a3bc5cdc0168f820f78cde57/lib/arduino_ci/cpp_library.rb#L217-L226 | train |
ianfixes/arduino_ci | lib/arduino_ci/cpp_library.rb | ArduinoCI.CppLibrary.include_args | def include_args(aux_libraries)
all_aux_include_dirs = arduino_library_src_dirs(aux_libraries)
places = [ARDUINO_HEADER_DIR, UNITTEST_HEADER_DIR] + header_dirs + all_aux_include_dirs
places.map { |d| "-I#{d}" }
end | ruby | def include_args(aux_libraries)
all_aux_include_dirs = arduino_library_src_dirs(aux_libraries)
places = [ARDUINO_HEADER_DIR, UNITTEST_HEADER_DIR] + header_dirs + all_aux_include_dirs
places.map { |d| "-I#{d}" }
end | [
"def",
"include_args",
"(",
"aux_libraries",
")",
"all_aux_include_dirs",
"=",
"arduino_library_src_dirs",
"(",
"aux_libraries",
")",
"places",
"=",
"[",
"ARDUINO_HEADER_DIR",
",",
"UNITTEST_HEADER_DIR",
"]",
"+",
"header_dirs",
"+",
"all_aux_include_dirs",
"places",
".... | GCC command line arguments for including aux libraries
@param aux_libraries [Array<Pathname>] The external Arduino libraries required by this project
@return [Array<String>] The GCC command-line flags necessary to include those libraries | [
"GCC",
"command",
"line",
"arguments",
"for",
"including",
"aux",
"libraries"
] | cb3fe8df14a744b9a3bc5cdc0168f820f78cde57 | https://github.com/ianfixes/arduino_ci/blob/cb3fe8df14a744b9a3bc5cdc0168f820f78cde57/lib/arduino_ci/cpp_library.rb#L231-L235 | train |
ianfixes/arduino_ci | lib/arduino_ci/arduino_downloader.rb | ArduinoCI.ArduinoDownloader.execute | def execute
error_preparing = prepare
unless error_preparing.nil?
@output.puts "Arduino force-install failed preparation: #{error_preparing}"
return false
end
attempts = 0
loop do
if File.exist? package_file
@output.puts "Arduino package seems to have be... | ruby | def execute
error_preparing = prepare
unless error_preparing.nil?
@output.puts "Arduino force-install failed preparation: #{error_preparing}"
return false
end
attempts = 0
loop do
if File.exist? package_file
@output.puts "Arduino package seems to have be... | [
"def",
"execute",
"error_preparing",
"=",
"prepare",
"unless",
"error_preparing",
".",
"nil?",
"@output",
".",
"puts",
"\"Arduino force-install failed preparation: #{error_preparing}\"",
"return",
"false",
"end",
"attempts",
"=",
"0",
"loop",
"do",
"if",
"File",
".",
... | Forcibly install Arduino on linux from the web
@return [bool] Whether the command succeeded | [
"Forcibly",
"install",
"Arduino",
"on",
"linux",
"from",
"the",
"web"
] | cb3fe8df14a744b9a3bc5cdc0168f820f78cde57 | https://github.com/ianfixes/arduino_ci/blob/cb3fe8df14a744b9a3bc5cdc0168f820f78cde57/lib/arduino_ci/arduino_downloader.rb#L157-L197 | train |
ianfixes/arduino_ci | lib/arduino_ci/arduino_cmd.rb | ArduinoCI.ArduinoCmd.parse_pref_string | def parse_pref_string(arduino_output)
lines = arduino_output.split("\n").select { |l| l.include? "=" }
ret = lines.each_with_object({}) do |e, acc|
parts = e.split("=", 2)
acc[parts[0]] = parts[1]
acc
end
ret
end | ruby | def parse_pref_string(arduino_output)
lines = arduino_output.split("\n").select { |l| l.include? "=" }
ret = lines.each_with_object({}) do |e, acc|
parts = e.split("=", 2)
acc[parts[0]] = parts[1]
acc
end
ret
end | [
"def",
"parse_pref_string",
"(",
"arduino_output",
")",
"lines",
"=",
"arduino_output",
".",
"split",
"(",
"\"\\n\"",
")",
".",
"select",
"{",
"|",
"l",
"|",
"l",
".",
"include?",
"\"=\"",
"}",
"ret",
"=",
"lines",
".",
"each_with_object",
"(",
"{",
"}",... | Convert a preferences dump into a flat hash
@param arduino_output [String] The raw Arduino executable output
@return [Hash] preferences as a hash | [
"Convert",
"a",
"preferences",
"dump",
"into",
"a",
"flat",
"hash"
] | cb3fe8df14a744b9a3bc5cdc0168f820f78cde57 | https://github.com/ianfixes/arduino_ci/blob/cb3fe8df14a744b9a3bc5cdc0168f820f78cde57/lib/arduino_ci/arduino_cmd.rb#L66-L74 | train |
ianfixes/arduino_ci | lib/arduino_ci/arduino_cmd.rb | ArduinoCI.ArduinoCmd.run_and_output | def run_and_output(*args, **kwargs)
_wrap_run((proc { |*a, **k| Host.run_and_output(*a, **k) }), *args, **kwargs)
end | ruby | def run_and_output(*args, **kwargs)
_wrap_run((proc { |*a, **k| Host.run_and_output(*a, **k) }), *args, **kwargs)
end | [
"def",
"run_and_output",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"_wrap_run",
"(",
"(",
"proc",
"{",
"|",
"*",
"a",
",",
"**",
"k",
"|",
"Host",
".",
"run_and_output",
"(",
"*",
"a",
",",
"**",
"k",
")",
"}",
")",
",",
"*",
"args",
",",
"... | build and run the arduino command | [
"build",
"and",
"run",
"the",
"arduino",
"command"
] | cb3fe8df14a744b9a3bc5cdc0168f820f78cde57 | https://github.com/ianfixes/arduino_ci/blob/cb3fe8df14a744b9a3bc5cdc0168f820f78cde57/lib/arduino_ci/arduino_cmd.rb#L142-L144 | train |
ianfixes/arduino_ci | lib/arduino_ci/arduino_cmd.rb | ArduinoCI.ArduinoCmd.run_and_capture | def run_and_capture(*args, **kwargs)
ret = _wrap_run((proc { |*a, **k| Host.run_and_capture(*a, **k) }), *args, **kwargs)
@last_err = ret[:err]
@last_out = ret[:out]
ret
end | ruby | def run_and_capture(*args, **kwargs)
ret = _wrap_run((proc { |*a, **k| Host.run_and_capture(*a, **k) }), *args, **kwargs)
@last_err = ret[:err]
@last_out = ret[:out]
ret
end | [
"def",
"run_and_capture",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"ret",
"=",
"_wrap_run",
"(",
"(",
"proc",
"{",
"|",
"*",
"a",
",",
"**",
"k",
"|",
"Host",
".",
"run_and_capture",
"(",
"*",
"a",
",",
"**",
"k",
")",
"}",
")",
",",
"*",
... | run a command and capture its output
@return [Hash] {:out => String, :err => String, :success => bool} | [
"run",
"a",
"command",
"and",
"capture",
"its",
"output"
] | cb3fe8df14a744b9a3bc5cdc0168f820f78cde57 | https://github.com/ianfixes/arduino_ci/blob/cb3fe8df14a744b9a3bc5cdc0168f820f78cde57/lib/arduino_ci/arduino_cmd.rb#L148-L153 | train |
ianfixes/arduino_ci | lib/arduino_ci/arduino_cmd.rb | ArduinoCI.ArduinoCmd.install_boards | def install_boards(boardfamily)
# TODO: find out why IO.pipe fails but File::NULL succeeds :(
result = run_and_capture(flag_install_boards, boardfamily)
already_installed = result[:err].include?("Platform is already installed!")
result[:success] || already_installed
end | ruby | def install_boards(boardfamily)
# TODO: find out why IO.pipe fails but File::NULL succeeds :(
result = run_and_capture(flag_install_boards, boardfamily)
already_installed = result[:err].include?("Platform is already installed!")
result[:success] || already_installed
end | [
"def",
"install_boards",
"(",
"boardfamily",
")",
"result",
"=",
"run_and_capture",
"(",
"flag_install_boards",
",",
"boardfamily",
")",
"already_installed",
"=",
"result",
"[",
":err",
"]",
".",
"include?",
"(",
"\"Platform is already installed!\"",
")",
"result",
... | install a board by name
@param name [String] the board name
@return [bool] whether the command succeeded | [
"install",
"a",
"board",
"by",
"name"
] | cb3fe8df14a744b9a3bc5cdc0168f820f78cde57 | https://github.com/ianfixes/arduino_ci/blob/cb3fe8df14a744b9a3bc5cdc0168f820f78cde57/lib/arduino_ci/arduino_cmd.rb#L182-L187 | train |
ianfixes/arduino_ci | lib/arduino_ci/arduino_cmd.rb | ArduinoCI.ArduinoCmd._install_library | def _install_library(library_name)
result = run_and_capture(flag_install_library, library_name)
already_installed = result[:err].include?("Library is already installed: #{library_name}")
success = result[:success] || already_installed
@libraries_indexed = (@libraries_indexed || success) if lib... | ruby | def _install_library(library_name)
result = run_and_capture(flag_install_library, library_name)
already_installed = result[:err].include?("Library is already installed: #{library_name}")
success = result[:success] || already_installed
@libraries_indexed = (@libraries_indexed || success) if lib... | [
"def",
"_install_library",
"(",
"library_name",
")",
"result",
"=",
"run_and_capture",
"(",
"flag_install_library",
",",
"library_name",
")",
"already_installed",
"=",
"result",
"[",
":err",
"]",
".",
"include?",
"(",
"\"Library is already installed: #{library_name}\"",
... | install a library by name
@param name [String] the library name
@return [bool] whether the command succeeded | [
"install",
"a",
"library",
"by",
"name"
] | cb3fe8df14a744b9a3bc5cdc0168f820f78cde57 | https://github.com/ianfixes/arduino_ci/blob/cb3fe8df14a744b9a3bc5cdc0168f820f78cde57/lib/arduino_ci/arduino_cmd.rb#L192-L200 | train |
ianfixes/arduino_ci | lib/arduino_ci/arduino_cmd.rb | ArduinoCI.ArduinoCmd.use_board! | def use_board!(boardname)
return true if use_board(boardname)
boardfamily = boardname.split(":")[0..1].join(":")
puts "Board '#{boardname}' not found; attempting to install '#{boardfamily}'"
return false unless install_boards(boardfamily) # guess board family from first 2 :-separated fields
... | ruby | def use_board!(boardname)
return true if use_board(boardname)
boardfamily = boardname.split(":")[0..1].join(":")
puts "Board '#{boardname}' not found; attempting to install '#{boardfamily}'"
return false unless install_boards(boardfamily) # guess board family from first 2 :-separated fields
... | [
"def",
"use_board!",
"(",
"boardname",
")",
"return",
"true",
"if",
"use_board",
"(",
"boardname",
")",
"boardfamily",
"=",
"boardname",
".",
"split",
"(",
"\":\"",
")",
"[",
"0",
"..",
"1",
"]",
".",
"join",
"(",
"\":\"",
")",
"puts",
"\"Board '#{boardn... | use a particular board for compilation, installing it if necessary
@param boardname [String] The board to use
@return [bool] whether the command succeeded | [
"use",
"a",
"particular",
"board",
"for",
"compilation",
"installing",
"it",
"if",
"necessary"
] | cb3fe8df14a744b9a3bc5cdc0168f820f78cde57 | https://github.com/ianfixes/arduino_ci/blob/cb3fe8df14a744b9a3bc5cdc0168f820f78cde57/lib/arduino_ci/arduino_cmd.rb#L256-L264 | train |
ianfixes/arduino_ci | lib/arduino_ci/arduino_cmd.rb | ArduinoCI.ArduinoCmd.install_local_library | def install_local_library(path)
src_path = path.realpath
library_name = src_path.basename
destination_path = library_path(library_name)
# things get weird if the sketchbook contains the library.
# check that first
if destination_path.exist?
uhoh = "There is already a library... | ruby | def install_local_library(path)
src_path = path.realpath
library_name = src_path.basename
destination_path = library_path(library_name)
# things get weird if the sketchbook contains the library.
# check that first
if destination_path.exist?
uhoh = "There is already a library... | [
"def",
"install_local_library",
"(",
"path",
")",
"src_path",
"=",
"path",
".",
"realpath",
"library_name",
"=",
"src_path",
".",
"basename",
"destination_path",
"=",
"library_path",
"(",
"library_name",
")",
"if",
"destination_path",
".",
"exist?",
"uhoh",
"=",
... | ensure that the given library is installed, or symlinked as appropriate
return the path of the prepared library, or nil
@param path [Pathname] library to use
@return [String] the path of the installed library | [
"ensure",
"that",
"the",
"given",
"library",
"is",
"installed",
"or",
"symlinked",
"as",
"appropriate",
"return",
"the",
"path",
"of",
"the",
"prepared",
"library",
"or",
"nil"
] | cb3fe8df14a744b9a3bc5cdc0168f820f78cde57 | https://github.com/ianfixes/arduino_ci/blob/cb3fe8df14a744b9a3bc5cdc0168f820f78cde57/lib/arduino_ci/arduino_cmd.rb#L286-L312 | train |
ianfixes/arduino_ci | lib/arduino_ci/ci_config.rb | ArduinoCI.CIConfig.validate_data | def validate_data(rootname, source, schema)
return nil if source.nil?
good_data = {}
source.each do |key, value|
ksym = key.to_sym
expected_type = schema[ksym].class == Class ? schema[ksym] : Hash
if !schema.include?(ksym)
puts "Warning: unknown field '#{ksym}' under... | ruby | def validate_data(rootname, source, schema)
return nil if source.nil?
good_data = {}
source.each do |key, value|
ksym = key.to_sym
expected_type = schema[ksym].class == Class ? schema[ksym] : Hash
if !schema.include?(ksym)
puts "Warning: unknown field '#{ksym}' under... | [
"def",
"validate_data",
"(",
"rootname",
",",
"source",
",",
"schema",
")",
"return",
"nil",
"if",
"source",
".",
"nil?",
"good_data",
"=",
"{",
"}",
"source",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"ksym",
"=",
"key",
".",
"to_sym",
"expe... | validate a data source according to a schema
print out warnings for bad fields, and return only the good ones
@param rootname [String] the name, for printing
@param source [Hash] source data
@param schema [Hash] a mapping of field names to their expected type
@return [Hash] a copy, containing only expected & valid... | [
"validate",
"a",
"data",
"source",
"according",
"to",
"a",
"schema",
"print",
"out",
"warnings",
"for",
"bad",
"fields",
"and",
"return",
"only",
"the",
"good",
"ones"
] | cb3fe8df14a744b9a3bc5cdc0168f820f78cde57 | https://github.com/ianfixes/arduino_ci/blob/cb3fe8df14a744b9a3bc5cdc0168f820f78cde57/lib/arduino_ci/ci_config.rb#L103-L121 | train |
ianfixes/arduino_ci | lib/arduino_ci/ci_config.rb | ArduinoCI.CIConfig.load_yaml | def load_yaml(path)
yml = YAML.load_file(path)
raise ConfigurationError, "The YAML file at #{path} failed to load" unless yml
apply_configuration(yml)
end | ruby | def load_yaml(path)
yml = YAML.load_file(path)
raise ConfigurationError, "The YAML file at #{path} failed to load" unless yml
apply_configuration(yml)
end | [
"def",
"load_yaml",
"(",
"path",
")",
"yml",
"=",
"YAML",
".",
"load_file",
"(",
"path",
")",
"raise",
"ConfigurationError",
",",
"\"The YAML file at #{path} failed to load\"",
"unless",
"yml",
"apply_configuration",
"(",
"yml",
")",
"end"
] | Load configuration yaml from a file
@param path [String] the source file
@return [ArduinoCI::CIConfig] a reference to self | [
"Load",
"configuration",
"yaml",
"from",
"a",
"file"
] | cb3fe8df14a744b9a3bc5cdc0168f820f78cde57 | https://github.com/ianfixes/arduino_ci/blob/cb3fe8df14a744b9a3bc5cdc0168f820f78cde57/lib/arduino_ci/ci_config.rb#L126-L131 | train |
ianfixes/arduino_ci | lib/arduino_ci/ci_config.rb | ArduinoCI.CIConfig.apply_configuration | def apply_configuration(yml)
if yml.include?("packages")
yml["packages"].each do |k, v|
valid_data = validate_data("packages", v, PACKAGE_SCHEMA)
@package_info[k] = valid_data
end
end
if yml.include?("platforms")
yml["platforms"].each do |k, v|
va... | ruby | def apply_configuration(yml)
if yml.include?("packages")
yml["packages"].each do |k, v|
valid_data = validate_data("packages", v, PACKAGE_SCHEMA)
@package_info[k] = valid_data
end
end
if yml.include?("platforms")
yml["platforms"].each do |k, v|
va... | [
"def",
"apply_configuration",
"(",
"yml",
")",
"if",
"yml",
".",
"include?",
"(",
"\"packages\"",
")",
"yml",
"[",
"\"packages\"",
"]",
".",
"each",
"do",
"|",
"k",
",",
"v",
"|",
"valid_data",
"=",
"validate_data",
"(",
"\"packages\"",
",",
"v",
",",
... | Load configuration from a hash
@param yml [Hash] the source data
@return [ArduinoCI::CIConfig] a reference to self | [
"Load",
"configuration",
"from",
"a",
"hash"
] | cb3fe8df14a744b9a3bc5cdc0168f820f78cde57 | https://github.com/ianfixes/arduino_ci/blob/cb3fe8df14a744b9a3bc5cdc0168f820f78cde57/lib/arduino_ci/ci_config.rb#L136-L162 | train |
ianfixes/arduino_ci | lib/arduino_ci/ci_config.rb | ArduinoCI.CIConfig.with_config | def with_config(base_dir, val_when_no_match)
CONFIG_FILENAMES.each do |f|
path = base_dir.nil? ? f : File.join(base_dir, f)
return (yield path) if File.exist?(path)
end
val_when_no_match
end | ruby | def with_config(base_dir, val_when_no_match)
CONFIG_FILENAMES.each do |f|
path = base_dir.nil? ? f : File.join(base_dir, f)
return (yield path) if File.exist?(path)
end
val_when_no_match
end | [
"def",
"with_config",
"(",
"base_dir",
",",
"val_when_no_match",
")",
"CONFIG_FILENAMES",
".",
"each",
"do",
"|",
"f",
"|",
"path",
"=",
"base_dir",
".",
"nil?",
"?",
"f",
":",
"File",
".",
"join",
"(",
"base_dir",
",",
"f",
")",
"return",
"(",
"yield"... | Get the config file at a given path, if it exists, and pass that to a block.
Many config files may exist, but only the first match is used
@param base_dir [String] The directory in which to search for a config file
@param val_when_no_match [Object] The value to return if no config files are found
@yield [path] Proc... | [
"Get",
"the",
"config",
"file",
"at",
"a",
"given",
"path",
"if",
"it",
"exists",
"and",
"pass",
"that",
"to",
"a",
"block",
".",
"Many",
"config",
"files",
"may",
"exist",
"but",
"only",
"the",
"first",
"match",
"is",
"used"
] | cb3fe8df14a744b9a3bc5cdc0168f820f78cde57 | https://github.com/ianfixes/arduino_ci/blob/cb3fe8df14a744b9a3bc5cdc0168f820f78cde57/lib/arduino_ci/ci_config.rb#L201-L207 | train |
ianfixes/arduino_ci | lib/arduino_ci/ci_config.rb | ArduinoCI.CIConfig.from_example | def from_example(example_path)
base_dir = File.directory?(example_path) ? example_path : File.dirname(example_path)
with_config(base_dir, self) { |path| with_override(path) }
end | ruby | def from_example(example_path)
base_dir = File.directory?(example_path) ? example_path : File.dirname(example_path)
with_config(base_dir, self) { |path| with_override(path) }
end | [
"def",
"from_example",
"(",
"example_path",
")",
"base_dir",
"=",
"File",
".",
"directory?",
"(",
"example_path",
")",
"?",
"example_path",
":",
"File",
".",
"dirname",
"(",
"example_path",
")",
"with_config",
"(",
"base_dir",
",",
"self",
")",
"{",
"|",
"... | Produce a configuration override taken from an Arduino library example path
handle either path to example file or example dir
@param path [String] the path to the settings yaml file
@return [ArduinoCI::CIConfig] the new settings object | [
"Produce",
"a",
"configuration",
"override",
"taken",
"from",
"an",
"Arduino",
"library",
"example",
"path",
"handle",
"either",
"path",
"to",
"example",
"file",
"or",
"example",
"dir"
] | cb3fe8df14a744b9a3bc5cdc0168f820f78cde57 | https://github.com/ianfixes/arduino_ci/blob/cb3fe8df14a744b9a3bc5cdc0168f820f78cde57/lib/arduino_ci/ci_config.rb#L219-L222 | train |
activemerchant/offsite_payments | lib/offsite_payments/action_view_helper.rb | OffsitePayments.ActionViewHelper.payment_service_for | def payment_service_for(order, account, options = {}, &proc)
raise ArgumentError, "Missing block" unless block_given?
integration_module = OffsitePayments::integration(options.delete(:service).to_s)
service_class = integration_module.const_get('Helper')
form_options = options.delete(:html) || ... | ruby | def payment_service_for(order, account, options = {}, &proc)
raise ArgumentError, "Missing block" unless block_given?
integration_module = OffsitePayments::integration(options.delete(:service).to_s)
service_class = integration_module.const_get('Helper')
form_options = options.delete(:html) || ... | [
"def",
"payment_service_for",
"(",
"order",
",",
"account",
",",
"options",
"=",
"{",
"}",
",",
"&",
"proc",
")",
"raise",
"ArgumentError",
",",
"\"Missing block\"",
"unless",
"block_given?",
"integration_module",
"=",
"OffsitePayments",
"::",
"integration",
"(",
... | This helper allows the usage of different payment integrations
through a single form helper. Payment integrations are the
type of service where the user is redirected to the secure
site of the service, like Paypal or Chronopay.
The helper creates a scope around a payment service helper
which provides the specifi... | [
"This",
"helper",
"allows",
"the",
"usage",
"of",
"different",
"payment",
"integrations",
"through",
"a",
"single",
"form",
"helper",
".",
"Payment",
"integrations",
"are",
"the",
"type",
"of",
"service",
"where",
"the",
"user",
"is",
"redirected",
"to",
"the"... | e331582d3d7b4cc479c83355f1748ea407efc66f | https://github.com/activemerchant/offsite_payments/blob/e331582d3d7b4cc479c83355f1748ea407efc66f/lib/offsite_payments/action_view_helper.rb#L42-L70 | train |
activemerchant/offsite_payments | lib/offsite_payments/notification.rb | OffsitePayments.Notification.valid_sender? | def valid_sender?(ip)
return true if OffsitePayments.mode == :test || production_ips.blank?
production_ips.include?(ip)
end | ruby | def valid_sender?(ip)
return true if OffsitePayments.mode == :test || production_ips.blank?
production_ips.include?(ip)
end | [
"def",
"valid_sender?",
"(",
"ip",
")",
"return",
"true",
"if",
"OffsitePayments",
".",
"mode",
"==",
":test",
"||",
"production_ips",
".",
"blank?",
"production_ips",
".",
"include?",
"(",
"ip",
")",
"end"
] | Check if the request comes from an official IP | [
"Check",
"if",
"the",
"request",
"comes",
"from",
"an",
"official",
"IP"
] | e331582d3d7b4cc479c83355f1748ea407efc66f | https://github.com/activemerchant/offsite_payments/blob/e331582d3d7b4cc479c83355f1748ea407efc66f/lib/offsite_payments/notification.rb#L46-L49 | train |
activemerchant/offsite_payments | lib/offsite_payments/helper.rb | OffsitePayments.Helper.add_field | def add_field(name, value)
return if name.blank? || value.blank?
@fields[name.to_s] = value.to_s
end | ruby | def add_field(name, value)
return if name.blank? || value.blank?
@fields[name.to_s] = value.to_s
end | [
"def",
"add_field",
"(",
"name",
",",
"value",
")",
"return",
"if",
"name",
".",
"blank?",
"||",
"value",
".",
"blank?",
"@fields",
"[",
"name",
".",
"to_s",
"]",
"=",
"value",
".",
"to_s",
"end"
] | Add an input in the form. Useful when gateway requires some uncommon
fields not provided by the gem.
# inside `payment_service_for do |service|` block
service.add_field('c_id','_xclick')
Gateway implementor can also use this to add default fields in the form:
# in a subclass of ActiveMerchant::Billing::Integrat... | [
"Add",
"an",
"input",
"in",
"the",
"form",
".",
"Useful",
"when",
"gateway",
"requires",
"some",
"uncommon",
"fields",
"not",
"provided",
"by",
"the",
"gem",
"."
] | e331582d3d7b4cc479c83355f1748ea407efc66f | https://github.com/activemerchant/offsite_payments/blob/e331582d3d7b4cc479c83355f1748ea407efc66f/lib/offsite_payments/helper.rb#L93-L96 | train |
Airtable/airtable-ruby | lib/airtable/record.rb | Airtable.Record.[]= | def []=(name, value)
@column_keys << name
@attrs[to_key(name)] = value
define_accessor(name) unless respond_to?(name)
end | ruby | def []=(name, value)
@column_keys << name
@attrs[to_key(name)] = value
define_accessor(name) unless respond_to?(name)
end | [
"def",
"[]=",
"(",
"name",
",",
"value",
")",
"@column_keys",
"<<",
"name",
"@attrs",
"[",
"to_key",
"(",
"name",
")",
"]",
"=",
"value",
"define_accessor",
"(",
"name",
")",
"unless",
"respond_to?",
"(",
"name",
")",
"end"
] | Set the given attribute to value | [
"Set",
"the",
"given",
"attribute",
"to",
"value"
] | 041a8baf8ae59279630912d6ff329faa64398cb2 | https://github.com/Airtable/airtable-ruby/blob/041a8baf8ae59279630912d6ff329faa64398cb2/lib/airtable/record.rb#L17-L21 | train |
Airtable/airtable-ruby | lib/airtable/record.rb | Airtable.Record.override_attributes! | def override_attributes!(attrs={})
@column_keys = attrs.keys
@attrs = HashWithIndifferentAccess.new(Hash[attrs.map { |k, v| [ to_key(k), v ] }])
@attrs.map { |k, v| define_accessor(k) }
end | ruby | def override_attributes!(attrs={})
@column_keys = attrs.keys
@attrs = HashWithIndifferentAccess.new(Hash[attrs.map { |k, v| [ to_key(k), v ] }])
@attrs.map { |k, v| define_accessor(k) }
end | [
"def",
"override_attributes!",
"(",
"attrs",
"=",
"{",
"}",
")",
"@column_keys",
"=",
"attrs",
".",
"keys",
"@attrs",
"=",
"HashWithIndifferentAccess",
".",
"new",
"(",
"Hash",
"[",
"attrs",
".",
"map",
"{",
"|",
"k",
",",
"v",
"|",
"[",
"to_key",
"(",... | Removes old and add new attributes for the record | [
"Removes",
"old",
"and",
"add",
"new",
"attributes",
"for",
"the",
"record"
] | 041a8baf8ae59279630912d6ff329faa64398cb2 | https://github.com/Airtable/airtable-ruby/blob/041a8baf8ae59279630912d6ff329faa64398cb2/lib/airtable/record.rb#L31-L35 | train |
Airtable/airtable-ruby | lib/airtable/table.rb | Airtable.Table.find | def find(id)
result = self.class.get(worksheet_url + "/" + id).parsed_response
check_and_raise_error(result)
Record.new(result_attributes(result)) if result.present? && result["id"]
end | ruby | def find(id)
result = self.class.get(worksheet_url + "/" + id).parsed_response
check_and_raise_error(result)
Record.new(result_attributes(result)) if result.present? && result["id"]
end | [
"def",
"find",
"(",
"id",
")",
"result",
"=",
"self",
".",
"class",
".",
"get",
"(",
"worksheet_url",
"+",
"\"/\"",
"+",
"id",
")",
".",
"parsed_response",
"check_and_raise_error",
"(",
"result",
")",
"Record",
".",
"new",
"(",
"result_attributes",
"(",
... | Returns record based given row id | [
"Returns",
"record",
"based",
"given",
"row",
"id"
] | 041a8baf8ae59279630912d6ff329faa64398cb2 | https://github.com/Airtable/airtable-ruby/blob/041a8baf8ae59279630912d6ff329faa64398cb2/lib/airtable/table.rb#L55-L59 | train |
Airtable/airtable-ruby | lib/airtable/table.rb | Airtable.Table.create | def create(record)
result = self.class.post(worksheet_url,
:body => { "fields" => record.fields }.to_json,
:headers => { "Content-type" => "application/json" }).parsed_response
check_and_raise_error(result)
record.override_attributes!(result_attributes(result))
record
end | ruby | def create(record)
result = self.class.post(worksheet_url,
:body => { "fields" => record.fields }.to_json,
:headers => { "Content-type" => "application/json" }).parsed_response
check_and_raise_error(result)
record.override_attributes!(result_attributes(result))
record
end | [
"def",
"create",
"(",
"record",
")",
"result",
"=",
"self",
".",
"class",
".",
"post",
"(",
"worksheet_url",
",",
":body",
"=>",
"{",
"\"fields\"",
"=>",
"record",
".",
"fields",
"}",
".",
"to_json",
",",
":headers",
"=>",
"{",
"\"Content-type\"",
"=>",
... | Creates a record by posting to airtable | [
"Creates",
"a",
"record",
"by",
"posting",
"to",
"airtable"
] | 041a8baf8ae59279630912d6ff329faa64398cb2 | https://github.com/Airtable/airtable-ruby/blob/041a8baf8ae59279630912d6ff329faa64398cb2/lib/airtable/table.rb#L62-L71 | train |
Airtable/airtable-ruby | lib/airtable/table.rb | Airtable.Table.update | def update(record)
result = self.class.put(worksheet_url + "/" + record.id,
:body => { "fields" => record.fields_for_update }.to_json,
:headers => { "Content-type" => "application/json" }).parsed_response
check_and_raise_error(result)
record.override_attributes!(result_attributes(res... | ruby | def update(record)
result = self.class.put(worksheet_url + "/" + record.id,
:body => { "fields" => record.fields_for_update }.to_json,
:headers => { "Content-type" => "application/json" }).parsed_response
check_and_raise_error(result)
record.override_attributes!(result_attributes(res... | [
"def",
"update",
"(",
"record",
")",
"result",
"=",
"self",
".",
"class",
".",
"put",
"(",
"worksheet_url",
"+",
"\"/\"",
"+",
"record",
".",
"id",
",",
":body",
"=>",
"{",
"\"fields\"",
"=>",
"record",
".",
"fields_for_update",
"}",
".",
"to_json",
",... | Replaces record in airtable based on id | [
"Replaces",
"record",
"in",
"airtable",
"based",
"on",
"id"
] | 041a8baf8ae59279630912d6ff329faa64398cb2 | https://github.com/Airtable/airtable-ruby/blob/041a8baf8ae59279630912d6ff329faa64398cb2/lib/airtable/table.rb#L74-L84 | train |
ruby-numo/numo-narray | lib/numo/narray/extra.rb | Numo.NArray.triu! | def triu!(k=0)
if ndim < 2
raise NArray::ShapeError, "must be >= 2-dimensional array"
end
if contiguous?
*shp,m,n = shape
idx = tril_indices(k-1)
reshape!(*shp,m*n)
self[false,idx] = 0
reshape!(*shp,m,n)
else
store(triu(k))
end
en... | ruby | def triu!(k=0)
if ndim < 2
raise NArray::ShapeError, "must be >= 2-dimensional array"
end
if contiguous?
*shp,m,n = shape
idx = tril_indices(k-1)
reshape!(*shp,m*n)
self[false,idx] = 0
reshape!(*shp,m,n)
else
store(triu(k))
end
en... | [
"def",
"triu!",
"(",
"k",
"=",
"0",
")",
"if",
"ndim",
"<",
"2",
"raise",
"NArray",
"::",
"ShapeError",
",",
"\"must be >= 2-dimensional array\"",
"end",
"if",
"contiguous?",
"*",
"shp",
",",
"m",
",",
"n",
"=",
"shape",
"idx",
"=",
"tril_indices",
"(",
... | Upper triangular matrix.
Fill the self elements below the k-th diagonal with zero. | [
"Upper",
"triangular",
"matrix",
".",
"Fill",
"the",
"self",
"elements",
"below",
"the",
"k",
"-",
"th",
"diagonal",
"with",
"zero",
"."
] | 69c12dad12040486ac305d68d1f5fb32f07aba78 | https://github.com/ruby-numo/numo-narray/blob/69c12dad12040486ac305d68d1f5fb32f07aba78/lib/numo/narray/extra.rb#L1024-L1037 | train |
ruby-numo/numo-narray | lib/numo/narray/extra.rb | Numo.NArray.tril! | def tril!(k=0)
if ndim < 2
raise NArray::ShapeError, "must be >= 2-dimensional array"
end
if contiguous?
idx = triu_indices(k+1)
*shp,m,n = shape
reshape!(*shp,m*n)
self[false,idx] = 0
reshape!(*shp,m,n)
else
store(tril(k))
end
en... | ruby | def tril!(k=0)
if ndim < 2
raise NArray::ShapeError, "must be >= 2-dimensional array"
end
if contiguous?
idx = triu_indices(k+1)
*shp,m,n = shape
reshape!(*shp,m*n)
self[false,idx] = 0
reshape!(*shp,m,n)
else
store(tril(k))
end
en... | [
"def",
"tril!",
"(",
"k",
"=",
"0",
")",
"if",
"ndim",
"<",
"2",
"raise",
"NArray",
"::",
"ShapeError",
",",
"\"must be >= 2-dimensional array\"",
"end",
"if",
"contiguous?",
"idx",
"=",
"triu_indices",
"(",
"k",
"+",
"1",
")",
"*",
"shp",
",",
"m",
",... | Lower triangular matrix.
Fill the self elements above the k-th diagonal with zero. | [
"Lower",
"triangular",
"matrix",
".",
"Fill",
"the",
"self",
"elements",
"above",
"the",
"k",
"-",
"th",
"diagonal",
"with",
"zero",
"."
] | 69c12dad12040486ac305d68d1f5fb32f07aba78 | https://github.com/ruby-numo/numo-narray/blob/69c12dad12040486ac305d68d1f5fb32f07aba78/lib/numo/narray/extra.rb#L1063-L1076 | train |
ruby-numo/numo-narray | lib/numo/narray/extra.rb | Numo.NArray.diag_indices | def diag_indices(k=0)
if ndim < 2
raise NArray::ShapeError, "must be >= 2-dimensional array"
end
m,n = shape[-2..-1]
NArray.diag_indices(m,n,k)
end | ruby | def diag_indices(k=0)
if ndim < 2
raise NArray::ShapeError, "must be >= 2-dimensional array"
end
m,n = shape[-2..-1]
NArray.diag_indices(m,n,k)
end | [
"def",
"diag_indices",
"(",
"k",
"=",
"0",
")",
"if",
"ndim",
"<",
"2",
"raise",
"NArray",
"::",
"ShapeError",
",",
"\"must be >= 2-dimensional array\"",
"end",
"m",
",",
"n",
"=",
"shape",
"[",
"-",
"2",
"..",
"-",
"1",
"]",
"NArray",
".",
"diag_indic... | Return the k-th diagonal indices. | [
"Return",
"the",
"k",
"-",
"th",
"diagonal",
"indices",
"."
] | 69c12dad12040486ac305d68d1f5fb32f07aba78 | https://github.com/ruby-numo/numo-narray/blob/69c12dad12040486ac305d68d1f5fb32f07aba78/lib/numo/narray/extra.rb#L1095-L1101 | train |
ruby-numo/numo-narray | lib/numo/narray/extra.rb | Numo.NArray.diag | def diag(k=0)
*shp,n = shape
n += k.abs
a = self.class.zeros(*shp,n,n)
a.diagonal(k).store(self)
a
end | ruby | def diag(k=0)
*shp,n = shape
n += k.abs
a = self.class.zeros(*shp,n,n)
a.diagonal(k).store(self)
a
end | [
"def",
"diag",
"(",
"k",
"=",
"0",
")",
"*",
"shp",
",",
"n",
"=",
"shape",
"n",
"+=",
"k",
".",
"abs",
"a",
"=",
"self",
".",
"class",
".",
"zeros",
"(",
"*",
"shp",
",",
"n",
",",
"n",
")",
"a",
".",
"diagonal",
"(",
"k",
")",
".",
"s... | Return a matrix whose diagonal is constructed by self along the last axis. | [
"Return",
"a",
"matrix",
"whose",
"diagonal",
"is",
"constructed",
"by",
"self",
"along",
"the",
"last",
"axis",
"."
] | 69c12dad12040486ac305d68d1f5fb32f07aba78 | https://github.com/ruby-numo/numo-narray/blob/69c12dad12040486ac305d68d1f5fb32f07aba78/lib/numo/narray/extra.rb#L1111-L1117 | train |
ruby-numo/numo-narray | lib/numo/narray/extra.rb | Numo.NArray.trace | def trace(offset=nil,axis=nil,nan:false)
diagonal(offset,axis).sum(nan:nan,axis:-1)
end | ruby | def trace(offset=nil,axis=nil,nan:false)
diagonal(offset,axis).sum(nan:nan,axis:-1)
end | [
"def",
"trace",
"(",
"offset",
"=",
"nil",
",",
"axis",
"=",
"nil",
",",
"nan",
":",
"false",
")",
"diagonal",
"(",
"offset",
",",
"axis",
")",
".",
"sum",
"(",
"nan",
":",
"nan",
",",
"axis",
":",
"-",
"1",
")",
"end"
] | Return the sum along diagonals of the array.
If 2-D array, computes the summation along its diagonal with the
given offset, i.e., sum of `a[i,i+offset]`.
If more than 2-D array, the diagonal is determined from the axes
specified by axis argument. The default is axis=[-2,-1].
@param offset [Integer] (optional, def... | [
"Return",
"the",
"sum",
"along",
"diagonals",
"of",
"the",
"array",
"."
] | 69c12dad12040486ac305d68d1f5fb32f07aba78 | https://github.com/ruby-numo/numo-narray/blob/69c12dad12040486ac305d68d1f5fb32f07aba78/lib/numo/narray/extra.rb#L1129-L1131 | train |
ruby-numo/numo-narray | lib/numo/narray/extra.rb | Numo.NArray.dot | def dot(b)
t = self.class::UPCAST[b.class]
if defined?(Linalg) && [SFloat,DFloat,SComplex,DComplex].include?(t)
Linalg.dot(self,b)
else
b = self.class.asarray(b)
case b.ndim
when 1
mulsum(b, axis:-1)
else
case ndim
when 0
... | ruby | def dot(b)
t = self.class::UPCAST[b.class]
if defined?(Linalg) && [SFloat,DFloat,SComplex,DComplex].include?(t)
Linalg.dot(self,b)
else
b = self.class.asarray(b)
case b.ndim
when 1
mulsum(b, axis:-1)
else
case ndim
when 0
... | [
"def",
"dot",
"(",
"b",
")",
"t",
"=",
"self",
".",
"class",
"::",
"UPCAST",
"[",
"b",
".",
"class",
"]",
"if",
"defined?",
"(",
"Linalg",
")",
"&&",
"[",
"SFloat",
",",
"DFloat",
",",
"SComplex",
",",
"DComplex",
"]",
".",
"include?",
"(",
"t",
... | Dot product of two arrays.
@param b [Numo::NArray]
@return [Numo::NArray] return dot product | [
"Dot",
"product",
"of",
"two",
"arrays",
"."
] | 69c12dad12040486ac305d68d1f5fb32f07aba78 | https://github.com/ruby-numo/numo-narray/blob/69c12dad12040486ac305d68d1f5fb32f07aba78/lib/numo/narray/extra.rb#L1140-L1171 | train |
ruby-numo/numo-narray | lib/numo/narray/extra.rb | Numo.NArray.kron | def kron(b)
b = NArray.cast(b)
nda = ndim
ndb = b.ndim
shpa = shape
shpb = b.shape
adim = [:new]*(2*[ndb-nda,0].max) + [true,:new]*nda
bdim = [:new]*(2*[nda-ndb,0].max) + [:new,true]*ndb
shpr = (-[nda,ndb].max..-1).map{|i| (shpa[i]||1) * (shpb[i]||1)}
(self[*adim] *... | ruby | def kron(b)
b = NArray.cast(b)
nda = ndim
ndb = b.ndim
shpa = shape
shpb = b.shape
adim = [:new]*(2*[ndb-nda,0].max) + [true,:new]*nda
bdim = [:new]*(2*[nda-ndb,0].max) + [:new,true]*ndb
shpr = (-[nda,ndb].max..-1).map{|i| (shpa[i]||1) * (shpb[i]||1)}
(self[*adim] *... | [
"def",
"kron",
"(",
"b",
")",
"b",
"=",
"NArray",
".",
"cast",
"(",
"b",
")",
"nda",
"=",
"ndim",
"ndb",
"=",
"b",
".",
"ndim",
"shpa",
"=",
"shape",
"shpb",
"=",
"b",
".",
"shape",
"adim",
"=",
"[",
":new",
"]",
"*",
"(",
"2",
"*",
"[",
... | Kronecker product of two arrays.
kron(a,b)[k_0, k_1, ...] = a[i_0, i_1, ...] * b[j_0, j_1, ...]
where: k_n = i_n * b.shape[n] + j_n
@param b [Numo::NArray]
@return [Numo::NArray] return Kronecker product
@example
Numo::DFloat[1,10,100].kron([5,6,7])
=> Numo::DFloat#shape=[9]
[5, 6, 7, 50, 6... | [
"Kronecker",
"product",
"of",
"two",
"arrays",
"."
] | 69c12dad12040486ac305d68d1f5fb32f07aba78 | https://github.com/ruby-numo/numo-narray/blob/69c12dad12040486ac305d68d1f5fb32f07aba78/lib/numo/narray/extra.rb#L1243-L1253 | train |
cburnette/boxr | lib/boxr/collaborations.rb | Boxr.Client.pending_collaborations | def pending_collaborations(fields: [])
query = build_fields_query(fields, COLLABORATION_FIELDS_QUERY)
query[:status] = :pending
pending_collaborations, response = get(COLLABORATIONS_URI, query: query)
pending_collaborations['entries']
end | ruby | def pending_collaborations(fields: [])
query = build_fields_query(fields, COLLABORATION_FIELDS_QUERY)
query[:status] = :pending
pending_collaborations, response = get(COLLABORATIONS_URI, query: query)
pending_collaborations['entries']
end | [
"def",
"pending_collaborations",
"(",
"fields",
":",
"[",
"]",
")",
"query",
"=",
"build_fields_query",
"(",
"fields",
",",
"COLLABORATION_FIELDS_QUERY",
")",
"query",
"[",
":status",
"]",
"=",
":pending",
"pending_collaborations",
",",
"response",
"=",
"get",
"... | these are pending collaborations for the current user; use the As-User Header to request for different users | [
"these",
"are",
"pending",
"collaborations",
"for",
"the",
"current",
"user",
";",
"use",
"the",
"As",
"-",
"User",
"Header",
"to",
"request",
"for",
"different",
"users"
] | 5e68c8c3640f33d709d4830ce34631864b1f5db5 | https://github.com/cburnette/boxr/blob/5e68c8c3640f33d709d4830ce34631864b1f5db5/lib/boxr/collaborations.rb#L56-L61 | train |
hanami/router | lib/hanami/router.rb | Hanami.Router.redirect | def redirect(path, options = {}, &endpoint)
destination_path = @router.find(options)
get(path).redirect(destination_path, options[:code] || 301).tap do |route|
route.dest = Hanami::Routing::RedirectEndpoint.new(destination_path, route.dest)
end
end | ruby | def redirect(path, options = {}, &endpoint)
destination_path = @router.find(options)
get(path).redirect(destination_path, options[:code] || 301).tap do |route|
route.dest = Hanami::Routing::RedirectEndpoint.new(destination_path, route.dest)
end
end | [
"def",
"redirect",
"(",
"path",
",",
"options",
"=",
"{",
"}",
",",
"&",
"endpoint",
")",
"destination_path",
"=",
"@router",
".",
"find",
"(",
"options",
")",
"get",
"(",
"path",
")",
".",
"redirect",
"(",
"destination_path",
",",
"options",
"[",
":co... | Defines an HTTP redirect
@param path [String] the path that needs to be redirected
@param options [Hash] the options to customize the redirect behavior
@option options [Fixnum] the HTTP status to return (defaults to `301`)
@return [Hanami::Routing::Route] the generated route.
This may vary according to the `:r... | [
"Defines",
"an",
"HTTP",
"redirect"
] | 05bb4fb3fce8ff9a9f32858412cc31890d3c1aa7 | https://github.com/hanami/router/blob/05bb4fb3fce8ff9a9f32858412cc31890d3c1aa7/lib/hanami/router.rb#L624-L629 | train |
hanami/router | lib/hanami/router.rb | Hanami.Router.recognize | def recognize(env, options = {}, params = nil)
require 'hanami/routing/recognized_route'
env = env_for(env, options, params)
responses, _ = *@router.recognize(env)
Routing::RecognizedRoute.new(
responses.nil? ? responses : responses.first,
env, @router)
end | ruby | def recognize(env, options = {}, params = nil)
require 'hanami/routing/recognized_route'
env = env_for(env, options, params)
responses, _ = *@router.recognize(env)
Routing::RecognizedRoute.new(
responses.nil? ? responses : responses.first,
env, @router)
end | [
"def",
"recognize",
"(",
"env",
",",
"options",
"=",
"{",
"}",
",",
"params",
"=",
"nil",
")",
"require",
"'hanami/routing/recognized_route'",
"env",
"=",
"env_for",
"(",
"env",
",",
"options",
",",
"params",
")",
"responses",
",",
"_",
"=",
"*",
"@route... | Recognize the given env, path, or name and return a route for testing
inspection.
If the route cannot be recognized, it still returns an object for testing
inspection.
@param env [Hash, String, Symbol] Rack env, path or route name
@param options [Hash] a set of options for Rack env or route params
@param params... | [
"Recognize",
"the",
"given",
"env",
"path",
"or",
"name",
"and",
"return",
"a",
"route",
"for",
"testing",
"inspection",
"."
] | 05bb4fb3fce8ff9a9f32858412cc31890d3c1aa7 | https://github.com/hanami/router/blob/05bb4fb3fce8ff9a9f32858412cc31890d3c1aa7/lib/hanami/router.rb#L1130-L1139 | train |
hanami/router | lib/hanami/router.rb | Hanami.Router.env_for | def env_for(env, options = {}, params = nil)
env = case env
when String
Rack::MockRequest.env_for(env, options)
when Symbol
begin
url = path(env, params || options)
return env_for(url, options)
rescue Hanami::Routing::InvalidRouteException
{}
... | ruby | def env_for(env, options = {}, params = nil)
env = case env
when String
Rack::MockRequest.env_for(env, options)
when Symbol
begin
url = path(env, params || options)
return env_for(url, options)
rescue Hanami::Routing::InvalidRouteException
{}
... | [
"def",
"env_for",
"(",
"env",
",",
"options",
"=",
"{",
"}",
",",
"params",
"=",
"nil",
")",
"env",
"=",
"case",
"env",
"when",
"String",
"Rack",
"::",
"MockRequest",
".",
"env_for",
"(",
"env",
",",
"options",
")",
"when",
"Symbol",
"begin",
"url",
... | Fabricate Rack env for the given Rack env, path or named route
@param env [Hash, String, Symbol] Rack env, path or route name
@param options [Hash] a set of options for Rack env or route params
@param params [Hash] a set of params
@return [Hash] Rack env
@since 0.5.0
@api private
@see Hanami::Router#recogniz... | [
"Fabricate",
"Rack",
"env",
"for",
"the",
"given",
"Rack",
"env",
"path",
"or",
"named",
"route"
] | 05bb4fb3fce8ff9a9f32858412cc31890d3c1aa7 | https://github.com/hanami/router/blob/05bb4fb3fce8ff9a9f32858412cc31890d3c1aa7/lib/hanami/router.rb#L1236-L1250 | train |
biola/turnout | lib/turnout/i18n/accept_language_parser.rb | Turnout.AcceptLanguageParser.user_preferred_languages | def user_preferred_languages
return [] if header.to_s.strip.empty?
@user_preferred_languages ||= begin
header.to_s.gsub(/\s+/, '').split(',').map do |language|
locale, quality = language.split(';q=')
raise ArgumentError, 'Not correctly formatted' unless locale =~ /^[a-z\-0-9]+|\*... | ruby | def user_preferred_languages
return [] if header.to_s.strip.empty?
@user_preferred_languages ||= begin
header.to_s.gsub(/\s+/, '').split(',').map do |language|
locale, quality = language.split(';q=')
raise ArgumentError, 'Not correctly formatted' unless locale =~ /^[a-z\-0-9]+|\*... | [
"def",
"user_preferred_languages",
"return",
"[",
"]",
"if",
"header",
".",
"to_s",
".",
"strip",
".",
"empty?",
"@user_preferred_languages",
"||=",
"begin",
"header",
".",
"to_s",
".",
"gsub",
"(",
"/",
"\\s",
"/",
",",
"''",
")",
".",
"split",
"(",
"',... | Returns a sorted array based on user preference in HTTP_ACCEPT_LANGUAGE.
Browsers send this HTTP header, so don't think this is holy.
Example:
request.user_preferred_languages
# => [ 'nl-NL', 'nl-BE', 'nl', 'en-US', 'en' ] | [
"Returns",
"a",
"sorted",
"array",
"based",
"on",
"user",
"preference",
"in",
"HTTP_ACCEPT_LANGUAGE",
".",
"Browsers",
"send",
"this",
"HTTP",
"header",
"so",
"don",
"t",
"think",
"this",
"is",
"holy",
"."
] | 9c57f9d75e31904bc345ecceb9ec392ce3fdb634 | https://github.com/biola/turnout/blob/9c57f9d75e31904bc345ecceb9ec392ce3fdb634/lib/turnout/i18n/accept_language_parser.rb#L17-L36 | train |
biola/turnout | lib/turnout/i18n/accept_language_parser.rb | Turnout.AcceptLanguageParser.compatible_language_from | def compatible_language_from(available_languages)
user_preferred_languages.map do |preferred| #en-US
preferred = preferred.downcase
preferred_language = preferred.split('-', 2).first
available_languages.find do |available| # en
available = available.to_s.downcase
prefe... | ruby | def compatible_language_from(available_languages)
user_preferred_languages.map do |preferred| #en-US
preferred = preferred.downcase
preferred_language = preferred.split('-', 2).first
available_languages.find do |available| # en
available = available.to_s.downcase
prefe... | [
"def",
"compatible_language_from",
"(",
"available_languages",
")",
"user_preferred_languages",
".",
"map",
"do",
"|",
"preferred",
"|",
"preferred",
"=",
"preferred",
".",
"downcase",
"preferred_language",
"=",
"preferred",
".",
"split",
"(",
"'-'",
",",
"2",
")"... | Returns the first of the user_preferred_languages that is compatible
with the available locales. Ignores region.
Example:
request.compatible_language_from I18n.available_locales | [
"Returns",
"the",
"first",
"of",
"the",
"user_preferred_languages",
"that",
"is",
"compatible",
"with",
"the",
"available",
"locales",
".",
"Ignores",
"region",
"."
] | 9c57f9d75e31904bc345ecceb9ec392ce3fdb634 | https://github.com/biola/turnout/blob/9c57f9d75e31904bc345ecceb9ec392ce3fdb634/lib/turnout/i18n/accept_language_parser.rb#L62-L72 | train |
biola/turnout | lib/turnout/i18n/accept_language_parser.rb | Turnout.AcceptLanguageParser.sanitize_available_locales | def sanitize_available_locales(available_languages)
available_languages.map do |available|
available.to_s.split(/[_-]/).reject { |part| part.start_with?("x") }.join("-")
end
end | ruby | def sanitize_available_locales(available_languages)
available_languages.map do |available|
available.to_s.split(/[_-]/).reject { |part| part.start_with?("x") }.join("-")
end
end | [
"def",
"sanitize_available_locales",
"(",
"available_languages",
")",
"available_languages",
".",
"map",
"do",
"|",
"available",
"|",
"available",
".",
"to_s",
".",
"split",
"(",
"/",
"/",
")",
".",
"reject",
"{",
"|",
"part",
"|",
"part",
".",
"start_with?"... | Returns a supplied list of available locals without any extra application info
that may be attached to the locale for storage in the application.
Example:
[ja_JP-x1, en-US-x4, en_UK-x5, fr-FR-x3] => [ja-JP, en-US, en-UK, fr-FR] | [
"Returns",
"a",
"supplied",
"list",
"of",
"available",
"locals",
"without",
"any",
"extra",
"application",
"info",
"that",
"may",
"be",
"attached",
"to",
"the",
"locale",
"for",
"storage",
"in",
"the",
"application",
"."
] | 9c57f9d75e31904bc345ecceb9ec392ce3fdb634 | https://github.com/biola/turnout/blob/9c57f9d75e31904bc345ecceb9ec392ce3fdb634/lib/turnout/i18n/accept_language_parser.rb#L80-L84 | train |
biola/turnout | lib/turnout/i18n/accept_language_parser.rb | Turnout.AcceptLanguageParser.language_region_compatible_from | def language_region_compatible_from(available_languages)
available_languages = sanitize_available_locales(available_languages)
user_preferred_languages.map do |preferred| #en-US
preferred = preferred.downcase
preferred_language = preferred.split('-', 2).first
lang_group = available_... | ruby | def language_region_compatible_from(available_languages)
available_languages = sanitize_available_locales(available_languages)
user_preferred_languages.map do |preferred| #en-US
preferred = preferred.downcase
preferred_language = preferred.split('-', 2).first
lang_group = available_... | [
"def",
"language_region_compatible_from",
"(",
"available_languages",
")",
"available_languages",
"=",
"sanitize_available_locales",
"(",
"available_languages",
")",
"user_preferred_languages",
".",
"map",
"do",
"|",
"preferred",
"|",
"preferred",
"=",
"preferred",
".",
"... | Returns the first of the user preferred languages that is
also found in available languages. Finds best fit by matching on
primary language first and secondarily on region. If no matching region is
found, return the first language in the group matching that primary language.
Example:
request.language_region_... | [
"Returns",
"the",
"first",
"of",
"the",
"user",
"preferred",
"languages",
"that",
"is",
"also",
"found",
"in",
"available",
"languages",
".",
"Finds",
"best",
"fit",
"by",
"matching",
"on",
"primary",
"language",
"first",
"and",
"secondarily",
"on",
"region",
... | 9c57f9d75e31904bc345ecceb9ec392ce3fdb634 | https://github.com/biola/turnout/blob/9c57f9d75e31904bc345ecceb9ec392ce3fdb634/lib/turnout/i18n/accept_language_parser.rb#L95-L107 | train |
biola/turnout | lib/turnout/ordered_options.rb | Turnout.OrderedOptions.update | def update(other_hash)
if other_hash.is_a? Hash
super(other_hash)
else
other_hash.to_hash.each_pair do |key, value|
if block_given?
value = yield(key, value)
end
self[key] = value
end
self
end
end | ruby | def update(other_hash)
if other_hash.is_a? Hash
super(other_hash)
else
other_hash.to_hash.each_pair do |key, value|
if block_given?
value = yield(key, value)
end
self[key] = value
end
self
end
end | [
"def",
"update",
"(",
"other_hash",
")",
"if",
"other_hash",
".",
"is_a?",
"Hash",
"super",
"(",
"other_hash",
")",
"else",
"other_hash",
".",
"to_hash",
".",
"each_pair",
"do",
"|",
"key",
",",
"value",
"|",
"if",
"block_given?",
"value",
"=",
"yield",
... | make it protected | [
"make",
"it",
"protected"
] | 9c57f9d75e31904bc345ecceb9ec392ce3fdb634 | https://github.com/biola/turnout/blob/9c57f9d75e31904bc345ecceb9ec392ce3fdb634/lib/turnout/ordered_options.rb#L19-L31 | train |
schacon/git-scribe | docbook-xsl/epub/bin/lib/docbook.rb | DocBook.Epub.has_callouts? | def has_callouts?
parser = REXML::Parsers::PullParser.new(File.new(@docbook_file))
while parser.has_next?
el = parser.pull
if el.start_element? and (el[0] == "calloutlist" or el[0] == "co")
return true
end
end
return false
end | ruby | def has_callouts?
parser = REXML::Parsers::PullParser.new(File.new(@docbook_file))
while parser.has_next?
el = parser.pull
if el.start_element? and (el[0] == "calloutlist" or el[0] == "co")
return true
end
end
return false
end | [
"def",
"has_callouts?",
"parser",
"=",
"REXML",
"::",
"Parsers",
"::",
"PullParser",
".",
"new",
"(",
"File",
".",
"new",
"(",
"@docbook_file",
")",
")",
"while",
"parser",
".",
"has_next?",
"el",
"=",
"parser",
".",
"pull",
"if",
"el",
".",
"start_eleme... | Returns true if the document has code callouts | [
"Returns",
"true",
"if",
"the",
"document",
"has",
"code",
"callouts"
] | 41424bb312975cc49ed9716a932e216485ebf2d3 | https://github.com/schacon/git-scribe/blob/41424bb312975cc49ed9716a932e216485ebf2d3/docbook-xsl/epub/bin/lib/docbook.rb#L195-L204 | train |
piotrmurach/pastel | lib/pastel/delegator.rb | Pastel.Delegator.evaluate_block | def evaluate_block(&block)
delegator = self.class.new(resolver, DecoratorChain.empty)
delegator.instance_eval(&block)
end | ruby | def evaluate_block(&block)
delegator = self.class.new(resolver, DecoratorChain.empty)
delegator.instance_eval(&block)
end | [
"def",
"evaluate_block",
"(",
"&",
"block",
")",
"delegator",
"=",
"self",
".",
"class",
".",
"new",
"(",
"resolver",
",",
"DecoratorChain",
".",
"empty",
")",
"delegator",
".",
"instance_eval",
"(",
"&",
"block",
")",
"end"
] | Evaluate color block
@api private | [
"Evaluate",
"color",
"block"
] | 799c122b88de4f3676a960bdf620199ad7219d3f | https://github.com/piotrmurach/pastel/blob/799c122b88de4f3676a960bdf620199ad7219d3f/lib/pastel/delegator.rb#L87-L90 | train |
piotrmurach/pastel | lib/pastel/color.rb | Pastel.Color.decorate | def decorate(string, *colors)
return string if blank?(string) || !enabled || colors.empty?
ansi_colors = lookup(*colors.dup.uniq)
if eachline
string.dup.split(eachline).map! do |line|
apply_codes(line, ansi_colors)
end.join(eachline)
else
apply_codes(string.dup... | ruby | def decorate(string, *colors)
return string if blank?(string) || !enabled || colors.empty?
ansi_colors = lookup(*colors.dup.uniq)
if eachline
string.dup.split(eachline).map! do |line|
apply_codes(line, ansi_colors)
end.join(eachline)
else
apply_codes(string.dup... | [
"def",
"decorate",
"(",
"string",
",",
"*",
"colors",
")",
"return",
"string",
"if",
"blank?",
"(",
"string",
")",
"||",
"!",
"enabled",
"||",
"colors",
".",
"empty?",
"ansi_colors",
"=",
"lookup",
"(",
"*",
"colors",
".",
"dup",
".",
"uniq",
")",
"i... | Apply ANSI color to the given string.
Wraps eachline with clear escape.
@param [String] string
text to add ANSI strings
@param [Array[Symbol]] colors
the color names
@example
color.decorate "text", :yellow, :on_green, :underline
@return [String]
the colored string
@api public | [
"Apply",
"ANSI",
"color",
"to",
"the",
"given",
"string",
"."
] | 799c122b88de4f3676a960bdf620199ad7219d3f | https://github.com/piotrmurach/pastel/blob/799c122b88de4f3676a960bdf620199ad7219d3f/lib/pastel/color.rb#L57-L68 | train |
piotrmurach/pastel | lib/pastel/color.rb | Pastel.Color.strip | def strip(*strings)
modified = strings.map { |string| string.dup.gsub(ANSI_COLOR_REGEXP, '') }
modified.size == 1 ? modified[0] : modified
end | ruby | def strip(*strings)
modified = strings.map { |string| string.dup.gsub(ANSI_COLOR_REGEXP, '') }
modified.size == 1 ? modified[0] : modified
end | [
"def",
"strip",
"(",
"*",
"strings",
")",
"modified",
"=",
"strings",
".",
"map",
"{",
"|",
"string",
"|",
"string",
".",
"dup",
".",
"gsub",
"(",
"ANSI_COLOR_REGEXP",
",",
"''",
")",
"}",
"modified",
".",
"size",
"==",
"1",
"?",
"modified",
"[",
"... | Strip ANSI color codes from a string.
Only ANSI color codes are removed, not movement codes or
other escapes sequences are stripped.
@param [Array[String]] strings
a string or array of strings to sanitize
@example
strip("foo\e[1mbar\e[0m") # => "foobar"
@return [String]
@api public | [
"Strip",
"ANSI",
"color",
"codes",
"from",
"a",
"string",
"."
] | 799c122b88de4f3676a960bdf620199ad7219d3f | https://github.com/piotrmurach/pastel/blob/799c122b88de4f3676a960bdf620199ad7219d3f/lib/pastel/color.rb#L106-L109 | train |
piotrmurach/pastel | lib/pastel/color.rb | Pastel.Color.code | def code(*colors)
attribute = []
colors.each do |color|
value = ANSI::ATTRIBUTES[color] || ALIASES[color]
if value
attribute << value
else
validate(color)
end
end
attribute
end | ruby | def code(*colors)
attribute = []
colors.each do |color|
value = ANSI::ATTRIBUTES[color] || ALIASES[color]
if value
attribute << value
else
validate(color)
end
end
attribute
end | [
"def",
"code",
"(",
"*",
"colors",
")",
"attribute",
"=",
"[",
"]",
"colors",
".",
"each",
"do",
"|",
"color",
"|",
"value",
"=",
"ANSI",
"::",
"ATTRIBUTES",
"[",
"color",
"]",
"||",
"ALIASES",
"[",
"color",
"]",
"if",
"value",
"attribute",
"<<",
"... | Return raw color code without embeding it into a string.
@return [Array[String]]
ANSI escape codes
@api public | [
"Return",
"raw",
"color",
"code",
"without",
"embeding",
"it",
"into",
"a",
"string",
"."
] | 799c122b88de4f3676a960bdf620199ad7219d3f | https://github.com/piotrmurach/pastel/blob/799c122b88de4f3676a960bdf620199ad7219d3f/lib/pastel/color.rb#L151-L162 | train |
piotrmurach/pastel | lib/pastel/color.rb | Pastel.Color.alias_color | def alias_color(alias_name, *colors)
validate(*colors)
if !(alias_name.to_s =~ /^[\w]+$/)
fail InvalidAliasNameError, "Invalid alias name `#{alias_name}`"
elsif ANSI::ATTRIBUTES[alias_name]
fail InvalidAliasNameError,
"Cannot alias standard color `#{alias_name}`"
en... | ruby | def alias_color(alias_name, *colors)
validate(*colors)
if !(alias_name.to_s =~ /^[\w]+$/)
fail InvalidAliasNameError, "Invalid alias name `#{alias_name}`"
elsif ANSI::ATTRIBUTES[alias_name]
fail InvalidAliasNameError,
"Cannot alias standard color `#{alias_name}`"
en... | [
"def",
"alias_color",
"(",
"alias_name",
",",
"*",
"colors",
")",
"validate",
"(",
"*",
"colors",
")",
"if",
"!",
"(",
"alias_name",
".",
"to_s",
"=~",
"/",
"\\w",
"/",
")",
"fail",
"InvalidAliasNameError",
",",
"\"Invalid alias name `#{alias_name}`\"",
"elsif... | Define a new colors alias
@param [String] alias_name
the colors alias to define
@param [Array[Symbol,String]] color
the colors the alias will correspond to
@return [Array[String]]
the standard color values of the alias
@api public | [
"Define",
"a",
"new",
"colors",
"alias"
] | 799c122b88de4f3676a960bdf620199ad7219d3f | https://github.com/piotrmurach/pastel/blob/799c122b88de4f3676a960bdf620199ad7219d3f/lib/pastel/color.rb#L209-L221 | train |
piotrmurach/pastel | lib/pastel/alias_importer.rb | Pastel.AliasImporter.import | def import
color_aliases = env['PASTEL_COLORS_ALIASES']
return unless color_aliases
color_aliases.split(',').each do |color_alias|
new_color, old_colors = color_alias.split('=')
if !new_color || !old_colors
output.puts "Bad color mapping `#{color_alias}`"
else
... | ruby | def import
color_aliases = env['PASTEL_COLORS_ALIASES']
return unless color_aliases
color_aliases.split(',').each do |color_alias|
new_color, old_colors = color_alias.split('=')
if !new_color || !old_colors
output.puts "Bad color mapping `#{color_alias}`"
else
... | [
"def",
"import",
"color_aliases",
"=",
"env",
"[",
"'PASTEL_COLORS_ALIASES'",
"]",
"return",
"unless",
"color_aliases",
"color_aliases",
".",
"split",
"(",
"','",
")",
".",
"each",
"do",
"|",
"color_alias",
"|",
"new_color",
",",
"old_colors",
"=",
"color_alias"... | Create alias importer
@example
importer = Pastel::AliasImporter.new(Pastel::Color.new, {})
@api public
Import aliases from the environment
@example
importer = Pastel::AliasImporter.new(Pastel::Color.new, {})
importer.import
@return [nil]
@api public | [
"Create",
"alias",
"importer"
] | 799c122b88de4f3676a960bdf620199ad7219d3f | https://github.com/piotrmurach/pastel/blob/799c122b88de4f3676a960bdf620199ad7219d3f/lib/pastel/alias_importer.rb#L27-L39 | train |
SciRuby/daru-view | lib/daru/view/adapters/googlecharts/base_chart.rb | GoogleVisualr.BaseChart.draw_js_spreadsheet | def draw_js_spreadsheet(data, element_id=SecureRandom.uuid)
js = ''
js << "\n function #{chart_function_name(element_id)}() {"
js << "\n var query = new google.visualization.Query('#{data}');"
js << "\n query.send(#{query_response_function_name(element_id)});"
js << "\n }"
js << "\... | ruby | def draw_js_spreadsheet(data, element_id=SecureRandom.uuid)
js = ''
js << "\n function #{chart_function_name(element_id)}() {"
js << "\n var query = new google.visualization.Query('#{data}');"
js << "\n query.send(#{query_response_function_name(element_id)});"
js << "\n }"
js << "\... | [
"def",
"draw_js_spreadsheet",
"(",
"data",
",",
"element_id",
"=",
"SecureRandom",
".",
"uuid",
")",
"js",
"=",
"''",
"js",
"<<",
"\"\\n function #{chart_function_name(element_id)}() {\"",
"js",
"<<",
"\"\\n \tvar query = new google.visualization.Query('#{data}');\"",
"js",
... | Generates JavaScript function for rendering the chart when data is URL of
the google spreadsheet
@param (see #to_js_spreadsheet)
@return [String] JS function to render the google chart when data is URL
of the google spreadsheet | [
"Generates",
"JavaScript",
"function",
"for",
"rendering",
"the",
"chart",
"when",
"data",
"is",
"URL",
"of",
"the",
"google",
"spreadsheet"
] | 7662fae07a2f339d9600c1dda263b8e409fc5592 | https://github.com/SciRuby/daru-view/blob/7662fae07a2f339d9600c1dda263b8e409fc5592/lib/daru/view/adapters/googlecharts/base_chart.rb#L40-L54 | train |
SciRuby/daru-view | lib/daru/view/adapters/googlecharts/data_table_iruby.rb | GoogleVisualr.DataTable.to_js_full_script | def to_js_full_script(element_id=SecureRandom.uuid)
js = ''
js << '\n<script type=\'text/javascript\'>'
js << load_js(element_id)
js << draw_js(element_id)
js << '\n</script>'
js
end | ruby | def to_js_full_script(element_id=SecureRandom.uuid)
js = ''
js << '\n<script type=\'text/javascript\'>'
js << load_js(element_id)
js << draw_js(element_id)
js << '\n</script>'
js
end | [
"def",
"to_js_full_script",
"(",
"element_id",
"=",
"SecureRandom",
".",
"uuid",
")",
"js",
"=",
"''",
"js",
"<<",
"'\\n<script type=\\'text/javascript\\'>'",
"js",
"<<",
"load_js",
"(",
"element_id",
")",
"js",
"<<",
"draw_js",
"(",
"element_id",
")",
"js",
"... | Generates JavaScript and renders the Google Chart DataTable in the
final HTML output
@param element_id [String] The ID of the DIV element that the Google
Chart DataTable should be rendered in
@return [String] Javascript code to render the Google Chart DataTable | [
"Generates",
"JavaScript",
"and",
"renders",
"the",
"Google",
"Chart",
"DataTable",
"in",
"the",
"final",
"HTML",
"output"
] | 7662fae07a2f339d9600c1dda263b8e409fc5592 | https://github.com/SciRuby/daru-view/blob/7662fae07a2f339d9600c1dda263b8e409fc5592/lib/daru/view/adapters/googlecharts/data_table_iruby.rb#L58-L65 | train |
SciRuby/daru-view | lib/daru/view/adapters/googlecharts/data_table_iruby.rb | GoogleVisualr.DataTable.draw_js | def draw_js(element_id)
js = ''
js << "\n function #{chart_function_name(element_id)}() {"
js << "\n #{to_js}"
js << "\n var table = new google.visualization.Table("
js << "document.getElementById('#{element_id}'));"
js << add_listeners_js('table')
js << "\n table.dra... | ruby | def draw_js(element_id)
js = ''
js << "\n function #{chart_function_name(element_id)}() {"
js << "\n #{to_js}"
js << "\n var table = new google.visualization.Table("
js << "document.getElementById('#{element_id}'));"
js << add_listeners_js('table')
js << "\n table.dra... | [
"def",
"draw_js",
"(",
"element_id",
")",
"js",
"=",
"''",
"js",
"<<",
"\"\\n function #{chart_function_name(element_id)}() {\"",
"js",
"<<",
"\"\\n #{to_js}\"",
"js",
"<<",
"\"\\n var table = new google.visualization.Table(\"",
"js",
"<<",
"\"document.getElementById('#{... | Generates JavaScript function for rendering the google chart table.
@param element_id [String] The ID of the DIV element that the Google
Chart DataTable should be rendered in
@return [String] JS function to render the google chart table | [
"Generates",
"JavaScript",
"function",
"for",
"rendering",
"the",
"google",
"chart",
"table",
"."
] | 7662fae07a2f339d9600c1dda263b8e409fc5592 | https://github.com/SciRuby/daru-view/blob/7662fae07a2f339d9600c1dda263b8e409fc5592/lib/daru/view/adapters/googlecharts/data_table_iruby.rb#L109-L119 | train |
SciRuby/daru-view | lib/daru/view/adapters/googlecharts/data_table_iruby.rb | GoogleVisualr.DataTable.draw_js_spreadsheet | def draw_js_spreadsheet(data, element_id)
js = ''
js << "\n function #{chart_function_name(element_id)}() {"
js << "\n var query = new google.visualization.Query('#{data}');"
js << "\n query.send(#{query_response_function_name(element_id)});"
js << "\n }"
js << "\n function #{que... | ruby | def draw_js_spreadsheet(data, element_id)
js = ''
js << "\n function #{chart_function_name(element_id)}() {"
js << "\n var query = new google.visualization.Query('#{data}');"
js << "\n query.send(#{query_response_function_name(element_id)});"
js << "\n }"
js << "\n function #{que... | [
"def",
"draw_js_spreadsheet",
"(",
"data",
",",
"element_id",
")",
"js",
"=",
"''",
"js",
"<<",
"\"\\n function #{chart_function_name(element_id)}() {\"",
"js",
"<<",
"\"\\n var query = new google.visualization.Query('#{data}');\"",
"js",
"<<",
"\"\\n query.send(#{query_respo... | Generates JavaScript function for rendering the google chart table when
data is URL of the google spreadsheet
@param (see #to_js_full_script_spreadsheet)
@return [String] JS function to render the google chart table when data
is URL of the google spreadsheet | [
"Generates",
"JavaScript",
"function",
"for",
"rendering",
"the",
"google",
"chart",
"table",
"when",
"data",
"is",
"URL",
"of",
"the",
"google",
"spreadsheet"
] | 7662fae07a2f339d9600c1dda263b8e409fc5592 | https://github.com/SciRuby/daru-view/blob/7662fae07a2f339d9600c1dda263b8e409fc5592/lib/daru/view/adapters/googlecharts/data_table_iruby.rb#L127-L141 | train |
SciRuby/daru-view | lib/daru/view/adapters/highcharts/display.rb | LazyHighCharts.HighChart.to_html_iruby | def to_html_iruby(placeholder=random_canvas_id)
# TODO : placeholder pass, in plot#div
@div_id = placeholder
load_dependencies('iruby')
chart_hash_must_be_present
script = high_chart_css(placeholder)
script << high_chart_iruby(extract_chart_class, placeholder, self)
script
... | ruby | def to_html_iruby(placeholder=random_canvas_id)
# TODO : placeholder pass, in plot#div
@div_id = placeholder
load_dependencies('iruby')
chart_hash_must_be_present
script = high_chart_css(placeholder)
script << high_chart_iruby(extract_chart_class, placeholder, self)
script
... | [
"def",
"to_html_iruby",
"(",
"placeholder",
"=",
"random_canvas_id",
")",
"@div_id",
"=",
"placeholder",
"load_dependencies",
"(",
"'iruby'",
")",
"chart_hash_must_be_present",
"script",
"=",
"high_chart_css",
"(",
"placeholder",
")",
"script",
"<<",
"high_chart_iruby",... | This method is not needed if `to_html` generates the same code. Here
`to_html` generates the code with `onload`, so there is need of
`high_chart_iruby` which doesn't use `onload` in chart script. | [
"This",
"method",
"is",
"not",
"needed",
"if",
"to_html",
"generates",
"the",
"same",
"code",
".",
"Here",
"to_html",
"generates",
"the",
"code",
"with",
"onload",
"so",
"there",
"is",
"need",
"of",
"high_chart_iruby",
"which",
"doesn",
"t",
"use",
"onload",... | 7662fae07a2f339d9600c1dda263b8e409fc5592 | https://github.com/SciRuby/daru-view/blob/7662fae07a2f339d9600c1dda263b8e409fc5592/lib/daru/view/adapters/highcharts/display.rb#L95-L103 | train |
SciRuby/daru-view | lib/daru/view/adapters/highcharts/display.rb | LazyHighCharts.HighChart.load_dependencies | def load_dependencies(type)
dep_js = extract_dependencies
if type == 'iruby'
LazyHighCharts.init_iruby(dep_js) unless dep_js.nil?
elsif type == 'web_frameworks'
dep_js.nil? ? '' : LazyHighCharts.init_javascript(dep_js)
end
end | ruby | def load_dependencies(type)
dep_js = extract_dependencies
if type == 'iruby'
LazyHighCharts.init_iruby(dep_js) unless dep_js.nil?
elsif type == 'web_frameworks'
dep_js.nil? ? '' : LazyHighCharts.init_javascript(dep_js)
end
end | [
"def",
"load_dependencies",
"(",
"type",
")",
"dep_js",
"=",
"extract_dependencies",
"if",
"type",
"==",
"'iruby'",
"LazyHighCharts",
".",
"init_iruby",
"(",
"dep_js",
")",
"unless",
"dep_js",
".",
"nil?",
"elsif",
"type",
"==",
"'web_frameworks'",
"dep_js",
"."... | Loads the dependent mapdata and dependent modules of the chart
@param [String] to determine whether to load modules in IRuby or web
frameworks
@return [void, String] loads the initial script of the modules for IRuby
notebook and returns initial script of the modules for web frameworks | [
"Loads",
"the",
"dependent",
"mapdata",
"and",
"dependent",
"modules",
"of",
"the",
"chart"
] | 7662fae07a2f339d9600c1dda263b8e409fc5592 | https://github.com/SciRuby/daru-view/blob/7662fae07a2f339d9600c1dda263b8e409fc5592/lib/daru/view/adapters/highcharts/display.rb#L134-L141 | train |
SciRuby/daru-view | lib/daru/view/adapters/highcharts/display.rb | LazyHighCharts.HighChart.export_iruby | def export_iruby(export_type='png', file_name='chart')
js = ''
js << to_html_iruby
js << extract_export_code_iruby(@div_id, export_type, file_name)
IRuby.html js
end | ruby | def export_iruby(export_type='png', file_name='chart')
js = ''
js << to_html_iruby
js << extract_export_code_iruby(@div_id, export_type, file_name)
IRuby.html js
end | [
"def",
"export_iruby",
"(",
"export_type",
"=",
"'png'",
",",
"file_name",
"=",
"'chart'",
")",
"js",
"=",
"''",
"js",
"<<",
"to_html_iruby",
"js",
"<<",
"extract_export_code_iruby",
"(",
"@div_id",
",",
"export_type",
",",
"file_name",
")",
"IRuby",
".",
"h... | Exports chart to different formats in IRuby notebook
@param type [String] format to which chart has to be exported
@param file_name [String] The name of the file after exporting the chart
@return [void] loads the js code of chart along with the code to export
in IRuby notebook | [
"Exports",
"chart",
"to",
"different",
"formats",
"in",
"IRuby",
"notebook"
] | 7662fae07a2f339d9600c1dda263b8e409fc5592 | https://github.com/SciRuby/daru-view/blob/7662fae07a2f339d9600c1dda263b8e409fc5592/lib/daru/view/adapters/highcharts/display.rb#L189-L194 | train |
SciRuby/daru-view | lib/daru/view/adapters/highcharts/display.rb | LazyHighCharts.HighChart.extract_export_code | def extract_export_code(
placeholder=random_canvas_id, export_type='png', file_name='chart'
)
js = ''
js << "\n <script>"
js << "\n (function() {"
js << "\n \tvar onload = window.onload;"
js << "\n \twindow.onload = function(){"
js << "\n \t\tif (typeof onload == 'function'... | ruby | def extract_export_code(
placeholder=random_canvas_id, export_type='png', file_name='chart'
)
js = ''
js << "\n <script>"
js << "\n (function() {"
js << "\n \tvar onload = window.onload;"
js << "\n \twindow.onload = function(){"
js << "\n \t\tif (typeof onload == 'function'... | [
"def",
"extract_export_code",
"(",
"placeholder",
"=",
"random_canvas_id",
",",
"export_type",
"=",
"'png'",
",",
"file_name",
"=",
"'chart'",
")",
"js",
"=",
"''",
"js",
"<<",
"\"\\n <script>\"",
"js",
"<<",
"\"\\n (function() {\"",
"js",
"<<",
"\"\\n \\tvar onlo... | Returns the script to export the chart in different formats for
web frameworks
@param file_name [String] The name of the file after exporting the chart
@param placeholder [String] The ID of the DIV element that
the HighChart should be rendered in
@param type [String] format to which chart has to be exported
... | [
"Returns",
"the",
"script",
"to",
"export",
"the",
"chart",
"in",
"different",
"formats",
"for",
"web",
"frameworks"
] | 7662fae07a2f339d9600c1dda263b8e409fc5592 | https://github.com/SciRuby/daru-view/blob/7662fae07a2f339d9600c1dda263b8e409fc5592/lib/daru/view/adapters/highcharts/display.rb#L204-L222 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.