repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
partition
stringclasses
1 value
roo-rb/roo
lib/roo/excelx.rb
Roo.Excelx.process_zipfile
def process_zipfile(zipfilename_or_stream) @sheet_files = [] unless is_stream?(zipfilename_or_stream) zip_file = Zip::File.open(zipfilename_or_stream) else zip_file = Zip::CentralDirectory.new zip_file.read_from_stream zipfilename_or_stream end process_zipfile_ent...
ruby
def process_zipfile(zipfilename_or_stream) @sheet_files = [] unless is_stream?(zipfilename_or_stream) zip_file = Zip::File.open(zipfilename_or_stream) else zip_file = Zip::CentralDirectory.new zip_file.read_from_stream zipfilename_or_stream end process_zipfile_ent...
[ "def", "process_zipfile", "(", "zipfilename_or_stream", ")", "@sheet_files", "=", "[", "]", "unless", "is_stream?", "(", "zipfilename_or_stream", ")", "zip_file", "=", "Zip", "::", "File", ".", "open", "(", "zipfilename_or_stream", ")", "else", "zip_file", "=", ...
Extracts all needed files from the zip file
[ "Extracts", "all", "needed", "files", "from", "the", "zip", "file" ]
4ec1104f0c3c2a29711c0c907371cd2be12bcc3c
https://github.com/roo-rb/roo/blob/4ec1104f0c3c2a29711c0c907371cd2be12bcc3c/lib/roo/excelx.rb#L394-L405
train
roo-rb/roo
lib/roo/open_office.rb
Roo.OpenOffice.decrypt_if_necessary
def decrypt_if_necessary( zip_file, content_entry, roo_content_xml_path, options ) # Check if content.xml is encrypted by extracting manifest.xml # and searching for a manifest:encryption-data element if (manifest_entry = zip_file.glob('META-INF/manifest.xml').first) roo...
ruby
def decrypt_if_necessary( zip_file, content_entry, roo_content_xml_path, options ) # Check if content.xml is encrypted by extracting manifest.xml # and searching for a manifest:encryption-data element if (manifest_entry = zip_file.glob('META-INF/manifest.xml').first) roo...
[ "def", "decrypt_if_necessary", "(", "zip_file", ",", "content_entry", ",", "roo_content_xml_path", ",", "options", ")", "# Check if content.xml is encrypted by extracting manifest.xml", "# and searching for a manifest:encryption-data element", "if", "(", "manifest_entry", "=", "zip...
If the ODS file has an encryption-data element, then try to decrypt. If successful, the temporary content.xml will be overwritten with decrypted contents.
[ "If", "the", "ODS", "file", "has", "an", "encryption", "-", "data", "element", "then", "try", "to", "decrypt", ".", "If", "successful", "the", "temporary", "content", ".", "xml", "will", "be", "overwritten", "with", "decrypted", "contents", "." ]
4ec1104f0c3c2a29711c0c907371cd2be12bcc3c
https://github.com/roo-rb/roo/blob/4ec1104f0c3c2a29711c0c907371cd2be12bcc3c/lib/roo/open_office.rb#L227-L270
train
roo-rb/roo
lib/roo/open_office.rb
Roo.OpenOffice.perform_decryption
def perform_decryption( encryption_data, password, content_entry, roo_content_xml_path ) # Extract various expected attributes from the manifest that # describe the encryption algorithm_node = encryption_data.xpath('manifest:algorithm').first key_derivatio...
ruby
def perform_decryption( encryption_data, password, content_entry, roo_content_xml_path ) # Extract various expected attributes from the manifest that # describe the encryption algorithm_node = encryption_data.xpath('manifest:algorithm').first key_derivatio...
[ "def", "perform_decryption", "(", "encryption_data", ",", "password", ",", "content_entry", ",", "roo_content_xml_path", ")", "# Extract various expected attributes from the manifest that", "# describe the encryption", "algorithm_node", "=", "encryption_data", ".", "xpath", "(", ...
Process the ODS encryption manifest and perform the decryption
[ "Process", "the", "ODS", "encryption", "manifest", "and", "perform", "the", "decryption" ]
4ec1104f0c3c2a29711c0c907371cd2be12bcc3c
https://github.com/roo-rb/roo/blob/4ec1104f0c3c2a29711c0c907371cd2be12bcc3c/lib/roo/open_office.rb#L273-L344
train
roo-rb/roo
lib/roo/open_office.rb
Roo.OpenOffice.find_cipher_key
def find_cipher_key(*args) fail ArgumentError, 'Unknown key derivation name ', args[1] unless args[1] == 'PBKDF2' ::OpenSSL::PKCS5.pbkdf2_hmac_sha1(args[2], args[3], args[4], args[0].key_len) end
ruby
def find_cipher_key(*args) fail ArgumentError, 'Unknown key derivation name ', args[1] unless args[1] == 'PBKDF2' ::OpenSSL::PKCS5.pbkdf2_hmac_sha1(args[2], args[3], args[4], args[0].key_len) end
[ "def", "find_cipher_key", "(", "*", "args", ")", "fail", "ArgumentError", ",", "'Unknown key derivation name '", ",", "args", "[", "1", "]", "unless", "args", "[", "1", "]", "==", "'PBKDF2'", "::", "OpenSSL", "::", "PKCS5", ".", "pbkdf2_hmac_sha1", "(", "arg...
Create a cipher key based on an ODS algorithm string from manifest.xml
[ "Create", "a", "cipher", "key", "based", "on", "an", "ODS", "algorithm", "string", "from", "manifest", ".", "xml" ]
4ec1104f0c3c2a29711c0c907371cd2be12bcc3c
https://github.com/roo-rb/roo/blob/4ec1104f0c3c2a29711c0c907371cd2be12bcc3c/lib/roo/open_office.rb#L361-L365
train
roo-rb/roo
lib/roo/open_office.rb
Roo.OpenOffice.decrypt
def decrypt(content_entry, cipher) # Zip::Entry.extract writes a 0-length file when trying # to extract an encrypted stream, so we read the # raw bytes based on the offset and lengths decrypted = '' File.open(@filename, 'rb') do |zipfile| zipfile.seek( content_entry.local...
ruby
def decrypt(content_entry, cipher) # Zip::Entry.extract writes a 0-length file when trying # to extract an encrypted stream, so we read the # raw bytes based on the offset and lengths decrypted = '' File.open(@filename, 'rb') do |zipfile| zipfile.seek( content_entry.local...
[ "def", "decrypt", "(", "content_entry", ",", "cipher", ")", "# Zip::Entry.extract writes a 0-length file when trying", "# to extract an encrypted stream, so we read the", "# raw bytes based on the offset and lengths", "decrypted", "=", "''", "File", ".", "open", "(", "@filename", ...
Block decrypt raw bytes from the zip file based on the cipher
[ "Block", "decrypt", "raw", "bytes", "from", "the", "zip", "file", "based", "on", "the", "cipher" ]
4ec1104f0c3c2a29711c0c907371cd2be12bcc3c
https://github.com/roo-rb/roo/blob/4ec1104f0c3c2a29711c0c907371cd2be12bcc3c/lib/roo/open_office.rb#L368-L394
train
roo-rb/roo
lib/roo/open_office.rb
Roo.OpenOffice.set_cell_values
def set_cell_values(sheet, x, y, i, v, value_type, formula, table_cell, str_v, style_name) key = [y, x + i] @cell_type[sheet] ||= {} @cell_type[sheet][key] = value_type.to_sym if value_type @formula[sheet] ||= {} if formula ['of:', 'oooc:'].each do |prefix| if formula[0, ...
ruby
def set_cell_values(sheet, x, y, i, v, value_type, formula, table_cell, str_v, style_name) key = [y, x + i] @cell_type[sheet] ||= {} @cell_type[sheet][key] = value_type.to_sym if value_type @formula[sheet] ||= {} if formula ['of:', 'oooc:'].each do |prefix| if formula[0, ...
[ "def", "set_cell_values", "(", "sheet", ",", "x", ",", "y", ",", "i", ",", "v", ",", "value_type", ",", "formula", ",", "table_cell", ",", "str_v", ",", "style_name", ")", "key", "=", "[", "y", ",", "x", "+", "i", "]", "@cell_type", "[", "sheet", ...
helper function to set the internal representation of cells
[ "helper", "function", "to", "set", "the", "internal", "representation", "of", "cells" ]
4ec1104f0c3c2a29711c0c907371cd2be12bcc3c
https://github.com/roo-rb/roo/blob/4ec1104f0c3c2a29711c0c907371cd2be12bcc3c/lib/roo/open_office.rb#L408-L447
train
roo-rb/roo
lib/roo/utils.rb
Roo.Utils.num_cells_in_range
def num_cells_in_range(str) cells = str.split(':') return 1 if cells.count == 1 raise ArgumentError.new("invalid range string: #{str}. Supported range format 'A1:B2'") if cells.count != 2 x1, y1 = extract_coordinate(cells[0]) x2, y2 = extract_coordinate(cells[1]) (x2 - (x1 - 1)) * (y...
ruby
def num_cells_in_range(str) cells = str.split(':') return 1 if cells.count == 1 raise ArgumentError.new("invalid range string: #{str}. Supported range format 'A1:B2'") if cells.count != 2 x1, y1 = extract_coordinate(cells[0]) x2, y2 = extract_coordinate(cells[1]) (x2 - (x1 - 1)) * (y...
[ "def", "num_cells_in_range", "(", "str", ")", "cells", "=", "str", ".", "split", "(", "':'", ")", "return", "1", "if", "cells", ".", "count", "==", "1", "raise", "ArgumentError", ".", "new", "(", "\"invalid range string: #{str}. Supported range format 'A1:B2'\"", ...
Compute upper bound for cells in a given cell range.
[ "Compute", "upper", "bound", "for", "cells", "in", "a", "given", "cell", "range", "." ]
4ec1104f0c3c2a29711c0c907371cd2be12bcc3c
https://github.com/roo-rb/roo/blob/4ec1104f0c3c2a29711c0c907371cd2be12bcc3c/lib/roo/utils.rb#L69-L76
train
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.catalog
def catalog bundle new_map_hash = {} # Bundle always needs to be merged if it adds or removes sources merged = (bundle.sources.length == source_map_hash.values.length) bundle.sources.each do |source| if source_map_hash.key?(source.filename) if source_map_hash[source.filename].c...
ruby
def catalog bundle new_map_hash = {} # Bundle always needs to be merged if it adds or removes sources merged = (bundle.sources.length == source_map_hash.values.length) bundle.sources.each do |source| if source_map_hash.key?(source.filename) if source_map_hash[source.filename].c...
[ "def", "catalog", "bundle", "new_map_hash", "=", "{", "}", "# Bundle always needs to be merged if it adds or removes sources", "merged", "=", "(", "bundle", ".", "sources", ".", "length", "==", "source_map_hash", ".", "values", ".", "length", ")", "bundle", ".", "so...
Catalog a bundle. @param bundle [Bundle] @return [self]
[ "Catalog", "a", "bundle", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L64-L123
train
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.clip_at
def clip_at filename, position position = Position.normalize(position) SourceMap::Clip.new(self, cursor_at(filename, position)) end
ruby
def clip_at filename, position position = Position.normalize(position) SourceMap::Clip.new(self, cursor_at(filename, position)) end
[ "def", "clip_at", "filename", ",", "position", "position", "=", "Position", ".", "normalize", "(", "position", ")", "SourceMap", "::", "Clip", ".", "new", "(", "self", ",", "cursor_at", "(", "filename", ",", "position", ")", ")", "end" ]
Get a clip by filename and position. @param filename [String] @param position [Position, Array(Integer, Integer)] @return [SourceMap::Clip]
[ "Get", "a", "clip", "by", "filename", "and", "position", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L139-L142
train
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.get_constants
def get_constants namespace, context = '' namespace ||= '' cached = cache.get_constants(namespace, context) return cached.clone unless cached.nil? skip = [] result = [] bases = context.split('::') while bases.length > 0 built = bases.join('::') fqns = qualify(na...
ruby
def get_constants namespace, context = '' namespace ||= '' cached = cache.get_constants(namespace, context) return cached.clone unless cached.nil? skip = [] result = [] bases = context.split('::') while bases.length > 0 built = bases.join('::') fqns = qualify(na...
[ "def", "get_constants", "namespace", ",", "context", "=", "''", "namespace", "||=", "''", "cached", "=", "cache", ".", "get_constants", "(", "namespace", ",", "context", ")", "return", "cached", ".", "clone", "unless", "cached", ".", "nil?", "skip", "=", "...
Get suggestions for constants in the specified namespace. The result may contain both constant and namespace pins. @param namespace [String] The namespace @param context [String] The context @return [Array<Solargraph::Pin::Base>]
[ "Get", "suggestions", "for", "constants", "in", "the", "specified", "namespace", ".", "The", "result", "may", "contain", "both", "constant", "and", "namespace", "pins", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L191-L212
train
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.qualify
def qualify namespace, context = '' # @todo The return for self might work better elsewhere return nil if namespace.nil? return qualify(context) if namespace == 'self' cached = cache.get_qualified_namespace(namespace, context) return cached.clone unless cached.nil? result = if namesp...
ruby
def qualify namespace, context = '' # @todo The return for self might work better elsewhere return nil if namespace.nil? return qualify(context) if namespace == 'self' cached = cache.get_qualified_namespace(namespace, context) return cached.clone unless cached.nil? result = if namesp...
[ "def", "qualify", "namespace", ",", "context", "=", "''", "# @todo The return for self might work better elsewhere", "return", "nil", "if", "namespace", ".", "nil?", "return", "qualify", "(", "context", ")", "if", "namespace", "==", "'self'", "cached", "=", "cache",...
Get a fully qualified namespace name. This method will start the search in the specified context until it finds a match for the name. @param namespace [String, nil] The namespace to match @param context [String] The context to search @return [String]
[ "Get", "a", "fully", "qualified", "namespace", "name", ".", "This", "method", "will", "start", "the", "search", "in", "the", "specified", "context", "until", "it", "finds", "a", "match", "for", "the", "name", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L220-L233
train
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.get_instance_variable_pins
def get_instance_variable_pins(namespace, scope = :instance) result = [] result.concat store.get_instance_variables(namespace, scope) sc = qualify(store.get_superclass(namespace), namespace) until sc.nil? result.concat store.get_instance_variables(sc, scope) sc = qualify(store.ge...
ruby
def get_instance_variable_pins(namespace, scope = :instance) result = [] result.concat store.get_instance_variables(namespace, scope) sc = qualify(store.get_superclass(namespace), namespace) until sc.nil? result.concat store.get_instance_variables(sc, scope) sc = qualify(store.ge...
[ "def", "get_instance_variable_pins", "(", "namespace", ",", "scope", "=", ":instance", ")", "result", "=", "[", "]", "result", ".", "concat", "store", ".", "get_instance_variables", "(", "namespace", ",", "scope", ")", "sc", "=", "qualify", "(", "store", "."...
Get an array of instance variable pins defined in specified namespace and scope. @param namespace [String] A fully qualified namespace @param scope [Symbol] :instance or :class @return [Array<Solargraph::Pin::InstanceVariable>]
[ "Get", "an", "array", "of", "instance", "variable", "pins", "defined", "in", "specified", "namespace", "and", "scope", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L241-L250
train
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.get_methods
def get_methods fqns, scope: :instance, visibility: [:public], deep: true cached = cache.get_methods(fqns, scope, visibility, deep) return cached.clone unless cached.nil? result = [] skip = [] if fqns == '' # @todo Implement domains # domains.each do |domain| # ty...
ruby
def get_methods fqns, scope: :instance, visibility: [:public], deep: true cached = cache.get_methods(fqns, scope, visibility, deep) return cached.clone unless cached.nil? result = [] skip = [] if fqns == '' # @todo Implement domains # domains.each do |domain| # ty...
[ "def", "get_methods", "fqns", ",", "scope", ":", ":instance", ",", "visibility", ":", "[", ":public", "]", ",", "deep", ":", "true", "cached", "=", "cache", ".", "get_methods", "(", "fqns", ",", "scope", ",", "visibility", ",", "deep", ")", "return", "...
Get an array of methods available in a particular context. @param fqns [String] The fully qualified namespace to search for methods @param scope [Symbol] :class or :instance @param visibility [Array<Symbol>] :public, :protected, and/or :private @param deep [Boolean] True to include superclasses, mixins, etc. @ret...
[ "Get", "an", "array", "of", "methods", "available", "in", "a", "particular", "context", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L278-L303
train
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.get_complex_type_methods
def get_complex_type_methods type, context = '', internal = false # This method does not qualify the complex type's namespace because # it can cause conflicts between similar names, e.g., `Foo` vs. # `Other::Foo`. It still takes a context argument to determine whether # protected and private met...
ruby
def get_complex_type_methods type, context = '', internal = false # This method does not qualify the complex type's namespace because # it can cause conflicts between similar names, e.g., `Foo` vs. # `Other::Foo`. It still takes a context argument to determine whether # protected and private met...
[ "def", "get_complex_type_methods", "type", ",", "context", "=", "''", ",", "internal", "=", "false", "# This method does not qualify the complex type's namespace because", "# it can cause conflicts between similar names, e.g., `Foo` vs.", "# `Other::Foo`. It still takes a context argument ...
Get an array of method pins for a complex type. The type's namespace and the context should be fully qualified. If the context matches the namespace type or is a subclass of the type, protected methods are included in the results. If protected methods are included and internal is true, private methods are also inc...
[ "Get", "an", "array", "of", "method", "pins", "for", "a", "complex", "type", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L321-L344
train
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.get_method_stack
def get_method_stack fqns, name, scope: :instance get_methods(fqns, scope: scope, visibility: [:private, :protected, :public]).select{|p| p.name == name} end
ruby
def get_method_stack fqns, name, scope: :instance get_methods(fqns, scope: scope, visibility: [:private, :protected, :public]).select{|p| p.name == name} end
[ "def", "get_method_stack", "fqns", ",", "name", ",", "scope", ":", ":instance", "get_methods", "(", "fqns", ",", "scope", ":", "scope", ",", "visibility", ":", "[", ":private", ",", ":protected", ",", ":public", "]", ")", ".", "select", "{", "|", "p", ...
Get a stack of method pins for a method name in a namespace. The order of the pins corresponds to the ancestry chain, with highest precedence first. @example api_map.get_method_stack('Subclass', 'method_name') #=> [ <Subclass#method_name pin>, <Superclass#method_name pin> ] @param fqns [String] @param na...
[ "Get", "a", "stack", "of", "method", "pins", "for", "a", "method", "name", "in", "a", "namespace", ".", "The", "order", "of", "the", "pins", "corresponds", "to", "the", "ancestry", "chain", "with", "highest", "precedence", "first", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L358-L360
train
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.get_path_suggestions
def get_path_suggestions path return [] if path.nil? result = [] result.concat store.get_path_pins(path) # if result.empty? # lp = live_map.get_path_pin(path) # result.push lp unless lp.nil? # end resolve_method_aliases(result) end
ruby
def get_path_suggestions path return [] if path.nil? result = [] result.concat store.get_path_pins(path) # if result.empty? # lp = live_map.get_path_pin(path) # result.push lp unless lp.nil? # end resolve_method_aliases(result) end
[ "def", "get_path_suggestions", "path", "return", "[", "]", "if", "path", ".", "nil?", "result", "=", "[", "]", "result", ".", "concat", "store", ".", "get_path_pins", "(", "path", ")", "# if result.empty?", "# lp = live_map.get_path_pin(path)", "# result.push lp...
Get an array of all suggestions that match the specified path. @deprecated Use #get_path_pins instead. @param path [String] The path to find @return [Array<Solargraph::Pin::Base>]
[ "Get", "an", "array", "of", "all", "suggestions", "that", "match", "the", "specified", "path", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L368-L377
train
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.search
def search query rake_yard(store) found = [] code_object_paths.each do |k| if found.empty? || (query.include?('.') || query.include?('#')) || !(k.include?('.') || k.include?('#')) found.push k if k.downcase.include?(query.downcase) end end found end
ruby
def search query rake_yard(store) found = [] code_object_paths.each do |k| if found.empty? || (query.include?('.') || query.include?('#')) || !(k.include?('.') || k.include?('#')) found.push k if k.downcase.include?(query.downcase) end end found end
[ "def", "search", "query", "rake_yard", "(", "store", ")", "found", "=", "[", "]", "code_object_paths", ".", "each", "do", "|", "k", "|", "if", "found", ".", "empty?", "||", "(", "query", ".", "include?", "(", "'.'", ")", "||", "query", ".", "include?...
Get a list of documented paths that match the query. @example api_map.query('str') # Results will include `String` and `Struct` @param query [String] The text to match @return [Array<String>]
[ "Get", "a", "list", "of", "documented", "paths", "that", "match", "the", "query", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L394-L403
train
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.document
def document path rake_yard(store) docs = [] docs.push code_object_at(path) unless code_object_at(path).nil? docs end
ruby
def document path rake_yard(store) docs = [] docs.push code_object_at(path) unless code_object_at(path).nil? docs end
[ "def", "document", "path", "rake_yard", "(", "store", ")", "docs", "=", "[", "]", "docs", ".", "push", "code_object_at", "(", "path", ")", "unless", "code_object_at", "(", "path", ")", ".", "nil?", "docs", "end" ]
Get YARD documentation for the specified path. @example api_map.document('String#split') @param path [String] The path to find @return [Array<YARD::CodeObject::Base>]
[ "Get", "YARD", "documentation", "for", "the", "specified", "path", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L412-L417
train
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.query_symbols
def query_symbols query result = [] source_map_hash.values.each do |s| result.concat s.query_symbols(query) end result end
ruby
def query_symbols query result = [] source_map_hash.values.each do |s| result.concat s.query_symbols(query) end result end
[ "def", "query_symbols", "query", "result", "=", "[", "]", "source_map_hash", ".", "values", ".", "each", "do", "|", "s", "|", "result", ".", "concat", "s", ".", "query_symbols", "(", "query", ")", "end", "result", "end" ]
Get an array of all symbols in the workspace that match the query. @param query [String] @return [Array<Pin::Base>]
[ "Get", "an", "array", "of", "all", "symbols", "in", "the", "workspace", "that", "match", "the", "query", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L423-L429
train
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.require_extensions
def require_extensions Gem::Specification.all_names.select{|n| n.match(/^solargraph\-[a-z0-9_\-]*?\-ext\-[0-9\.]*$/)}.each do |n| Solargraph::Logging.logger.info "Loading extension #{n}" require n.match(/^(solargraph\-[a-z0-9_\-]*?\-ext)\-[0-9\.]*$/)[1] end end
ruby
def require_extensions Gem::Specification.all_names.select{|n| n.match(/^solargraph\-[a-z0-9_\-]*?\-ext\-[0-9\.]*$/)}.each do |n| Solargraph::Logging.logger.info "Loading extension #{n}" require n.match(/^(solargraph\-[a-z0-9_\-]*?\-ext)\-[0-9\.]*$/)[1] end end
[ "def", "require_extensions", "Gem", "::", "Specification", ".", "all_names", ".", "select", "{", "|", "n", "|", "n", ".", "match", "(", "/", "\\-", "\\-", "\\-", "\\-", "\\.", "/", ")", "}", ".", "each", "do", "|", "n", "|", "Solargraph", "::", "Lo...
Require extensions for the experimental plugin architecture. Any installed gem with a name that starts with "solargraph-" is considered an extension. @return [void]
[ "Require", "extensions", "for", "the", "experimental", "plugin", "architecture", ".", "Any", "installed", "gem", "with", "a", "name", "that", "starts", "with", "solargraph", "-", "is", "considered", "an", "extension", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L556-L561
train
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.prefer_non_nil_variables
def prefer_non_nil_variables pins result = [] nil_pins = [] pins.each do |pin| if pin.variable? && pin.nil_assignment? nil_pins.push pin else result.push pin end end result + nil_pins end
ruby
def prefer_non_nil_variables pins result = [] nil_pins = [] pins.each do |pin| if pin.variable? && pin.nil_assignment? nil_pins.push pin else result.push pin end end result + nil_pins end
[ "def", "prefer_non_nil_variables", "pins", "result", "=", "[", "]", "nil_pins", "=", "[", "]", "pins", ".", "each", "do", "|", "pin", "|", "if", "pin", ".", "variable?", "&&", "pin", ".", "nil_assignment?", "nil_pins", ".", "push", "pin", "else", "result...
Sort an array of pins to put nil or undefined variables last. @param pins [Array<Solargraph::Pin::Base>] @return [Array<Solargraph::Pin::Base>]
[ "Sort", "an", "array", "of", "pins", "to", "put", "nil", "or", "undefined", "variables", "last", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L620-L631
train
castwide/solargraph
lib/solargraph/api_map.rb
Solargraph.ApiMap.super_and_sub?
def super_and_sub?(sup, sub) fqsup = qualify(sup) cls = qualify(store.get_superclass(sub), sub) until cls.nil? return true if cls == fqsup cls = qualify(store.get_superclass(cls), cls) end false end
ruby
def super_and_sub?(sup, sub) fqsup = qualify(sup) cls = qualify(store.get_superclass(sub), sub) until cls.nil? return true if cls == fqsup cls = qualify(store.get_superclass(cls), cls) end false end
[ "def", "super_and_sub?", "(", "sup", ",", "sub", ")", "fqsup", "=", "qualify", "(", "sup", ")", "cls", "=", "qualify", "(", "store", ".", "get_superclass", "(", "sub", ")", ",", "sub", ")", "until", "cls", ".", "nil?", "return", "true", "if", "cls", ...
Check if a class is a superclass of another class. @param sup [String] The superclass @param sub [String] The subclass @return [Boolean]
[ "Check", "if", "a", "class", "is", "a", "superclass", "of", "another", "class", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/api_map.rb#L638-L646
train
castwide/solargraph
lib/solargraph/range.rb
Solargraph.Range.contain?
def contain? position position = Position.normalize(position) return false if position.line < start.line || position.line > ending.line return false if position.line == start.line && position.character < start.character return false if position.line == ending.line && position.character > ending....
ruby
def contain? position position = Position.normalize(position) return false if position.line < start.line || position.line > ending.line return false if position.line == start.line && position.character < start.character return false if position.line == ending.line && position.character > ending....
[ "def", "contain?", "position", "position", "=", "Position", ".", "normalize", "(", "position", ")", "return", "false", "if", "position", ".", "line", "<", "start", ".", "line", "||", "position", ".", "line", ">", "ending", ".", "line", "return", "false", ...
True if the specified position is inside the range. @param position [Position, Array(Integer, Integer)] @return [Boolean]
[ "True", "if", "the", "specified", "position", "is", "inside", "the", "range", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/range.rb#L33-L39
train
castwide/solargraph
lib/solargraph/range.rb
Solargraph.Range.include?
def include? position position = Position.normalize(position) contain?(position) && !(position.line == start.line && position.character == start.character) end
ruby
def include? position position = Position.normalize(position) contain?(position) && !(position.line == start.line && position.character == start.character) end
[ "def", "include?", "position", "position", "=", "Position", ".", "normalize", "(", "position", ")", "contain?", "(", "position", ")", "&&", "!", "(", "position", ".", "line", "==", "start", ".", "line", "&&", "position", ".", "character", "==", "start", ...
True if the range contains the specified position and the position does not precede it. @param position [Position, Array(Integer, Integer)] @return [Boolean]
[ "True", "if", "the", "range", "contains", "the", "specified", "position", "and", "the", "position", "does", "not", "precede", "it", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/range.rb#L45-L48
train
castwide/solargraph
lib/solargraph/source.rb
Solargraph.Source.tree_at
def tree_at(line, column) # offset = Position.line_char_to_offset(@code, line, column) position = Position.new(line, column) stack = [] inner_tree_at @node, position, stack stack end
ruby
def tree_at(line, column) # offset = Position.line_char_to_offset(@code, line, column) position = Position.new(line, column) stack = [] inner_tree_at @node, position, stack stack end
[ "def", "tree_at", "(", "line", ",", "column", ")", "# offset = Position.line_char_to_offset(@code, line, column)", "position", "=", "Position", ".", "new", "(", "line", ",", "column", ")", "stack", "=", "[", "]", "inner_tree_at", "@node", ",", "position", ",", "...
Get an array of nodes containing the specified index, starting with the nearest node and ending with the root. @param line [Integer] @param column [Integer] @return [Array<AST::Node>]
[ "Get", "an", "array", "of", "nodes", "containing", "the", "specified", "index", "starting", "with", "the", "nearest", "node", "and", "ending", "with", "the", "root", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/source.rb#L99-L105
train
castwide/solargraph
lib/solargraph/source.rb
Solargraph.Source.synchronize
def synchronize updater raise 'Invalid synchronization' unless updater.filename == filename real_code = updater.write(@code) if real_code == @code @version = updater.version return self end synced = Source.new(real_code, filename) if synced.parsed? synced.vers...
ruby
def synchronize updater raise 'Invalid synchronization' unless updater.filename == filename real_code = updater.write(@code) if real_code == @code @version = updater.version return self end synced = Source.new(real_code, filename) if synced.parsed? synced.vers...
[ "def", "synchronize", "updater", "raise", "'Invalid synchronization'", "unless", "updater", ".", "filename", "==", "filename", "real_code", "=", "updater", ".", "write", "(", "@code", ")", "if", "real_code", "==", "@code", "@version", "=", "updater", ".", "versi...
Synchronize the Source with an update. This method applies changes to the code, parses the new code's AST, and returns the resulting Source object. @param updater [Source::Updater] @return [Source]
[ "Synchronize", "the", "Source", "with", "an", "update", ".", "This", "method", "applies", "changes", "to", "the", "code", "parses", "the", "new", "code", "s", "AST", "and", "returns", "the", "resulting", "Source", "object", "." ]
47badb5d151aca775ccbe6c470236089eae7839d
https://github.com/castwide/solargraph/blob/47badb5d151aca775ccbe6c470236089eae7839d/lib/solargraph/source.rb#L156-L174
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train