_id
stringlengths
2
6
title
stringlengths
9
130
partition
stringclasses
3 values
text
stringlengths
30
4.3k
language
stringclasses
1 value
meta_information
dict
q11400
Solargraph.Source.location
train
def location st = Position.new(0, 0) en = Position.from_offset(code, code.length) range =
ruby
{ "resource": "" }
q11401
Solargraph.Source.associated_comments
train
def associated_comments @associated_comments ||= begin result = {} Parser::Source::Comment.associate_locations(node, comments).each_pair do |loc, all| block = all #.select{ |l| l.document? || code.lines[l.loc.line].strip.start_with?('#')}
ruby
{ "resource": "" }
q11402
Solargraph.Source.stringify_comment_array
train
def stringify_comment_array comments ctxt = '' num = nil started = false last_line = nil comments.each { |l| # Trim the comment and minimum leading whitespace p = l.text.gsub(/^#+/, '') if num.nil? and !p.strip.empty? num = p.index(/[^ ]/) starte...
ruby
{ "resource": "" }
q11403
Solargraph.Source.foldable_comment_block_ranges
train
def foldable_comment_block_ranges return [] unless synchronized? result = [] grouped = [] # @param cmnt [Parser::Source::Comment] @comments.each do |cmnt| if cmnt.document? result.push Range.from_expr(cmnt.loc.expression) elsif code.lines[cmnt.loc.expression.line]...
ruby
{ "resource": "" }
q11404
Solargraph.Workspace.merge
train
def merge source unless directory == '*' || source_hash.key?(source.filename) # Reload the config to determine if a new source should be included @config = Solargraph::Workspace::Config.new(directory)
ruby
{ "resource": "" }
q11405
Solargraph.Workspace.would_merge?
train
def would_merge? filename return true if directory == '*' || source_hash.include?(filename)
ruby
{ "resource": "" }
q11406
Solargraph.Workspace.remove
train
def remove filename return false unless source_hash.key?(filename)
ruby
{ "resource": "" }
q11407
Solargraph.Workspace.would_require?
train
def would_require? path require_paths.each do |rp|
ruby
{ "resource": "" }
q11408
Solargraph.Workspace.synchronize!
train
def synchronize! updater source_hash[updater.filename]
ruby
{ "resource": "" }
q11409
Solargraph.Workspace.generate_require_paths
train
def generate_require_paths return configured_require_paths unless gemspec? result = [] gemspecs.each do |file| base = File.dirname(file) # @todo Evaluating gemspec files violates the goal of not running # workspace code, but this is how Gem::Specification.load does it ...
ruby
{ "resource": "" }
q11410
Solargraph.Workspace.configured_require_paths
train
def configured_require_paths return ['lib'] if directory.empty? return [File.join(directory,
ruby
{ "resource": "" }
q11411
Solargraph.Library.create
train
def create filename, text result = false mutex.synchronize do next unless contain?(filename) || open?(filename) || workspace.would_merge?(filename) @synchronized = false
ruby
{ "resource": "" }
q11412
Solargraph.Library.create_from_disk
train
def create_from_disk filename result = false mutex.synchronize do next if File.directory?(filename) || !File.exist?(filename) next unless contain?(filename) || open?(filename) || workspace.would_merge?(filename) @synchronized = false
ruby
{ "resource": "" }
q11413
Solargraph.Library.delete
train
def delete filename detach filename result = false mutex.synchronize do result = workspace.remove(filename)
ruby
{ "resource": "" }
q11414
Solargraph.Library.completions_at
train
def completions_at filename, line, column position = Position.new(line, column) cursor =
ruby
{ "resource": "" }
q11415
Solargraph.Library.definitions_at
train
def definitions_at filename, line, column position = Position.new(line, column) cursor =
ruby
{ "resource": "" }
q11416
Solargraph.Library.signatures_at
train
def signatures_at filename, line, column position = Position.new(line, column) cursor =
ruby
{ "resource": "" }
q11417
Solargraph.Library.diagnose
train
def diagnose filename # @todo Only open files get diagnosed. Determine whether anything or # everything in the workspace should get diagnosed, or if there should # be an option to do so. # return [] unless open?(filename) catalog result = [] source = read(filename) ...
ruby
{ "resource": "" }
q11418
Solargraph.Library.catalog
train
def catalog @catalog_mutex.synchronize do break if synchronized? logger.info "Cataloging #{workspace.directory.empty? ? 'generic workspace' : workspace.directory}" api_map.catalog bundle
ruby
{ "resource": "" }
q11419
Solargraph.Library.merge
train
def merge source result = nil mutex.synchronize do result = workspace.merge(source)
ruby
{ "resource": "" }
q11420
Solargraph.Library.read
train
def read filename return @current if @current && @current.filename == filename
ruby
{ "resource": "" }
q11421
Vault.Request.extract_headers!
train
def extract_headers!(options = {}) extract = { wrap_ttl: Vault::Client::WRAP_TTL_HEADER, } {}.tap do |h| extract.each do |k,v| if options[k]
ruby
{ "resource": "" }
q11422
Vault.Sys.unseal
train
def unseal(shard) json = client.put("/v1/sys/unseal", JSON.fast_generate(
ruby
{ "resource": "" }
q11423
Vault.Logical.list
train
def list(path, options = {}) headers = extract_headers!(options) json = client.list("/v1/#{encode_path(path)}", {},
ruby
{ "resource": "" }
q11424
Vault.Logical.read
train
def read(path, options = {}) headers = extract_headers!(options) json = client.get("/v1/#{encode_path(path)}", {}, headers) return
ruby
{ "resource": "" }
q11425
Vault.Logical.unwrap
train
def unwrap(wrapper) client.with_token(wrapper) do |client| json = client.get("/v1/cubbyhole/response") secret = Secret.decode(json) # If there is nothing in the cubbyhole, return early. if secret.nil? || secret.data.nil? || secret.data[:response].nil? return nil ...
ruby
{ "resource": "" }
q11426
Vault.Logical.unwrap_token
train
def unwrap_token(wrapper) # If provided a secret, grab the token. This is really just to make the # API a bit nicer. if wrapper.is_a?(Secret) wrapper = wrapper.wrap_info.token end # Unwrap response = unwrap(wrapper) # If nothing was
ruby
{ "resource": "" }
q11427
Vault.Sys.auths
train
def auths json = client.get("/v1/sys/auth") json = json[:data] if json[:data] return Hash[*json.map do |k,v|
ruby
{ "resource": "" }
q11428
Vault.Sys.enable_auth
train
def enable_auth(path, type, description = nil) payload = { type: type } payload[:description] = description if !description.nil?
ruby
{ "resource": "" }
q11429
Vault.Sys.auth_tune
train
def auth_tune(path) json = client.get("/v1/sys/auth/#{encode_path(path)}/tune") return AuthConfig.decode(json)
ruby
{ "resource": "" }
q11430
Vault.Sys.put_auth_tune
train
def put_auth_tune(path, config = {}) json = client.put("/v1/sys/auth/#{encode_path(path)}/tune", JSON.fast_generate(config))
ruby
{ "resource": "" }
q11431
Vault.PersistentHTTP.expired?
train
def expired? connection return true if @max_requests && connection.requests >= @max_requests return false unless @idle_timeout return true if
ruby
{ "resource": "" }
q11432
Vault.PersistentHTTP.idempotent?
train
def idempotent? req case req when Net::HTTP::Delete, Net::HTTP::Get, Net::HTTP::Head,
ruby
{ "resource": "" }
q11433
Vault.PersistentHTTP.pipeline
train
def pipeline uri, requests, &block # :yields: responses connection_for uri do |connection|
ruby
{ "resource": "" }
q11434
Vault.PersistentHTTP.proxy_from_env
train
def proxy_from_env env_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY'] return nil if env_proxy.nil? or env_proxy.empty? uri = URI normalize_uri env_proxy env_no_proxy = ENV['no_proxy'] || ENV['NO_PROXY'] # '*' is special case for always bypass return nil if env_no_proxy == '*' if env_no_...
ruby
{ "resource": "" }
q11435
Vault.PersistentHTTP.proxy_bypass?
train
def proxy_bypass? host, port host = host.downcase host_port = [host, port].join ':' @no_proxy.each do
ruby
{ "resource": "" }
q11436
Vault.PersistentHTTP.request_failed
train
def request_failed exception, req, connection # :nodoc: due_to = "(due to #{exception.message} - #{exception.class})" message = "too many connection
ruby
{ "resource": "" }
q11437
Vault.PersistentHTTP.request_setup
train
def request_setup req_or_uri # :nodoc: req = if URI === req_or_uri then Net::HTTP::Get.new req_or_uri.request_uri else req_or_uri end @headers.each do |pair| req.add_field(*pair) end @override_headers.each do |name, value| req[name] = value
ruby
{ "resource": "" }
q11438
Vault.Authenticate.token
train
def token(new_token) old_token = client.token client.token = new_token json = client.get("/v1/auth/token/lookup-self") secret = Secret.decode(json)
ruby
{ "resource": "" }
q11439
Vault.Authenticate.app_id
train
def app_id(app_id, user_id, options = {}) payload = { app_id: app_id, user_id: user_id }.merge(options) json = client.post("/v1/auth/app-id/login", JSON.fast_generate(payload))
ruby
{ "resource": "" }
q11440
Vault.Authenticate.approle
train
def approle(role_id, secret_id=nil) payload = { role_id: role_id } payload[:secret_id] = secret_id if secret_id
ruby
{ "resource": "" }
q11441
Vault.Authenticate.userpass
train
def userpass(username, password, options = {}) payload = { password: password }.merge(options) json = client.post("/v1/auth/userpass/login/#{encode_path(username)}",
ruby
{ "resource": "" }
q11442
Vault.Authenticate.github
train
def github(github_token, path="/v1/auth/github/login") payload = {token: github_token} json = client.post(path, JSON.fast_generate(payload)) secret
ruby
{ "resource": "" }
q11443
Vault.Authenticate.aws_ec2
train
def aws_ec2(role, pkcs7, nonce = nil, route = nil) route ||= '/v1/auth/aws-ec2/login' payload = { role: role, pkcs7: pkcs7 } # Set a custom nonce if client is providing one payload[:nonce] = nonce if nonce
ruby
{ "resource": "" }
q11444
Vault.Authenticate.gcp
train
def gcp(role, jwt, path = 'gcp') payload = { role: role, jwt: jwt } json = client.post("/v1/auth/#{CGI.escape(path)}/login", JSON.fast_generate(payload)) secret =
ruby
{ "resource": "" }
q11445
Vault.Authenticate.tls
train
def tls(pem = nil, path = 'cert') new_client = client.dup new_client.ssl_pem_contents = pem if !pem.nil?
ruby
{ "resource": "" }
q11446
Vault.Sys.policy
train
def policy(name) json = client.get("/v1/sys/policy/#{encode_path(name)}") return Policy.decode(json)
ruby
{ "resource": "" }
q11447
Vault.Sys.put_policy
train
def put_policy(name, rules) client.put("/v1/sys/policy/#{encode_path(name)}", JSON.fast_generate(
ruby
{ "resource": "" }
q11448
Vault.Sys.audits
train
def audits json = client.get("/v1/sys/audit") json = json[:data] if json[:data] return Hash[*json.map do |k,v|
ruby
{ "resource": "" }
q11449
Vault.Sys.audit_hash
train
def audit_hash(path, input) json = client.post("/v1/sys/audit-hash/#{encode_path(path)}",
ruby
{ "resource": "" }
q11450
Vault.AuthToken.accessors
train
def accessors(options = {}) headers = extract_headers!(options) json
ruby
{ "resource": "" }
q11451
Vault.AuthToken.create
train
def create(options = {}) headers = extract_headers!(options) json =
ruby
{ "resource": "" }
q11452
Vault.AuthToken.create_with_role
train
def create_with_role(name, options = {}) headers = extract_headers!(options) json = client.post("/v1/auth/token/create/#{encode_path(name)}",
ruby
{ "resource": "" }
q11453
Vault.AuthToken.lookup
train
def lookup(token, options = {}) headers = extract_headers!(options) json = client.post("/v1/auth/token/lookup", JSON.fast_generate(
ruby
{ "resource": "" }
q11454
Vault.AuthToken.lookup_accessor
train
def lookup_accessor(accessor, options = {}) headers = extract_headers!(options) json = client.post("/v1/auth/token/lookup-accessor", JSON.fast_generate(
ruby
{ "resource": "" }
q11455
Vault.AuthToken.renew
train
def renew(token, increment = 0, options = {}) headers = extract_headers!(options) json = client.put("/v1/auth/token/renew", JSON.fast_generate( token: token,
ruby
{ "resource": "" }
q11456
Vault.AuthToken.renew_self
train
def renew_self(increment = 0, options = {}) headers = extract_headers!(options) json = client.put("/v1/auth/token/renew-self", JSON.fast_generate(
ruby
{ "resource": "" }
q11457
Vault.Client.pool
train
def pool @lock.synchronize do return @nhp if @nhp @nhp = PersistentHTTP.new("vault-ruby", nil, pool_size) if proxy_address proxy_uri = URI.parse "http://#{proxy_address}" proxy_uri.port = proxy_port if proxy_port if proxy_username proxy_uri.use...
ruby
{ "resource": "" }
q11458
Vault.Client.list
train
def list(path, params = {}, headers = {}) params = params.merge(list: true)
ruby
{ "resource": "" }
q11459
Vault.Sys.renew
train
def renew(id, increment = 0) json = client.put("/v1/sys/renew/#{id}", JSON.fast_generate(
ruby
{ "resource": "" }
q11460
Vault.Response.to_h
train
def to_h self.class.fields.inject({}) do |h, (k, opts)| if opts[:as].nil? h[k] = self.public_send(k) else
ruby
{ "resource": "" }
q11461
Vault.Sys.init
train
def init(options = {}) json = client.put("/v1/sys/init", JSON.fast_generate( root_token_pgp_key: options.fetch(:root_token_pgp_key, nil), secret_shares: options.fetch(:secret_shares, options.fetch(:shares, 5)), secret_threshold: options.fetch(:secret_threshold, options.fetch(:thresh...
ruby
{ "resource": "" }
q11462
Vault.AppRole.set_role
train
def set_role(name, options = {}) headers = extract_headers!(options)
ruby
{ "resource": "" }
q11463
Vault.AppRole.role
train
def role(name) json = client.get("/v1/auth/approle/role/#{encode_path(name)}") return Secret.decode(json)
ruby
{ "resource": "" }
q11464
Vault.AppRole.role_id
train
def role_id(name) json = client.get("/v1/auth/approle/role/#{encode_path(name)}/role-id") return Secret.decode(json).data[:role_id]
ruby
{ "resource": "" }
q11465
Vault.AppRole.set_role_id
train
def set_role_id(name, role_id) options = { role_id: role_id } client.post("/v1/auth/approle/role/#{en
ruby
{ "resource": "" }
q11466
Vault.AppRole.create_secret_id
train
def create_secret_id(role_name, options = {}) headers = extract_headers!(options) if options[:secret_id] json = client.post("/v1/auth/approle/role/#{encode_path(role_name)}/custom-secret-id", JSON.fast_generate(options), headers) else json
ruby
{ "resource": "" }
q11467
Vault.AppRole.secret_id
train
def secret_id(role_name, secret_id) opts = { secret_id: secret_id } json = client.post("/v1/auth/approle/role/#{encode_path(role_name)}/secret-id/lookup", JSON.fast_generate(opts), {}) return nil unless json return Secret.decode(json) rescue HTTPError => e if e.code == 404 || e.code ==...
ruby
{ "resource": "" }
q11468
Vault.AppRole.secret_id_accessors
train
def secret_id_accessors(role_name, options = {}) headers = extract_headers!(options) json = client.list("/v1/auth/approle/role/#{encode_path(role_name)}/secret-id", options, headers) return
ruby
{ "resource": "" }
q11469
Vault.EncodePath.encode_path
train
def encode_path(path) path.b.gsub(%r!([^a-zA-Z0-9_.-/]+)!) { |m|
ruby
{ "resource": "" }
q11470
Vault.Sys.mounts
train
def mounts json = client.get("/v1/sys/mounts") json = json[:data] if json[:data] return Hash[*json.map do |k,v|
ruby
{ "resource": "" }
q11471
Vault.Sys.mount_tune
train
def mount_tune(path, data = {}) json = client.post("/v1/sys/mounts/#{encode_path(path)}/tune",
ruby
{ "resource": "" }
q11472
Vault.Sys.remount
train
def remount(from, to) client.post("/v1/sys/remount", JSON.fast_generate(
ruby
{ "resource": "" }
q11473
SimpleCov.Configuration.coverage_path
train
def coverage_path @coverage_path ||= begin coverage_path = File.expand_path(coverage_dir, root)
ruby
{ "resource": "" }
q11474
SimpleCov.Configuration.at_exit
train
def at_exit(&block) return proc {} unless running || block_given?
ruby
{ "resource": "" }
q11475
SimpleCov.Configuration.project_name
train
def project_name(new_name = nil) return @project_name if defined?(@project_name) && @project_name && new_name.nil?
ruby
{ "resource": "" }
q11476
SimpleCov.Configuration.parse_filter
train
def parse_filter(filter_argument = nil, &filter_proc) filter = filter_argument || filter_proc if filter SimpleCov::Filter.build_filter(filter) else
ruby
{ "resource": "" }
q11477
SimpleCov.RawCoverage.merge_resultsets
train
def merge_resultsets(result1, result2) (result1.keys | result2.keys).each_with_object({}) do |filename, merged| file1 = result1[filename]
ruby
{ "resource": "" }
q11478
SimpleCov.Profiles.load
train
def load(name) name = name.to_sym raise "Could not find SimpleCov Profile called '#{name}'"
ruby
{ "resource": "" }
q11479
Reek.DocumentationLink.build
train
def build(subject) Kernel.format(HELP_LINK_TEMPLATE, version: Version::STRING,
ruby
{ "resource": "" }
q11480
Inline.C.load_cache
train
def load_cache begin file = File.join("inline", File.basename(so_name)) if require file then dir = Inline.directory warn "WAR\NING: #{dir} exists but is not being
ruby
{ "resource": "" }
q11481
Inline.C.add_type_converter
train
def add_type_converter(type, r2c, c2r) warn "WAR\NING: overridding #{type} on #{caller[0]}" if
ruby
{ "resource": "" }
q11482
Inline.C.c
train
def c src, options = {} options = { :expand_types => true, }.merge
ruby
{ "resource": "" }
q11483
Inline.C.c_singleton
train
def c_singleton src, options = {} options = { :expand_types => true, :singleton => true,
ruby
{ "resource": "" }
q11484
Inline.C.c_raw_singleton
train
def c_raw_singleton src, options = {} options = {
ruby
{ "resource": "" }
q11485
Reek.Spec.reek_of
train
def reek_of(smell_type, smell_details = {}, configuration
ruby
{ "resource": "" }
q11486
Reek.Spec.reek_only_of
train
def reek_only_of(smell_type, configuration = Configuration::AppConfiguration.default)
ruby
{ "resource": "" }
q11487
Reek.ContextBuilder.build
train
def build(exp, parent_exp = nil) context_processor = "process_#{exp.type}" if context_processor_exists?(context_processor) send(context_processor,
ruby
{ "resource": "" }
q11488
Reek.ContextBuilder.process
train
def process(exp) exp.children.grep(AST::Node).each
ruby
{ "resource": "" }
q11489
Reek.ContextBuilder.process_def
train
def process_def(exp, parent) inside_new_context(current_context.method_context_class, exp, parent) do
ruby
{ "resource": "" }
q11490
Reek.ContextBuilder.process_send
train
def process_send(exp, _parent) process(exp) case current_context when Context::ModuleContext
ruby
{ "resource": "" }
q11491
Reek.ContextBuilder.process_if
train
def process_if(exp, _parent) children = exp.children increase_statement_count_by(children[1])
ruby
{ "resource": "" }
q11492
Reek.ContextBuilder.process_rescue
train
def process_rescue(exp, _parent) increase_statement_count_by(exp.children.first)
ruby
{ "resource": "" }
q11493
Reek.ContextBuilder.inside_new_context
train
def inside_new_context(klass, *args) new_context = append_new_context(klass, *args) orig, self.current_context
ruby
{ "resource": "" }
q11494
Reek.ContextBuilder.append_new_context
train
def append_new_context(klass, *args) klass.new(*args).tap do |new_context|
ruby
{ "resource": "" }
q11495
Reek.SmellConfiguration.value
train
def value(key, context) overrides_for(context).each { |conf| return conf[key]
ruby
{ "resource": "" }
q11496
Reek.Overrides.for_context
train
def for_context(context) contexts = hash.keys.select
ruby
{ "resource": "" }
q11497
Reek.TreeDresser.dress
train
def dress(sexp, comment_map) return sexp unless sexp.is_a? ::Parser::AST::Node type = sexp.type children = sexp.children.map { |child| dress(child, comment_map) } comments = comment_map[sexp]
ruby
{ "resource": "" }
q11498
Fluent::Plugin.ElasticsearchOutput.append_record_to_messages
train
def append_record_to_messages(op, meta, header, record, msgs) case op when UPDATE_OP, UPSERT_OP if meta.has_key?(ID_FIELD) header[UPDATE_OP] = meta msgs << @dump_proc.call(header) << BODY_DELIMITER msgs << @dump_proc.call(update_body(record, op)) << BODY_DELIMITER ...
ruby
{ "resource": "" }
q11499
Fluent::Plugin.ElasticsearchOutput.send_bulk
train
def send_bulk(data, tag, chunk, bulk_message_count, extracted_values, info) begin log.on_trace { log.trace "bulk request: #{data}" } response = client(info.host).bulk body: data, index: info.index log.on_trace { log.trace "bulk response: #{response}" } if response['errors'] ...
ruby
{ "resource": "" }