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,400 | castwide/solargraph | lib/solargraph/source.rb | Solargraph.Source.location | def location
st = Position.new(0, 0)
en = Position.from_offset(code, code.length)
range = Range.new(st, en)
Location.new(filename, range)
end | ruby | def location
st = Position.new(0, 0)
en = Position.from_offset(code, code.length)
range = Range.new(st, en)
Location.new(filename, range)
end | [
"def",
"location",
"st",
"=",
"Position",
".",
"new",
"(",
"0",
",",
"0",
")",
"en",
"=",
"Position",
".",
"from_offset",
"(",
"code",
",",
"code",
".",
"length",
")",
"range",
"=",
"Range",
".",
"new",
"(",
"st",
",",
"en",
")",
"Location",
".",... | A location representing the file in its entirety.
@return [Location] | [
"A",
"location",
"representing",
"the",
"file",
"in",
"its",
"entirety",
"."
] | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/source.rb#L255-L260 |
11,401 | castwide/solargraph | lib/solargraph/source.rb | Solargraph.Source.associated_comments | 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?('#')}
next if block.empty?
result[l... | ruby | 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?('#')}
next if block.empty?
result[l... | [
"def",
"associated_comments",
"@associated_comments",
"||=",
"begin",
"result",
"=",
"{",
"}",
"Parser",
"::",
"Source",
"::",
"Comment",
".",
"associate_locations",
"(",
"node",
",",
"comments",
")",
".",
"each_pair",
"do",
"|",
"loc",
",",
"all",
"|",
"blo... | Get a hash of comments grouped by the line numbers of the associated code.
@return [Hash{Integer => Array<Parser::Source::Comment>}] | [
"Get",
"a",
"hash",
"of",
"comments",
"grouped",
"by",
"the",
"line",
"numbers",
"of",
"the",
"associated",
"code",
"."
] | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/source.rb#L289-L300 |
11,402 | castwide/solargraph | lib/solargraph/source.rb | Solargraph.Source.stringify_comment_array | 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 | 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... | [
"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",
... | Get a string representation of an array of comments.
@param comments [Array<Parser::Source::Comment>]
@return [String] | [
"Get",
"a",
"string",
"representation",
"of",
"an",
"array",
"of",
"comments",
"."
] | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/source.rb#L324-L345 |
11,403 | castwide/solargraph | lib/solargraph/source.rb | Solargraph.Source.foldable_comment_block_ranges | 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 | 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]... | [
"def",
"foldable_comment_block_ranges",
"return",
"[",
"]",
"unless",
"synchronized?",
"result",
"=",
"[",
"]",
"grouped",
"=",
"[",
"]",
"# @param cmnt [Parser::Source::Comment]",
"@comments",
".",
"each",
"do",
"|",
"cmnt",
"|",
"if",
"cmnt",
".",
"document?",
... | Get an array of foldable comment block ranges. Blocks are excluded if
they are less than 3 lines long.
@return [Array<Range>] | [
"Get",
"an",
"array",
"of",
"foldable",
"comment",
"block",
"ranges",
".",
"Blocks",
"are",
"excluded",
"if",
"they",
"are",
"less",
"than",
"3",
"lines",
"long",
"."
] | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/source.rb#L370-L394 |
11,404 | castwide/solargraph | lib/solargraph/workspace.rb | Solargraph.Workspace.merge | 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)
return false unless config.calculated.include?(source.filename)
end
source_ha... | ruby | 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)
return false unless config.calculated.include?(source.filename)
end
source_ha... | [
"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",
... | Merge the source. A merge will update the existing source for the file
or add it to the sources if the workspace is configured to include it.
The source is ignored if the configuration excludes it.
@param source [Solargraph::Source]
@return [Boolean] True if the source was added to the workspace | [
"Merge",
"the",
"source",
".",
"A",
"merge",
"will",
"update",
"the",
"existing",
"source",
"for",
"the",
"file",
"or",
"add",
"it",
"to",
"the",
"sources",
"if",
"the",
"workspace",
"is",
"configured",
"to",
"include",
"it",
".",
"The",
"source",
"is",
... | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/workspace.rb#L31-L39 |
11,405 | castwide/solargraph | lib/solargraph/workspace.rb | Solargraph.Workspace.would_merge? | def would_merge? filename
return true if directory == '*' || source_hash.include?(filename)
@config = Solargraph::Workspace::Config.new(directory)
config.calculated.include?(filename)
end | ruby | def would_merge? filename
return true if directory == '*' || source_hash.include?(filename)
@config = Solargraph::Workspace::Config.new(directory)
config.calculated.include?(filename)
end | [
"def",
"would_merge?",
"filename",
"return",
"true",
"if",
"directory",
"==",
"'*'",
"||",
"source_hash",
".",
"include?",
"(",
"filename",
")",
"@config",
"=",
"Solargraph",
"::",
"Workspace",
"::",
"Config",
".",
"new",
"(",
"directory",
")",
"config",
"."... | Determine whether a file would be merged into the workspace.
@param filename [String]
@return [Boolean] | [
"Determine",
"whether",
"a",
"file",
"would",
"be",
"merged",
"into",
"the",
"workspace",
"."
] | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/workspace.rb#L45-L49 |
11,406 | castwide/solargraph | lib/solargraph/workspace.rb | Solargraph.Workspace.remove | def remove filename
return false unless source_hash.key?(filename)
source_hash.delete filename
true
end | ruby | def remove filename
return false unless source_hash.key?(filename)
source_hash.delete filename
true
end | [
"def",
"remove",
"filename",
"return",
"false",
"unless",
"source_hash",
".",
"key?",
"(",
"filename",
")",
"source_hash",
".",
"delete",
"filename",
"true",
"end"
] | Remove a source from the workspace. The source will not be removed if
its file exists and the workspace is configured to include it.
@param filename [String]
@return [Boolean] True if the source was removed from the workspace | [
"Remove",
"a",
"source",
"from",
"the",
"workspace",
".",
"The",
"source",
"will",
"not",
"be",
"removed",
"if",
"its",
"file",
"exists",
"and",
"the",
"workspace",
"is",
"configured",
"to",
"include",
"it",
"."
] | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/workspace.rb#L56-L60 |
11,407 | castwide/solargraph | lib/solargraph/workspace.rb | Solargraph.Workspace.would_require? | def would_require? path
require_paths.each do |rp|
return true if File.exist?(File.join(rp, "#{path}.rb"))
end
false
end | ruby | def would_require? path
require_paths.each do |rp|
return true if File.exist?(File.join(rp, "#{path}.rb"))
end
false
end | [
"def",
"would_require?",
"path",
"require_paths",
".",
"each",
"do",
"|",
"rp",
"|",
"return",
"true",
"if",
"File",
".",
"exist?",
"(",
"File",
".",
"join",
"(",
"rp",
",",
"\"#{path}.rb\"",
")",
")",
"end",
"false",
"end"
] | True if the path resolves to a file in the workspace's require paths.
@param path [String]
@return [Boolean] | [
"True",
"if",
"the",
"path",
"resolves",
"to",
"a",
"file",
"in",
"the",
"workspace",
"s",
"require",
"paths",
"."
] | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/workspace.rb#L97-L102 |
11,408 | castwide/solargraph | lib/solargraph/workspace.rb | Solargraph.Workspace.synchronize! | def synchronize! updater
source_hash[updater.filename] = source_hash[updater.filename].synchronize(updater)
end | ruby | def synchronize! updater
source_hash[updater.filename] = source_hash[updater.filename].synchronize(updater)
end | [
"def",
"synchronize!",
"updater",
"source_hash",
"[",
"updater",
".",
"filename",
"]",
"=",
"source_hash",
"[",
"updater",
".",
"filename",
"]",
".",
"synchronize",
"(",
"updater",
")",
"end"
] | Synchronize the workspace from the provided updater.
@param updater [Source::Updater]
@return [void] | [
"Synchronize",
"the",
"workspace",
"from",
"the",
"provided",
"updater",
"."
] | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/workspace.rb#L123-L125 |
11,409 | castwide/solargraph | lib/solargraph/workspace.rb | Solargraph.Workspace.generate_require_paths | 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 | 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
... | [
"def",
"generate_require_paths",
"return",
"configured_require_paths",
"unless",
"gemspec?",
"result",
"=",
"[",
"]",
"gemspecs",
".",
"each",
"do",
"|",
"file",
"|",
"base",
"=",
"File",
".",
"dirname",
"(",
"file",
")",
"# @todo Evaluating gemspec files violates t... | Generate require paths from gemspecs if they exist or assume the default
lib directory.
@return [Array<String>] | [
"Generate",
"require",
"paths",
"from",
"gemspecs",
"if",
"they",
"exist",
"or",
"assume",
"the",
"default",
"lib",
"directory",
"."
] | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/workspace.rb#L150-L172 |
11,410 | castwide/solargraph | lib/solargraph/workspace.rb | Solargraph.Workspace.configured_require_paths | def configured_require_paths
return ['lib'] if directory.empty?
return [File.join(directory, 'lib')] if config.require_paths.empty?
config.require_paths.map{|p| File.join(directory, p)}
end | ruby | def configured_require_paths
return ['lib'] if directory.empty?
return [File.join(directory, 'lib')] if config.require_paths.empty?
config.require_paths.map{|p| File.join(directory, p)}
end | [
"def",
"configured_require_paths",
"return",
"[",
"'lib'",
"]",
"if",
"directory",
".",
"empty?",
"return",
"[",
"File",
".",
"join",
"(",
"directory",
",",
"'lib'",
")",
"]",
"if",
"config",
".",
"require_paths",
".",
"empty?",
"config",
".",
"require_paths... | Get additional require paths defined in the configuration.
@return [Array<String>] | [
"Get",
"additional",
"require",
"paths",
"defined",
"in",
"the",
"configuration",
"."
] | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/workspace.rb#L177-L181 |
11,411 | castwide/solargraph | lib/solargraph/library.rb | Solargraph.Library.create | def create filename, text
result = false
mutex.synchronize do
next unless contain?(filename) || open?(filename) || workspace.would_merge?(filename)
@synchronized = false
source = Solargraph::Source.load_string(text, filename)
workspace.merge(source)
result = true
... | ruby | def create filename, text
result = false
mutex.synchronize do
next unless contain?(filename) || open?(filename) || workspace.would_merge?(filename)
@synchronized = false
source = Solargraph::Source.load_string(text, filename)
workspace.merge(source)
result = true
... | [
"def",
"create",
"filename",
",",
"text",
"result",
"=",
"false",
"mutex",
".",
"synchronize",
"do",
"next",
"unless",
"contain?",
"(",
"filename",
")",
"||",
"open?",
"(",
"filename",
")",
"||",
"workspace",
".",
"would_merge?",
"(",
"filename",
")",
"@sy... | Create a source to be added to the workspace. The file is ignored if it is
neither open in the library nor included in the workspace.
@param filename [String]
@param text [String] The contents of the file
@return [Boolean] True if the file was added to the workspace. | [
"Create",
"a",
"source",
"to",
"be",
"added",
"to",
"the",
"workspace",
".",
"The",
"file",
"is",
"ignored",
"if",
"it",
"is",
"neither",
"open",
"in",
"the",
"library",
"nor",
"included",
"in",
"the",
"workspace",
"."
] | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/library.rb#L94-L104 |
11,412 | castwide/solargraph | lib/solargraph/library.rb | Solargraph.Library.create_from_disk | 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
source = Solargraph::Source.load_string(Fi... | ruby | 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
source = Solargraph::Source.load_string(Fi... | [
"def",
"create_from_disk",
"filename",
"result",
"=",
"false",
"mutex",
".",
"synchronize",
"do",
"next",
"if",
"File",
".",
"directory?",
"(",
"filename",
")",
"||",
"!",
"File",
".",
"exist?",
"(",
"filename",
")",
"next",
"unless",
"contain?",
"(",
"fil... | Create a file source from a file on disk. The file is ignored if it is
neither open in the library nor included in the workspace.
@param filename [String]
@return [Boolean] True if the file was added to the workspace. | [
"Create",
"a",
"file",
"source",
"from",
"a",
"file",
"on",
"disk",
".",
"The",
"file",
"is",
"ignored",
"if",
"it",
"is",
"neither",
"open",
"in",
"the",
"library",
"nor",
"included",
"in",
"the",
"workspace",
"."
] | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/library.rb#L111-L122 |
11,413 | castwide/solargraph | lib/solargraph/library.rb | Solargraph.Library.delete | def delete filename
detach filename
result = false
mutex.synchronize do
result = workspace.remove(filename)
@synchronized = !result if synchronized?
end
result
end | ruby | def delete filename
detach filename
result = false
mutex.synchronize do
result = workspace.remove(filename)
@synchronized = !result if synchronized?
end
result
end | [
"def",
"delete",
"filename",
"detach",
"filename",
"result",
"=",
"false",
"mutex",
".",
"synchronize",
"do",
"result",
"=",
"workspace",
".",
"remove",
"(",
"filename",
")",
"@synchronized",
"=",
"!",
"result",
"if",
"synchronized?",
"end",
"result",
"end"
] | Delete a file from the library. Deleting a file will make it unavailable
for checkout and optionally remove it from the workspace unless the
workspace configuration determines that it should still exist.
@param filename [String]
@return [Boolean] True if the file was deleted | [
"Delete",
"a",
"file",
"from",
"the",
"library",
".",
"Deleting",
"a",
"file",
"will",
"make",
"it",
"unavailable",
"for",
"checkout",
"and",
"optionally",
"remove",
"it",
"from",
"the",
"workspace",
"unless",
"the",
"workspace",
"configuration",
"determines",
... | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/library.rb#L130-L138 |
11,414 | castwide/solargraph | lib/solargraph/library.rb | Solargraph.Library.completions_at | def completions_at filename, line, column
position = Position.new(line, column)
cursor = Source::Cursor.new(checkout(filename), position)
api_map.clip(cursor).complete
end | ruby | def completions_at filename, line, column
position = Position.new(line, column)
cursor = Source::Cursor.new(checkout(filename), position)
api_map.clip(cursor).complete
end | [
"def",
"completions_at",
"filename",
",",
"line",
",",
"column",
"position",
"=",
"Position",
".",
"new",
"(",
"line",
",",
"column",
")",
"cursor",
"=",
"Source",
"::",
"Cursor",
".",
"new",
"(",
"checkout",
"(",
"filename",
")",
",",
"position",
")",
... | Get completion suggestions at the specified file and location.
@param filename [String] The file to analyze
@param line [Integer] The zero-based line number
@param column [Integer] The zero-based column number
@return [SourceMap::Completion]
@todo Take a Location instead of filename/line/column | [
"Get",
"completion",
"suggestions",
"at",
"the",
"specified",
"file",
"and",
"location",
"."
] | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/library.rb#L160-L164 |
11,415 | castwide/solargraph | lib/solargraph/library.rb | Solargraph.Library.definitions_at | def definitions_at filename, line, column
position = Position.new(line, column)
cursor = Source::Cursor.new(checkout(filename), position)
api_map.clip(cursor).define
end | ruby | def definitions_at filename, line, column
position = Position.new(line, column)
cursor = Source::Cursor.new(checkout(filename), position)
api_map.clip(cursor).define
end | [
"def",
"definitions_at",
"filename",
",",
"line",
",",
"column",
"position",
"=",
"Position",
".",
"new",
"(",
"line",
",",
"column",
")",
"cursor",
"=",
"Source",
"::",
"Cursor",
".",
"new",
"(",
"checkout",
"(",
"filename",
")",
",",
"position",
")",
... | Get definition suggestions for the expression at the specified file and
location.
@param filename [String] The file to analyze
@param line [Integer] The zero-based line number
@param column [Integer] The zero-based column number
@return [Array<Solargraph::Pin::Base>]
@todo Take filename/position instead of filen... | [
"Get",
"definition",
"suggestions",
"for",
"the",
"expression",
"at",
"the",
"specified",
"file",
"and",
"location",
"."
] | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/library.rb#L174-L178 |
11,416 | castwide/solargraph | lib/solargraph/library.rb | Solargraph.Library.signatures_at | def signatures_at filename, line, column
position = Position.new(line, column)
cursor = Source::Cursor.new(checkout(filename), position)
api_map.clip(cursor).signify
end | ruby | def signatures_at filename, line, column
position = Position.new(line, column)
cursor = Source::Cursor.new(checkout(filename), position)
api_map.clip(cursor).signify
end | [
"def",
"signatures_at",
"filename",
",",
"line",
",",
"column",
"position",
"=",
"Position",
".",
"new",
"(",
"line",
",",
"column",
")",
"cursor",
"=",
"Source",
"::",
"Cursor",
".",
"new",
"(",
"checkout",
"(",
"filename",
")",
",",
"position",
")",
... | Get signature suggestions for the method at the specified file and
location.
@param filename [String] The file to analyze
@param line [Integer] The zero-based line number
@param column [Integer] The zero-based column number
@return [Array<Solargraph::Pin::Base>]
@todo Take filename/position instead of filename/l... | [
"Get",
"signature",
"suggestions",
"for",
"the",
"method",
"at",
"the",
"specified",
"file",
"and",
"location",
"."
] | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/library.rb#L188-L192 |
11,417 | castwide/solargraph | lib/solargraph/library.rb | Solargraph.Library.diagnose | 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 | 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)
... | [
"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",
... | Get diagnostics about a file.
@param filename [String]
@return [Array<Hash>] | [
"Get",
"diagnostics",
"about",
"a",
"file",
"."
] | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/library.rb#L323-L338 |
11,418 | castwide/solargraph | lib/solargraph/library.rb | Solargraph.Library.catalog | def catalog
@catalog_mutex.synchronize do
break if synchronized?
logger.info "Cataloging #{workspace.directory.empty? ? 'generic workspace' : workspace.directory}"
api_map.catalog bundle
@synchronized = true
logger.info "Catalog complete (#{api_map.pins.length} pins)"
... | ruby | def catalog
@catalog_mutex.synchronize do
break if synchronized?
logger.info "Cataloging #{workspace.directory.empty? ? 'generic workspace' : workspace.directory}"
api_map.catalog bundle
@synchronized = true
logger.info "Catalog complete (#{api_map.pins.length} pins)"
... | [
"def",
"catalog",
"@catalog_mutex",
".",
"synchronize",
"do",
"break",
"if",
"synchronized?",
"logger",
".",
"info",
"\"Cataloging #{workspace.directory.empty? ? 'generic workspace' : workspace.directory}\"",
"api_map",
".",
"catalog",
"bundle",
"@synchronized",
"=",
"true",
... | Update the ApiMap from the library's workspace and open files.
@return [void] | [
"Update",
"the",
"ApiMap",
"from",
"the",
"library",
"s",
"workspace",
"and",
"open",
"files",
"."
] | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/library.rb#L343-L351 |
11,419 | castwide/solargraph | lib/solargraph/library.rb | Solargraph.Library.merge | def merge source
result = nil
mutex.synchronize do
result = workspace.merge(source)
@synchronized = !result if synchronized?
end
result
end | ruby | def merge source
result = nil
mutex.synchronize do
result = workspace.merge(source)
@synchronized = !result if synchronized?
end
result
end | [
"def",
"merge",
"source",
"result",
"=",
"nil",
"mutex",
".",
"synchronize",
"do",
"result",
"=",
"workspace",
".",
"merge",
"(",
"source",
")",
"@synchronized",
"=",
"!",
"result",
"if",
"synchronized?",
"end",
"result",
"end"
] | Try to merge a source into the library's workspace. If the workspace is
not configured to include the source, it gets ignored.
@param source [Source]
@return [Boolean] True if the source was merged into the workspace. | [
"Try",
"to",
"merge",
"a",
"source",
"into",
"the",
"library",
"s",
"workspace",
".",
"If",
"the",
"workspace",
"is",
"not",
"configured",
"to",
"include",
"the",
"source",
"it",
"gets",
"ignored",
"."
] | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/library.rb#L378-L385 |
11,420 | castwide/solargraph | lib/solargraph/library.rb | Solargraph.Library.read | def read filename
return @current if @current && @current.filename == filename
raise FileNotFoundError, "File not found: #{filename}" unless workspace.has_file?(filename)
workspace.source(filename)
end | ruby | def read filename
return @current if @current && @current.filename == filename
raise FileNotFoundError, "File not found: #{filename}" unless workspace.has_file?(filename)
workspace.source(filename)
end | [
"def",
"read",
"filename",
"return",
"@current",
"if",
"@current",
"&&",
"@current",
".",
"filename",
"==",
"filename",
"raise",
"FileNotFoundError",
",",
"\"File not found: #{filename}\"",
"unless",
"workspace",
".",
"has_file?",
"(",
"filename",
")",
"workspace",
... | Get the source for an open file or create a new source if the file
exists on disk. Sources created from disk are not added to the open
workspace files, i.e., the version on disk remains the authoritative
version.
@raise [FileNotFoundError] if the file does not exist
@param filename [String]
@return [Solargraph::... | [
"Get",
"the",
"source",
"for",
"an",
"open",
"file",
"or",
"create",
"a",
"new",
"source",
"if",
"the",
"file",
"exists",
"on",
"disk",
".",
"Sources",
"created",
"from",
"disk",
"are",
"not",
"added",
"to",
"the",
"open",
"workspace",
"files",
"i",
".... | 47badb5d151aca775ccbe6c470236089eae7839d | https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/library.rb#L415-L419 |
11,421 | hashicorp/vault-ruby | lib/vault/request.rb | Vault.Request.extract_headers! | def extract_headers!(options = {})
extract = {
wrap_ttl: Vault::Client::WRAP_TTL_HEADER,
}
{}.tap do |h|
extract.each do |k,v|
if options[k]
h[v] = options.delete(k)
end
end
end
end | ruby | def extract_headers!(options = {})
extract = {
wrap_ttl: Vault::Client::WRAP_TTL_HEADER,
}
{}.tap do |h|
extract.each do |k,v|
if options[k]
h[v] = options.delete(k)
end
end
end
end | [
"def",
"extract_headers!",
"(",
"options",
"=",
"{",
"}",
")",
"extract",
"=",
"{",
"wrap_ttl",
":",
"Vault",
"::",
"Client",
"::",
"WRAP_TTL_HEADER",
",",
"}",
"{",
"}",
".",
"tap",
"do",
"|",
"h",
"|",
"extract",
".",
"each",
"do",
"|",
"k",
",",... | Removes the given header fields from options and returns the result. This
modifies the given options in place.
@param [Hash] options
@return [Hash] | [
"Removes",
"the",
"given",
"header",
"fields",
"from",
"options",
"and",
"returns",
"the",
"result",
".",
"This",
"modifies",
"the",
"given",
"options",
"in",
"place",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/request.rb#L29-L41 |
11,422 | hashicorp/vault-ruby | lib/vault/api/sys/seal.rb | Vault.Sys.unseal | def unseal(shard)
json = client.put("/v1/sys/unseal", JSON.fast_generate(
key: shard,
))
return SealStatus.decode(json)
end | ruby | def unseal(shard)
json = client.put("/v1/sys/unseal", JSON.fast_generate(
key: shard,
))
return SealStatus.decode(json)
end | [
"def",
"unseal",
"(",
"shard",
")",
"json",
"=",
"client",
".",
"put",
"(",
"\"/v1/sys/unseal\"",
",",
"JSON",
".",
"fast_generate",
"(",
"key",
":",
"shard",
",",
")",
")",
"return",
"SealStatus",
".",
"decode",
"(",
"json",
")",
"end"
] | Unseal the vault with the given shard.
@example
Vault.sys.unseal("abcd-1234") #=> #<Vault::SealStatus sealed=true, t=3, n=5, progress=1>
@param [String] shard
the key to use
@return [SealStatus] | [
"Unseal",
"the",
"vault",
"with",
"the",
"given",
"shard",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/sys/seal.rb#L74-L79 |
11,423 | hashicorp/vault-ruby | lib/vault/api/logical.rb | Vault.Logical.list | def list(path, options = {})
headers = extract_headers!(options)
json = client.list("/v1/#{encode_path(path)}", {}, headers)
json[:data][:keys] || []
rescue HTTPError => e
return [] if e.code == 404
raise
end | ruby | def list(path, options = {})
headers = extract_headers!(options)
json = client.list("/v1/#{encode_path(path)}", {}, headers)
json[:data][:keys] || []
rescue HTTPError => e
return [] if e.code == 404
raise
end | [
"def",
"list",
"(",
"path",
",",
"options",
"=",
"{",
"}",
")",
"headers",
"=",
"extract_headers!",
"(",
"options",
")",
"json",
"=",
"client",
".",
"list",
"(",
"\"/v1/#{encode_path(path)}\"",
",",
"{",
"}",
",",
"headers",
")",
"json",
"[",
":data",
... | List the secrets at the given path, if the path supports listing. If the
the path does not exist, an exception will be raised.
@example
Vault.logical.list("secret") #=> [#<Vault::Secret>, #<Vault::Secret>, ...]
@param [String] path
the path to list
@return [Array<String>] | [
"List",
"the",
"secrets",
"at",
"the",
"given",
"path",
"if",
"the",
"path",
"supports",
"listing",
".",
"If",
"the",
"the",
"path",
"does",
"not",
"exist",
"an",
"exception",
"will",
"be",
"raised",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/logical.rb#L26-L33 |
11,424 | hashicorp/vault-ruby | lib/vault/api/logical.rb | Vault.Logical.read | def read(path, options = {})
headers = extract_headers!(options)
json = client.get("/v1/#{encode_path(path)}", {}, headers)
return Secret.decode(json)
rescue HTTPError => e
return nil if e.code == 404
raise
end | ruby | def read(path, options = {})
headers = extract_headers!(options)
json = client.get("/v1/#{encode_path(path)}", {}, headers)
return Secret.decode(json)
rescue HTTPError => e
return nil if e.code == 404
raise
end | [
"def",
"read",
"(",
"path",
",",
"options",
"=",
"{",
"}",
")",
"headers",
"=",
"extract_headers!",
"(",
"options",
")",
"json",
"=",
"client",
".",
"get",
"(",
"\"/v1/#{encode_path(path)}\"",
",",
"{",
"}",
",",
"headers",
")",
"return",
"Secret",
".",
... | Read the secret at the given path. If the secret does not exist, +nil+
will be returned.
@example
Vault.logical.read("secret/password") #=> #<Vault::Secret lease_id="">
@param [String] path
the path to read
@return [Secret, nil] | [
"Read",
"the",
"secret",
"at",
"the",
"given",
"path",
".",
"If",
"the",
"secret",
"does",
"not",
"exist",
"+",
"nil",
"+",
"will",
"be",
"returned",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/logical.rb#L45-L52 |
11,425 | hashicorp/vault-ruby | lib/vault/api/logical.rb | Vault.Logical.unwrap | 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 | 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
... | [
"def",
"unwrap",
"(",
"wrapper",
")",
"client",
".",
"with_token",
"(",
"wrapper",
")",
"do",
"|",
"client",
"|",
"json",
"=",
"client",
".",
"get",
"(",
"\"/v1/cubbyhole/response\"",
")",
"secret",
"=",
"Secret",
".",
"decode",
"(",
"json",
")",
"# If t... | Unwrap the data stored against the given token. If the secret does not
exist, `nil` will be returned.
@example
Vault.logical.unwrap("f363dba8-25a7-08c5-430c-00b2367124e6") #=> #<Vault::Secret lease_id="">
@param [String] wrapper
the token to use when unwrapping the value
@return [Secret, nil] | [
"Unwrap",
"the",
"data",
"stored",
"against",
"the",
"given",
"token",
".",
"If",
"the",
"secret",
"does",
"not",
"exist",
"nil",
"will",
"be",
"returned",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/logical.rb#L101-L119 |
11,426 | hashicorp/vault-ruby | lib/vault/api/logical.rb | Vault.Logical.unwrap_token | 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 there, return nil
if response... | ruby | 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 there, return nil
if response... | [
"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",
... | Unwrap a token in a wrapped response given the temporary token.
@example
Vault.logical.unwrap("f363dba8-25a7-08c5-430c-00b2367124e6") #=> "0f0f40fd-06ce-4af1-61cb-cdc12796f42b"
@param [String, Secret] wrapper
the token to unwrap
@return [String, nil] | [
"Unwrap",
"a",
"token",
"in",
"a",
"wrapped",
"response",
"given",
"the",
"temporary",
"token",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/logical.rb#L130-L148 |
11,427 | hashicorp/vault-ruby | lib/vault/api/sys/auth.rb | Vault.Sys.auths | def auths
json = client.get("/v1/sys/auth")
json = json[:data] if json[:data]
return Hash[*json.map do |k,v|
[k.to_s.chomp("/").to_sym, Auth.decode(v)]
end.flatten]
end | ruby | def auths
json = client.get("/v1/sys/auth")
json = json[:data] if json[:data]
return Hash[*json.map do |k,v|
[k.to_s.chomp("/").to_sym, Auth.decode(v)]
end.flatten]
end | [
"def",
"auths",
"json",
"=",
"client",
".",
"get",
"(",
"\"/v1/sys/auth\"",
")",
"json",
"=",
"json",
"[",
":data",
"]",
"if",
"json",
"[",
":data",
"]",
"return",
"Hash",
"[",
"json",
".",
"map",
"do",
"|",
"k",
",",
"v",
"|",
"[",
"k",
".",
"... | List all auths in Vault.
@example
Vault.sys.auths #=> {:token => #<Vault::Auth type="token", description="token based credentials">}
@return [Hash<Symbol, Auth>] | [
"List",
"all",
"auths",
"in",
"Vault",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/sys/auth.rb#L35-L41 |
11,428 | hashicorp/vault-ruby | lib/vault/api/sys/auth.rb | Vault.Sys.enable_auth | def enable_auth(path, type, description = nil)
payload = { type: type }
payload[:description] = description if !description.nil?
client.post("/v1/sys/auth/#{encode_path(path)}", JSON.fast_generate(payload))
return true
end | ruby | def enable_auth(path, type, description = nil)
payload = { type: type }
payload[:description] = description if !description.nil?
client.post("/v1/sys/auth/#{encode_path(path)}", JSON.fast_generate(payload))
return true
end | [
"def",
"enable_auth",
"(",
"path",
",",
"type",
",",
"description",
"=",
"nil",
")",
"payload",
"=",
"{",
"type",
":",
"type",
"}",
"payload",
"[",
":description",
"]",
"=",
"description",
"if",
"!",
"description",
".",
"nil?",
"client",
".",
"post",
"... | Enable a particular authentication at the given path.
@example
Vault.sys.enable_auth("github", "github") #=> true
@param [String] path
the path to mount the auth
@param [String] type
the type of authentication
@param [String] description
a human-friendly description (optional)
@return [true] | [
"Enable",
"a",
"particular",
"authentication",
"at",
"the",
"given",
"path",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/sys/auth.rb#L56-L62 |
11,429 | hashicorp/vault-ruby | lib/vault/api/sys/auth.rb | Vault.Sys.auth_tune | def auth_tune(path)
json = client.get("/v1/sys/auth/#{encode_path(path)}/tune")
return AuthConfig.decode(json)
rescue HTTPError => e
return nil if e.code == 404
raise
end | ruby | def auth_tune(path)
json = client.get("/v1/sys/auth/#{encode_path(path)}/tune")
return AuthConfig.decode(json)
rescue HTTPError => e
return nil if e.code == 404
raise
end | [
"def",
"auth_tune",
"(",
"path",
")",
"json",
"=",
"client",
".",
"get",
"(",
"\"/v1/sys/auth/#{encode_path(path)}/tune\"",
")",
"return",
"AuthConfig",
".",
"decode",
"(",
"json",
")",
"rescue",
"HTTPError",
"=>",
"e",
"return",
"nil",
"if",
"e",
".",
"code... | Read the given auth path's configuration.
@example
Vault.sys.auth_tune("github") #=> #<Vault::AuthConfig "default_lease_ttl"=3600, "max_lease_ttl"=7200>
@param [String] path
the path to retrieve configuration for
@return [AuthConfig]
configuration of the given auth path | [
"Read",
"the",
"given",
"auth",
"path",
"s",
"configuration",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/sys/auth.rb#L89-L95 |
11,430 | hashicorp/vault-ruby | lib/vault/api/sys/auth.rb | Vault.Sys.put_auth_tune | def put_auth_tune(path, config = {})
json = client.put("/v1/sys/auth/#{encode_path(path)}/tune", JSON.fast_generate(config))
if json.nil?
return true
else
return Secret.decode(json)
end
end | ruby | def put_auth_tune(path, config = {})
json = client.put("/v1/sys/auth/#{encode_path(path)}/tune", JSON.fast_generate(config))
if json.nil?
return true
else
return Secret.decode(json)
end
end | [
"def",
"put_auth_tune",
"(",
"path",
",",
"config",
"=",
"{",
"}",
")",
"json",
"=",
"client",
".",
"put",
"(",
"\"/v1/sys/auth/#{encode_path(path)}/tune\"",
",",
"JSON",
".",
"fast_generate",
"(",
"config",
")",
")",
"if",
"json",
".",
"nil?",
"return",
"... | Write the given auth path's configuration.
@example
Vault.sys.auth_tune("github", "default_lease_ttl" => 600, "max_lease_ttl" => 1200 ) #=> true
@param [String] path
the path to retrieve configuration for
@return [AuthConfig]
configuration of the given auth path | [
"Write",
"the",
"given",
"auth",
"path",
"s",
"configuration",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/sys/auth.rb#L107-L114 |
11,431 | hashicorp/vault-ruby | lib/vault/persistent.rb | Vault.PersistentHTTP.expired? | def expired? connection
return true if @max_requests && connection.requests >= @max_requests
return false unless @idle_timeout
return true if @idle_timeout.zero?
Time.now - connection.last_use > @idle_timeout
end | ruby | def expired? connection
return true if @max_requests && connection.requests >= @max_requests
return false unless @idle_timeout
return true if @idle_timeout.zero?
Time.now - connection.last_use > @idle_timeout
end | [
"def",
"expired?",
"connection",
"return",
"true",
"if",
"@max_requests",
"&&",
"connection",
".",
"requests",
">=",
"@max_requests",
"return",
"false",
"unless",
"@idle_timeout",
"return",
"true",
"if",
"@idle_timeout",
".",
"zero?",
"Time",
".",
"now",
"-",
"c... | Returns true if the connection should be reset due to an idle timeout, or
maximum request count, false otherwise. | [
"Returns",
"true",
"if",
"the",
"connection",
"should",
"be",
"reset",
"due",
"to",
"an",
"idle",
"timeout",
"or",
"maximum",
"request",
"count",
"false",
"otherwise",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/persistent.rb#L683-L689 |
11,432 | hashicorp/vault-ruby | lib/vault/persistent.rb | Vault.PersistentHTTP.idempotent? | def idempotent? req
case req
when Net::HTTP::Delete, Net::HTTP::Get, Net::HTTP::Head,
Net::HTTP::Options, Net::HTTP::Put, Net::HTTP::Trace then
true
end
end | ruby | def idempotent? req
case req
when Net::HTTP::Delete, Net::HTTP::Get, Net::HTTP::Head,
Net::HTTP::Options, Net::HTTP::Put, Net::HTTP::Trace then
true
end
end | [
"def",
"idempotent?",
"req",
"case",
"req",
"when",
"Net",
"::",
"HTTP",
"::",
"Delete",
",",
"Net",
"::",
"HTTP",
"::",
"Get",
",",
"Net",
"::",
"HTTP",
"::",
"Head",
",",
"Net",
"::",
"HTTP",
"::",
"Options",
",",
"Net",
"::",
"HTTP",
"::",
"Put"... | Is +req+ idempotent according to RFC 2616? | [
"Is",
"+",
"req",
"+",
"idempotent",
"according",
"to",
"RFC",
"2616?"
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/persistent.rb#L729-L735 |
11,433 | hashicorp/vault-ruby | lib/vault/persistent.rb | Vault.PersistentHTTP.pipeline | def pipeline uri, requests, &block # :yields: responses
connection_for uri do |connection|
connection.http.pipeline requests, &block
end
end | ruby | def pipeline uri, requests, &block # :yields: responses
connection_for uri do |connection|
connection.http.pipeline requests, &block
end
end | [
"def",
"pipeline",
"uri",
",",
"requests",
",",
"&",
"block",
"# :yields: responses",
"connection_for",
"uri",
"do",
"|",
"connection",
"|",
"connection",
".",
"http",
".",
"pipeline",
"requests",
",",
"block",
"end",
"end"
] | Pipelines +requests+ to the HTTP server at +uri+ yielding responses if a
block is given. Returns all responses recieved.
See
Net::HTTP::Pipeline[http://docs.seattlerb.org/net-http-pipeline/Net/HTTP/Pipeline.html]
for further details.
Only if <tt>net-http-pipeline</tt> was required before
<tt>net-http-persisten... | [
"Pipelines",
"+",
"requests",
"+",
"to",
"the",
"HTTP",
"server",
"at",
"+",
"uri",
"+",
"yielding",
"responses",
"if",
"a",
"block",
"is",
"given",
".",
"Returns",
"all",
"responses",
"recieved",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/persistent.rb#L762-L766 |
11,434 | hashicorp/vault-ruby | lib/vault/persistent.rb | Vault.PersistentHTTP.proxy_from_env | 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 | 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_... | [
"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... | Creates a URI for an HTTP proxy server from ENV variables.
If +HTTP_PROXY+ is set a proxy will be returned.
If +HTTP_PROXY_USER+ or +HTTP_PROXY_PASS+ are set the URI is given the
indicated user and password unless HTTP_PROXY contains either of these in
the URI.
The +NO_PROXY+ ENV variable can be used to specify... | [
"Creates",
"a",
"URI",
"for",
"an",
"HTTP",
"proxy",
"server",
"from",
"ENV",
"variables",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/persistent.rb#L841-L863 |
11,435 | hashicorp/vault-ruby | lib/vault/persistent.rb | Vault.PersistentHTTP.proxy_bypass? | def proxy_bypass? host, port
host = host.downcase
host_port = [host, port].join ':'
@no_proxy.each do |name|
return true if host[-name.length, name.length] == name or
host_port[-name.length, name.length] == name
end
false
end | ruby | def proxy_bypass? host, port
host = host.downcase
host_port = [host, port].join ':'
@no_proxy.each do |name|
return true if host[-name.length, name.length] == name or
host_port[-name.length, name.length] == name
end
false
end | [
"def",
"proxy_bypass?",
"host",
",",
"port",
"host",
"=",
"host",
".",
"downcase",
"host_port",
"=",
"[",
"host",
",",
"port",
"]",
".",
"join",
"':'",
"@no_proxy",
".",
"each",
"do",
"|",
"name",
"|",
"return",
"true",
"if",
"host",
"[",
"-",
"name"... | Returns true when proxy should by bypassed for host. | [
"Returns",
"true",
"when",
"proxy",
"should",
"by",
"bypassed",
"for",
"host",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/persistent.rb#L868-L878 |
11,436 | hashicorp/vault-ruby | lib/vault/persistent.rb | Vault.PersistentHTTP.request_failed | def request_failed exception, req, connection # :nodoc:
due_to = "(due to #{exception.message} - #{exception.class})"
message = "too many connection resets #{due_to} #{error_message connection}"
finish connection
raise Error, message, exception.backtrace
end | ruby | def request_failed exception, req, connection # :nodoc:
due_to = "(due to #{exception.message} - #{exception.class})"
message = "too many connection resets #{due_to} #{error_message connection}"
finish connection
raise Error, message, exception.backtrace
end | [
"def",
"request_failed",
"exception",
",",
"req",
",",
"connection",
"# :nodoc:",
"due_to",
"=",
"\"(due to #{exception.message} - #{exception.class})\"",
"message",
"=",
"\"too many connection resets #{due_to} #{error_message connection}\"",
"finish",
"connection",
"raise",
"Error... | Raises an Error for +exception+ which resulted from attempting the request
+req+ on the +connection+.
Finishes the +connection+. | [
"Raises",
"an",
"Error",
"for",
"+",
"exception",
"+",
"which",
"resulted",
"from",
"attempting",
"the",
"request",
"+",
"req",
"+",
"on",
"the",
"+",
"connection",
"+",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/persistent.rb#L992-L999 |
11,437 | hashicorp/vault-ruby | lib/vault/persistent.rb | Vault.PersistentHTTP.request_setup | 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
e... | ruby | 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
e... | [
"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",
... | Creates a GET request if +req_or_uri+ is a URI and adds headers to the
request.
Returns the request. | [
"Creates",
"a",
"GET",
"request",
"if",
"+",
"req_or_uri",
"+",
"is",
"a",
"URI",
"and",
"adds",
"headers",
"to",
"the",
"request",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/persistent.rb#L1007-L1028 |
11,438 | hashicorp/vault-ruby | lib/vault/api/auth.rb | Vault.Authenticate.token | def token(new_token)
old_token = client.token
client.token = new_token
json = client.get("/v1/auth/token/lookup-self")
secret = Secret.decode(json)
return secret
rescue
client.token = old_token
raise
end | ruby | def token(new_token)
old_token = client.token
client.token = new_token
json = client.get("/v1/auth/token/lookup-self")
secret = Secret.decode(json)
return secret
rescue
client.token = old_token
raise
end | [
"def",
"token",
"(",
"new_token",
")",
"old_token",
"=",
"client",
".",
"token",
"client",
".",
"token",
"=",
"new_token",
"json",
"=",
"client",
".",
"get",
"(",
"\"/v1/auth/token/lookup-self\"",
")",
"secret",
"=",
"Secret",
".",
"decode",
"(",
"json",
"... | Authenticate via the "token" authentication method. This authentication
method is a bit bizarre because you already have a token, but hey,
whatever floats your boat.
This method hits the `/v1/auth/token/lookup-self` endpoint after setting
the Vault client's token to the given token parameter. If the self lookup
s... | [
"Authenticate",
"via",
"the",
"token",
"authentication",
"method",
".",
"This",
"authentication",
"method",
"is",
"a",
"bit",
"bizarre",
"because",
"you",
"already",
"have",
"a",
"token",
"but",
"hey",
"whatever",
"floats",
"your",
"boat",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/auth.rb#L34-L43 |
11,439 | hashicorp/vault-ruby | lib/vault/api/auth.rb | Vault.Authenticate.app_id | 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))
secret = Secret.decode(json)
client.token = secret.auth.client_token
return secret
end | ruby | 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))
secret = Secret.decode(json)
client.token = secret.auth.client_token
return secret
end | [
"def",
"app_id",
"(",
"app_id",
",",
"user_id",
",",
"options",
"=",
"{",
"}",
")",
"payload",
"=",
"{",
"app_id",
":",
"app_id",
",",
"user_id",
":",
"user_id",
"}",
".",
"merge",
"(",
"options",
")",
"json",
"=",
"client",
".",
"post",
"(",
"\"/v... | Authenticate via the "app-id" authentication method. If authentication is
successful, the resulting token will be stored on the client and used for
future requests.
@example
Vault.auth.app_id(
"aeece56e-3f9b-40c3-8f85-781d3e9a8f68",
"3b87be76-95cf-493a-a61b-7d5fc70870ad",
) #=> #<Vault::Secret lease... | [
"Authenticate",
"via",
"the",
"app",
"-",
"id",
"authentication",
"method",
".",
"If",
"authentication",
"is",
"successful",
"the",
"resulting",
"token",
"will",
"be",
"stored",
"on",
"the",
"client",
"and",
"used",
"for",
"future",
"requests",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/auth.rb#L69-L75 |
11,440 | hashicorp/vault-ruby | lib/vault/api/auth.rb | Vault.Authenticate.approle | def approle(role_id, secret_id=nil)
payload = { role_id: role_id }
payload[:secret_id] = secret_id if secret_id
json = client.post("/v1/auth/approle/login", JSON.fast_generate(payload))
secret = Secret.decode(json)
client.token = secret.auth.client_token
return secret
end | ruby | def approle(role_id, secret_id=nil)
payload = { role_id: role_id }
payload[:secret_id] = secret_id if secret_id
json = client.post("/v1/auth/approle/login", JSON.fast_generate(payload))
secret = Secret.decode(json)
client.token = secret.auth.client_token
return secret
end | [
"def",
"approle",
"(",
"role_id",
",",
"secret_id",
"=",
"nil",
")",
"payload",
"=",
"{",
"role_id",
":",
"role_id",
"}",
"payload",
"[",
":secret_id",
"]",
"=",
"secret_id",
"if",
"secret_id",
"json",
"=",
"client",
".",
"post",
"(",
"\"/v1/auth/approle/l... | Authenticate via the "approle" authentication method. If authentication is
successful, the resulting token will be stored on the client and used for
future requests.
@example
Vault.auth.approle(
"db02de05-fa39-4855-059b-67221c5c2f63",
"6a174c20-f6de-a53c-74d2-6018fcceff64",
) #=> #<Vault::Secret lea... | [
"Authenticate",
"via",
"the",
"approle",
"authentication",
"method",
".",
"If",
"authentication",
"is",
"successful",
"the",
"resulting",
"token",
"will",
"be",
"stored",
"on",
"the",
"client",
"and",
"used",
"for",
"future",
"requests",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/auth.rb#L92-L99 |
11,441 | hashicorp/vault-ruby | lib/vault/api/auth.rb | Vault.Authenticate.userpass | def userpass(username, password, options = {})
payload = { password: password }.merge(options)
json = client.post("/v1/auth/userpass/login/#{encode_path(username)}", JSON.fast_generate(payload))
secret = Secret.decode(json)
client.token = secret.auth.client_token
return secret
end | ruby | def userpass(username, password, options = {})
payload = { password: password }.merge(options)
json = client.post("/v1/auth/userpass/login/#{encode_path(username)}", JSON.fast_generate(payload))
secret = Secret.decode(json)
client.token = secret.auth.client_token
return secret
end | [
"def",
"userpass",
"(",
"username",
",",
"password",
",",
"options",
"=",
"{",
"}",
")",
"payload",
"=",
"{",
"password",
":",
"password",
"}",
".",
"merge",
"(",
"options",
")",
"json",
"=",
"client",
".",
"post",
"(",
"\"/v1/auth/userpass/login/#{encode_... | Authenticate via the "userpass" authentication method. If authentication
is successful, the resulting token will be stored on the client and used
for future requests.
@example
Vault.auth.userpass("sethvargo", "s3kr3t") #=> #<Vault::Secret lease_id="">
@example with a custom mount point
Vault.auth.userpass("... | [
"Authenticate",
"via",
"the",
"userpass",
"authentication",
"method",
".",
"If",
"authentication",
"is",
"successful",
"the",
"resulting",
"token",
"will",
"be",
"stored",
"on",
"the",
"client",
"and",
"used",
"for",
"future",
"requests",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/auth.rb#L118-L124 |
11,442 | hashicorp/vault-ruby | lib/vault/api/auth.rb | Vault.Authenticate.github | def github(github_token, path="/v1/auth/github/login")
payload = {token: github_token}
json = client.post(path, JSON.fast_generate(payload))
secret = Secret.decode(json)
client.token = secret.auth.client_token
return secret
end | ruby | def github(github_token, path="/v1/auth/github/login")
payload = {token: github_token}
json = client.post(path, JSON.fast_generate(payload))
secret = Secret.decode(json)
client.token = secret.auth.client_token
return secret
end | [
"def",
"github",
"(",
"github_token",
",",
"path",
"=",
"\"/v1/auth/github/login\"",
")",
"payload",
"=",
"{",
"token",
":",
"github_token",
"}",
"json",
"=",
"client",
".",
"post",
"(",
"path",
",",
"JSON",
".",
"fast_generate",
"(",
"payload",
")",
")",
... | Authenticate via the GitHub authentication method. If authentication is
successful, the resulting token will be stored on the client and used
for future requests.
@example
Vault.auth.github("mypersonalgithubtoken") #=> #<Vault::Secret lease_id="">
@param [String] github_token
@return [Secret] | [
"Authenticate",
"via",
"the",
"GitHub",
"authentication",
"method",
".",
"If",
"authentication",
"is",
"successful",
"the",
"resulting",
"token",
"will",
"be",
"stored",
"on",
"the",
"client",
"and",
"used",
"for",
"future",
"requests",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/auth.rb#L158-L164 |
11,443 | hashicorp/vault-ruby | lib/vault/api/auth.rb | Vault.Authenticate.aws_ec2 | 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
json = client.post(route, JSON.fast_generate(payload))
secret = Secret.decode(... | ruby | 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
json = client.post(route, JSON.fast_generate(payload))
secret = Secret.decode(... | [
"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 pr... | Authenticate via the AWS EC2 authentication method. If authentication is
successful, the resulting token will be stored on the client and used
for future requests.
@example
Vault.auth.aws_ec2("read-only", "pkcs7", "vault-nonce") #=> #<Vault::Secret lease_id="">
@param [String] role
@param [String] pkcs7
pk... | [
"Authenticate",
"via",
"the",
"AWS",
"EC2",
"authentication",
"method",
".",
"If",
"authentication",
"is",
"successful",
"the",
"resulting",
"token",
"will",
"be",
"stored",
"on",
"the",
"client",
"and",
"used",
"for",
"future",
"requests",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/auth.rb#L180-L189 |
11,444 | hashicorp/vault-ruby | lib/vault/api/auth.rb | Vault.Authenticate.gcp | 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 = Secret.decode(json)
client.token = secret.auth.client_token
return secret
end | ruby | 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 = Secret.decode(json)
client.token = secret.auth.client_token
return secret
end | [
"def",
"gcp",
"(",
"role",
",",
"jwt",
",",
"path",
"=",
"'gcp'",
")",
"payload",
"=",
"{",
"role",
":",
"role",
",",
"jwt",
":",
"jwt",
"}",
"json",
"=",
"client",
".",
"post",
"(",
"\"/v1/auth/#{CGI.escape(path)}/login\"",
",",
"JSON",
".",
"fast_gen... | Authenticate via the GCP authentication method. If authentication is
successful, the resulting token will be stored on the client and used
for future requests.
@example
Vault.auth.gcp("read-only", "jwt", "gcp") #=> #<Vault::Secret lease_id="">
@param [String] role
@param [String] jwt
jwt returned by the in... | [
"Authenticate",
"via",
"the",
"GCP",
"authentication",
"method",
".",
"If",
"authentication",
"is",
"successful",
"the",
"resulting",
"token",
"will",
"be",
"stored",
"on",
"the",
"client",
"and",
"used",
"for",
"future",
"requests",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/auth.rb#L262-L268 |
11,445 | hashicorp/vault-ruby | lib/vault/api/auth.rb | Vault.Authenticate.tls | def tls(pem = nil, path = 'cert')
new_client = client.dup
new_client.ssl_pem_contents = pem if !pem.nil?
json = new_client.post("/v1/auth/#{CGI.escape(path)}/login")
secret = Secret.decode(json)
client.token = secret.auth.client_token
return secret
end | ruby | def tls(pem = nil, path = 'cert')
new_client = client.dup
new_client.ssl_pem_contents = pem if !pem.nil?
json = new_client.post("/v1/auth/#{CGI.escape(path)}/login")
secret = Secret.decode(json)
client.token = secret.auth.client_token
return secret
end | [
"def",
"tls",
"(",
"pem",
"=",
"nil",
",",
"path",
"=",
"'cert'",
")",
"new_client",
"=",
"client",
".",
"dup",
"new_client",
".",
"ssl_pem_contents",
"=",
"pem",
"if",
"!",
"pem",
".",
"nil?",
"json",
"=",
"new_client",
".",
"post",
"(",
"\"/v1/auth/#... | Authenticate via a TLS authentication method. If authentication is
successful, the resulting token will be stored on the client and used
for future requests.
@example Sending raw pem contents
Vault.auth.tls(pem_contents) #=> #<Vault::Secret lease_id="">
@example Reading a pem from disk
Vault.auth.tls(File.r... | [
"Authenticate",
"via",
"a",
"TLS",
"authentication",
"method",
".",
"If",
"authentication",
"is",
"successful",
"the",
"resulting",
"token",
"will",
"be",
"stored",
"on",
"the",
"client",
"and",
"used",
"for",
"future",
"requests",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/auth.rb#L290-L298 |
11,446 | hashicorp/vault-ruby | lib/vault/api/sys/policy.rb | Vault.Sys.policy | def policy(name)
json = client.get("/v1/sys/policy/#{encode_path(name)}")
return Policy.decode(json)
rescue HTTPError => e
return nil if e.code == 404
raise
end | ruby | def policy(name)
json = client.get("/v1/sys/policy/#{encode_path(name)}")
return Policy.decode(json)
rescue HTTPError => e
return nil if e.code == 404
raise
end | [
"def",
"policy",
"(",
"name",
")",
"json",
"=",
"client",
".",
"get",
"(",
"\"/v1/sys/policy/#{encode_path(name)}\"",
")",
"return",
"Policy",
".",
"decode",
"(",
"json",
")",
"rescue",
"HTTPError",
"=>",
"e",
"return",
"nil",
"if",
"e",
".",
"code",
"==",... | Get the policy by the given name. If a policy does not exist by that name,
+nil+ is returned.
@example
Vault.sys.policy("root") #=> #<Vault::Policy rules="">
@return [Policy, nil] | [
"Get",
"the",
"policy",
"by",
"the",
"given",
"name",
".",
"If",
"a",
"policy",
"does",
"not",
"exist",
"by",
"that",
"name",
"+",
"nil",
"+",
"is",
"returned",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/sys/policy.rb#L42-L48 |
11,447 | hashicorp/vault-ruby | lib/vault/api/sys/policy.rb | Vault.Sys.put_policy | def put_policy(name, rules)
client.put("/v1/sys/policy/#{encode_path(name)}", JSON.fast_generate(
rules: rules,
))
return true
end | ruby | def put_policy(name, rules)
client.put("/v1/sys/policy/#{encode_path(name)}", JSON.fast_generate(
rules: rules,
))
return true
end | [
"def",
"put_policy",
"(",
"name",
",",
"rules",
")",
"client",
".",
"put",
"(",
"\"/v1/sys/policy/#{encode_path(name)}\"",
",",
"JSON",
".",
"fast_generate",
"(",
"rules",
":",
"rules",
",",
")",
")",
"return",
"true",
"end"
] | Create a new policy with the given name and rules.
@example
policy = <<-EOH
path "sys" {
policy = "deny"
}
EOH
Vault.sys.put_policy("dev", policy) #=> true
It is recommend that you load policy rules from a file:
@example
policy = File.read("/path/to/my/policy.hcl")
Vault.sys.put_po... | [
"Create",
"a",
"new",
"policy",
"with",
"the",
"given",
"name",
"and",
"rules",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/sys/policy.rb#L72-L77 |
11,448 | hashicorp/vault-ruby | lib/vault/api/sys/audit.rb | Vault.Sys.audits | def audits
json = client.get("/v1/sys/audit")
json = json[:data] if json[:data]
return Hash[*json.map do |k,v|
[k.to_s.chomp("/").to_sym, Audit.decode(v)]
end.flatten]
end | ruby | def audits
json = client.get("/v1/sys/audit")
json = json[:data] if json[:data]
return Hash[*json.map do |k,v|
[k.to_s.chomp("/").to_sym, Audit.decode(v)]
end.flatten]
end | [
"def",
"audits",
"json",
"=",
"client",
".",
"get",
"(",
"\"/v1/sys/audit\"",
")",
"json",
"=",
"json",
"[",
":data",
"]",
"if",
"json",
"[",
":data",
"]",
"return",
"Hash",
"[",
"json",
".",
"map",
"do",
"|",
"k",
",",
"v",
"|",
"[",
"k",
".",
... | List all audits for the vault.
@example
Vault.sys.audits #=> { :file => #<Audit> }
@return [Hash<Symbol, Audit>] | [
"List",
"all",
"audits",
"for",
"the",
"vault",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/sys/audit.rb#L28-L34 |
11,449 | hashicorp/vault-ruby | lib/vault/api/sys/audit.rb | Vault.Sys.audit_hash | def audit_hash(path, input)
json = client.post("/v1/sys/audit-hash/#{encode_path(path)}", JSON.fast_generate(input: input))
json = json[:data] if json[:data]
json[:hash]
end | ruby | def audit_hash(path, input)
json = client.post("/v1/sys/audit-hash/#{encode_path(path)}", JSON.fast_generate(input: input))
json = json[:data] if json[:data]
json[:hash]
end | [
"def",
"audit_hash",
"(",
"path",
",",
"input",
")",
"json",
"=",
"client",
".",
"post",
"(",
"\"/v1/sys/audit-hash/#{encode_path(path)}\"",
",",
"JSON",
".",
"fast_generate",
"(",
"input",
":",
"input",
")",
")",
"json",
"=",
"json",
"[",
":data",
"]",
"i... | Generates a HMAC verifier for a given input.
@example
Vault.sys.audit_hash("file-audit", "my input") #=> "hmac-sha256:30aa7de18a5e90bbc1063db91e7c387b32b9fa895977eb8c177bbc91e7d7c542"
@param [String] path
the path of the audit backend
@param [String] input
the input to generate a HMAC for
@return [Strin... | [
"Generates",
"a",
"HMAC",
"verifier",
"for",
"a",
"given",
"input",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/sys/audit.rb#L85-L89 |
11,450 | hashicorp/vault-ruby | lib/vault/api/auth_token.rb | Vault.AuthToken.accessors | def accessors(options = {})
headers = extract_headers!(options)
json = client.list("/v1/auth/token/accessors", options, headers)
return Secret.decode(json)
end | ruby | def accessors(options = {})
headers = extract_headers!(options)
json = client.list("/v1/auth/token/accessors", options, headers)
return Secret.decode(json)
end | [
"def",
"accessors",
"(",
"options",
"=",
"{",
"}",
")",
"headers",
"=",
"extract_headers!",
"(",
"options",
")",
"json",
"=",
"client",
".",
"list",
"(",
"\"/v1/auth/token/accessors\"",
",",
"options",
",",
"headers",
")",
"return",
"Secret",
".",
"decode",
... | Lists all token accessors.
@example Listing token accessors
result = Vault.auth_token.accessors #=> #<Vault::Secret>
result.data[:keys] #=> ["476ea048-ded5-4d07-eeea-938c6b4e43ec", "bb00c093-b7d3-b0e9-69cc-c4d85081165b"]
@return [Array<Secret>] | [
"Lists",
"all",
"token",
"accessors",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/auth_token.rb#L25-L29 |
11,451 | hashicorp/vault-ruby | lib/vault/api/auth_token.rb | Vault.AuthToken.create | def create(options = {})
headers = extract_headers!(options)
json = client.post("/v1/auth/token/create", JSON.fast_generate(options), headers)
return Secret.decode(json)
end | ruby | def create(options = {})
headers = extract_headers!(options)
json = client.post("/v1/auth/token/create", JSON.fast_generate(options), headers)
return Secret.decode(json)
end | [
"def",
"create",
"(",
"options",
"=",
"{",
"}",
")",
"headers",
"=",
"extract_headers!",
"(",
"options",
")",
"json",
"=",
"client",
".",
"post",
"(",
"\"/v1/auth/token/create\"",
",",
"JSON",
".",
"fast_generate",
"(",
"options",
")",
",",
"headers",
")",... | Create an authentication token. Note that the parameters specified below
are not validated and passed directly to the Vault server. Depending on
the version of Vault in operation, some of these options may not work, and
newer options may be available that are not listed here.
@example Creating a token
Vault.aut... | [
"Create",
"an",
"authentication",
"token",
".",
"Note",
"that",
"the",
"parameters",
"specified",
"below",
"are",
"not",
"validated",
"and",
"passed",
"directly",
"to",
"the",
"Vault",
"server",
".",
"Depending",
"on",
"the",
"version",
"of",
"Vault",
"in",
... | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/auth_token.rb#L67-L71 |
11,452 | hashicorp/vault-ruby | lib/vault/api/auth_token.rb | Vault.AuthToken.create_with_role | def create_with_role(name, options = {})
headers = extract_headers!(options)
json = client.post("/v1/auth/token/create/#{encode_path(name)}", JSON.fast_generate(options), headers)
return Secret.decode(json)
end | ruby | def create_with_role(name, options = {})
headers = extract_headers!(options)
json = client.post("/v1/auth/token/create/#{encode_path(name)}", JSON.fast_generate(options), headers)
return Secret.decode(json)
end | [
"def",
"create_with_role",
"(",
"name",
",",
"options",
"=",
"{",
"}",
")",
"headers",
"=",
"extract_headers!",
"(",
"options",
")",
"json",
"=",
"client",
".",
"post",
"(",
"\"/v1/auth/token/create/#{encode_path(name)}\"",
",",
"JSON",
".",
"fast_generate",
"("... | Create an orphaned authentication token.
@example
Vault.auth_token.create_with_role("developer") #=> #<Vault::Secret lease_id="">
@param [Hash] options
@return [Secret] | [
"Create",
"an",
"orphaned",
"authentication",
"token",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/auth_token.rb#L96-L100 |
11,453 | hashicorp/vault-ruby | lib/vault/api/auth_token.rb | Vault.AuthToken.lookup | def lookup(token, options = {})
headers = extract_headers!(options)
json = client.post("/v1/auth/token/lookup", JSON.fast_generate(
token: token,
), headers)
return Secret.decode(json)
end | ruby | def lookup(token, options = {})
headers = extract_headers!(options)
json = client.post("/v1/auth/token/lookup", JSON.fast_generate(
token: token,
), headers)
return Secret.decode(json)
end | [
"def",
"lookup",
"(",
"token",
",",
"options",
"=",
"{",
"}",
")",
"headers",
"=",
"extract_headers!",
"(",
"options",
")",
"json",
"=",
"client",
".",
"post",
"(",
"\"/v1/auth/token/lookup\"",
",",
"JSON",
".",
"fast_generate",
"(",
"token",
":",
"token",... | Lookup information about the current token.
@example
Vault.auth_token.lookup("abcd-...") #=> #<Vault::Secret lease_id="">
@param [String] token
@param [Hash] options
@return [Secret] | [
"Lookup",
"information",
"about",
"the",
"current",
"token",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/auth_token.rb#L111-L117 |
11,454 | hashicorp/vault-ruby | lib/vault/api/auth_token.rb | Vault.AuthToken.lookup_accessor | def lookup_accessor(accessor, options = {})
headers = extract_headers!(options)
json = client.post("/v1/auth/token/lookup-accessor", JSON.fast_generate(
accessor: accessor,
), headers)
return Secret.decode(json)
end | ruby | def lookup_accessor(accessor, options = {})
headers = extract_headers!(options)
json = client.post("/v1/auth/token/lookup-accessor", JSON.fast_generate(
accessor: accessor,
), headers)
return Secret.decode(json)
end | [
"def",
"lookup_accessor",
"(",
"accessor",
",",
"options",
"=",
"{",
"}",
")",
"headers",
"=",
"extract_headers!",
"(",
"options",
")",
"json",
"=",
"client",
".",
"post",
"(",
"\"/v1/auth/token/lookup-accessor\"",
",",
"JSON",
".",
"fast_generate",
"(",
"acce... | Lookup information about the given token accessor.
@example
Vault.auth_token.lookup_accessor("acbd-...") #=> #<Vault::Secret lease_id="">
@param [String] accessor
@param [Hash] options | [
"Lookup",
"information",
"about",
"the",
"given",
"token",
"accessor",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/auth_token.rb#L126-L132 |
11,455 | hashicorp/vault-ruby | lib/vault/api/auth_token.rb | Vault.AuthToken.renew | def renew(token, increment = 0, options = {})
headers = extract_headers!(options)
json = client.put("/v1/auth/token/renew", JSON.fast_generate(
token: token,
increment: increment,
), headers)
return Secret.decode(json)
end | ruby | def renew(token, increment = 0, options = {})
headers = extract_headers!(options)
json = client.put("/v1/auth/token/renew", JSON.fast_generate(
token: token,
increment: increment,
), headers)
return Secret.decode(json)
end | [
"def",
"renew",
"(",
"token",
",",
"increment",
"=",
"0",
",",
"options",
"=",
"{",
"}",
")",
"headers",
"=",
"extract_headers!",
"(",
"options",
")",
"json",
"=",
"client",
".",
"put",
"(",
"\"/v1/auth/token/renew\"",
",",
"JSON",
".",
"fast_generate",
... | Renew the given authentication token.
@example
Vault.auth_token.renew("abcd-1234") #=> #<Vault::Secret lease_id="">
@param [String] token
the auth token
@param [Fixnum] increment
@return [Secret] | [
"Renew",
"the",
"given",
"authentication",
"token",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/auth_token.rb#L155-L162 |
11,456 | hashicorp/vault-ruby | lib/vault/api/auth_token.rb | Vault.AuthToken.renew_self | def renew_self(increment = 0, options = {})
headers = extract_headers!(options)
json = client.put("/v1/auth/token/renew-self", JSON.fast_generate(
increment: increment,
), headers)
return Secret.decode(json)
end | ruby | def renew_self(increment = 0, options = {})
headers = extract_headers!(options)
json = client.put("/v1/auth/token/renew-self", JSON.fast_generate(
increment: increment,
), headers)
return Secret.decode(json)
end | [
"def",
"renew_self",
"(",
"increment",
"=",
"0",
",",
"options",
"=",
"{",
"}",
")",
"headers",
"=",
"extract_headers!",
"(",
"options",
")",
"json",
"=",
"client",
".",
"put",
"(",
"\"/v1/auth/token/renew-self\"",
",",
"JSON",
".",
"fast_generate",
"(",
"... | Renews a lease associated with the calling token.
@example
Vault.auth_token.renew_self #=> #<Vault::Secret lease_id="">
@param [Fixnum] increment
@return [Secret] | [
"Renews",
"a",
"lease",
"associated",
"with",
"the",
"calling",
"token",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/auth_token.rb#L172-L178 |
11,457 | hashicorp/vault-ruby | lib/vault/client.rb | Vault.Client.pool | 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 | 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... | [
"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://#{p... | Create a new Client with the given options. Any options given take
precedence over the default options.
@return [Vault::Client] | [
"Create",
"a",
"new",
"Client",
"with",
"the",
"given",
"options",
".",
"Any",
"options",
"given",
"take",
"precedence",
"over",
"the",
"default",
"options",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/client.rb#L82-L153 |
11,458 | hashicorp/vault-ruby | lib/vault/client.rb | Vault.Client.list | def list(path, params = {}, headers = {})
params = params.merge(list: true)
request(:get, path, params, headers)
end | ruby | def list(path, params = {}, headers = {})
params = params.merge(list: true)
request(:get, path, params, headers)
end | [
"def",
"list",
"(",
"path",
",",
"params",
"=",
"{",
"}",
",",
"headers",
"=",
"{",
"}",
")",
"params",
"=",
"params",
".",
"merge",
"(",
"list",
":",
"true",
")",
"request",
"(",
":get",
",",
"path",
",",
"params",
",",
"headers",
")",
"end"
] | Perform a LIST request.
@see Client#request | [
"Perform",
"a",
"LIST",
"request",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/client.rb#L189-L192 |
11,459 | hashicorp/vault-ruby | lib/vault/api/sys/lease.rb | Vault.Sys.renew | def renew(id, increment = 0)
json = client.put("/v1/sys/renew/#{id}", JSON.fast_generate(
increment: increment,
))
return Secret.decode(json)
end | ruby | def renew(id, increment = 0)
json = client.put("/v1/sys/renew/#{id}", JSON.fast_generate(
increment: increment,
))
return Secret.decode(json)
end | [
"def",
"renew",
"(",
"id",
",",
"increment",
"=",
"0",
")",
"json",
"=",
"client",
".",
"put",
"(",
"\"/v1/sys/renew/#{id}\"",
",",
"JSON",
".",
"fast_generate",
"(",
"increment",
":",
"increment",
",",
")",
")",
"return",
"Secret",
".",
"decode",
"(",
... | Renew a lease with the given ID.
@example
Vault.sys.renew("aws/username") #=> #<Vault::Secret ...>
@param [String] id
the lease ID
@param [Fixnum] increment
@return [Secret] | [
"Renew",
"a",
"lease",
"with",
"the",
"given",
"ID",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/sys/lease.rb#L13-L18 |
11,460 | hashicorp/vault-ruby | lib/vault/response.rb | Vault.Response.to_h | def to_h
self.class.fields.inject({}) do |h, (k, opts)|
if opts[:as].nil?
h[k] = self.public_send(k)
else
h[k] = self.public_send(opts[:as])
end
if !h[k].nil? && !h[k].is_a?(Array) && h[k].respond_to?(:to_h)
h[k] = h[k].to_h
end
h
... | ruby | def to_h
self.class.fields.inject({}) do |h, (k, opts)|
if opts[:as].nil?
h[k] = self.public_send(k)
else
h[k] = self.public_send(opts[:as])
end
if !h[k].nil? && !h[k].is_a?(Array) && h[k].respond_to?(:to_h)
h[k] = h[k].to_h
end
h
... | [
"def",
"to_h",
"self",
".",
"class",
".",
"fields",
".",
"inject",
"(",
"{",
"}",
")",
"do",
"|",
"h",
",",
"(",
"k",
",",
"opts",
")",
"|",
"if",
"opts",
"[",
":as",
"]",
".",
"nil?",
"h",
"[",
"k",
"]",
"=",
"self",
".",
"public_send",
"(... | Create a hash-bashed representation of this response.
@return [Hash] | [
"Create",
"a",
"hash",
"-",
"bashed",
"representation",
"of",
"this",
"response",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/response.rb#L69-L83 |
11,461 | hashicorp/vault-ruby | lib/vault/api/sys/init.rb | Vault.Sys.init | 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 | 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... | [
"def",
"init",
"(",
"options",
"=",
"{",
"}",
")",
"json",
"=",
"client",
".",
"put",
"(",
"\"/v1/sys/init\"",
",",
"JSON",
".",
"fast_generate",
"(",
"root_token_pgp_key",
":",
"options",
".",
"fetch",
"(",
":root_token_pgp_key",
",",
"nil",
")",
",",
"... | Initialize a new vault.
@example
Vault.sys.init #=> #<Vault::InitResponse keys=["..."] root_token="...">
@param [Hash] options
the list of init options
@option options [String] :root_token_pgp_key
optional base64-encoded PGP public key used to encrypt the initial root
token.
@option options [Fixnum] ... | [
"Initialize",
"a",
"new",
"vault",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/sys/init.rb#L69-L81 |
11,462 | hashicorp/vault-ruby | lib/vault/api/approle.rb | Vault.AppRole.set_role | def set_role(name, options = {})
headers = extract_headers!(options)
client.post("/v1/auth/approle/role/#{encode_path(name)}", JSON.fast_generate(options), headers)
return true
end | ruby | def set_role(name, options = {})
headers = extract_headers!(options)
client.post("/v1/auth/approle/role/#{encode_path(name)}", JSON.fast_generate(options), headers)
return true
end | [
"def",
"set_role",
"(",
"name",
",",
"options",
"=",
"{",
"}",
")",
"headers",
"=",
"extract_headers!",
"(",
"options",
")",
"client",
".",
"post",
"(",
"\"/v1/auth/approle/role/#{encode_path(name)}\"",
",",
"JSON",
".",
"fast_generate",
"(",
"options",
")",
"... | Creates a new AppRole or update an existing AppRole with the given name
and attributes.
@example
Vault.approle.set_role("testrole", {
secret_id_ttl: "10m",
token_ttl: "20m",
policies: "default",
period: 3600,
}) #=> true
@param [String] name
The name of the AppRole
@pa... | [
"Creates",
"a",
"new",
"AppRole",
"or",
"update",
"an",
"existing",
"AppRole",
"with",
"the",
"given",
"name",
"and",
"attributes",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/approle.rb#L59-L63 |
11,463 | hashicorp/vault-ruby | lib/vault/api/approle.rb | Vault.AppRole.role | def role(name)
json = client.get("/v1/auth/approle/role/#{encode_path(name)}")
return Secret.decode(json)
rescue HTTPError => e
return nil if e.code == 404
raise
end | ruby | def role(name)
json = client.get("/v1/auth/approle/role/#{encode_path(name)}")
return Secret.decode(json)
rescue HTTPError => e
return nil if e.code == 404
raise
end | [
"def",
"role",
"(",
"name",
")",
"json",
"=",
"client",
".",
"get",
"(",
"\"/v1/auth/approle/role/#{encode_path(name)}\"",
")",
"return",
"Secret",
".",
"decode",
"(",
"json",
")",
"rescue",
"HTTPError",
"=>",
"e",
"return",
"nil",
"if",
"e",
".",
"code",
... | Gets the AppRole by the given name. If an AppRole does not exist by that
name, +nil+ is returned.
@example
Vault.approle.role("testrole") #=> #<Vault::Secret lease_id="...">
@return [Secret, nil] | [
"Gets",
"the",
"AppRole",
"by",
"the",
"given",
"name",
".",
"If",
"an",
"AppRole",
"does",
"not",
"exist",
"by",
"that",
"name",
"+",
"nil",
"+",
"is",
"returned",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/approle.rb#L72-L78 |
11,464 | hashicorp/vault-ruby | lib/vault/api/approle.rb | Vault.AppRole.role_id | def role_id(name)
json = client.get("/v1/auth/approle/role/#{encode_path(name)}/role-id")
return Secret.decode(json).data[:role_id]
rescue HTTPError => e
return nil if e.code == 404
raise
end | ruby | def role_id(name)
json = client.get("/v1/auth/approle/role/#{encode_path(name)}/role-id")
return Secret.decode(json).data[:role_id]
rescue HTTPError => e
return nil if e.code == 404
raise
end | [
"def",
"role_id",
"(",
"name",
")",
"json",
"=",
"client",
".",
"get",
"(",
"\"/v1/auth/approle/role/#{encode_path(name)}/role-id\"",
")",
"return",
"Secret",
".",
"decode",
"(",
"json",
")",
".",
"data",
"[",
":role_id",
"]",
"rescue",
"HTTPError",
"=>",
"e",... | Reads the RoleID of an existing AppRole. If an AppRole does not exist by
that name, +nil+ is returned.
@example
Vault.approle.role_id("testrole") #=> #<Vault::Secret lease_id="...">
@return [Secret, nil] | [
"Reads",
"the",
"RoleID",
"of",
"an",
"existing",
"AppRole",
".",
"If",
"an",
"AppRole",
"does",
"not",
"exist",
"by",
"that",
"name",
"+",
"nil",
"+",
"is",
"returned",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/approle.rb#L102-L108 |
11,465 | hashicorp/vault-ruby | lib/vault/api/approle.rb | Vault.AppRole.set_role_id | def set_role_id(name, role_id)
options = { role_id: role_id }
client.post("/v1/auth/approle/role/#{encode_path(name)}/role-id", JSON.fast_generate(options))
return true
end | ruby | def set_role_id(name, role_id)
options = { role_id: role_id }
client.post("/v1/auth/approle/role/#{encode_path(name)}/role-id", JSON.fast_generate(options))
return true
end | [
"def",
"set_role_id",
"(",
"name",
",",
"role_id",
")",
"options",
"=",
"{",
"role_id",
":",
"role_id",
"}",
"client",
".",
"post",
"(",
"\"/v1/auth/approle/role/#{encode_path(name)}/role-id\"",
",",
"JSON",
".",
"fast_generate",
"(",
"options",
")",
")",
"retur... | Updates the RoleID of an existing AppRole to a custom value.
@example
Vault.approle.set_role_id("testrole") #=> true
@return [true] | [
"Updates",
"the",
"RoleID",
"of",
"an",
"existing",
"AppRole",
"to",
"a",
"custom",
"value",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/approle.rb#L116-L120 |
11,466 | hashicorp/vault-ruby | lib/vault/api/approle.rb | Vault.AppRole.create_secret_id | 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 = client.post("/v1/auth/approle/role/#{encode_... | ruby | 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 = client.post("/v1/auth/approle/role/#{encode_... | [
"def",
"create_secret_id",
"(",
"role_name",
",",
"options",
"=",
"{",
"}",
")",
"headers",
"=",
"extract_headers!",
"(",
"options",
")",
"if",
"options",
"[",
":secret_id",
"]",
"json",
"=",
"client",
".",
"post",
"(",
"\"/v1/auth/approle/role/#{encode_path(rol... | Generates and issues a new SecretID on an existing AppRole.
@example Generate a new SecretID
result = Vault.approle.create_secret_id("testrole") #=> #<Vault::Secret lease_id="...">
result.data[:secret_id] #=> "841771dc-11c9-bbc7-bcac-6a3945a69cd9"
@example Assign a custom SecretID
result = Vault.approle.cr... | [
"Generates",
"and",
"issues",
"a",
"new",
"SecretID",
"on",
"an",
"existing",
"AppRole",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/approle.rb#L160-L168 |
11,467 | hashicorp/vault-ruby | lib/vault/api/approle.rb | Vault.AppRole.secret_id | 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 | 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 ==... | [
"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",
"("... | Reads out the properties of a SecretID assigned to an AppRole.
If the specified SecretID don't exist, +nil+ is returned.
@example
Vault.approle.role("testrole", "841771dc-11c9-...") #=> #<Vault::Secret lease_id="...">
@param [String] role_name
The name of the AppRole
@param [String] secret_id
SecretID be... | [
"Reads",
"out",
"the",
"properties",
"of",
"a",
"SecretID",
"assigned",
"to",
"an",
"AppRole",
".",
"If",
"the",
"specified",
"SecretID",
"don",
"t",
"exist",
"+",
"nil",
"+",
"is",
"returned",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/approle.rb#L182-L199 |
11,468 | hashicorp/vault-ruby | lib/vault/api/approle.rb | Vault.AppRole.secret_id_accessors | 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 Secret.decode(json).data[:keys] || []
rescue HTTPError => e
return [] if e.code == 404
raise
... | ruby | 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 Secret.decode(json).data[:keys] || []
rescue HTTPError => e
return [] if e.code == 404
raise
... | [
"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",
","... | Lists the accessors of all the SecretIDs issued against the AppRole.
This includes the accessors for "custom" SecretIDs as well. If there are
no SecretIDs against this role, an empty array will be returned.
@example
Vault.approle.secret_ids("testrole") #=> ["ce102d2a-...", "a1c8dee4-..."]
@return [Array<String... | [
"Lists",
"the",
"accessors",
"of",
"all",
"the",
"SecretIDs",
"issued",
"against",
"the",
"AppRole",
".",
"This",
"includes",
"the",
"accessors",
"for",
"custom",
"SecretIDs",
"as",
"well",
".",
"If",
"there",
"are",
"no",
"SecretIDs",
"against",
"this",
"ro... | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/approle.rb#L209-L216 |
11,469 | hashicorp/vault-ruby | lib/vault/encode.rb | Vault.EncodePath.encode_path | def encode_path(path)
path.b.gsub(%r!([^a-zA-Z0-9_.-/]+)!) { |m|
'%' + m.unpack('H2' * m.bytesize).join('%').upcase
}
end | ruby | def encode_path(path)
path.b.gsub(%r!([^a-zA-Z0-9_.-/]+)!) { |m|
'%' + m.unpack('H2' * m.bytesize).join('%').upcase
}
end | [
"def",
"encode_path",
"(",
"path",
")",
"path",
".",
"b",
".",
"gsub",
"(",
"%r!",
"!",
")",
"{",
"|",
"m",
"|",
"'%'",
"+",
"m",
".",
"unpack",
"(",
"'H2'",
"*",
"m",
".",
"bytesize",
")",
".",
"join",
"(",
"'%'",
")",
".",
"upcase",
"}",
... | Encodes a string according to the rules for URL paths. This is
used as opposed to CGI.escape because in a URL path, space
needs to be escaped as %20 and CGI.escapes a space as +.
@param [String]
@return [String] | [
"Encodes",
"a",
"string",
"according",
"to",
"the",
"rules",
"for",
"URL",
"paths",
".",
"This",
"is",
"used",
"as",
"opposed",
"to",
"CGI",
".",
"escape",
"because",
"in",
"a",
"URL",
"path",
"space",
"needs",
"to",
"be",
"escaped",
"as",
"%20",
"and"... | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/encode.rb#L11-L15 |
11,470 | hashicorp/vault-ruby | lib/vault/api/sys/mount.rb | Vault.Sys.mounts | def mounts
json = client.get("/v1/sys/mounts")
json = json[:data] if json[:data]
return Hash[*json.map do |k,v|
[k.to_s.chomp("/").to_sym, Mount.decode(v)]
end.flatten]
end | ruby | def mounts
json = client.get("/v1/sys/mounts")
json = json[:data] if json[:data]
return Hash[*json.map do |k,v|
[k.to_s.chomp("/").to_sym, Mount.decode(v)]
end.flatten]
end | [
"def",
"mounts",
"json",
"=",
"client",
".",
"get",
"(",
"\"/v1/sys/mounts\"",
")",
"json",
"=",
"json",
"[",
":data",
"]",
"if",
"json",
"[",
":data",
"]",
"return",
"Hash",
"[",
"json",
".",
"map",
"do",
"|",
"k",
",",
"v",
"|",
"[",
"k",
".",
... | List all mounts in the vault.
@example
Vault.sys.mounts #=> { :secret => #<struct Vault::Mount type="generic", description="generic secret storage"> }
@return [Hash<Symbol, Mount>] | [
"List",
"all",
"mounts",
"in",
"the",
"vault",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/sys/mount.rb#L28-L34 |
11,471 | hashicorp/vault-ruby | lib/vault/api/sys/mount.rb | Vault.Sys.mount_tune | def mount_tune(path, data = {})
json = client.post("/v1/sys/mounts/#{encode_path(path)}/tune", JSON.fast_generate(data))
return true
end | ruby | def mount_tune(path, data = {})
json = client.post("/v1/sys/mounts/#{encode_path(path)}/tune", JSON.fast_generate(data))
return true
end | [
"def",
"mount_tune",
"(",
"path",
",",
"data",
"=",
"{",
"}",
")",
"json",
"=",
"client",
".",
"post",
"(",
"\"/v1/sys/mounts/#{encode_path(path)}/tune\"",
",",
"JSON",
".",
"fast_generate",
"(",
"data",
")",
")",
"return",
"true",
"end"
] | Tune a mount at the given path.
@example
Vault.sys.mount_tune("pki", max_lease_ttl: '87600h') #=> true
@param [String] path
the path to write
@param [Hash] data
the data to write | [
"Tune",
"a",
"mount",
"at",
"the",
"given",
"path",
"."
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/sys/mount.rb#L64-L67 |
11,472 | hashicorp/vault-ruby | lib/vault/api/sys/mount.rb | Vault.Sys.remount | def remount(from, to)
client.post("/v1/sys/remount", JSON.fast_generate(
from: from,
to: to,
))
return true
end | ruby | def remount(from, to)
client.post("/v1/sys/remount", JSON.fast_generate(
from: from,
to: to,
))
return true
end | [
"def",
"remount",
"(",
"from",
",",
"to",
")",
"client",
".",
"post",
"(",
"\"/v1/sys/remount\"",
",",
"JSON",
".",
"fast_generate",
"(",
"from",
":",
"from",
",",
"to",
":",
"to",
",",
")",
")",
"return",
"true",
"end"
] | Change the name of the mount
@example
Vault.sys.remount("pg", "postgres") #=> true
@param [String] from
the origin mount path
@param [String] to
the new mount path
@return [true] | [
"Change",
"the",
"name",
"of",
"the",
"mount"
] | 02f0532a802ba1a2a0d8703a4585dab76eb9d864 | https://github.com/hashicorp/vault-ruby/blob/02f0532a802ba1a2a0d8703a4585dab76eb9d864/lib/vault/api/sys/mount.rb#L95-L101 |
11,473 | colszowka/simplecov | lib/simplecov/configuration.rb | SimpleCov.Configuration.coverage_path | def coverage_path
@coverage_path ||= begin
coverage_path = File.expand_path(coverage_dir, root)
FileUtils.mkdir_p coverage_path
coverage_path
end
end | ruby | def coverage_path
@coverage_path ||= begin
coverage_path = File.expand_path(coverage_dir, root)
FileUtils.mkdir_p coverage_path
coverage_path
end
end | [
"def",
"coverage_path",
"@coverage_path",
"||=",
"begin",
"coverage_path",
"=",
"File",
".",
"expand_path",
"(",
"coverage_dir",
",",
"root",
")",
"FileUtils",
".",
"mkdir_p",
"coverage_path",
"coverage_path",
"end",
"end"
] | Returns the full path to the output directory using SimpleCov.root
and SimpleCov.coverage_dir, so you can adjust this by configuring those
values. Will create the directory if it's missing | [
"Returns",
"the",
"full",
"path",
"to",
"the",
"output",
"directory",
"using",
"SimpleCov",
".",
"root",
"and",
"SimpleCov",
".",
"coverage_dir",
"so",
"you",
"can",
"adjust",
"this",
"by",
"configuring",
"those",
"values",
".",
"Will",
"create",
"the",
"dir... | 8f6978a2513f10c4dd8d7dd7eed666fe3f2b55c2 | https://github.com/colszowka/simplecov/blob/8f6978a2513f10c4dd8d7dd7eed666fe3f2b55c2/lib/simplecov/configuration.rb#L42-L48 |
11,474 | colszowka/simplecov | lib/simplecov/configuration.rb | SimpleCov.Configuration.at_exit | def at_exit(&block)
return proc {} unless running || block_given?
@at_exit = block if block_given?
@at_exit ||= proc { SimpleCov.result.format! }
end | ruby | def at_exit(&block)
return proc {} unless running || block_given?
@at_exit = block if block_given?
@at_exit ||= proc { SimpleCov.result.format! }
end | [
"def",
"at_exit",
"(",
"&",
"block",
")",
"return",
"proc",
"{",
"}",
"unless",
"running",
"||",
"block_given?",
"@at_exit",
"=",
"block",
"if",
"block_given?",
"@at_exit",
"||=",
"proc",
"{",
"SimpleCov",
".",
"result",
".",
"format!",
"}",
"end"
] | Gets or sets the behavior to process coverage results.
By default, it will call SimpleCov.result.format!
Configure with:
SimpleCov.at_exit do
puts "Coverage done"
SimpleCov.result.format!
end | [
"Gets",
"or",
"sets",
"the",
"behavior",
"to",
"process",
"coverage",
"results",
"."
] | 8f6978a2513f10c4dd8d7dd7eed666fe3f2b55c2 | https://github.com/colszowka/simplecov/blob/8f6978a2513f10c4dd8d7dd7eed666fe3f2b55c2/lib/simplecov/configuration.rb#L179-L183 |
11,475 | colszowka/simplecov | lib/simplecov/configuration.rb | SimpleCov.Configuration.project_name | def project_name(new_name = nil)
return @project_name if defined?(@project_name) && @project_name && new_name.nil?
@project_name = new_name if new_name.is_a?(String)
@project_name ||= File.basename(root.split("/").last).capitalize.tr("_", " ")
end | ruby | def project_name(new_name = nil)
return @project_name if defined?(@project_name) && @project_name && new_name.nil?
@project_name = new_name if new_name.is_a?(String)
@project_name ||= File.basename(root.split("/").last).capitalize.tr("_", " ")
end | [
"def",
"project_name",
"(",
"new_name",
"=",
"nil",
")",
"return",
"@project_name",
"if",
"defined?",
"(",
"@project_name",
")",
"&&",
"@project_name",
"&&",
"new_name",
".",
"nil?",
"@project_name",
"=",
"new_name",
"if",
"new_name",
".",
"is_a?",
"(",
"Strin... | Returns the project name - currently assuming the last dirname in
the SimpleCov.root is this. | [
"Returns",
"the",
"project",
"name",
"-",
"currently",
"assuming",
"the",
"last",
"dirname",
"in",
"the",
"SimpleCov",
".",
"root",
"is",
"this",
"."
] | 8f6978a2513f10c4dd8d7dd7eed666fe3f2b55c2 | https://github.com/colszowka/simplecov/blob/8f6978a2513f10c4dd8d7dd7eed666fe3f2b55c2/lib/simplecov/configuration.rb#L189-L193 |
11,476 | colszowka/simplecov | lib/simplecov/configuration.rb | SimpleCov.Configuration.parse_filter | def parse_filter(filter_argument = nil, &filter_proc)
filter = filter_argument || filter_proc
if filter
SimpleCov::Filter.build_filter(filter)
else
raise ArgumentError, "Please specify either a filter or a block to filter with"
end
end | ruby | def parse_filter(filter_argument = nil, &filter_proc)
filter = filter_argument || filter_proc
if filter
SimpleCov::Filter.build_filter(filter)
else
raise ArgumentError, "Please specify either a filter or a block to filter with"
end
end | [
"def",
"parse_filter",
"(",
"filter_argument",
"=",
"nil",
",",
"&",
"filter_proc",
")",
"filter",
"=",
"filter_argument",
"||",
"filter_proc",
"if",
"filter",
"SimpleCov",
"::",
"Filter",
".",
"build_filter",
"(",
"filter",
")",
"else",
"raise",
"ArgumentError"... | The actual filter processor. Not meant for direct use | [
"The",
"actual",
"filter",
"processor",
".",
"Not",
"meant",
"for",
"direct",
"use"
] | 8f6978a2513f10c4dd8d7dd7eed666fe3f2b55c2 | https://github.com/colszowka/simplecov/blob/8f6978a2513f10c4dd8d7dd7eed666fe3f2b55c2/lib/simplecov/configuration.rb#L295-L303 |
11,477 | colszowka/simplecov | lib/simplecov/raw_coverage.rb | SimpleCov.RawCoverage.merge_resultsets | def merge_resultsets(result1, result2)
(result1.keys | result2.keys).each_with_object({}) do |filename, merged|
file1 = result1[filename]
file2 = result2[filename]
merged[filename] = merge_file_coverage(file1, file2)
end
end | ruby | def merge_resultsets(result1, result2)
(result1.keys | result2.keys).each_with_object({}) do |filename, merged|
file1 = result1[filename]
file2 = result2[filename]
merged[filename] = merge_file_coverage(file1, file2)
end
end | [
"def",
"merge_resultsets",
"(",
"result1",
",",
"result2",
")",
"(",
"result1",
".",
"keys",
"|",
"result2",
".",
"keys",
")",
".",
"each_with_object",
"(",
"{",
"}",
")",
"do",
"|",
"filename",
",",
"merged",
"|",
"file1",
"=",
"result1",
"[",
"filena... | Merges two Coverage.result hashes | [
"Merges",
"two",
"Coverage",
".",
"result",
"hashes"
] | 8f6978a2513f10c4dd8d7dd7eed666fe3f2b55c2 | https://github.com/colszowka/simplecov/blob/8f6978a2513f10c4dd8d7dd7eed666fe3f2b55c2/lib/simplecov/raw_coverage.rb#L15-L21 |
11,478 | colszowka/simplecov | lib/simplecov/profiles.rb | SimpleCov.Profiles.load | def load(name)
name = name.to_sym
raise "Could not find SimpleCov Profile called '#{name}'" unless key?(name)
SimpleCov.configure(&self[name])
end | ruby | def load(name)
name = name.to_sym
raise "Could not find SimpleCov Profile called '#{name}'" unless key?(name)
SimpleCov.configure(&self[name])
end | [
"def",
"load",
"(",
"name",
")",
"name",
"=",
"name",
".",
"to_sym",
"raise",
"\"Could not find SimpleCov Profile called '#{name}'\"",
"unless",
"key?",
"(",
"name",
")",
"SimpleCov",
".",
"configure",
"(",
"self",
"[",
"name",
"]",
")",
"end"
] | Applies the profile of given name on SimpleCov.configure | [
"Applies",
"the",
"profile",
"of",
"given",
"name",
"on",
"SimpleCov",
".",
"configure"
] | 8f6978a2513f10c4dd8d7dd7eed666fe3f2b55c2 | https://github.com/colszowka/simplecov/blob/8f6978a2513f10c4dd8d7dd7eed666fe3f2b55c2/lib/simplecov/profiles.rb#L27-L31 |
11,479 | troessner/reek | lib/reek/documentation_link.rb | Reek.DocumentationLink.build | def build(subject)
Kernel.format(HELP_LINK_TEMPLATE, version: Version::STRING, item: name_to_param(subject))
end | ruby | def build(subject)
Kernel.format(HELP_LINK_TEMPLATE, version: Version::STRING, item: name_to_param(subject))
end | [
"def",
"build",
"(",
"subject",
")",
"Kernel",
".",
"format",
"(",
"HELP_LINK_TEMPLATE",
",",
"version",
":",
"Version",
"::",
"STRING",
",",
"item",
":",
"name_to_param",
"(",
"subject",
")",
")",
"end"
] | Build link to the documentation about the given subject for the current
version of Reek. The subject can be either a smell type like
'FeatureEnvy' or a general subject like 'Rake Task'.
@param subject [String]
@return [String] the full URL for the relevant documentation | [
"Build",
"link",
"to",
"the",
"documentation",
"about",
"the",
"given",
"subject",
"for",
"the",
"current",
"version",
"of",
"Reek",
".",
"The",
"subject",
"can",
"be",
"either",
"a",
"smell",
"type",
"like",
"FeatureEnvy",
"or",
"a",
"general",
"subject",
... | 8c6b5c0c6228a6981ab48543457889f9ea984054 | https://github.com/troessner/reek/blob/8c6b5c0c6228a6981ab48543457889f9ea984054/lib/reek/documentation_link.rb#L16-L18 |
11,480 | troessner/reek | samples/smelly_source/inline.rb | Inline.C.load_cache | 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 used" if test ?d, dir and $VERBOSE
return true
end
rescue LoadError
end
return ... | ruby | 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 used" if test ?d, dir and $VERBOSE
return true
end
rescue LoadError
end
return ... | [
"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 b... | Attempts to load pre-generated code returning true if it succeeds. | [
"Attempts",
"to",
"load",
"pre",
"-",
"generated",
"code",
"returning",
"true",
"if",
"it",
"succeeds",
"."
] | 8c6b5c0c6228a6981ab48543457889f9ea984054 | https://github.com/troessner/reek/blob/8c6b5c0c6228a6981ab48543457889f9ea984054/samples/smelly_source/inline.rb#L315-L326 |
11,481 | troessner/reek | samples/smelly_source/inline.rb | Inline.C.add_type_converter | def add_type_converter(type, r2c, c2r)
warn "WAR\NING: overridding #{type} on #{caller[0]}" if @@type_map.has_key? type
@@type_map[type] = [r2c, c2r]
end | ruby | def add_type_converter(type, r2c, c2r)
warn "WAR\NING: overridding #{type} on #{caller[0]}" if @@type_map.has_key? type
@@type_map[type] = [r2c, c2r]
end | [
"def",
"add_type_converter",
"(",
"type",
",",
"r2c",
",",
"c2r",
")",
"warn",
"\"WAR\\NING: overridding #{type} on #{caller[0]}\"",
"if",
"@@type_map",
".",
"has_key?",
"type",
"@@type_map",
"[",
"type",
"]",
"=",
"[",
"r2c",
",",
"c2r",
"]",
"end"
] | Registers C type-casts +r2c+ and +c2r+ for +type+. | [
"Registers",
"C",
"type",
"-",
"casts",
"+",
"r2c",
"+",
"and",
"+",
"c2r",
"+",
"for",
"+",
"type",
"+",
"."
] | 8c6b5c0c6228a6981ab48543457889f9ea984054 | https://github.com/troessner/reek/blob/8c6b5c0c6228a6981ab48543457889f9ea984054/samples/smelly_source/inline.rb#L520-L523 |
11,482 | troessner/reek | samples/smelly_source/inline.rb | Inline.C.c | def c src, options = {}
options = {
:expand_types => true,
}.merge options
self.generate src, options
end | ruby | def c src, options = {}
options = {
:expand_types => true,
}.merge options
self.generate src, options
end | [
"def",
"c",
"src",
",",
"options",
"=",
"{",
"}",
"options",
"=",
"{",
":expand_types",
"=>",
"true",
",",
"}",
".",
"merge",
"options",
"self",
".",
"generate",
"src",
",",
"options",
"end"
] | Adds a C function to the source, including performing automatic
type conversion to arguments and the return value. The Ruby
method name can be overridden by providing method_name. Unknown
type conversions can be extended by using +add_type_converter+. | [
"Adds",
"a",
"C",
"function",
"to",
"the",
"source",
"including",
"performing",
"automatic",
"type",
"conversion",
"to",
"arguments",
"and",
"the",
"return",
"value",
".",
"The",
"Ruby",
"method",
"name",
"can",
"be",
"overridden",
"by",
"providing",
"method_n... | 8c6b5c0c6228a6981ab48543457889f9ea984054 | https://github.com/troessner/reek/blob/8c6b5c0c6228a6981ab48543457889f9ea984054/samples/smelly_source/inline.rb#L575-L580 |
11,483 | troessner/reek | samples/smelly_source/inline.rb | Inline.C.c_singleton | def c_singleton src, options = {}
options = {
:expand_types => true,
:singleton => true,
}.merge options
self.generate src, options
end | ruby | def c_singleton src, options = {}
options = {
:expand_types => true,
:singleton => true,
}.merge options
self.generate src, options
end | [
"def",
"c_singleton",
"src",
",",
"options",
"=",
"{",
"}",
"options",
"=",
"{",
":expand_types",
"=>",
"true",
",",
":singleton",
"=>",
"true",
",",
"}",
".",
"merge",
"options",
"self",
".",
"generate",
"src",
",",
"options",
"end"
] | Same as +c+, but adds a class function. | [
"Same",
"as",
"+",
"c",
"+",
"but",
"adds",
"a",
"class",
"function",
"."
] | 8c6b5c0c6228a6981ab48543457889f9ea984054 | https://github.com/troessner/reek/blob/8c6b5c0c6228a6981ab48543457889f9ea984054/samples/smelly_source/inline.rb#L585-L591 |
11,484 | troessner/reek | samples/smelly_source/inline.rb | Inline.C.c_raw_singleton | def c_raw_singleton src, options = {}
options = {
:singleton => true,
}.merge options
self.generate src, options
end | ruby | def c_raw_singleton src, options = {}
options = {
:singleton => true,
}.merge options
self.generate src, options
end | [
"def",
"c_raw_singleton",
"src",
",",
"options",
"=",
"{",
"}",
"options",
"=",
"{",
":singleton",
"=>",
"true",
",",
"}",
".",
"merge",
"options",
"self",
".",
"generate",
"src",
",",
"options",
"end"
] | Same as +c_raw+, but adds a class function. | [
"Same",
"as",
"+",
"c_raw",
"+",
"but",
"adds",
"a",
"class",
"function",
"."
] | 8c6b5c0c6228a6981ab48543457889f9ea984054 | https://github.com/troessner/reek/blob/8c6b5c0c6228a6981ab48543457889f9ea984054/samples/smelly_source/inline.rb#L606-L611 |
11,485 | troessner/reek | lib/reek/spec.rb | Reek.Spec.reek_of | def reek_of(smell_type,
smell_details = {},
configuration = Configuration::AppConfiguration.default)
ShouldReekOf.new(smell_type, smell_details, configuration)
end | ruby | def reek_of(smell_type,
smell_details = {},
configuration = Configuration::AppConfiguration.default)
ShouldReekOf.new(smell_type, smell_details, configuration)
end | [
"def",
"reek_of",
"(",
"smell_type",
",",
"smell_details",
"=",
"{",
"}",
",",
"configuration",
"=",
"Configuration",
"::",
"AppConfiguration",
".",
"default",
")",
"ShouldReekOf",
".",
"new",
"(",
"smell_type",
",",
"smell_details",
",",
"configuration",
")",
... | Checks the target source code for instances of "smell type"
and returns true only if it can find one of them that matches.
You can pass the smell type you want to check for as String or as Symbol:
- :UtilityFunction
- "UtilityFunction"
It is recommended to pass this as a symbol like :UtilityFunction. Howeve... | [
"Checks",
"the",
"target",
"source",
"code",
"for",
"instances",
"of",
"smell",
"type",
"and",
"returns",
"true",
"only",
"if",
"it",
"can",
"find",
"one",
"of",
"them",
"that",
"matches",
"."
] | 8c6b5c0c6228a6981ab48543457889f9ea984054 | https://github.com/troessner/reek/blob/8c6b5c0c6228a6981ab48543457889f9ea984054/lib/reek/spec.rb#L88-L92 |
11,486 | troessner/reek | lib/reek/spec.rb | Reek.Spec.reek_only_of | def reek_only_of(smell_type, configuration = Configuration::AppConfiguration.default)
ShouldReekOnlyOf.new(smell_type, configuration)
end | ruby | def reek_only_of(smell_type, configuration = Configuration::AppConfiguration.default)
ShouldReekOnlyOf.new(smell_type, configuration)
end | [
"def",
"reek_only_of",
"(",
"smell_type",
",",
"configuration",
"=",
"Configuration",
"::",
"AppConfiguration",
".",
"default",
")",
"ShouldReekOnlyOf",
".",
"new",
"(",
"smell_type",
",",
"configuration",
")",
"end"
] | See the documentaton for "reek_of".
Notable differences to reek_of:
1.) "reek_of" doesn't mind if there are other smells of a different type.
"reek_only_of" will fail in that case.
2.) "reek_only_of" doesn't support the additional smell_details hash.
@param smell_type [Symbol, String] The "smell type" ... | [
"See",
"the",
"documentaton",
"for",
"reek_of",
"."
] | 8c6b5c0c6228a6981ab48543457889f9ea984054 | https://github.com/troessner/reek/blob/8c6b5c0c6228a6981ab48543457889f9ea984054/lib/reek/spec.rb#L107-L109 |
11,487 | troessner/reek | lib/reek/context_builder.rb | Reek.ContextBuilder.build | def build(exp, parent_exp = nil)
context_processor = "process_#{exp.type}"
if context_processor_exists?(context_processor)
send(context_processor, exp, parent_exp)
else
process exp
end
current_context
end | ruby | def build(exp, parent_exp = nil)
context_processor = "process_#{exp.type}"
if context_processor_exists?(context_processor)
send(context_processor, exp, parent_exp)
else
process exp
end
current_context
end | [
"def",
"build",
"(",
"exp",
",",
"parent_exp",
"=",
"nil",
")",
"context_processor",
"=",
"\"process_#{exp.type}\"",
"if",
"context_processor_exists?",
"(",
"context_processor",
")",
"send",
"(",
"context_processor",
",",
"exp",
",",
"parent_exp",
")",
"else",
"pr... | Processes the given AST, memoizes it and returns a tree of nested
contexts.
For example this ruby code:
class Car; def drive; end; end
would get compiled into this AST:
(class
(const nil :Car) nil
(def :drive
(args) nil))
Processing this AST would result in a context tree where each node... | [
"Processes",
"the",
"given",
"AST",
"memoizes",
"it",
"and",
"returns",
"a",
"tree",
"of",
"nested",
"contexts",
"."
] | 8c6b5c0c6228a6981ab48543457889f9ea984054 | https://github.com/troessner/reek/blob/8c6b5c0c6228a6981ab48543457889f9ea984054/lib/reek/context_builder.rb#L62-L70 |
11,488 | troessner/reek | lib/reek/context_builder.rb | Reek.ContextBuilder.process | def process(exp)
exp.children.grep(AST::Node).each { |child| build(child, exp) }
end | ruby | def process(exp)
exp.children.grep(AST::Node).each { |child| build(child, exp) }
end | [
"def",
"process",
"(",
"exp",
")",
"exp",
".",
"children",
".",
"grep",
"(",
"AST",
"::",
"Node",
")",
".",
"each",
"{",
"|",
"child",
"|",
"build",
"(",
"child",
",",
"exp",
")",
"}",
"end"
] | Handles every node for which we have no context_processor. | [
"Handles",
"every",
"node",
"for",
"which",
"we",
"have",
"no",
"context_processor",
"."
] | 8c6b5c0c6228a6981ab48543457889f9ea984054 | https://github.com/troessner/reek/blob/8c6b5c0c6228a6981ab48543457889f9ea984054/lib/reek/context_builder.rb#L74-L76 |
11,489 | troessner/reek | lib/reek/context_builder.rb | Reek.ContextBuilder.process_def | def process_def(exp, parent)
inside_new_context(current_context.method_context_class, exp, parent) do
increase_statement_count_by(exp.body)
process(exp)
end
end | ruby | def process_def(exp, parent)
inside_new_context(current_context.method_context_class, exp, parent) do
increase_statement_count_by(exp.body)
process(exp)
end
end | [
"def",
"process_def",
"(",
"exp",
",",
"parent",
")",
"inside_new_context",
"(",
"current_context",
".",
"method_context_class",
",",
"exp",
",",
"parent",
")",
"do",
"increase_statement_count_by",
"(",
"exp",
".",
"body",
")",
"process",
"(",
"exp",
")",
"end... | Handles `def` nodes.
An input example that would trigger this method would be:
def call_me; foo = 2; bar = 5; end
Given the above example we would count 2 statements overall. | [
"Handles",
"def",
"nodes",
"."
] | 8c6b5c0c6228a6981ab48543457889f9ea984054 | https://github.com/troessner/reek/blob/8c6b5c0c6228a6981ab48543457889f9ea984054/lib/reek/context_builder.rb#L123-L128 |
11,490 | troessner/reek | lib/reek/context_builder.rb | Reek.ContextBuilder.process_send | def process_send(exp, _parent)
process(exp)
case current_context
when Context::ModuleContext
handle_send_for_modules exp
when Context::MethodContext
handle_send_for_methods exp
end
end | ruby | def process_send(exp, _parent)
process(exp)
case current_context
when Context::ModuleContext
handle_send_for_modules exp
when Context::MethodContext
handle_send_for_methods exp
end
end | [
"def",
"process_send",
"(",
"exp",
",",
"_parent",
")",
"process",
"(",
"exp",
")",
"case",
"current_context",
"when",
"Context",
"::",
"ModuleContext",
"handle_send_for_modules",
"exp",
"when",
"Context",
"::",
"MethodContext",
"handle_send_for_methods",
"exp",
"en... | Handles `send` nodes a.k.a. method calls.
An input example that would trigger this method would be:
call_me()
Besides checking if it's a visibility modifier or an attribute writer
we also record to what the method call is referring to
which we later use for smell detectors like FeatureEnvy. | [
"Handles",
"send",
"nodes",
"a",
".",
"k",
".",
"a",
".",
"method",
"calls",
"."
] | 8c6b5c0c6228a6981ab48543457889f9ea984054 | https://github.com/troessner/reek/blob/8c6b5c0c6228a6981ab48543457889f9ea984054/lib/reek/context_builder.rb#L155-L163 |
11,491 | troessner/reek | lib/reek/context_builder.rb | Reek.ContextBuilder.process_if | def process_if(exp, _parent)
children = exp.children
increase_statement_count_by(children[1])
increase_statement_count_by(children[2])
decrease_statement_count
process(exp)
end | ruby | def process_if(exp, _parent)
children = exp.children
increase_statement_count_by(children[1])
increase_statement_count_by(children[2])
decrease_statement_count
process(exp)
end | [
"def",
"process_if",
"(",
"exp",
",",
"_parent",
")",
"children",
"=",
"exp",
".",
"children",
"increase_statement_count_by",
"(",
"children",
"[",
"1",
"]",
")",
"increase_statement_count_by",
"(",
"children",
"[",
"2",
"]",
")",
"decrease_statement_count",
"pr... | Handles `if` nodes.
An input example that would trigger this method would be:
if a > 5 && b < 3
puts 'bingo'
else
3
end
Counts the `if` body as one statement and the `else` body as another statement.
At the end we subtract one statement because the surrounding context was already counted
as one (e.g. v... | [
"Handles",
"if",
"nodes",
"."
] | 8c6b5c0c6228a6981ab48543457889f9ea984054 | https://github.com/troessner/reek/blob/8c6b5c0c6228a6981ab48543457889f9ea984054/lib/reek/context_builder.rb#L312-L318 |
11,492 | troessner/reek | lib/reek/context_builder.rb | Reek.ContextBuilder.process_rescue | def process_rescue(exp, _parent)
increase_statement_count_by(exp.children.first)
decrease_statement_count
process(exp)
end | ruby | def process_rescue(exp, _parent)
increase_statement_count_by(exp.children.first)
decrease_statement_count
process(exp)
end | [
"def",
"process_rescue",
"(",
"exp",
",",
"_parent",
")",
"increase_statement_count_by",
"(",
"exp",
".",
"children",
".",
"first",
")",
"decrease_statement_count",
"process",
"(",
"exp",
")",
"end"
] | Handles `rescue` nodes.
An input example that would trigger this method would be:
def simple
raise ArgumentError, 'raising...'
rescue => e
puts 'rescued!'
end
Counts everything before the `rescue` body as one statement.
At the end we subtract one statement because the surrounding context was already cou... | [
"Handles",
"rescue",
"nodes",
"."
] | 8c6b5c0c6228a6981ab48543457889f9ea984054 | https://github.com/troessner/reek/blob/8c6b5c0c6228a6981ab48543457889f9ea984054/lib/reek/context_builder.rb#L388-L392 |
11,493 | troessner/reek | lib/reek/context_builder.rb | Reek.ContextBuilder.inside_new_context | def inside_new_context(klass, *args)
new_context = append_new_context(klass, *args)
orig, self.current_context = current_context, new_context
yield
self.current_context = orig
end | ruby | def inside_new_context(klass, *args)
new_context = append_new_context(klass, *args)
orig, self.current_context = current_context, new_context
yield
self.current_context = orig
end | [
"def",
"inside_new_context",
"(",
"klass",
",",
"*",
"args",
")",
"new_context",
"=",
"append_new_context",
"(",
"klass",
",",
"args",
")",
"orig",
",",
"self",
".",
"current_context",
"=",
"current_context",
",",
"new_context",
"yield",
"self",
".",
"current_... | Stores a reference to the current context, creates a nested new one,
yields to the given block and then restores the previous context.
@param klass [Context::*Context] context class
@param args arguments for the class initializer
@yield block | [
"Stores",
"a",
"reference",
"to",
"the",
"current",
"context",
"creates",
"a",
"nested",
"new",
"one",
"yields",
"to",
"the",
"given",
"block",
"and",
"then",
"restores",
"the",
"previous",
"context",
"."
] | 8c6b5c0c6228a6981ab48543457889f9ea984054 | https://github.com/troessner/reek/blob/8c6b5c0c6228a6981ab48543457889f9ea984054/lib/reek/context_builder.rb#L489-L495 |
11,494 | troessner/reek | lib/reek/context_builder.rb | Reek.ContextBuilder.append_new_context | def append_new_context(klass, *args)
klass.new(*args).tap do |new_context|
new_context.register_with_parent(current_context)
end
end | ruby | def append_new_context(klass, *args)
klass.new(*args).tap do |new_context|
new_context.register_with_parent(current_context)
end
end | [
"def",
"append_new_context",
"(",
"klass",
",",
"*",
"args",
")",
"klass",
".",
"new",
"(",
"args",
")",
".",
"tap",
"do",
"|",
"new_context",
"|",
"new_context",
".",
"register_with_parent",
"(",
"current_context",
")",
"end",
"end"
] | Appends a new child context to the current context but does not change
the current context.
@param klass [Context::*Context] context class
@param args arguments for the class initializer
@return [Context::*Context] the context that was appended | [
"Appends",
"a",
"new",
"child",
"context",
"to",
"the",
"current",
"context",
"but",
"does",
"not",
"change",
"the",
"current",
"context",
"."
] | 8c6b5c0c6228a6981ab48543457889f9ea984054 | https://github.com/troessner/reek/blob/8c6b5c0c6228a6981ab48543457889f9ea984054/lib/reek/context_builder.rb#L505-L509 |
11,495 | troessner/reek | lib/reek/smell_configuration.rb | Reek.SmellConfiguration.value | def value(key, context)
overrides_for(context).each { |conf| return conf[key] if conf.key?(key) }
options.fetch(key)
end | ruby | def value(key, context)
overrides_for(context).each { |conf| return conf[key] if conf.key?(key) }
options.fetch(key)
end | [
"def",
"value",
"(",
"key",
",",
"context",
")",
"overrides_for",
"(",
"context",
")",
".",
"each",
"{",
"|",
"conf",
"|",
"return",
"conf",
"[",
"key",
"]",
"if",
"conf",
".",
"key?",
"(",
"key",
")",
"}",
"options",
".",
"fetch",
"(",
"key",
")... | Retrieves the value, if any, for the given +key+ in the given +context+.
Raises an error if neither the context nor this config have a value for
the key. | [
"Retrieves",
"the",
"value",
"if",
"any",
"for",
"the",
"given",
"+",
"key",
"+",
"in",
"the",
"given",
"+",
"context",
"+",
"."
] | 8c6b5c0c6228a6981ab48543457889f9ea984054 | https://github.com/troessner/reek/blob/8c6b5c0c6228a6981ab48543457889f9ea984054/lib/reek/smell_configuration.rb#L37-L40 |
11,496 | troessner/reek | lib/reek/smell_configuration.rb | Reek.Overrides.for_context | def for_context(context)
contexts = hash.keys.select { |ckey| context.matches?([ckey]) }
contexts.map { |exc| hash[exc] }
end | ruby | def for_context(context)
contexts = hash.keys.select { |ckey| context.matches?([ckey]) }
contexts.map { |exc| hash[exc] }
end | [
"def",
"for_context",
"(",
"context",
")",
"contexts",
"=",
"hash",
".",
"keys",
".",
"select",
"{",
"|",
"ckey",
"|",
"context",
".",
"matches?",
"(",
"[",
"ckey",
"]",
")",
"}",
"contexts",
".",
"map",
"{",
"|",
"exc",
"|",
"hash",
"[",
"exc",
... | Find any overrides that match the supplied context | [
"Find",
"any",
"overrides",
"that",
"match",
"the",
"supplied",
"context"
] | 8c6b5c0c6228a6981ab48543457889f9ea984054 | https://github.com/troessner/reek/blob/8c6b5c0c6228a6981ab48543457889f9ea984054/lib/reek/smell_configuration.rb#L56-L59 |
11,497 | troessner/reek | lib/reek/tree_dresser.rb | Reek.TreeDresser.dress | 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]
klass_map.klass_for(type).new(type, children,
location: sexp.... | ruby | 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]
klass_map.klass_for(type).new(type, children,
location: sexp.... | [
"def",
"dress",
"(",
"sexp",
",",
"comment_map",
")",
"return",
"sexp",
"unless",
"sexp",
".",
"is_a?",
"::",
"Parser",
"::",
"AST",
"::",
"Node",
"type",
"=",
"sexp",
".",
"type",
"children",
"=",
"sexp",
".",
"children",
".",
"map",
"{",
"|",
"chil... | Recursively enhance an AST with type-dependent mixins, and comments.
See {file:docs/How-reek-works-internally.md} for the big picture of how this works.
Example:
This
class Klazz; def meth(argument); argument.call_me; end; end
corresponds to this sexp:
(class
(const nil :Klazz) nil
(def :meth
... | [
"Recursively",
"enhance",
"an",
"AST",
"with",
"type",
"-",
"dependent",
"mixins",
"and",
"comments",
"."
] | 8c6b5c0c6228a6981ab48543457889f9ea984054 | https://github.com/troessner/reek/blob/8c6b5c0c6228a6981ab48543457889f9ea984054/lib/reek/tree_dresser.rb#L42-L50 |
11,498 | uken/fluent-plugin-elasticsearch | lib/fluent/plugin/out_elasticsearch.rb | Fluent::Plugin.ElasticsearchOutput.append_record_to_messages | 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 | 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
... | [
"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",
"]",
"=",
"m... | append_record_to_messages adds a record to the bulk message
payload to be submitted to Elasticsearch. Records that do
not include '_id' field are skipped when 'write_operation'
is configured for 'create' or 'update'
returns 'true' if record was appended to the bulk message
and 'false' otherwise | [
"append_record_to_messages",
"adds",
"a",
"record",
"to",
"the",
"bulk",
"message",
"payload",
"to",
"be",
"submitted",
"to",
"Elasticsearch",
".",
"Records",
"that",
"do",
"not",
"include",
"_id",
"field",
"are",
"skipped",
"when",
"write_operation",
"is",
"con... | 9f9e51ddd012acb36c7f9d7a16e00970004098bc | https://github.com/uken/fluent-plugin-elasticsearch/blob/9f9e51ddd012acb36c7f9d7a16e00970004098bc/lib/fluent/plugin/out_elasticsearch.rb#L492-L515 |
11,499 | uken/fluent-plugin-elasticsearch | lib/fluent/plugin/out_elasticsearch.rb | Fluent::Plugin.ElasticsearchOutput.send_bulk | 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 | 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']
... | [
"def",
"send_bulk",
"(",
"data",
",",
"tag",
",",
"chunk",
",",
"bulk_message_count",
",",
"extracted_values",
",",
"info",
")",
"begin",
"log",
".",
"on_trace",
"{",
"log",
".",
"trace",
"\"bulk request: #{data}\"",
"}",
"response",
"=",
"client",
"(",
"inf... | send_bulk given a specific bulk request, the original tag,
chunk, and bulk_message_count | [
"send_bulk",
"given",
"a",
"specific",
"bulk",
"request",
"the",
"original",
"tag",
"chunk",
"and",
"bulk_message_count"
] | 9f9e51ddd012acb36c7f9d7a16e00970004098bc | https://github.com/uken/fluent-plugin-elasticsearch/blob/9f9e51ddd012acb36c7f9d7a16e00970004098bc/lib/fluent/plugin/out_elasticsearch.rb#L709-L736 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.