id
int32
0
24.9k
repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
11,300
TrestleAdmin/trestle
app/helpers/trestle/table_helper.rb
Trestle.TableHelper.table
def table(name=nil, options={}, &block) if block_given? if name.is_a?(Hash) options = name else collection = name end table = Table::Builder.build(options, &block) elsif name.is_a?(Trestle::Table) table = name else table = admin.tabl...
ruby
def table(name=nil, options={}, &block) if block_given? if name.is_a?(Hash) options = name else collection = name end table = Table::Builder.build(options, &block) elsif name.is_a?(Trestle::Table) table = name else table = admin.tabl...
[ "def", "table", "(", "name", "=", "nil", ",", "options", "=", "{", "}", ",", "&", "block", ")", "if", "block_given?", "if", "name", ".", "is_a?", "(", "Hash", ")", "options", "=", "name", "else", "collection", "=", "name", "end", "table", "=", "Tab...
Renders an existing named table or builds and renders a custom table if a block is provided. name - The (optional) name of the table to render (as a Symbol), or the actual Trestle::Table instance itself. options - Hash of options that will be passed to the table builder (default: {}): :collection - The...
[ "Renders", "an", "existing", "named", "table", "or", "builds", "and", "renders", "a", "custom", "table", "if", "a", "block", "is", "provided", "." ]
fd5b8aeb5077e13d539cb5ddd99db1dd279f19ca
https://github.com/TrestleAdmin/trestle/blob/fd5b8aeb5077e13d539cb5ddd99db1dd279f19ca/app/helpers/trestle/table_helper.rb#L26-L45
11,301
TrestleAdmin/trestle
app/helpers/trestle/pagination_helper.rb
Trestle.PaginationHelper.page_entries_info
def page_entries_info(collection, options = {}) entry_name = options[:entry_name] || "entry" entry_name = entry_name.pluralize unless collection.total_count == 1 if collection.total_pages < 2 t('trestle.helpers.page_entries_info.one_page.display_entries', entry_name: entry_name, count: collec...
ruby
def page_entries_info(collection, options = {}) entry_name = options[:entry_name] || "entry" entry_name = entry_name.pluralize unless collection.total_count == 1 if collection.total_pages < 2 t('trestle.helpers.page_entries_info.one_page.display_entries', entry_name: entry_name, count: collec...
[ "def", "page_entries_info", "(", "collection", ",", "options", "=", "{", "}", ")", "entry_name", "=", "options", "[", ":entry_name", "]", "||", "\"entry\"", "entry_name", "=", "entry_name", ".", "pluralize", "unless", "collection", ".", "total_count", "==", "1...
Custom version of Kaminari's page_entries_info helper to use a Trestle-scoped I18n key and add a delimiter to the total count.
[ "Custom", "version", "of", "Kaminari", "s", "page_entries_info", "helper", "to", "use", "a", "Trestle", "-", "scoped", "I18n", "key", "and", "add", "a", "delimiter", "to", "the", "total", "count", "." ]
fd5b8aeb5077e13d539cb5ddd99db1dd279f19ca
https://github.com/TrestleAdmin/trestle/blob/fd5b8aeb5077e13d539cb5ddd99db1dd279f19ca/app/helpers/trestle/pagination_helper.rb#L5-L18
11,302
TrestleAdmin/trestle
lib/trestle/configuration.rb
Trestle.Configuration.hook
def hook(name, options={}, &block) hooks[name.to_s] << Hook.new(name.to_s, options, &block) end
ruby
def hook(name, options={}, &block) hooks[name.to_s] << Hook.new(name.to_s, options, &block) end
[ "def", "hook", "(", "name", ",", "options", "=", "{", "}", ",", "&", "block", ")", "hooks", "[", "name", ".", "to_s", "]", "<<", "Hook", ".", "new", "(", "name", ".", "to_s", ",", "options", ",", "block", ")", "end" ]
Register an extension hook
[ "Register", "an", "extension", "hook" ]
fd5b8aeb5077e13d539cb5ddd99db1dd279f19ca
https://github.com/TrestleAdmin/trestle/blob/fd5b8aeb5077e13d539cb5ddd99db1dd279f19ca/lib/trestle/configuration.rb#L90-L92
11,303
Shopify/shipit-engine
app/models/shipit/deploy.rb
Shipit.Deploy.trigger_rollback
def trigger_rollback(user = AnonymousUser.new, env: nil, force: false) rollback = build_rollback(user, env: env, force: force) rollback.save! rollback.enqueue lock_reason = "A rollback for #{rollback.since_commit.sha} has been triggered. " \ "Please make sure the reason for the rollback...
ruby
def trigger_rollback(user = AnonymousUser.new, env: nil, force: false) rollback = build_rollback(user, env: env, force: force) rollback.save! rollback.enqueue lock_reason = "A rollback for #{rollback.since_commit.sha} has been triggered. " \ "Please make sure the reason for the rollback...
[ "def", "trigger_rollback", "(", "user", "=", "AnonymousUser", ".", "new", ",", "env", ":", "nil", ",", "force", ":", "false", ")", "rollback", "=", "build_rollback", "(", "user", ",", "env", ":", "env", ",", "force", ":", "force", ")", "rollback", ".",...
Rolls the stack back to this deploy
[ "Rolls", "the", "stack", "back", "to", "this", "deploy" ]
f6b93d8a242962016e0f82e99c2eb223bdc75003
https://github.com/Shopify/shipit-engine/blob/f6b93d8a242962016e0f82e99c2eb223bdc75003/app/models/shipit/deploy.rb#L76-L86
11,304
realm/jazzy
lib/jazzy/podspec_documenter.rb
Jazzy.PodspecDocumenter.compiler_swift_version
def compiler_swift_version(user_version) return LATEST_SWIFT_VERSION unless user_version LONG_SWIFT_VERSIONS.select do |version| user_version.start_with?(version) end.last || "#{user_version[0]}.0" end
ruby
def compiler_swift_version(user_version) return LATEST_SWIFT_VERSION unless user_version LONG_SWIFT_VERSIONS.select do |version| user_version.start_with?(version) end.last || "#{user_version[0]}.0" end
[ "def", "compiler_swift_version", "(", "user_version", ")", "return", "LATEST_SWIFT_VERSION", "unless", "user_version", "LONG_SWIFT_VERSIONS", ".", "select", "do", "|", "version", "|", "user_version", ".", "start_with?", "(", "version", ")", "end", ".", "last", "||",...
Go from a full Swift version like 4.2.1 to something valid for SWIFT_VERSION.
[ "Go", "from", "a", "full", "Swift", "version", "like", "4", ".", "2", ".", "1", "to", "something", "valid", "for", "SWIFT_VERSION", "." ]
e8744dbdb78814b237e8d57a82d40953560e9143
https://github.com/realm/jazzy/blob/e8744dbdb78814b237e8d57a82d40953560e9143/lib/jazzy/podspec_documenter.rb#L109-L115
11,305
cerebris/jsonapi-resources
lib/jsonapi/resource_id_tree.rb
JSONAPI.ResourceIdTree.fetch_related_resource_id_tree
def fetch_related_resource_id_tree(relationship) relationship_name = relationship.name.to_sym @related_resource_id_trees[relationship_name] ||= RelatedResourceIdTree.new(relationship, self) end
ruby
def fetch_related_resource_id_tree(relationship) relationship_name = relationship.name.to_sym @related_resource_id_trees[relationship_name] ||= RelatedResourceIdTree.new(relationship, self) end
[ "def", "fetch_related_resource_id_tree", "(", "relationship", ")", "relationship_name", "=", "relationship", ".", "name", ".", "to_sym", "@related_resource_id_trees", "[", "relationship_name", "]", "||=", "RelatedResourceIdTree", ".", "new", "(", "relationship", ",", "s...
Gets the related Resource Id Tree for a relationship, and creates it first if it does not exist @param relationship [JSONAPI::Relationship] @return [JSONAPI::RelatedResourceIdTree] the new or existing resource id tree for the requested relationship
[ "Gets", "the", "related", "Resource", "Id", "Tree", "for", "a", "relationship", "and", "creates", "it", "first", "if", "it", "does", "not", "exist" ]
1ac6bba777e364eaa36706f888792b99b63d8d1a
https://github.com/cerebris/jsonapi-resources/blob/1ac6bba777e364eaa36706f888792b99b63d8d1a/lib/jsonapi/resource_id_tree.rb#L15-L18
11,306
cerebris/jsonapi-resources
lib/jsonapi/resource_id_tree.rb
JSONAPI.PrimaryResourceIdTree.add_resource_fragment
def add_resource_fragment(fragment, include_related) fragment.primary = true init_included_relationships(fragment, include_related) @fragments[fragment.identity] = fragment end
ruby
def add_resource_fragment(fragment, include_related) fragment.primary = true init_included_relationships(fragment, include_related) @fragments[fragment.identity] = fragment end
[ "def", "add_resource_fragment", "(", "fragment", ",", "include_related", ")", "fragment", ".", "primary", "=", "true", "init_included_relationships", "(", "fragment", ",", "include_related", ")", "@fragments", "[", "fragment", ".", "identity", "]", "=", "fragment", ...
Adds a Resource Fragment to the Resources hash @param fragment [JSONAPI::ResourceFragment] @param include_related [Hash] @return [null]
[ "Adds", "a", "Resource", "Fragment", "to", "the", "Resources", "hash" ]
1ac6bba777e364eaa36706f888792b99b63d8d1a
https://github.com/cerebris/jsonapi-resources/blob/1ac6bba777e364eaa36706f888792b99b63d8d1a/lib/jsonapi/resource_id_tree.rb#L55-L61
11,307
cerebris/jsonapi-resources
lib/jsonapi/resource_id_tree.rb
JSONAPI.RelatedResourceIdTree.add_resource_fragment
def add_resource_fragment(fragment, include_related) init_included_relationships(fragment, include_related) fragment.related_from.each do |rid| @source_resource_id_tree.fragments[rid].add_related_identity(parent_relationship.name, fragment.identity) end @fragments[fragment.identity] = ...
ruby
def add_resource_fragment(fragment, include_related) init_included_relationships(fragment, include_related) fragment.related_from.each do |rid| @source_resource_id_tree.fragments[rid].add_related_identity(parent_relationship.name, fragment.identity) end @fragments[fragment.identity] = ...
[ "def", "add_resource_fragment", "(", "fragment", ",", "include_related", ")", "init_included_relationships", "(", "fragment", ",", "include_related", ")", "fragment", ".", "related_from", ".", "each", "do", "|", "rid", "|", "@source_resource_id_tree", ".", "fragments"...
Adds a Resource Fragment to the fragments hash @param fragment [JSONAPI::ResourceFragment] @param include_related [Hash] @return [null]
[ "Adds", "a", "Resource", "Fragment", "to", "the", "fragments", "hash" ]
1ac6bba777e364eaa36706f888792b99b63d8d1a
https://github.com/cerebris/jsonapi-resources/blob/1ac6bba777e364eaa36706f888792b99b63d8d1a/lib/jsonapi/resource_id_tree.rb#L102-L110
11,308
googleapis/google-cloud-ruby
google-cloud-error_reporting/lib/google-cloud-error_reporting.rb
Google.Cloud.error_reporting
def error_reporting scope: nil, timeout: nil, client_config: nil Google::Cloud.error_reporting @project, @keyfile, scope: scope, timeout: (timeout || @timeout), client_config: client_config end
ruby
def error_reporting scope: nil, timeout: nil, client_config: nil Google::Cloud.error_reporting @project, @keyfile, scope: scope, timeout: (timeout || @timeout), client_config: client_config end
[ "def", "error_reporting", "scope", ":", "nil", ",", "timeout", ":", "nil", ",", "client_config", ":", "nil", "Google", "::", "Cloud", ".", "error_reporting", "@project", ",", "@keyfile", ",", "scope", ":", "scope", ",", "timeout", ":", "(", "timeout", "||"...
Create a new object for connecting to the Stackdriver Error Reporting service. Each call creates a new connection. For more information on connecting to Google Cloud see the {file:AUTHENTICATION.md Authentication Guide}. @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the set of resources...
[ "Create", "a", "new", "object", "for", "connecting", "to", "the", "Stackdriver", "Error", "Reporting", "service", ".", "Each", "call", "creates", "a", "new", "connection", "." ]
846c1a57250ac860ef4de1b54853a480ab2ff702
https://github.com/googleapis/google-cloud-ruby/blob/846c1a57250ac860ef4de1b54853a480ab2ff702/google-cloud-error_reporting/lib/google-cloud-error_reporting.rb#L62-L67
11,309
googleapis/google-cloud-ruby
google-cloud-dns/lib/google-cloud-dns.rb
Google.Cloud.dns
def dns scope: nil, retries: nil, timeout: nil Google::Cloud.dns @project, @keyfile, scope: scope, retries: (retries || @retries), timeout: (timeout || @timeout) end
ruby
def dns scope: nil, retries: nil, timeout: nil Google::Cloud.dns @project, @keyfile, scope: scope, retries: (retries || @retries), timeout: (timeout || @timeout) end
[ "def", "dns", "scope", ":", "nil", ",", "retries", ":", "nil", ",", "timeout", ":", "nil", "Google", "::", "Cloud", ".", "dns", "@project", ",", "@keyfile", ",", "scope", ":", "scope", ",", "retries", ":", "(", "retries", "||", "@retries", ")", ",", ...
Creates a new object for connecting to the DNS service. Each call creates a new connection. For more information on connecting to Google Cloud see the {file:AUTHENTICATION.md Authentication Guide}. @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the set of resources and operations that th...
[ "Creates", "a", "new", "object", "for", "connecting", "to", "the", "DNS", "service", ".", "Each", "call", "creates", "a", "new", "connection", "." ]
846c1a57250ac860ef4de1b54853a480ab2ff702
https://github.com/googleapis/google-cloud-ruby/blob/846c1a57250ac860ef4de1b54853a480ab2ff702/google-cloud-dns/lib/google-cloud-dns.rb#L66-L70
11,310
googleapis/google-cloud-ruby
google-cloud-spanner/lib/google-cloud-spanner.rb
Google.Cloud.spanner
def spanner scope: nil, timeout: nil, client_config: nil Google::Cloud.spanner @project, @keyfile, scope: scope, timeout: (timeout || @timeout), client_config: client_config end
ruby
def spanner scope: nil, timeout: nil, client_config: nil Google::Cloud.spanner @project, @keyfile, scope: scope, timeout: (timeout || @timeout), client_config: client_config end
[ "def", "spanner", "scope", ":", "nil", ",", "timeout", ":", "nil", ",", "client_config", ":", "nil", "Google", "::", "Cloud", ".", "spanner", "@project", ",", "@keyfile", ",", "scope", ":", "scope", ",", "timeout", ":", "(", "timeout", "||", "@timeout", ...
Creates a new object for connecting to the Spanner service. Each call creates a new connection. For more information on connecting to Google Cloud see the {file:AUTHENTICATION.md Authentication Guide}. @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the set of resources and operations tha...
[ "Creates", "a", "new", "object", "for", "connecting", "to", "the", "Spanner", "service", ".", "Each", "call", "creates", "a", "new", "connection", "." ]
846c1a57250ac860ef4de1b54853a480ab2ff702
https://github.com/googleapis/google-cloud-ruby/blob/846c1a57250ac860ef4de1b54853a480ab2ff702/google-cloud-spanner/lib/google-cloud-spanner.rb#L64-L68
11,311
googleapis/google-cloud-ruby
google-cloud-logging/lib/google-cloud-logging.rb
Google.Cloud.logging
def logging scope: nil, timeout: nil, client_config: nil timeout ||= @timeout Google::Cloud.logging @project, @keyfile, scope: scope, timeout: timeout, client_config: client_config end
ruby
def logging scope: nil, timeout: nil, client_config: nil timeout ||= @timeout Google::Cloud.logging @project, @keyfile, scope: scope, timeout: timeout, client_config: client_config end
[ "def", "logging", "scope", ":", "nil", ",", "timeout", ":", "nil", ",", "client_config", ":", "nil", "timeout", "||=", "@timeout", "Google", "::", "Cloud", ".", "logging", "@project", ",", "@keyfile", ",", "scope", ":", "scope", ",", "timeout", ":", "tim...
Creates a new object for connecting to the Stackdriver Logging service. Each call creates a new connection. For more information on connecting to Google Cloud see the {file:AUTHENTICATION.md Authentication Guide}. @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the set of resources and op...
[ "Creates", "a", "new", "object", "for", "connecting", "to", "the", "Stackdriver", "Logging", "service", ".", "Each", "call", "creates", "a", "new", "connection", "." ]
846c1a57250ac860ef4de1b54853a480ab2ff702
https://github.com/googleapis/google-cloud-ruby/blob/846c1a57250ac860ef4de1b54853a480ab2ff702/google-cloud-logging/lib/google-cloud-logging.rb#L69-L74
11,312
googleapis/google-cloud-ruby
google-cloud-bigquery/lib/google-cloud-bigquery.rb
Google.Cloud.bigquery
def bigquery scope: nil, retries: nil, timeout: nil Google::Cloud.bigquery @project, @keyfile, scope: scope, retries: (retries || @retries), timeout: (timeout || @timeout) end
ruby
def bigquery scope: nil, retries: nil, timeout: nil Google::Cloud.bigquery @project, @keyfile, scope: scope, retries: (retries || @retries), timeout: (timeout || @timeout) end
[ "def", "bigquery", "scope", ":", "nil", ",", "retries", ":", "nil", ",", "timeout", ":", "nil", "Google", "::", "Cloud", ".", "bigquery", "@project", ",", "@keyfile", ",", "scope", ":", "scope", ",", "retries", ":", "(", "retries", "||", "@retries", ")...
Creates a new object for connecting to the BigQuery service. Each call creates a new connection. For more information on connecting to Google Cloud see the {file:AUTHENTICATION.md Authentication Guide}. @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the set of resources and operations th...
[ "Creates", "a", "new", "object", "for", "connecting", "to", "the", "BigQuery", "service", ".", "Each", "call", "creates", "a", "new", "connection", "." ]
846c1a57250ac860ef4de1b54853a480ab2ff702
https://github.com/googleapis/google-cloud-ruby/blob/846c1a57250ac860ef4de1b54853a480ab2ff702/google-cloud-bigquery/lib/google-cloud-bigquery.rb#L67-L71
11,313
googleapis/google-cloud-ruby
google-cloud-debugger/lib/google-cloud-debugger.rb
Google.Cloud.debugger
def debugger service_name: nil, service_version: nil, scope: nil, timeout: nil, client_config: nil Google::Cloud.debugger @project, @keyfile, service_name: service_name, service_version: service_version, scope:...
ruby
def debugger service_name: nil, service_version: nil, scope: nil, timeout: nil, client_config: nil Google::Cloud.debugger @project, @keyfile, service_name: service_name, service_version: service_version, scope:...
[ "def", "debugger", "service_name", ":", "nil", ",", "service_version", ":", "nil", ",", "scope", ":", "nil", ",", "timeout", ":", "nil", ",", "client_config", ":", "nil", "Google", "::", "Cloud", ".", "debugger", "@project", ",", "@keyfile", ",", "service_...
Creates a new debugger object for instrumenting Stackdriver Debugger for an application. Each call creates a new debugger agent with independent connection service. For more information on connecting to Google Cloud see the {file:AUTHENTICATION.md Authentication Guide}. @param [String] service_name Name for the ...
[ "Creates", "a", "new", "debugger", "object", "for", "instrumenting", "Stackdriver", "Debugger", "for", "an", "application", ".", "Each", "call", "creates", "a", "new", "debugger", "agent", "with", "independent", "connection", "service", "." ]
846c1a57250ac860ef4de1b54853a480ab2ff702
https://github.com/googleapis/google-cloud-ruby/blob/846c1a57250ac860ef4de1b54853a480ab2ff702/google-cloud-debugger/lib/google-cloud-debugger.rb#L71-L79
11,314
googleapis/google-cloud-ruby
google-cloud-datastore/lib/google-cloud-datastore.rb
Google.Cloud.datastore
def datastore scope: nil, timeout: nil, client_config: nil Google::Cloud.datastore @project, @keyfile, scope: scope, timeout: (timeout || @timeout), client_config: client_config end
ruby
def datastore scope: nil, timeout: nil, client_config: nil Google::Cloud.datastore @project, @keyfile, scope: scope, timeout: (timeout || @timeout), client_config: client_config end
[ "def", "datastore", "scope", ":", "nil", ",", "timeout", ":", "nil", ",", "client_config", ":", "nil", "Google", "::", "Cloud", ".", "datastore", "@project", ",", "@keyfile", ",", "scope", ":", "scope", ",", "timeout", ":", "(", "timeout", "||", "@timeou...
Creates a new object for connecting to the Datastore service. Each call creates a new connection. For more information on connecting to Google Cloud see the {file:AUTHENTICATION.md Authentication Guide}. @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the set of resources and operations t...
[ "Creates", "a", "new", "object", "for", "connecting", "to", "the", "Datastore", "service", ".", "Each", "call", "creates", "a", "new", "connection", "." ]
846c1a57250ac860ef4de1b54853a480ab2ff702
https://github.com/googleapis/google-cloud-ruby/blob/846c1a57250ac860ef4de1b54853a480ab2ff702/google-cloud-datastore/lib/google-cloud-datastore.rb#L72-L76
11,315
googleapis/google-cloud-ruby
google-cloud-resource_manager/lib/google-cloud-resource_manager.rb
Google.Cloud.resource_manager
def resource_manager scope: nil, retries: nil, timeout: nil Google::Cloud.resource_manager @keyfile, scope: scope, retries: (retries || @retries), timeout: (timeout || @timeout) end
ruby
def resource_manager scope: nil, retries: nil, timeout: nil Google::Cloud.resource_manager @keyfile, scope: scope, retries: (retries || @retries), timeout: (timeout || @timeout) end
[ "def", "resource_manager", "scope", ":", "nil", ",", "retries", ":", "nil", ",", "timeout", ":", "nil", "Google", "::", "Cloud", ".", "resource_manager", "@keyfile", ",", "scope", ":", "scope", ",", "retries", ":", "(", "retries", "||", "@retries", ")", ...
Creates a new object for connecting to the Resource Manager service. Each call creates a new connection. For more information on connecting to Google Cloud see the {file:AUTHENTICATION.md Authentication Guide}. @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the set of resources and opera...
[ "Creates", "a", "new", "object", "for", "connecting", "to", "the", "Resource", "Manager", "service", ".", "Each", "call", "creates", "a", "new", "connection", "." ]
846c1a57250ac860ef4de1b54853a480ab2ff702
https://github.com/googleapis/google-cloud-ruby/blob/846c1a57250ac860ef4de1b54853a480ab2ff702/google-cloud-resource_manager/lib/google-cloud-resource_manager.rb#L67-L71
11,316
googleapis/google-cloud-ruby
google-cloud-storage/lib/google-cloud-storage.rb
Google.Cloud.storage
def storage scope: nil, retries: nil, timeout: nil Google::Cloud.storage @project, @keyfile, scope: scope, retries: (retries || @retries), timeout: (timeout || @timeout) end
ruby
def storage scope: nil, retries: nil, timeout: nil Google::Cloud.storage @project, @keyfile, scope: scope, retries: (retries || @retries), timeout: (timeout || @timeout) end
[ "def", "storage", "scope", ":", "nil", ",", "retries", ":", "nil", ",", "timeout", ":", "nil", "Google", "::", "Cloud", ".", "storage", "@project", ",", "@keyfile", ",", "scope", ":", "scope", ",", "retries", ":", "(", "retries", "||", "@retries", ")",...
Creates a new object for connecting to the Storage service. Each call creates a new connection. For more information on connecting to Google Cloud see the {file:AUTHENTICATION.md Authentication Guide}. @see https://cloud.google.com/storage/docs/authentication#oauth Storage OAuth 2.0 Authentication @param [St...
[ "Creates", "a", "new", "object", "for", "connecting", "to", "the", "Storage", "service", ".", "Each", "call", "creates", "a", "new", "connection", "." ]
846c1a57250ac860ef4de1b54853a480ab2ff702
https://github.com/googleapis/google-cloud-ruby/blob/846c1a57250ac860ef4de1b54853a480ab2ff702/google-cloud-storage/lib/google-cloud-storage.rb#L67-L71
11,317
googleapis/google-cloud-ruby
google-cloud-translate/lib/google-cloud-translate.rb
Google.Cloud.translate
def translate key = nil, scope: nil, retries: nil, timeout: nil Google::Cloud.translate key, project_id: @project, credentials: @keyfile, scope: scope, retries: (retries || @retries), timeout: (timeout || @tim...
ruby
def translate key = nil, scope: nil, retries: nil, timeout: nil Google::Cloud.translate key, project_id: @project, credentials: @keyfile, scope: scope, retries: (retries || @retries), timeout: (timeout || @tim...
[ "def", "translate", "key", "=", "nil", ",", "scope", ":", "nil", ",", "retries", ":", "nil", ",", "timeout", ":", "nil", "Google", "::", "Cloud", ".", "translate", "key", ",", "project_id", ":", "@project", ",", "credentials", ":", "@keyfile", ",", "sc...
Creates a new object for connecting to the Cloud Translation API. Each call creates a new connection. Like other Cloud Platform services, Google Cloud Translation API supports authentication using a project ID and OAuth 2.0 credentials. In addition, it supports authentication using a public API access key. (If bot...
[ "Creates", "a", "new", "object", "for", "connecting", "to", "the", "Cloud", "Translation", "API", ".", "Each", "call", "creates", "a", "new", "connection", "." ]
846c1a57250ac860ef4de1b54853a480ab2ff702
https://github.com/googleapis/google-cloud-ruby/blob/846c1a57250ac860ef4de1b54853a480ab2ff702/google-cloud-translate/lib/google-cloud-translate.rb#L74-L79
11,318
googleapis/google-cloud-ruby
google-cloud-firestore/lib/google-cloud-firestore.rb
Google.Cloud.firestore
def firestore scope: nil, timeout: nil, client_config: nil Google::Cloud.firestore @project, @keyfile, scope: scope, timeout: (timeout || @timeout), client_config: client_config end
ruby
def firestore scope: nil, timeout: nil, client_config: nil Google::Cloud.firestore @project, @keyfile, scope: scope, timeout: (timeout || @timeout), client_config: client_config end
[ "def", "firestore", "scope", ":", "nil", ",", "timeout", ":", "nil", ",", "client_config", ":", "nil", "Google", "::", "Cloud", ".", "firestore", "@project", ",", "@keyfile", ",", "scope", ":", "scope", ",", "timeout", ":", "(", "timeout", "||", "@timeou...
Creates a new object for connecting to the Firestore service. Each call creates a new connection. For more information on connecting to Google Cloud see the {file:AUTHENTICATION.md Authentication Guide}. @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the set of resources and operations t...
[ "Creates", "a", "new", "object", "for", "connecting", "to", "the", "Firestore", "service", ".", "Each", "call", "creates", "a", "new", "connection", "." ]
846c1a57250ac860ef4de1b54853a480ab2ff702
https://github.com/googleapis/google-cloud-ruby/blob/846c1a57250ac860ef4de1b54853a480ab2ff702/google-cloud-firestore/lib/google-cloud-firestore.rb#L63-L67
11,319
googleapis/google-cloud-ruby
google-cloud-trace/lib/google-cloud-trace.rb
Google.Cloud.trace
def trace scope: nil, timeout: nil, client_config: nil Google::Cloud.trace @project, @keyfile, scope: scope, timeout: (timeout || @timeout), client_config: client_config end
ruby
def trace scope: nil, timeout: nil, client_config: nil Google::Cloud.trace @project, @keyfile, scope: scope, timeout: (timeout || @timeout), client_config: client_config end
[ "def", "trace", "scope", ":", "nil", ",", "timeout", ":", "nil", ",", "client_config", ":", "nil", "Google", "::", "Cloud", ".", "trace", "@project", ",", "@keyfile", ",", "scope", ":", "scope", ",", "timeout", ":", "(", "timeout", "||", "@timeout", ")...
Creates a new object for connecting to the Stackdriver Trace service. Each call creates a new connection. For more information on connecting to Google Cloud see the {file:AUTHENTICATION.md Authentication Guide}. @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the set of resources and oper...
[ "Creates", "a", "new", "object", "for", "connecting", "to", "the", "Stackdriver", "Trace", "service", ".", "Each", "call", "creates", "a", "new", "connection", "." ]
846c1a57250ac860ef4de1b54853a480ab2ff702
https://github.com/googleapis/google-cloud-ruby/blob/846c1a57250ac860ef4de1b54853a480ab2ff702/google-cloud-trace/lib/google-cloud-trace.rb#L60-L64
11,320
googleapis/google-cloud-ruby
google-cloud-bigtable/lib/google-cloud-bigtable.rb
Google.Cloud.bigtable
def bigtable scope: nil, timeout: nil, credentials: nil, client_config: nil Google::Cloud.bigtable( project_id: @project, credentials: (credentials || @keyfile), scope: scope, timeout: (timeout || @timeout), client_config: client_config ) end
ruby
def bigtable scope: nil, timeout: nil, credentials: nil, client_config: nil Google::Cloud.bigtable( project_id: @project, credentials: (credentials || @keyfile), scope: scope, timeout: (timeout || @timeout), client_config: client_config ) end
[ "def", "bigtable", "scope", ":", "nil", ",", "timeout", ":", "nil", ",", "credentials", ":", "nil", ",", "client_config", ":", "nil", "Google", "::", "Cloud", ".", "bigtable", "(", "project_id", ":", "@project", ",", "credentials", ":", "(", "credentials",...
Creates a new object for connecting to the Cloud Bigtable service. For more information on connecting to Google Cloud Platform, see the {file:AUTHENTICATION.md Authentication Guide}. @param scope [Array<String>] The OAuth 2.0 scopes controlling the set of resources and operations that the connection can acce...
[ "Creates", "a", "new", "object", "for", "connecting", "to", "the", "Cloud", "Bigtable", "service", "." ]
846c1a57250ac860ef4de1b54853a480ab2ff702
https://github.com/googleapis/google-cloud-ruby/blob/846c1a57250ac860ef4de1b54853a480ab2ff702/google-cloud-bigtable/lib/google-cloud-bigtable.rb#L71-L79
11,321
bblimke/webmock
lib/webmock/request_pattern.rb
WebMock.BodyPattern.matching_body_hashes?
def matching_body_hashes?(query_parameters, pattern, content_type) return false unless query_parameters.is_a?(Hash) return false unless query_parameters.keys.sort == pattern.keys.sort query_parameters.each do |key, actual| expected = pattern[key] if actual.is_a?(Hash) && expected.is_a...
ruby
def matching_body_hashes?(query_parameters, pattern, content_type) return false unless query_parameters.is_a?(Hash) return false unless query_parameters.keys.sort == pattern.keys.sort query_parameters.each do |key, actual| expected = pattern[key] if actual.is_a?(Hash) && expected.is_a...
[ "def", "matching_body_hashes?", "(", "query_parameters", ",", "pattern", ",", "content_type", ")", "return", "false", "unless", "query_parameters", ".", "is_a?", "(", "Hash", ")", "return", "false", "unless", "query_parameters", ".", "keys", ".", "sort", "==", "...
Compare two hashes for equality For two hashes to match they must have the same length and all values must match when compared using `#===`. The following hashes are examples of matches: {a: /\d+/} and {a: '123'} {a: '123'} and {a: '123'} {a: {b: /\d+/}} and {a: {b: '123'}} {a: {b: 'wow'}} ...
[ "Compare", "two", "hashes", "for", "equality" ]
c0bcc09af372286cd110ec4159112ce583007951
https://github.com/bblimke/webmock/blob/c0bcc09af372286cd110ec4159112ce583007951/lib/webmock/request_pattern.rb#L310-L324
11,322
jch/html-pipeline
lib/html/pipeline.rb
HTML.Pipeline.call
def call(html, context = {}, result = nil) context = @default_context.merge(context) context = context.freeze result ||= @result_class.new payload = default_payload filters: @filters.map(&:name), context: context, result: result instrument 'call_pipeline.htm...
ruby
def call(html, context = {}, result = nil) context = @default_context.merge(context) context = context.freeze result ||= @result_class.new payload = default_payload filters: @filters.map(&:name), context: context, result: result instrument 'call_pipeline.htm...
[ "def", "call", "(", "html", ",", "context", "=", "{", "}", ",", "result", "=", "nil", ")", "context", "=", "@default_context", ".", "merge", "(", "context", ")", "context", "=", "context", ".", "freeze", "result", "||=", "@result_class", ".", "new", "p...
Apply all filters in the pipeline to the given HTML. html - A String containing HTML or a DocumentFragment object. context - The context hash passed to each filter. See the Filter docs for more info on possible values. This object MUST NOT be modified in place by filters. Use the Result for...
[ "Apply", "all", "filters", "in", "the", "pipeline", "to", "the", "given", "HTML", "." ]
f1bbce4858876dc2619c61a8b18637b5d3321b1c
https://github.com/jch/html-pipeline/blob/f1bbce4858876dc2619c61a8b18637b5d3321b1c/lib/html/pipeline.rb#L107-L120
11,323
jch/html-pipeline
lib/html/pipeline.rb
HTML.Pipeline.to_document
def to_document(input, context = {}, result = nil) result = call(input, context, result) HTML::Pipeline.parse(result[:output]) end
ruby
def to_document(input, context = {}, result = nil) result = call(input, context, result) HTML::Pipeline.parse(result[:output]) end
[ "def", "to_document", "(", "input", ",", "context", "=", "{", "}", ",", "result", "=", "nil", ")", "result", "=", "call", "(", "input", ",", "context", ",", "result", ")", "HTML", "::", "Pipeline", ".", "parse", "(", "result", "[", ":output", "]", ...
Like call but guarantee the value returned is a DocumentFragment. Pipelines may return a DocumentFragment or a String. Callers that need a DocumentFragment should use this method.
[ "Like", "call", "but", "guarantee", "the", "value", "returned", "is", "a", "DocumentFragment", ".", "Pipelines", "may", "return", "a", "DocumentFragment", "or", "a", "String", ".", "Callers", "that", "need", "a", "DocumentFragment", "should", "use", "this", "m...
f1bbce4858876dc2619c61a8b18637b5d3321b1c
https://github.com/jch/html-pipeline/blob/f1bbce4858876dc2619c61a8b18637b5d3321b1c/lib/html/pipeline.rb#L138-L141
11,324
jch/html-pipeline
lib/html/pipeline.rb
HTML.Pipeline.to_html
def to_html(input, context = {}, result = nil) result = call(input, context, result = nil) output = result[:output] if output.respond_to?(:to_html) output.to_html else output.to_s end end
ruby
def to_html(input, context = {}, result = nil) result = call(input, context, result = nil) output = result[:output] if output.respond_to?(:to_html) output.to_html else output.to_s end end
[ "def", "to_html", "(", "input", ",", "context", "=", "{", "}", ",", "result", "=", "nil", ")", "result", "=", "call", "(", "input", ",", "context", ",", "result", "=", "nil", ")", "output", "=", "result", "[", ":output", "]", "if", "output", ".", ...
Like call but guarantee the value returned is a string of HTML markup.
[ "Like", "call", "but", "guarantee", "the", "value", "returned", "is", "a", "string", "of", "HTML", "markup", "." ]
f1bbce4858876dc2619c61a8b18637b5d3321b1c
https://github.com/jch/html-pipeline/blob/f1bbce4858876dc2619c61a8b18637b5d3321b1c/lib/html/pipeline.rb#L144-L152
11,325
kaminari/kaminari
kaminari-core/lib/kaminari/models/page_scope_methods.rb
Kaminari.PageScopeMethods.total_pages
def total_pages count_without_padding = total_count count_without_padding -= @_padding if defined?(@_padding) && @_padding count_without_padding = 0 if count_without_padding < 0 total_pages_count = (count_without_padding.to_f / limit_value).ceil max_pages && (max_pages < total_pages_count...
ruby
def total_pages count_without_padding = total_count count_without_padding -= @_padding if defined?(@_padding) && @_padding count_without_padding = 0 if count_without_padding < 0 total_pages_count = (count_without_padding.to_f / limit_value).ceil max_pages && (max_pages < total_pages_count...
[ "def", "total_pages", "count_without_padding", "=", "total_count", "count_without_padding", "-=", "@_padding", "if", "defined?", "(", "@_padding", ")", "&&", "@_padding", "count_without_padding", "=", "0", "if", "count_without_padding", "<", "0", "total_pages_count", "=...
Total number of pages
[ "Total", "number", "of", "pages" ]
e2078ce46b145b811423dc8b5993e4bc87dc88b8
https://github.com/kaminari/kaminari/blob/e2078ce46b145b811423dc8b5993e4bc87dc88b8/kaminari-core/lib/kaminari/models/page_scope_methods.rb#L35-L44
11,326
kaminari/kaminari
kaminari-core/lib/kaminari/models/page_scope_methods.rb
Kaminari.PageScopeMethods.current_page
def current_page offset_without_padding = offset_value offset_without_padding -= @_padding if defined?(@_padding) && @_padding offset_without_padding = 0 if offset_without_padding < 0 (offset_without_padding / limit_value) + 1 rescue ZeroDivisionError raise ZeroPerPageOperation, "Curr...
ruby
def current_page offset_without_padding = offset_value offset_without_padding -= @_padding if defined?(@_padding) && @_padding offset_without_padding = 0 if offset_without_padding < 0 (offset_without_padding / limit_value) + 1 rescue ZeroDivisionError raise ZeroPerPageOperation, "Curr...
[ "def", "current_page", "offset_without_padding", "=", "offset_value", "offset_without_padding", "-=", "@_padding", "if", "defined?", "(", "@_padding", ")", "&&", "@_padding", "offset_without_padding", "=", "0", "if", "offset_without_padding", "<", "0", "(", "offset_with...
Current page number
[ "Current", "page", "number" ]
e2078ce46b145b811423dc8b5993e4bc87dc88b8
https://github.com/kaminari/kaminari/blob/e2078ce46b145b811423dc8b5993e4bc87dc88b8/kaminari-core/lib/kaminari/models/page_scope_methods.rb#L47-L55
11,327
kaminari/kaminari
kaminari-activerecord/lib/kaminari/activerecord/active_record_relation_methods.rb
Kaminari.ActiveRecordRelationMethods.entry_name
def entry_name(options = {}) default = options[:count] == 1 ? model_name.human : model_name.human.pluralize model_name.human(options.reverse_merge(default: default)) end
ruby
def entry_name(options = {}) default = options[:count] == 1 ? model_name.human : model_name.human.pluralize model_name.human(options.reverse_merge(default: default)) end
[ "def", "entry_name", "(", "options", "=", "{", "}", ")", "default", "=", "options", "[", ":count", "]", "==", "1", "?", "model_name", ".", "human", ":", "model_name", ".", "human", ".", "pluralize", "model_name", ".", "human", "(", "options", ".", "rev...
Used for page_entry_info
[ "Used", "for", "page_entry_info" ]
e2078ce46b145b811423dc8b5993e4bc87dc88b8
https://github.com/kaminari/kaminari/blob/e2078ce46b145b811423dc8b5993e4bc87dc88b8/kaminari-activerecord/lib/kaminari/activerecord/active_record_relation_methods.rb#L7-L10
11,328
guard/guard
lib/guard/watcher.rb
Guard.Watcher.call_action
def call_action(matches) @action.arity > 0 ? @action.call(matches) : @action.call rescue => ex UI.error "Problem with watch action!\n#{ex.message}" UI.error ex.backtrace.join("\n") end
ruby
def call_action(matches) @action.arity > 0 ? @action.call(matches) : @action.call rescue => ex UI.error "Problem with watch action!\n#{ex.message}" UI.error ex.backtrace.join("\n") end
[ "def", "call_action", "(", "matches", ")", "@action", ".", "arity", ">", "0", "?", "@action", ".", "call", "(", "matches", ")", ":", "@action", ".", "call", "rescue", "=>", "ex", "UI", ".", "error", "\"Problem with watch action!\\n#{ex.message}\"", "UI", "."...
Executes a watcher action. @param [String, MatchData] matches the matched path or the match from the Regex @return [String] the final paths
[ "Executes", "a", "watcher", "action", "." ]
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/watcher.rb#L81-L86
11,329
guard/guard
lib/guard/cli.rb
Guard.CLI.start
def start if defined?(JRUBY_VERSION) unless options[:no_interactions] abort "\nSorry, JRuby and interactive mode are incompatible.\n"\ "As a workaround, use the '-i' option instead.\n\n"\ "More info: \n"\ " * https://github.com/guard/guard/issues/754\n"\ ...
ruby
def start if defined?(JRUBY_VERSION) unless options[:no_interactions] abort "\nSorry, JRuby and interactive mode are incompatible.\n"\ "As a workaround, use the '-i' option instead.\n\n"\ "More info: \n"\ " * https://github.com/guard/guard/issues/754\n"\ ...
[ "def", "start", "if", "defined?", "(", "JRUBY_VERSION", ")", "unless", "options", "[", ":no_interactions", "]", "abort", "\"\\nSorry, JRuby and interactive mode are incompatible.\\n\"", "\"As a workaround, use the '-i' option instead.\\n\\n\"", "\"More info: \\n\"", "\" * https://git...
Start Guard by initializing the defined Guard plugins and watch the file system. This is the default task, so calling `guard` is the same as calling `guard start`. @see Guard.start
[ "Start", "Guard", "by", "initializing", "the", "defined", "Guard", "plugins", "and", "watch", "the", "file", "system", "." ]
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/cli.rb#L112-L123
11,330
guard/guard
lib/guard/cli.rb
Guard.CLI.notifiers
def notifiers Cli::Environments::EvaluateOnly.new(options).evaluate # TODO: pass the data directly to the notifiers? DslDescriber.new.notifiers end
ruby
def notifiers Cli::Environments::EvaluateOnly.new(options).evaluate # TODO: pass the data directly to the notifiers? DslDescriber.new.notifiers end
[ "def", "notifiers", "Cli", "::", "Environments", "::", "EvaluateOnly", ".", "new", "(", "options", ")", ".", "evaluate", "# TODO: pass the data directly to the notifiers?", "DslDescriber", ".", "new", ".", "notifiers", "end" ]
List the Notifiers for use in your system. @see Guard::DslDescriber.notifiers
[ "List", "the", "Notifiers", "for", "use", "in", "your", "system", "." ]
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/cli.rb#L143-L147
11,331
guard/guard
lib/guard/cli.rb
Guard.CLI.init
def init(*plugin_names) env = Cli::Environments::Valid.new(options) exitcode = env.initialize_guardfile(plugin_names) exit(exitcode) end
ruby
def init(*plugin_names) env = Cli::Environments::Valid.new(options) exitcode = env.initialize_guardfile(plugin_names) exit(exitcode) end
[ "def", "init", "(", "*", "plugin_names", ")", "env", "=", "Cli", "::", "Environments", "::", "Valid", ".", "new", "(", "options", ")", "exitcode", "=", "env", ".", "initialize_guardfile", "(", "plugin_names", ")", "exit", "(", "exitcode", ")", "end" ]
Initializes the templates of all installed Guard plugins and adds them to the `Guardfile` when no Guard name is passed. When passing Guard plugin names it does the same but only for those Guard plugins. @see Guard::Guardfile.initialize_template @see Guard::Guardfile.initialize_all_templates @param [Array<String>...
[ "Initializes", "the", "templates", "of", "all", "installed", "Guard", "plugins", "and", "adds", "them", "to", "the", "Guardfile", "when", "no", "Guard", "name", "is", "passed", ".", "When", "passing", "Guard", "plugin", "names", "it", "does", "the", "same", ...
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/cli.rb#L181-L185
11,332
guard/guard
lib/guard/cli.rb
Guard.CLI.show
def show Cli::Environments::EvaluateOnly.new(options).evaluate DslDescriber.new.show end
ruby
def show Cli::Environments::EvaluateOnly.new(options).evaluate DslDescriber.new.show end
[ "def", "show", "Cli", "::", "Environments", "::", "EvaluateOnly", ".", "new", "(", "options", ")", ".", "evaluate", "DslDescriber", ".", "new", ".", "show", "end" ]
Shows all Guard plugins and their options that are defined in the `Guardfile` @see Guard::DslDescriber.show
[ "Shows", "all", "Guard", "plugins", "and", "their", "options", "that", "are", "defined", "in", "the", "Guardfile" ]
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/cli.rb#L195-L198
11,333
guard/guard
lib/guard/plugin_util.rb
Guard.PluginUtil.add_to_guardfile
def add_to_guardfile klass = plugin_class # call here to avoid failing later require_relative "guardfile/evaluator" # TODO: move this to Generator? options = Guard.state.session.evaluator_options evaluator = Guardfile::Evaluator.new(options) begin evaluator.evaluate re...
ruby
def add_to_guardfile klass = plugin_class # call here to avoid failing later require_relative "guardfile/evaluator" # TODO: move this to Generator? options = Guard.state.session.evaluator_options evaluator = Guardfile::Evaluator.new(options) begin evaluator.evaluate re...
[ "def", "add_to_guardfile", "klass", "=", "plugin_class", "# call here to avoid failing later", "require_relative", "\"guardfile/evaluator\"", "# TODO: move this to Generator?", "options", "=", "Guard", ".", "state", ".", "session", ".", "evaluator_options", "evaluator", "=", ...
Adds a plugin's template to the Guardfile.
[ "Adds", "a", "plugin", "s", "template", "to", "the", "Guardfile", "." ]
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/plugin_util.rb#L126-L150
11,334
guard/guard
lib/guard/plugin_util.rb
Guard.PluginUtil._plugin_constant
def _plugin_constant @_plugin_constant ||= Guard.constants.detect do |c| c.to_s.casecmp(_constant_name.downcase).zero? end end
ruby
def _plugin_constant @_plugin_constant ||= Guard.constants.detect do |c| c.to_s.casecmp(_constant_name.downcase).zero? end end
[ "def", "_plugin_constant", "@_plugin_constant", "||=", "Guard", ".", "constants", ".", "detect", "do", "|", "c", "|", "c", ".", "to_s", ".", "casecmp", "(", "_constant_name", ".", "downcase", ")", ".", "zero?", "end", "end" ]
Returns the constant for the current plugin. @example Returns the constant for a plugin > Guard::PluginUtil.new('rspec').send(:_plugin_constant) => Guard::RSpec
[ "Returns", "the", "constant", "for", "the", "current", "plugin", "." ]
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/plugin_util.rb#L160-L164
11,335
guard/guard
lib/guard/dsl.rb
Guard.Dsl.interactor
def interactor(options) # TODO: remove dependency on Interactor (let session handle this) case options when :off Interactor.enabled = false when Hash Interactor.options = options end end
ruby
def interactor(options) # TODO: remove dependency on Interactor (let session handle this) case options when :off Interactor.enabled = false when Hash Interactor.options = options end end
[ "def", "interactor", "(", "options", ")", "# TODO: remove dependency on Interactor (let session handle this)", "case", "options", "when", ":off", "Interactor", ".", "enabled", "=", "false", "when", "Hash", "Interactor", ".", "options", "=", "options", "end", "end" ]
Sets the interactor options or disable the interactor. @example Pass options to the interactor interactor option1: 'value1', option2: 'value2' @example Turn off interactions interactor :off @param [Symbol, Hash] options either `:off` or a Hash with interactor options
[ "Sets", "the", "interactor", "options", "or", "disable", "the", "interactor", "." ]
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/dsl.rb#L90-L98
11,336
guard/guard
lib/guard/dsl.rb
Guard.Dsl.guard
def guard(name, options = {}) @plugin_options = options.merge(watchers: [], callbacks: []) yield if block_given? @current_groups ||= [] groups = @current_groups && @current_groups.last || [:default] groups.each do |group| opts = @plugin_options.merge(group: group) # TODO:...
ruby
def guard(name, options = {}) @plugin_options = options.merge(watchers: [], callbacks: []) yield if block_given? @current_groups ||= [] groups = @current_groups && @current_groups.last || [:default] groups.each do |group| opts = @plugin_options.merge(group: group) # TODO:...
[ "def", "guard", "(", "name", ",", "options", "=", "{", "}", ")", "@plugin_options", "=", "options", ".", "merge", "(", "watchers", ":", "[", "]", ",", "callbacks", ":", "[", "]", ")", "yield", "if", "block_given?", "@current_groups", "||=", "[", "]", ...
Declares a Guard plugin to be used when running `guard start`. The name parameter is usually the name of the gem without the 'guard-' prefix. The available options are different for each Guard implementation. @example Declare a Guard without `watch` patterns guard :rspec @example Declare a Guard with a `wat...
[ "Declares", "a", "Guard", "plugin", "to", "be", "used", "when", "running", "guard", "start", "." ]
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/dsl.rb#L175-L189
11,337
guard/guard
lib/guard/dsl.rb
Guard.Dsl.watch
def watch(pattern, &action) # Allow watches in the global scope (to execute arbitrary commands) by # building a generic Guard::Plugin. @plugin_options ||= nil return guard(:plugin) { watch(pattern, &action) } unless @plugin_options @plugin_options[:watchers] << Watcher.new(pattern, action...
ruby
def watch(pattern, &action) # Allow watches in the global scope (to execute arbitrary commands) by # building a generic Guard::Plugin. @plugin_options ||= nil return guard(:plugin) { watch(pattern, &action) } unless @plugin_options @plugin_options[:watchers] << Watcher.new(pattern, action...
[ "def", "watch", "(", "pattern", ",", "&", "action", ")", "# Allow watches in the global scope (to execute arbitrary commands) by", "# building a generic Guard::Plugin.", "@plugin_options", "||=", "nil", "return", "guard", "(", ":plugin", ")", "{", "watch", "(", "pattern", ...
Defines a pattern to be watched in order to run actions on file modification. @example Declare watchers for a Guard guard :rspec do watch('spec/spec_helper.rb') watch(%r{^.+_spec.rb}) watch(%r{^app/controllers/(.+).rb}) do |m| 'spec/acceptance/#{m[1]}s_spec.rb' end end @example Dec...
[ "Defines", "a", "pattern", "to", "be", "watched", "in", "order", "to", "run", "actions", "on", "file", "modification", "." ]
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/dsl.rb#L217-L224
11,338
guard/guard
lib/guard/dsl.rb
Guard.Dsl.callback
def callback(*args, &block) @plugin_options ||= nil fail "callback must be called within a guard block" unless @plugin_options block, events = if args.size > 1 # block must be the first argument in that case, the # yielded block is ignored ...
ruby
def callback(*args, &block) @plugin_options ||= nil fail "callback must be called within a guard block" unless @plugin_options block, events = if args.size > 1 # block must be the first argument in that case, the # yielded block is ignored ...
[ "def", "callback", "(", "*", "args", ",", "&", "block", ")", "@plugin_options", "||=", "nil", "fail", "\"callback must be called within a guard block\"", "unless", "@plugin_options", "block", ",", "events", "=", "if", "args", ".", "size", ">", "1", "# block must b...
Defines a callback to execute arbitrary code before or after any of the `start`, `stop`, `reload`, `run_all`, `run_on_changes`, `run_on_additions`, `run_on_modifications` and `run_on_removals` plugin method. @example Add callback before the `reload` action. callback(:reload_begin) { puts "Let's reload!" } @ex...
[ "Defines", "a", "callback", "to", "execute", "arbitrary", "code", "before", "or", "after", "any", "of", "the", "start", "stop", "reload", "run_all", "run_on_changes", "run_on_additions", "run_on_modifications", "and", "run_on_removals", "plugin", "method", "." ]
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/dsl.rb#L245-L257
11,339
guard/guard
lib/guard/dsl.rb
Guard.Dsl.logger
def logger(options) if options[:level] options[:level] = options[:level].to_sym unless [:debug, :info, :warn, :error].include? options[:level] UI.warning(format(WARN_INVALID_LOG_LEVEL, options[:level])) options.delete :level end end if options[:only] && op...
ruby
def logger(options) if options[:level] options[:level] = options[:level].to_sym unless [:debug, :info, :warn, :error].include? options[:level] UI.warning(format(WARN_INVALID_LOG_LEVEL, options[:level])) options.delete :level end end if options[:only] && op...
[ "def", "logger", "(", "options", ")", "if", "options", "[", ":level", "]", "options", "[", ":level", "]", "=", "options", "[", ":level", "]", ".", "to_sym", "unless", "[", ":debug", ",", ":info", ",", ":warn", ",", ":error", "]", ".", "include?", "op...
Configures the Guard logger. * Log level must be either `:debug`, `:info`, `:warn` or `:error`. * Template supports the following placeholders: `:time`, `:severity`, `:progname`, `:pid`, `:unit_of_work_id` and `:message`. * Time format directives are the same as `Time#strftime` or `:milliseconds`. * The `:on...
[ "Configures", "the", "Guard", "logger", "." ]
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/dsl.rb#L324-L353
11,340
guard/guard
lib/guard/dsl.rb
Guard.Dsl.directories
def directories(directories) directories.each do |dir| fail "Directory #{dir.inspect} does not exist!" unless Dir.exist?(dir) end Guard.state.session.watchdirs = directories end
ruby
def directories(directories) directories.each do |dir| fail "Directory #{dir.inspect} does not exist!" unless Dir.exist?(dir) end Guard.state.session.watchdirs = directories end
[ "def", "directories", "(", "directories", ")", "directories", ".", "each", "do", "|", "dir", "|", "fail", "\"Directory #{dir.inspect} does not exist!\"", "unless", "Dir", ".", "exist?", "(", "dir", ")", "end", "Guard", ".", "state", ".", "session", ".", "watch...
Sets the directories to pass to Listen @example watch only given directories directories %w(lib specs) @param [Array] directories directories for Listen to watch
[ "Sets", "the", "directories", "to", "pass", "to", "Listen" ]
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/dsl.rb#L393-L398
11,341
guard/guard
lib/guard/commander.rb
Guard.Commander.start
def start(options = {}) setup(options) UI.debug "Guard starts all plugins" Runner.new.run(:start) listener.start watched = Guard.state.session.watchdirs.join("', '") UI.info "Guard is now watching at '#{ watched }'" exitcode = 0 begin while interactor.foreground...
ruby
def start(options = {}) setup(options) UI.debug "Guard starts all plugins" Runner.new.run(:start) listener.start watched = Guard.state.session.watchdirs.join("', '") UI.info "Guard is now watching at '#{ watched }'" exitcode = 0 begin while interactor.foreground...
[ "def", "start", "(", "options", "=", "{", "}", ")", "setup", "(", "options", ")", "UI", ".", "debug", "\"Guard starts all plugins\"", "Runner", ".", "new", ".", "run", "(", ":start", ")", "listener", ".", "start", "watched", "=", "Guard", ".", "state", ...
Start Guard by evaluating the `Guardfile`, initializing declared Guard plugins and starting the available file change listener. Main method for Guard that is called from the CLI when Guard starts. - Setup Guard internals - Evaluate the `Guardfile` - Configure Notifiers - Initialize the declared Guard plugins - ...
[ "Start", "Guard", "by", "evaluating", "the", "Guardfile", "initializing", "declared", "Guard", "plugins", "and", "starting", "the", "available", "file", "change", "listener", ".", "Main", "method", "for", "Guard", "that", "is", "called", "from", "the", "CLI", ...
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/commander.rb#L31-L53
11,342
guard/guard
lib/guard/commander.rb
Guard.Commander.run_all
def run_all(scopes = {}) UI.clear(force: true) UI.action_with_scopes("Run", scopes) Runner.new.run(:run_all, scopes) end
ruby
def run_all(scopes = {}) UI.clear(force: true) UI.action_with_scopes("Run", scopes) Runner.new.run(:run_all, scopes) end
[ "def", "run_all", "(", "scopes", "=", "{", "}", ")", "UI", ".", "clear", "(", "force", ":", "true", ")", "UI", ".", "action_with_scopes", "(", "\"Run\"", ",", "scopes", ")", "Runner", ".", "new", ".", "run", "(", ":run_all", ",", "scopes", ")", "en...
Trigger `run_all` on all Guard plugins currently enabled. @param [Hash] scopes hash with a Guard plugin or a group scope
[ "Trigger", "run_all", "on", "all", "Guard", "plugins", "currently", "enabled", "." ]
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/commander.rb#L80-L84
11,343
guard/guard
lib/guard/commander.rb
Guard.Commander.pause
def pause(expected = nil) paused = listener.paused? states = { paused: true, unpaused: false, toggle: !paused } pause = states[expected || :toggle] fail ArgumentError, "invalid mode: #{expected.inspect}" if pause.nil? return if pause == paused listener.public_send(pause ? :pause : :...
ruby
def pause(expected = nil) paused = listener.paused? states = { paused: true, unpaused: false, toggle: !paused } pause = states[expected || :toggle] fail ArgumentError, "invalid mode: #{expected.inspect}" if pause.nil? return if pause == paused listener.public_send(pause ? :pause : :...
[ "def", "pause", "(", "expected", "=", "nil", ")", "paused", "=", "listener", ".", "paused?", "states", "=", "{", "paused", ":", "true", ",", "unpaused", ":", "false", ",", "toggle", ":", "!", "paused", "}", "pause", "=", "states", "[", "expected", "|...
Pause Guard listening to file changes.
[ "Pause", "Guard", "listening", "to", "file", "changes", "." ]
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/commander.rb#L88-L97
11,344
guard/guard
lib/guard/dsl_describer.rb
Guard.DslDescriber.show
def show # collect metadata groups = Guard.state.session.groups.all objects = [] empty_plugin = OpenStruct.new empty_plugin.options = [["", nil]] groups.each do |group| plugins = Array(Guard.state.session.plugins.all(group: group.name)) plugins = [empty_plugin] if ...
ruby
def show # collect metadata groups = Guard.state.session.groups.all objects = [] empty_plugin = OpenStruct.new empty_plugin.options = [["", nil]] groups.each do |group| plugins = Array(Guard.state.session.plugins.all(group: group.name)) plugins = [empty_plugin] if ...
[ "def", "show", "# collect metadata", "groups", "=", "Guard", ".", "state", ".", "session", ".", "groups", ".", "all", "objects", "=", "[", "]", "empty_plugin", "=", "OpenStruct", ".", "new", "empty_plugin", ".", "options", "=", "[", "[", "\"\"", ",", "ni...
Shows all Guard plugins and their options that are defined in the `Guardfile`. @see CLI#show
[ "Shows", "all", "Guard", "plugins", "and", "their", "options", "that", "are", "defined", "in", "the", "Guardfile", "." ]
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/dsl_describer.rb#L53-L102
11,345
guard/guard
lib/guard/dsl_describer.rb
Guard.DslDescriber.notifiers
def notifiers supported = Notifier.supported Notifier.connect(notify: true, silent: true) detected = Notifier.detected Notifier.disconnect detected_names = detected.map { |item| item[:name] } final_rows = supported.each_with_object([]) do |(name, _), rows| available = detec...
ruby
def notifiers supported = Notifier.supported Notifier.connect(notify: true, silent: true) detected = Notifier.detected Notifier.disconnect detected_names = detected.map { |item| item[:name] } final_rows = supported.each_with_object([]) do |(name, _), rows| available = detec...
[ "def", "notifiers", "supported", "=", "Notifier", ".", "supported", "Notifier", ".", "connect", "(", "notify", ":", "true", ",", "silent", ":", "true", ")", "detected", "=", "Notifier", ".", "detected", "Notifier", ".", "disconnect", "detected_names", "=", "...
Shows all notifiers and their options that are defined in the `Guardfile`. @see CLI#show
[ "Shows", "all", "notifiers", "and", "their", "options", "that", "are", "defined", "in", "the", "Guardfile", "." ]
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/dsl_describer.rb#L109-L146
11,346
guard/guard
lib/guard/runner.rb
Guard.Runner.run
def run(task, scope_hash = {}) Lumberjack.unit_of_work do items = Guard.state.scope.grouped_plugins(scope_hash || {}) items.each do |_group, plugins| _run_group_plugins(plugins) do |plugin| _supervise(plugin, task) if plugin.respond_to?(task) end end e...
ruby
def run(task, scope_hash = {}) Lumberjack.unit_of_work do items = Guard.state.scope.grouped_plugins(scope_hash || {}) items.each do |_group, plugins| _run_group_plugins(plugins) do |plugin| _supervise(plugin, task) if plugin.respond_to?(task) end end e...
[ "def", "run", "(", "task", ",", "scope_hash", "=", "{", "}", ")", "Lumberjack", ".", "unit_of_work", "do", "items", "=", "Guard", ".", "state", ".", "scope", ".", "grouped_plugins", "(", "scope_hash", "||", "{", "}", ")", "items", ".", "each", "do", ...
Runs a Guard-task on all registered plugins. @param [Symbol] task the task to run @param [Hash] scope_hash either the Guard plugin or the group to run the task on
[ "Runs", "a", "Guard", "-", "task", "on", "all", "registered", "plugins", "." ]
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/runner.rb#L17-L26
11,347
guard/guard
lib/guard/runner.rb
Guard.Runner.run_on_changes
def run_on_changes(modified, added, removed) types = { MODIFICATION_TASKS => modified, ADDITION_TASKS => added, REMOVAL_TASKS => removed } UI.clearable Guard.state.scope.grouped_plugins.each do |_group, plugins| _run_group_plugins(plugins) do |plugin| ...
ruby
def run_on_changes(modified, added, removed) types = { MODIFICATION_TASKS => modified, ADDITION_TASKS => added, REMOVAL_TASKS => removed } UI.clearable Guard.state.scope.grouped_plugins.each do |_group, plugins| _run_group_plugins(plugins) do |plugin| ...
[ "def", "run_on_changes", "(", "modified", ",", "added", ",", "removed", ")", "types", "=", "{", "MODIFICATION_TASKS", "=>", "modified", ",", "ADDITION_TASKS", "=>", "added", ",", "REMOVAL_TASKS", "=>", "removed", "}", "UI", ".", "clearable", "Guard", ".", "s...
Runs the appropriate tasks on all registered plugins based on the passed changes. @param [Array<String>] modified the modified paths. @param [Array<String>] added the added paths. @param [Array<String>] removed the removed paths.
[ "Runs", "the", "appropriate", "tasks", "on", "all", "registered", "plugins", "based", "on", "the", "passed", "changes", "." ]
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/runner.rb#L44-L65
11,348
guard/guard
lib/guard/runner.rb
Guard.Runner._supervise
def _supervise(plugin, task, *args) catch self.class.stopping_symbol_for(plugin) do plugin.hook("#{ task }_begin", *args) result = UI.options.with_progname(plugin.class.name) do begin plugin.send(task, *args) rescue Interrupt throw(:task_has_failed) ...
ruby
def _supervise(plugin, task, *args) catch self.class.stopping_symbol_for(plugin) do plugin.hook("#{ task }_begin", *args) result = UI.options.with_progname(plugin.class.name) do begin plugin.send(task, *args) rescue Interrupt throw(:task_has_failed) ...
[ "def", "_supervise", "(", "plugin", ",", "task", ",", "*", "args", ")", "catch", "self", ".", "class", ".", "stopping_symbol_for", "(", "plugin", ")", "do", "plugin", ".", "hook", "(", "\"#{ task }_begin\"", ",", "args", ")", "result", "=", "UI", ".", ...
Run a Guard plugin task, but remove the Guard plugin when his work leads to a system failure. When the Group has `:halt_on_fail` disabled, we've to catch `:task_has_failed` here in order to avoid an uncaught throw error. @param [Guard::Plugin] plugin guard the Guard to execute @param [Symbol] task the task to ru...
[ "Run", "a", "Guard", "plugin", "task", "but", "remove", "the", "Guard", "plugin", "when", "his", "work", "leads", "to", "a", "system", "failure", "." ]
e2508cd83badf0d537dbaba35d307adc35d92e4f
https://github.com/guard/guard/blob/e2508cd83badf0d537dbaba35d307adc35d92e4f/lib/guard/runner.rb#L78-L99
11,349
httprb/http
lib/http/response.rb
HTTP.Response.content_length
def content_length # http://greenbytes.de/tech/webdav/rfc7230.html#rfc.section.3.3.3 # Clause 3: "If a message is received with both a Transfer-Encoding # and a Content-Length header field, the Transfer-Encoding overrides the Content-Length. return nil if @headers.include?(Headers::TRANSFER_ENCO...
ruby
def content_length # http://greenbytes.de/tech/webdav/rfc7230.html#rfc.section.3.3.3 # Clause 3: "If a message is received with both a Transfer-Encoding # and a Content-Length header field, the Transfer-Encoding overrides the Content-Length. return nil if @headers.include?(Headers::TRANSFER_ENCO...
[ "def", "content_length", "# http://greenbytes.de/tech/webdav/rfc7230.html#rfc.section.3.3.3", "# Clause 3: \"If a message is received with both a Transfer-Encoding", "# and a Content-Length header field, the Transfer-Encoding overrides the Content-Length.", "return", "nil", "if", "@headers", ".", ...
Value of the Content-Length header. @return [nil] if Content-Length was not given, or it's value was invalid (not an integer, e.g. empty string or string with non-digits). @return [Integer] otherwise
[ "Value", "of", "the", "Content", "-", "Length", "header", "." ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/response.rb#L103-L117
11,350
httprb/http
lib/http/connection.rb
HTTP.Connection.readpartial
def readpartial(size = BUFFER_SIZE) return unless @pending_response chunk = @parser.read(size) return chunk if chunk finished = (read_more(size) == :eof) || @parser.finished? chunk = @parser.read(size) finish_response if finished chunk.to_s end
ruby
def readpartial(size = BUFFER_SIZE) return unless @pending_response chunk = @parser.read(size) return chunk if chunk finished = (read_more(size) == :eof) || @parser.finished? chunk = @parser.read(size) finish_response if finished chunk.to_s end
[ "def", "readpartial", "(", "size", "=", "BUFFER_SIZE", ")", "return", "unless", "@pending_response", "chunk", "=", "@parser", ".", "read", "(", "size", ")", "return", "chunk", "if", "chunk", "finished", "=", "(", "read_more", "(", "size", ")", "==", ":eof"...
Read a chunk of the body @return [String] data chunk @return [nil] when no more data left
[ "Read", "a", "chunk", "of", "the", "body" ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/connection.rb#L86-L97
11,351
httprb/http
lib/http/connection.rb
HTTP.Connection.start_tls
def start_tls(req, options) return unless req.uri.https? && !failed_proxy_connect? ssl_context = options.ssl_context unless ssl_context ssl_context = OpenSSL::SSL::SSLContext.new ssl_context.set_params(options.ssl || {}) end @socket.start_tls(req.uri.host, options.ssl_so...
ruby
def start_tls(req, options) return unless req.uri.https? && !failed_proxy_connect? ssl_context = options.ssl_context unless ssl_context ssl_context = OpenSSL::SSL::SSLContext.new ssl_context.set_params(options.ssl || {}) end @socket.start_tls(req.uri.host, options.ssl_so...
[ "def", "start_tls", "(", "req", ",", "options", ")", "return", "unless", "req", ".", "uri", ".", "https?", "&&", "!", "failed_proxy_connect?", "ssl_context", "=", "options", ".", "ssl_context", "unless", "ssl_context", "ssl_context", "=", "OpenSSL", "::", "SSL...
Sets up SSL context and starts TLS if needed. @param (see #initialize) @return [void]
[ "Sets", "up", "SSL", "context", "and", "starts", "TLS", "if", "needed", "." ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/connection.rb#L148-L159
11,352
httprb/http
lib/http/connection.rb
HTTP.Connection.send_proxy_connect_request
def send_proxy_connect_request(req) return unless req.uri.https? && req.using_proxy? @pending_request = true req.connect_using_proxy @socket @pending_request = false @pending_response = true read_headers! @proxy_response_headers = @parser.headers if @parser.status_c...
ruby
def send_proxy_connect_request(req) return unless req.uri.https? && req.using_proxy? @pending_request = true req.connect_using_proxy @socket @pending_request = false @pending_response = true read_headers! @proxy_response_headers = @parser.headers if @parser.status_c...
[ "def", "send_proxy_connect_request", "(", "req", ")", "return", "unless", "req", ".", "uri", ".", "https?", "&&", "req", ".", "using_proxy?", "@pending_request", "=", "true", "req", ".", "connect_using_proxy", "@socket", "@pending_request", "=", "false", "@pending...
Open tunnel through proxy
[ "Open", "tunnel", "through", "proxy" ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/connection.rb#L162-L182
11,353
httprb/http
lib/http/connection.rb
HTTP.Connection.set_keep_alive
def set_keep_alive return @keep_alive = false unless @persistent @keep_alive = case @parser.http_version when HTTP_1_0 # HTTP/1.0 requires opt in for Keep Alive @parser.headers[Headers::CONNECTION] == KEEP_ALIVE when HTTP_1_1 # HTTP/1.1 is opt-out @parser.headers...
ruby
def set_keep_alive return @keep_alive = false unless @persistent @keep_alive = case @parser.http_version when HTTP_1_0 # HTTP/1.0 requires opt in for Keep Alive @parser.headers[Headers::CONNECTION] == KEEP_ALIVE when HTTP_1_1 # HTTP/1.1 is opt-out @parser.headers...
[ "def", "set_keep_alive", "return", "@keep_alive", "=", "false", "unless", "@persistent", "@keep_alive", "=", "case", "@parser", ".", "http_version", "when", "HTTP_1_0", "# HTTP/1.0 requires opt in for Keep Alive", "@parser", ".", "headers", "[", "Headers", "::", "CONNEC...
Store whether the connection should be kept alive. Once we reset the parser, we lose all of this state. @return [void]
[ "Store", "whether", "the", "connection", "should", "be", "kept", "alive", ".", "Once", "we", "reset", "the", "parser", "we", "lose", "all", "of", "this", "state", "." ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/connection.rb#L193-L205
11,354
httprb/http
lib/http/connection.rb
HTTP.Connection.read_more
def read_more(size) return if @parser.finished? value = @socket.readpartial(size, @buffer) if value == :eof @parser << "" :eof elsif value @parser << value end rescue IOError, SocketError, SystemCallError => ex raise ConnectionError, "error reading from s...
ruby
def read_more(size) return if @parser.finished? value = @socket.readpartial(size, @buffer) if value == :eof @parser << "" :eof elsif value @parser << value end rescue IOError, SocketError, SystemCallError => ex raise ConnectionError, "error reading from s...
[ "def", "read_more", "(", "size", ")", "return", "if", "@parser", ".", "finished?", "value", "=", "@socket", ".", "readpartial", "(", "size", ",", "@buffer", ")", "if", "value", "==", ":eof", "@parser", "<<", "\"\"", ":eof", "elsif", "value", "@parser", "...
Feeds some more data into parser @return [void]
[ "Feeds", "some", "more", "data", "into", "parser" ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/connection.rb#L209-L221
11,355
httprb/http
lib/http/chainable.rb
HTTP.Chainable.via
def via(*proxy) proxy_hash = {} proxy_hash[:proxy_address] = proxy[0] if proxy[0].is_a?(String) proxy_hash[:proxy_port] = proxy[1] if proxy[1].is_a?(Integer) proxy_hash[:proxy_username] = proxy[2] if proxy[2].is_a?(String) proxy_hash[:proxy_password] = proxy[3] if proxy[3].is_a?(Strin...
ruby
def via(*proxy) proxy_hash = {} proxy_hash[:proxy_address] = proxy[0] if proxy[0].is_a?(String) proxy_hash[:proxy_port] = proxy[1] if proxy[1].is_a?(Integer) proxy_hash[:proxy_username] = proxy[2] if proxy[2].is_a?(String) proxy_hash[:proxy_password] = proxy[3] if proxy[3].is_a?(Strin...
[ "def", "via", "(", "*", "proxy", ")", "proxy_hash", "=", "{", "}", "proxy_hash", "[", ":proxy_address", "]", "=", "proxy", "[", "0", "]", "if", "proxy", "[", "0", "]", ".", "is_a?", "(", "String", ")", "proxy_hash", "[", ":proxy_port", "]", "=", "p...
Make a request through an HTTP proxy @param [Array] proxy @raise [Request::Error] if HTTP proxy is invalid
[ "Make", "a", "request", "through", "an", "HTTP", "proxy" ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/chainable.rb#L155-L167
11,356
httprb/http
lib/http/chainable.rb
HTTP.Chainable.basic_auth
def basic_auth(opts) user = opts.fetch :user pass = opts.fetch :pass auth("Basic " + Base64.strict_encode64("#{user}:#{pass}")) end
ruby
def basic_auth(opts) user = opts.fetch :user pass = opts.fetch :pass auth("Basic " + Base64.strict_encode64("#{user}:#{pass}")) end
[ "def", "basic_auth", "(", "opts", ")", "user", "=", "opts", ".", "fetch", ":user", "pass", "=", "opts", ".", "fetch", ":pass", "auth", "(", "\"Basic \"", "+", "Base64", ".", "strict_encode64", "(", "\"#{user}:#{pass}\"", ")", ")", "end" ]
Make a request with the given Basic authorization header @see http://tools.ietf.org/html/rfc2617 @param [#fetch] opts @option opts [#to_s] :user @option opts [#to_s] :pass
[ "Make", "a", "request", "with", "the", "given", "Basic", "authorization", "header" ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/chainable.rb#L211-L216
11,357
httprb/http
lib/http/client.rb
HTTP.Client.request
def request(verb, uri, opts = {}) # rubocop:disable Style/OptionHash opts = @default_options.merge(opts) req = build_request(verb, uri, opts) res = perform(req, opts) return res unless opts.follow Redirector.new(opts.follow).perform(req, res) do |request| perform(request, opts) ...
ruby
def request(verb, uri, opts = {}) # rubocop:disable Style/OptionHash opts = @default_options.merge(opts) req = build_request(verb, uri, opts) res = perform(req, opts) return res unless opts.follow Redirector.new(opts.follow).perform(req, res) do |request| perform(request, opts) ...
[ "def", "request", "(", "verb", ",", "uri", ",", "opts", "=", "{", "}", ")", "# rubocop:disable Style/OptionHash", "opts", "=", "@default_options", ".", "merge", "(", "opts", ")", "req", "=", "build_request", "(", "verb", ",", "uri", ",", "opts", ")", "re...
Make an HTTP request
[ "Make", "an", "HTTP", "request" ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/client.rb#L28-L37
11,358
httprb/http
lib/http/client.rb
HTTP.Client.build_request
def build_request(verb, uri, opts = {}) # rubocop:disable Style/OptionHash opts = @default_options.merge(opts) uri = make_request_uri(uri, opts) headers = make_request_headers(opts) body = make_request_body(opts, headers) req = HTTP::Request.new( :verb => verb,...
ruby
def build_request(verb, uri, opts = {}) # rubocop:disable Style/OptionHash opts = @default_options.merge(opts) uri = make_request_uri(uri, opts) headers = make_request_headers(opts) body = make_request_body(opts, headers) req = HTTP::Request.new( :verb => verb,...
[ "def", "build_request", "(", "verb", ",", "uri", ",", "opts", "=", "{", "}", ")", "# rubocop:disable Style/OptionHash", "opts", "=", "@default_options", ".", "merge", "(", "opts", ")", "uri", "=", "make_request_uri", "(", "uri", ",", "opts", ")", "headers", ...
Prepare an HTTP request
[ "Prepare", "an", "HTTP", "request" ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/client.rb#L40-L58
11,359
httprb/http
lib/http/client.rb
HTTP.Client.verify_connection!
def verify_connection!(uri) if default_options.persistent? && uri.origin != default_options.persistent raise StateError, "Persistence is enabled for #{default_options.persistent}, but we got #{uri.origin}" # We re-create the connection object because we want to let prior requests # lazily load...
ruby
def verify_connection!(uri) if default_options.persistent? && uri.origin != default_options.persistent raise StateError, "Persistence is enabled for #{default_options.persistent}, but we got #{uri.origin}" # We re-create the connection object because we want to let prior requests # lazily load...
[ "def", "verify_connection!", "(", "uri", ")", "if", "default_options", ".", "persistent?", "&&", "uri", ".", "origin", "!=", "default_options", ".", "persistent", "raise", "StateError", ",", "\"Persistence is enabled for #{default_options.persistent}, but we got #{uri.origin}...
Verify our request isn't going to be made against another URI
[ "Verify", "our", "request", "isn", "t", "going", "to", "be", "made", "against", "another", "URI" ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/client.rb#L110-L122
11,360
httprb/http
lib/http/client.rb
HTTP.Client.make_request_uri
def make_request_uri(uri, opts) uri = uri.to_s if default_options.persistent? && uri !~ HTTP_OR_HTTPS_RE uri = "#{default_options.persistent}#{uri}" end uri = HTTP::URI.parse uri if opts.params && !opts.params.empty? uri.query_values = uri.query_values(Array).to_a.concat...
ruby
def make_request_uri(uri, opts) uri = uri.to_s if default_options.persistent? && uri !~ HTTP_OR_HTTPS_RE uri = "#{default_options.persistent}#{uri}" end uri = HTTP::URI.parse uri if opts.params && !opts.params.empty? uri.query_values = uri.query_values(Array).to_a.concat...
[ "def", "make_request_uri", "(", "uri", ",", "opts", ")", "uri", "=", "uri", ".", "to_s", "if", "default_options", ".", "persistent?", "&&", "uri", "!~", "HTTP_OR_HTTPS_RE", "uri", "=", "\"#{default_options.persistent}#{uri}\"", "end", "uri", "=", "HTTP", "::", ...
Merges query params if needed @param [#to_s] uri @return [URI]
[ "Merges", "query", "params", "if", "needed" ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/client.rb#L128-L147
11,361
httprb/http
lib/http/client.rb
HTTP.Client.make_request_body
def make_request_body(opts, headers) case when opts.body opts.body when opts.form form = HTTP::FormData.create opts.form headers[Headers::CONTENT_TYPE] ||= form.content_type form when opts.json body = MimeType[:json].encode opts.json headers[Header...
ruby
def make_request_body(opts, headers) case when opts.body opts.body when opts.form form = HTTP::FormData.create opts.form headers[Headers::CONTENT_TYPE] ||= form.content_type form when opts.json body = MimeType[:json].encode opts.json headers[Header...
[ "def", "make_request_body", "(", "opts", ",", "headers", ")", "case", "when", "opts", ".", "body", "opts", ".", "body", "when", "opts", ".", "form", "form", "=", "HTTP", "::", "FormData", ".", "create", "opts", ".", "form", "headers", "[", "Headers", "...
Create the request body object to send
[ "Create", "the", "request", "body", "object", "to", "send" ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/client.rb#L167-L180
11,362
httprb/http
lib/http/headers.rb
HTTP.Headers.delete
def delete(name) name = normalize_header name.to_s @pile.delete_if { |k, _| k == name } end
ruby
def delete(name) name = normalize_header name.to_s @pile.delete_if { |k, _| k == name } end
[ "def", "delete", "(", "name", ")", "name", "=", "normalize_header", "name", ".", "to_s", "@pile", ".", "delete_if", "{", "|", "k", ",", "_", "|", "k", "==", "name", "}", "end" ]
Removes header. @param [#to_s] name header name @return [void]
[ "Removes", "header", "." ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/headers.rb#L41-L44
11,363
httprb/http
lib/http/headers.rb
HTTP.Headers.add
def add(name, value) name = normalize_header name.to_s Array(value).each { |v| @pile << [name, validate_value(v)] } end
ruby
def add(name, value) name = normalize_header name.to_s Array(value).each { |v| @pile << [name, validate_value(v)] } end
[ "def", "add", "(", "name", ",", "value", ")", "name", "=", "normalize_header", "name", ".", "to_s", "Array", "(", "value", ")", ".", "each", "{", "|", "v", "|", "@pile", "<<", "[", "name", ",", "validate_value", "(", "v", ")", "]", "}", "end" ]
Appends header. @param [#to_s] name header name @param [Array<#to_s>, #to_s] value header value(s) to be appended @return [void]
[ "Appends", "header", "." ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/headers.rb#L51-L54
11,364
httprb/http
lib/http/headers.rb
HTTP.Headers.get
def get(name) name = normalize_header name.to_s @pile.select { |k, _| k == name }.map { |_, v| v } end
ruby
def get(name) name = normalize_header name.to_s @pile.select { |k, _| k == name }.map { |_, v| v } end
[ "def", "get", "(", "name", ")", "name", "=", "normalize_header", "name", ".", "to_s", "@pile", ".", "select", "{", "|", "k", ",", "_", "|", "k", "==", "name", "}", ".", "map", "{", "|", "_", ",", "v", "|", "v", "}", "end" ]
Returns list of header values if any. @return [Array<String>]
[ "Returns", "list", "of", "header", "values", "if", "any", "." ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/headers.rb#L59-L62
11,365
httprb/http
lib/http/headers.rb
HTTP.Headers.include?
def include?(name) name = normalize_header name.to_s @pile.any? { |k, _| k == name } end
ruby
def include?(name) name = normalize_header name.to_s @pile.any? { |k, _| k == name } end
[ "def", "include?", "(", "name", ")", "name", "=", "normalize_header", "name", ".", "to_s", "@pile", ".", "any?", "{", "|", "k", ",", "_", "|", "k", "==", "name", "}", "end" ]
Tells whenever header with given `name` is set or not. @return [Boolean]
[ "Tells", "whenever", "header", "with", "given", "name", "is", "set", "or", "not", "." ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/headers.rb#L82-L85
11,366
httprb/http
lib/http/headers.rb
HTTP.Headers.merge!
def merge!(other) self.class.coerce(other).to_h.each { |name, values| set name, values } end
ruby
def merge!(other) self.class.coerce(other).to_h.each { |name, values| set name, values } end
[ "def", "merge!", "(", "other", ")", "self", ".", "class", ".", "coerce", "(", "other", ")", ".", "to_h", ".", "each", "{", "|", "name", ",", "values", "|", "set", "name", ",", "values", "}", "end" ]
Merges `other` headers into `self`. @see #merge @return [void]
[ "Merges", "other", "headers", "into", "self", "." ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/headers.rb#L160-L162
11,367
httprb/http
lib/http/headers.rb
HTTP.Headers.normalize_header
def normalize_header(name) return name if name =~ CANONICAL_NAME_RE normalized = name.split(/[\-_]/).each(&:capitalize!).join("-") return normalized if normalized =~ COMPLIANT_NAME_RE raise HeaderError, "Invalid HTTP header field name: #{name.inspect}" end
ruby
def normalize_header(name) return name if name =~ CANONICAL_NAME_RE normalized = name.split(/[\-_]/).each(&:capitalize!).join("-") return normalized if normalized =~ COMPLIANT_NAME_RE raise HeaderError, "Invalid HTTP header field name: #{name.inspect}" end
[ "def", "normalize_header", "(", "name", ")", "return", "name", "if", "name", "=~", "CANONICAL_NAME_RE", "normalized", "=", "name", ".", "split", "(", "/", "\\-", "/", ")", ".", "each", "(", ":capitalize!", ")", ".", "join", "(", "\"-\"", ")", "return", ...
Transforms `name` to canonical HTTP header capitalization @param [String] name @raise [HeaderError] if normalized name does not match {HEADER_NAME_RE} @return [String] canonical HTTP header name
[ "Transforms", "name", "to", "canonical", "HTTP", "header", "capitalization" ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/headers.rb#L203-L211
11,368
httprb/http
lib/http/headers.rb
HTTP.Headers.validate_value
def validate_value(value) v = value.to_s return v unless v.include?("\n") raise HeaderError, "Invalid HTTP header field value: #{v.inspect}" end
ruby
def validate_value(value) v = value.to_s return v unless v.include?("\n") raise HeaderError, "Invalid HTTP header field value: #{v.inspect}" end
[ "def", "validate_value", "(", "value", ")", "v", "=", "value", ".", "to_s", "return", "v", "unless", "v", ".", "include?", "(", "\"\\n\"", ")", "raise", "HeaderError", ",", "\"Invalid HTTP header field value: #{v.inspect}\"", "end" ]
Ensures there is no new line character in the header value @param [String] value @raise [HeaderError] if value includes new line character @return [String] stringified header value
[ "Ensures", "there", "is", "no", "new", "line", "character", "in", "the", "header", "value" ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/headers.rb#L218-L222
11,369
httprb/http
lib/http/redirector.rb
HTTP.Redirector.redirect_to
def redirect_to(uri) raise StateError, "no Location header in redirect" unless uri verb = @request.verb code = @response.status.code if UNSAFE_VERBS.include?(verb) && STRICT_SENSITIVE_CODES.include?(code) raise StateError, "can't follow #{@response.status} redirect" if @strict ...
ruby
def redirect_to(uri) raise StateError, "no Location header in redirect" unless uri verb = @request.verb code = @response.status.code if UNSAFE_VERBS.include?(verb) && STRICT_SENSITIVE_CODES.include?(code) raise StateError, "can't follow #{@response.status} redirect" if @strict ...
[ "def", "redirect_to", "(", "uri", ")", "raise", "StateError", ",", "\"no Location header in redirect\"", "unless", "uri", "verb", "=", "@request", ".", "verb", "code", "=", "@response", ".", "status", ".", "code", "if", "UNSAFE_VERBS", ".", "include?", "(", "v...
Redirect policy for follow @return [Request]
[ "Redirect", "policy", "for", "follow" ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/redirector.rb#L84-L98
11,370
httprb/http
lib/http/request.rb
HTTP.Request.stream
def stream(socket) include_proxy_headers if using_proxy? && !@uri.https? Request::Writer.new(socket, body, headers, headline).stream end
ruby
def stream(socket) include_proxy_headers if using_proxy? && !@uri.https? Request::Writer.new(socket, body, headers, headline).stream end
[ "def", "stream", "(", "socket", ")", "include_proxy_headers", "if", "using_proxy?", "&&", "!", "@uri", ".", "https?", "Request", "::", "Writer", ".", "new", "(", "socket", ",", "body", ",", "headers", ",", "headline", ")", ".", "stream", "end" ]
Stream the request to a socket
[ "Stream", "the", "request", "to", "a", "socket" ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/request.rb#L116-L119
11,371
httprb/http
lib/http/request.rb
HTTP.Request.proxy_connect_headers
def proxy_connect_headers connect_headers = HTTP::Headers.coerce( Headers::HOST => headers[Headers::HOST], Headers::USER_AGENT => headers[Headers::USER_AGENT] ) connect_headers[Headers::PROXY_AUTHORIZATION] = proxy_authorization_header if using_authenticated_proxy? conne...
ruby
def proxy_connect_headers connect_headers = HTTP::Headers.coerce( Headers::HOST => headers[Headers::HOST], Headers::USER_AGENT => headers[Headers::USER_AGENT] ) connect_headers[Headers::PROXY_AUTHORIZATION] = proxy_authorization_header if using_authenticated_proxy? conne...
[ "def", "proxy_connect_headers", "connect_headers", "=", "HTTP", "::", "Headers", ".", "coerce", "(", "Headers", "::", "HOST", "=>", "headers", "[", "Headers", "::", "HOST", "]", ",", "Headers", "::", "USER_AGENT", "=>", "headers", "[", "Headers", "::", "USER...
Headers to send with proxy connect request
[ "Headers", "to", "send", "with", "proxy", "connect", "request" ]
f37a10ea4fab3ee411907ea2e4251ddf0ca33a93
https://github.com/httprb/http/blob/f37a10ea4fab3ee411907ea2e4251ddf0ca33a93/lib/http/request.rb#L169-L178
11,372
roo-rb/roo
lib/roo/excelx.rb
Roo.Excelx.column
def column(column_number, sheet = nil) if column_number.is_a?(::String) column_number = ::Roo::Utils.letter_to_number(column_number) end sheet_for(sheet).column(column_number) end
ruby
def column(column_number, sheet = nil) if column_number.is_a?(::String) column_number = ::Roo::Utils.letter_to_number(column_number) end sheet_for(sheet).column(column_number) end
[ "def", "column", "(", "column_number", ",", "sheet", "=", "nil", ")", "if", "column_number", ".", "is_a?", "(", "::", "String", ")", "column_number", "=", "::", "Roo", "::", "Utils", ".", "letter_to_number", "(", "column_number", ")", "end", "sheet_for", "...
returns all values in this column as an array column numbers are 1,2,3,... like in the spreadsheet
[ "returns", "all", "values", "in", "this", "column", "as", "an", "array", "column", "numbers", "are", "1", "2", "3", "...", "like", "in", "the", "spreadsheet" ]
4ec1104f0c3c2a29711c0c907371cd2be12bcc3c
https://github.com/roo-rb/roo/blob/4ec1104f0c3c2a29711c0c907371cd2be12bcc3c/lib/roo/excelx.rb#L124-L129
11,373
roo-rb/roo
lib/roo/excelx.rb
Roo.Excelx.excelx_format
def excelx_format(row, col, sheet = nil) key = normalize(row, col) sheet_for(sheet).excelx_format(key) end
ruby
def excelx_format(row, col, sheet = nil) key = normalize(row, col) sheet_for(sheet).excelx_format(key) end
[ "def", "excelx_format", "(", "row", ",", "col", ",", "sheet", "=", "nil", ")", "key", "=", "normalize", "(", "row", ",", "col", ")", "sheet_for", "(", "sheet", ")", ".", "excelx_format", "(", "key", ")", "end" ]
returns the internal format of an excel cell
[ "returns", "the", "internal", "format", "of", "an", "excel", "cell" ]
4ec1104f0c3c2a29711c0c907371cd2be12bcc3c
https://github.com/roo-rb/roo/blob/4ec1104f0c3c2a29711c0c907371cd2be12bcc3c/lib/roo/excelx.rb#L226-L229
11,374
roo-rb/roo
lib/roo/excelx.rb
Roo.Excelx.process_zipfile
def process_zipfile(zipfilename_or_stream) @sheet_files = [] unless is_stream?(zipfilename_or_stream) zip_file = Zip::File.open(zipfilename_or_stream) else zip_file = Zip::CentralDirectory.new zip_file.read_from_stream zipfilename_or_stream end process_zipfile_ent...
ruby
def process_zipfile(zipfilename_or_stream) @sheet_files = [] unless is_stream?(zipfilename_or_stream) zip_file = Zip::File.open(zipfilename_or_stream) else zip_file = Zip::CentralDirectory.new zip_file.read_from_stream zipfilename_or_stream end process_zipfile_ent...
[ "def", "process_zipfile", "(", "zipfilename_or_stream", ")", "@sheet_files", "=", "[", "]", "unless", "is_stream?", "(", "zipfilename_or_stream", ")", "zip_file", "=", "Zip", "::", "File", ".", "open", "(", "zipfilename_or_stream", ")", "else", "zip_file", "=", ...
Extracts all needed files from the zip file
[ "Extracts", "all", "needed", "files", "from", "the", "zip", "file" ]
4ec1104f0c3c2a29711c0c907371cd2be12bcc3c
https://github.com/roo-rb/roo/blob/4ec1104f0c3c2a29711c0c907371cd2be12bcc3c/lib/roo/excelx.rb#L394-L405
11,375
roo-rb/roo
lib/roo/open_office.rb
Roo.OpenOffice.decrypt_if_necessary
def decrypt_if_necessary( zip_file, content_entry, roo_content_xml_path, options ) # Check if content.xml is encrypted by extracting manifest.xml # and searching for a manifest:encryption-data element if (manifest_entry = zip_file.glob('META-INF/manifest.xml').first) roo...
ruby
def decrypt_if_necessary( zip_file, content_entry, roo_content_xml_path, options ) # Check if content.xml is encrypted by extracting manifest.xml # and searching for a manifest:encryption-data element if (manifest_entry = zip_file.glob('META-INF/manifest.xml').first) roo...
[ "def", "decrypt_if_necessary", "(", "zip_file", ",", "content_entry", ",", "roo_content_xml_path", ",", "options", ")", "# Check if content.xml is encrypted by extracting manifest.xml", "# and searching for a manifest:encryption-data element", "if", "(", "manifest_entry", "=", "zip...
If the ODS file has an encryption-data element, then try to decrypt. If successful, the temporary content.xml will be overwritten with decrypted contents.
[ "If", "the", "ODS", "file", "has", "an", "encryption", "-", "data", "element", "then", "try", "to", "decrypt", ".", "If", "successful", "the", "temporary", "content", ".", "xml", "will", "be", "overwritten", "with", "decrypted", "contents", "." ]
4ec1104f0c3c2a29711c0c907371cd2be12bcc3c
https://github.com/roo-rb/roo/blob/4ec1104f0c3c2a29711c0c907371cd2be12bcc3c/lib/roo/open_office.rb#L227-L270
11,376
roo-rb/roo
lib/roo/open_office.rb
Roo.OpenOffice.perform_decryption
def perform_decryption( encryption_data, password, content_entry, roo_content_xml_path ) # Extract various expected attributes from the manifest that # describe the encryption algorithm_node = encryption_data.xpath('manifest:algorithm').first key_derivatio...
ruby
def perform_decryption( encryption_data, password, content_entry, roo_content_xml_path ) # Extract various expected attributes from the manifest that # describe the encryption algorithm_node = encryption_data.xpath('manifest:algorithm').first key_derivatio...
[ "def", "perform_decryption", "(", "encryption_data", ",", "password", ",", "content_entry", ",", "roo_content_xml_path", ")", "# Extract various expected attributes from the manifest that", "# describe the encryption", "algorithm_node", "=", "encryption_data", ".", "xpath", "(", ...
Process the ODS encryption manifest and perform the decryption
[ "Process", "the", "ODS", "encryption", "manifest", "and", "perform", "the", "decryption" ]
4ec1104f0c3c2a29711c0c907371cd2be12bcc3c
https://github.com/roo-rb/roo/blob/4ec1104f0c3c2a29711c0c907371cd2be12bcc3c/lib/roo/open_office.rb#L273-L344
11,377
roo-rb/roo
lib/roo/open_office.rb
Roo.OpenOffice.find_cipher_key
def find_cipher_key(*args) fail ArgumentError, 'Unknown key derivation name ', args[1] unless args[1] == 'PBKDF2' ::OpenSSL::PKCS5.pbkdf2_hmac_sha1(args[2], args[3], args[4], args[0].key_len) end
ruby
def find_cipher_key(*args) fail ArgumentError, 'Unknown key derivation name ', args[1] unless args[1] == 'PBKDF2' ::OpenSSL::PKCS5.pbkdf2_hmac_sha1(args[2], args[3], args[4], args[0].key_len) end
[ "def", "find_cipher_key", "(", "*", "args", ")", "fail", "ArgumentError", ",", "'Unknown key derivation name '", ",", "args", "[", "1", "]", "unless", "args", "[", "1", "]", "==", "'PBKDF2'", "::", "OpenSSL", "::", "PKCS5", ".", "pbkdf2_hmac_sha1", "(", "arg...
Create a cipher key based on an ODS algorithm string from manifest.xml
[ "Create", "a", "cipher", "key", "based", "on", "an", "ODS", "algorithm", "string", "from", "manifest", ".", "xml" ]
4ec1104f0c3c2a29711c0c907371cd2be12bcc3c
https://github.com/roo-rb/roo/blob/4ec1104f0c3c2a29711c0c907371cd2be12bcc3c/lib/roo/open_office.rb#L361-L365
11,378
roo-rb/roo
lib/roo/open_office.rb
Roo.OpenOffice.decrypt
def decrypt(content_entry, cipher) # Zip::Entry.extract writes a 0-length file when trying # to extract an encrypted stream, so we read the # raw bytes based on the offset and lengths decrypted = '' File.open(@filename, 'rb') do |zipfile| zipfile.seek( content_entry.local...
ruby
def decrypt(content_entry, cipher) # Zip::Entry.extract writes a 0-length file when trying # to extract an encrypted stream, so we read the # raw bytes based on the offset and lengths decrypted = '' File.open(@filename, 'rb') do |zipfile| zipfile.seek( content_entry.local...
[ "def", "decrypt", "(", "content_entry", ",", "cipher", ")", "# Zip::Entry.extract writes a 0-length file when trying", "# to extract an encrypted stream, so we read the", "# raw bytes based on the offset and lengths", "decrypted", "=", "''", "File", ".", "open", "(", "@filename", ...
Block decrypt raw bytes from the zip file based on the cipher
[ "Block", "decrypt", "raw", "bytes", "from", "the", "zip", "file", "based", "on", "the", "cipher" ]
4ec1104f0c3c2a29711c0c907371cd2be12bcc3c
https://github.com/roo-rb/roo/blob/4ec1104f0c3c2a29711c0c907371cd2be12bcc3c/lib/roo/open_office.rb#L368-L394
11,379
roo-rb/roo
lib/roo/open_office.rb
Roo.OpenOffice.set_cell_values
def set_cell_values(sheet, x, y, i, v, value_type, formula, table_cell, str_v, style_name) key = [y, x + i] @cell_type[sheet] ||= {} @cell_type[sheet][key] = value_type.to_sym if value_type @formula[sheet] ||= {} if formula ['of:', 'oooc:'].each do |prefix| if formula[0, ...
ruby
def set_cell_values(sheet, x, y, i, v, value_type, formula, table_cell, str_v, style_name) key = [y, x + i] @cell_type[sheet] ||= {} @cell_type[sheet][key] = value_type.to_sym if value_type @formula[sheet] ||= {} if formula ['of:', 'oooc:'].each do |prefix| if formula[0, ...
[ "def", "set_cell_values", "(", "sheet", ",", "x", ",", "y", ",", "i", ",", "v", ",", "value_type", ",", "formula", ",", "table_cell", ",", "str_v", ",", "style_name", ")", "key", "=", "[", "y", ",", "x", "+", "i", "]", "@cell_type", "[", "sheet", ...
helper function to set the internal representation of cells
[ "helper", "function", "to", "set", "the", "internal", "representation", "of", "cells" ]
4ec1104f0c3c2a29711c0c907371cd2be12bcc3c
https://github.com/roo-rb/roo/blob/4ec1104f0c3c2a29711c0c907371cd2be12bcc3c/lib/roo/open_office.rb#L408-L447
11,380
roo-rb/roo
lib/roo/utils.rb
Roo.Utils.num_cells_in_range
def num_cells_in_range(str) cells = str.split(':') return 1 if cells.count == 1 raise ArgumentError.new("invalid range string: #{str}. Supported range format 'A1:B2'") if cells.count != 2 x1, y1 = extract_coordinate(cells[0]) x2, y2 = extract_coordinate(cells[1]) (x2 - (x1 - 1)) * (y...
ruby
def num_cells_in_range(str) cells = str.split(':') return 1 if cells.count == 1 raise ArgumentError.new("invalid range string: #{str}. Supported range format 'A1:B2'") if cells.count != 2 x1, y1 = extract_coordinate(cells[0]) x2, y2 = extract_coordinate(cells[1]) (x2 - (x1 - 1)) * (y...
[ "def", "num_cells_in_range", "(", "str", ")", "cells", "=", "str", ".", "split", "(", "':'", ")", "return", "1", "if", "cells", ".", "count", "==", "1", "raise", "ArgumentError", ".", "new", "(", "\"invalid range string: #{str}. Supported range format 'A1:B2'\"", ...
Compute upper bound for cells in a given cell range.
[ "Compute", "upper", "bound", "for", "cells", "in", "a", "given", "cell", "range", "." ]
4ec1104f0c3c2a29711c0c907371cd2be12bcc3c
https://github.com/roo-rb/roo/blob/4ec1104f0c3c2a29711c0c907371cd2be12bcc3c/lib/roo/utils.rb#L69-L76
11,381
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.catalog
def catalog bundle new_map_hash = {} # Bundle always needs to be merged if it adds or removes sources merged = (bundle.sources.length == source_map_hash.values.length) bundle.sources.each do |source| if source_map_hash.key?(source.filename) if source_map_hash[source.filename].c...
ruby
def catalog bundle new_map_hash = {} # Bundle always needs to be merged if it adds or removes sources merged = (bundle.sources.length == source_map_hash.values.length) bundle.sources.each do |source| if source_map_hash.key?(source.filename) if source_map_hash[source.filename].c...
[ "def", "catalog", "bundle", "new_map_hash", "=", "{", "}", "# Bundle always needs to be merged if it adds or removes sources", "merged", "=", "(", "bundle", ".", "sources", ".", "length", "==", "source_map_hash", ".", "values", ".", "length", ")", "bundle", ".", "so...
Catalog a bundle. @param bundle [Bundle] @return [self]
[ "Catalog", "a", "bundle", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L64-L123
11,382
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.clip_at
def clip_at filename, position position = Position.normalize(position) SourceMap::Clip.new(self, cursor_at(filename, position)) end
ruby
def clip_at filename, position position = Position.normalize(position) SourceMap::Clip.new(self, cursor_at(filename, position)) end
[ "def", "clip_at", "filename", ",", "position", "position", "=", "Position", ".", "normalize", "(", "position", ")", "SourceMap", "::", "Clip", ".", "new", "(", "self", ",", "cursor_at", "(", "filename", ",", "position", ")", ")", "end" ]
Get a clip by filename and position. @param filename [String] @param position [Position, Array(Integer, Integer)] @return [SourceMap::Clip]
[ "Get", "a", "clip", "by", "filename", "and", "position", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L139-L142
11,383
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.get_constants
def get_constants namespace, context = '' namespace ||= '' cached = cache.get_constants(namespace, context) return cached.clone unless cached.nil? skip = [] result = [] bases = context.split('::') while bases.length > 0 built = bases.join('::') fqns = qualify(na...
ruby
def get_constants namespace, context = '' namespace ||= '' cached = cache.get_constants(namespace, context) return cached.clone unless cached.nil? skip = [] result = [] bases = context.split('::') while bases.length > 0 built = bases.join('::') fqns = qualify(na...
[ "def", "get_constants", "namespace", ",", "context", "=", "''", "namespace", "||=", "''", "cached", "=", "cache", ".", "get_constants", "(", "namespace", ",", "context", ")", "return", "cached", ".", "clone", "unless", "cached", ".", "nil?", "skip", "=", "...
Get suggestions for constants in the specified namespace. The result may contain both constant and namespace pins. @param namespace [String] The namespace @param context [String] The context @return [Array<Solargraph::Pin::Base>]
[ "Get", "suggestions", "for", "constants", "in", "the", "specified", "namespace", ".", "The", "result", "may", "contain", "both", "constant", "and", "namespace", "pins", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L191-L212
11,384
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.qualify
def qualify namespace, context = '' # @todo The return for self might work better elsewhere return nil if namespace.nil? return qualify(context) if namespace == 'self' cached = cache.get_qualified_namespace(namespace, context) return cached.clone unless cached.nil? result = if namesp...
ruby
def qualify namespace, context = '' # @todo The return for self might work better elsewhere return nil if namespace.nil? return qualify(context) if namespace == 'self' cached = cache.get_qualified_namespace(namespace, context) return cached.clone unless cached.nil? result = if namesp...
[ "def", "qualify", "namespace", ",", "context", "=", "''", "# @todo The return for self might work better elsewhere", "return", "nil", "if", "namespace", ".", "nil?", "return", "qualify", "(", "context", ")", "if", "namespace", "==", "'self'", "cached", "=", "cache",...
Get a fully qualified namespace name. This method will start the search in the specified context until it finds a match for the name. @param namespace [String, nil] The namespace to match @param context [String] The context to search @return [String]
[ "Get", "a", "fully", "qualified", "namespace", "name", ".", "This", "method", "will", "start", "the", "search", "in", "the", "specified", "context", "until", "it", "finds", "a", "match", "for", "the", "name", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L220-L233
11,385
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.get_instance_variable_pins
def get_instance_variable_pins(namespace, scope = :instance) result = [] result.concat store.get_instance_variables(namespace, scope) sc = qualify(store.get_superclass(namespace), namespace) until sc.nil? result.concat store.get_instance_variables(sc, scope) sc = qualify(store.ge...
ruby
def get_instance_variable_pins(namespace, scope = :instance) result = [] result.concat store.get_instance_variables(namespace, scope) sc = qualify(store.get_superclass(namespace), namespace) until sc.nil? result.concat store.get_instance_variables(sc, scope) sc = qualify(store.ge...
[ "def", "get_instance_variable_pins", "(", "namespace", ",", "scope", "=", ":instance", ")", "result", "=", "[", "]", "result", ".", "concat", "store", ".", "get_instance_variables", "(", "namespace", ",", "scope", ")", "sc", "=", "qualify", "(", "store", "."...
Get an array of instance variable pins defined in specified namespace and scope. @param namespace [String] A fully qualified namespace @param scope [Symbol] :instance or :class @return [Array<Solargraph::Pin::InstanceVariable>]
[ "Get", "an", "array", "of", "instance", "variable", "pins", "defined", "in", "specified", "namespace", "and", "scope", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L241-L250
11,386
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.get_methods
def get_methods fqns, scope: :instance, visibility: [:public], deep: true cached = cache.get_methods(fqns, scope, visibility, deep) return cached.clone unless cached.nil? result = [] skip = [] if fqns == '' # @todo Implement domains # domains.each do |domain| # ty...
ruby
def get_methods fqns, scope: :instance, visibility: [:public], deep: true cached = cache.get_methods(fqns, scope, visibility, deep) return cached.clone unless cached.nil? result = [] skip = [] if fqns == '' # @todo Implement domains # domains.each do |domain| # ty...
[ "def", "get_methods", "fqns", ",", "scope", ":", ":instance", ",", "visibility", ":", "[", ":public", "]", ",", "deep", ":", "true", "cached", "=", "cache", ".", "get_methods", "(", "fqns", ",", "scope", ",", "visibility", ",", "deep", ")", "return", "...
Get an array of methods available in a particular context. @param fqns [String] The fully qualified namespace to search for methods @param scope [Symbol] :class or :instance @param visibility [Array<Symbol>] :public, :protected, and/or :private @param deep [Boolean] True to include superclasses, mixins, etc. @ret...
[ "Get", "an", "array", "of", "methods", "available", "in", "a", "particular", "context", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L278-L303
11,387
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.get_complex_type_methods
def get_complex_type_methods type, context = '', internal = false # This method does not qualify the complex type's namespace because # it can cause conflicts between similar names, e.g., `Foo` vs. # `Other::Foo`. It still takes a context argument to determine whether # protected and private met...
ruby
def get_complex_type_methods type, context = '', internal = false # This method does not qualify the complex type's namespace because # it can cause conflicts between similar names, e.g., `Foo` vs. # `Other::Foo`. It still takes a context argument to determine whether # protected and private met...
[ "def", "get_complex_type_methods", "type", ",", "context", "=", "''", ",", "internal", "=", "false", "# This method does not qualify the complex type's namespace because", "# it can cause conflicts between similar names, e.g., `Foo` vs.", "# `Other::Foo`. It still takes a context argument ...
Get an array of method pins for a complex type. The type's namespace and the context should be fully qualified. If the context matches the namespace type or is a subclass of the type, protected methods are included in the results. If protected methods are included and internal is true, private methods are also inc...
[ "Get", "an", "array", "of", "method", "pins", "for", "a", "complex", "type", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L321-L344
11,388
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.get_method_stack
def get_method_stack fqns, name, scope: :instance get_methods(fqns, scope: scope, visibility: [:private, :protected, :public]).select{|p| p.name == name} end
ruby
def get_method_stack fqns, name, scope: :instance get_methods(fqns, scope: scope, visibility: [:private, :protected, :public]).select{|p| p.name == name} end
[ "def", "get_method_stack", "fqns", ",", "name", ",", "scope", ":", ":instance", "get_methods", "(", "fqns", ",", "scope", ":", "scope", ",", "visibility", ":", "[", ":private", ",", ":protected", ",", ":public", "]", ")", ".", "select", "{", "|", "p", ...
Get a stack of method pins for a method name in a namespace. The order of the pins corresponds to the ancestry chain, with highest precedence first. @example api_map.get_method_stack('Subclass', 'method_name') #=> [ <Subclass#method_name pin>, <Superclass#method_name pin> ] @param fqns [String] @param na...
[ "Get", "a", "stack", "of", "method", "pins", "for", "a", "method", "name", "in", "a", "namespace", ".", "The", "order", "of", "the", "pins", "corresponds", "to", "the", "ancestry", "chain", "with", "highest", "precedence", "first", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L358-L360
11,389
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.get_path_suggestions
def get_path_suggestions path return [] if path.nil? result = [] result.concat store.get_path_pins(path) # if result.empty? # lp = live_map.get_path_pin(path) # result.push lp unless lp.nil? # end resolve_method_aliases(result) end
ruby
def get_path_suggestions path return [] if path.nil? result = [] result.concat store.get_path_pins(path) # if result.empty? # lp = live_map.get_path_pin(path) # result.push lp unless lp.nil? # end resolve_method_aliases(result) end
[ "def", "get_path_suggestions", "path", "return", "[", "]", "if", "path", ".", "nil?", "result", "=", "[", "]", "result", ".", "concat", "store", ".", "get_path_pins", "(", "path", ")", "# if result.empty?", "# lp = live_map.get_path_pin(path)", "# result.push lp...
Get an array of all suggestions that match the specified path. @deprecated Use #get_path_pins instead. @param path [String] The path to find @return [Array<Solargraph::Pin::Base>]
[ "Get", "an", "array", "of", "all", "suggestions", "that", "match", "the", "specified", "path", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L368-L377
11,390
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.search
def search query rake_yard(store) found = [] code_object_paths.each do |k| if found.empty? || (query.include?('.') || query.include?('#')) || !(k.include?('.') || k.include?('#')) found.push k if k.downcase.include?(query.downcase) end end found end
ruby
def search query rake_yard(store) found = [] code_object_paths.each do |k| if found.empty? || (query.include?('.') || query.include?('#')) || !(k.include?('.') || k.include?('#')) found.push k if k.downcase.include?(query.downcase) end end found end
[ "def", "search", "query", "rake_yard", "(", "store", ")", "found", "=", "[", "]", "code_object_paths", ".", "each", "do", "|", "k", "|", "if", "found", ".", "empty?", "||", "(", "query", ".", "include?", "(", "'.'", ")", "||", "query", ".", "include?...
Get a list of documented paths that match the query. @example api_map.query('str') # Results will include `String` and `Struct` @param query [String] The text to match @return [Array<String>]
[ "Get", "a", "list", "of", "documented", "paths", "that", "match", "the", "query", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L394-L403
11,391
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.document
def document path rake_yard(store) docs = [] docs.push code_object_at(path) unless code_object_at(path).nil? docs end
ruby
def document path rake_yard(store) docs = [] docs.push code_object_at(path) unless code_object_at(path).nil? docs end
[ "def", "document", "path", "rake_yard", "(", "store", ")", "docs", "=", "[", "]", "docs", ".", "push", "code_object_at", "(", "path", ")", "unless", "code_object_at", "(", "path", ")", ".", "nil?", "docs", "end" ]
Get YARD documentation for the specified path. @example api_map.document('String#split') @param path [String] The path to find @return [Array<YARD::CodeObject::Base>]
[ "Get", "YARD", "documentation", "for", "the", "specified", "path", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L412-L417
11,392
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.query_symbols
def query_symbols query result = [] source_map_hash.values.each do |s| result.concat s.query_symbols(query) end result end
ruby
def query_symbols query result = [] source_map_hash.values.each do |s| result.concat s.query_symbols(query) end result end
[ "def", "query_symbols", "query", "result", "=", "[", "]", "source_map_hash", ".", "values", ".", "each", "do", "|", "s", "|", "result", ".", "concat", "s", ".", "query_symbols", "(", "query", ")", "end", "result", "end" ]
Get an array of all symbols in the workspace that match the query. @param query [String] @return [Array<Pin::Base>]
[ "Get", "an", "array", "of", "all", "symbols", "in", "the", "workspace", "that", "match", "the", "query", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L423-L429
11,393
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.require_extensions
def require_extensions Gem::Specification.all_names.select{|n| n.match(/^solargraph\-[a-z0-9_\-]*?\-ext\-[0-9\.]*$/)}.each do |n| Solargraph::Logging.logger.info "Loading extension #{n}" require n.match(/^(solargraph\-[a-z0-9_\-]*?\-ext)\-[0-9\.]*$/)[1] end end
ruby
def require_extensions Gem::Specification.all_names.select{|n| n.match(/^solargraph\-[a-z0-9_\-]*?\-ext\-[0-9\.]*$/)}.each do |n| Solargraph::Logging.logger.info "Loading extension #{n}" require n.match(/^(solargraph\-[a-z0-9_\-]*?\-ext)\-[0-9\.]*$/)[1] end end
[ "def", "require_extensions", "Gem", "::", "Specification", ".", "all_names", ".", "select", "{", "|", "n", "|", "n", ".", "match", "(", "/", "\\-", "\\-", "\\-", "\\-", "\\.", "/", ")", "}", ".", "each", "do", "|", "n", "|", "Solargraph", "::", "Lo...
Require extensions for the experimental plugin architecture. Any installed gem with a name that starts with "solargraph-" is considered an extension. @return [void]
[ "Require", "extensions", "for", "the", "experimental", "plugin", "architecture", ".", "Any", "installed", "gem", "with", "a", "name", "that", "starts", "with", "solargraph", "-", "is", "considered", "an", "extension", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L556-L561
11,394
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.prefer_non_nil_variables
def prefer_non_nil_variables pins result = [] nil_pins = [] pins.each do |pin| if pin.variable? && pin.nil_assignment? nil_pins.push pin else result.push pin end end result + nil_pins end
ruby
def prefer_non_nil_variables pins result = [] nil_pins = [] pins.each do |pin| if pin.variable? && pin.nil_assignment? nil_pins.push pin else result.push pin end end result + nil_pins end
[ "def", "prefer_non_nil_variables", "pins", "result", "=", "[", "]", "nil_pins", "=", "[", "]", "pins", ".", "each", "do", "|", "pin", "|", "if", "pin", ".", "variable?", "&&", "pin", ".", "nil_assignment?", "nil_pins", ".", "push", "pin", "else", "result...
Sort an array of pins to put nil or undefined variables last. @param pins [Array<Solargraph::Pin::Base>] @return [Array<Solargraph::Pin::Base>]
[ "Sort", "an", "array", "of", "pins", "to", "put", "nil", "or", "undefined", "variables", "last", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L620-L631
11,395
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.super_and_sub?
def super_and_sub?(sup, sub) fqsup = qualify(sup) cls = qualify(store.get_superclass(sub), sub) until cls.nil? return true if cls == fqsup cls = qualify(store.get_superclass(cls), cls) end false end
ruby
def super_and_sub?(sup, sub) fqsup = qualify(sup) cls = qualify(store.get_superclass(sub), sub) until cls.nil? return true if cls == fqsup cls = qualify(store.get_superclass(cls), cls) end false end
[ "def", "super_and_sub?", "(", "sup", ",", "sub", ")", "fqsup", "=", "qualify", "(", "sup", ")", "cls", "=", "qualify", "(", "store", ".", "get_superclass", "(", "sub", ")", ",", "sub", ")", "until", "cls", ".", "nil?", "return", "true", "if", "cls", ...
Check if a class is a superclass of another class. @param sup [String] The superclass @param sub [String] The subclass @return [Boolean]
[ "Check", "if", "a", "class", "is", "a", "superclass", "of", "another", "class", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L638-L646
11,396
castwide/solargraph
lib/solargraph/range.rb
Solargraph.Range.contain?
def contain? position position = Position.normalize(position) return false if position.line < start.line || position.line > ending.line return false if position.line == start.line && position.character < start.character return false if position.line == ending.line && position.character > ending....
ruby
def contain? position position = Position.normalize(position) return false if position.line < start.line || position.line > ending.line return false if position.line == start.line && position.character < start.character return false if position.line == ending.line && position.character > ending....
[ "def", "contain?", "position", "position", "=", "Position", ".", "normalize", "(", "position", ")", "return", "false", "if", "position", ".", "line", "<", "start", ".", "line", "||", "position", ".", "line", ">", "ending", ".", "line", "return", "false", ...
True if the specified position is inside the range. @param position [Position, Array(Integer, Integer)] @return [Boolean]
[ "True", "if", "the", "specified", "position", "is", "inside", "the", "range", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/range.rb#L33-L39
11,397
castwide/solargraph
lib/solargraph/range.rb
Solargraph.Range.include?
def include? position position = Position.normalize(position) contain?(position) && !(position.line == start.line && position.character == start.character) end
ruby
def include? position position = Position.normalize(position) contain?(position) && !(position.line == start.line && position.character == start.character) end
[ "def", "include?", "position", "position", "=", "Position", ".", "normalize", "(", "position", ")", "contain?", "(", "position", ")", "&&", "!", "(", "position", ".", "line", "==", "start", ".", "line", "&&", "position", ".", "character", "==", "start", ...
True if the range contains the specified position and the position does not precede it. @param position [Position, Array(Integer, Integer)] @return [Boolean]
[ "True", "if", "the", "range", "contains", "the", "specified", "position", "and", "the", "position", "does", "not", "precede", "it", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/range.rb#L45-L48
11,398
castwide/solargraph
lib/solargraph/source.rb
Solargraph.Source.tree_at
def tree_at(line, column) # offset = Position.line_char_to_offset(@code, line, column) position = Position.new(line, column) stack = [] inner_tree_at @node, position, stack stack end
ruby
def tree_at(line, column) # offset = Position.line_char_to_offset(@code, line, column) position = Position.new(line, column) stack = [] inner_tree_at @node, position, stack stack end
[ "def", "tree_at", "(", "line", ",", "column", ")", "# offset = Position.line_char_to_offset(@code, line, column)", "position", "=", "Position", ".", "new", "(", "line", ",", "column", ")", "stack", "=", "[", "]", "inner_tree_at", "@node", ",", "position", ",", "...
Get an array of nodes containing the specified index, starting with the nearest node and ending with the root. @param line [Integer] @param column [Integer] @return [Array<AST::Node>]
[ "Get", "an", "array", "of", "nodes", "containing", "the", "specified", "index", "starting", "with", "the", "nearest", "node", "and", "ending", "with", "the", "root", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/source.rb#L99-L105
11,399
castwide/solargraph
lib/solargraph/source.rb
Solargraph.Source.synchronize
def synchronize updater raise 'Invalid synchronization' unless updater.filename == filename real_code = updater.write(@code) if real_code == @code @version = updater.version return self end synced = Source.new(real_code, filename) if synced.parsed? synced.vers...
ruby
def synchronize updater raise 'Invalid synchronization' unless updater.filename == filename real_code = updater.write(@code) if real_code == @code @version = updater.version return self end synced = Source.new(real_code, filename) if synced.parsed? synced.vers...
[ "def", "synchronize", "updater", "raise", "'Invalid synchronization'", "unless", "updater", ".", "filename", "==", "filename", "real_code", "=", "updater", ".", "write", "(", "@code", ")", "if", "real_code", "==", "@code", "@version", "=", "updater", ".", "versi...
Synchronize the Source with an update. This method applies changes to the code, parses the new code's AST, and returns the resulting Source object. @param updater [Source::Updater] @return [Source]
[ "Synchronize", "the", "Source", "with", "an", "update", ".", "This", "method", "applies", "changes", "to", "the", "code", "parses", "the", "new", "code", "s", "AST", "and", "returns", "the", "resulting", "Source", "object", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/source.rb#L156-L174