class GitDS::RepoConfig
Provides access to the repo .git/config file as a hash.
Note that this limits access to a specific section of the config file, named by the parameter ‘section’.
Public Class Methods
new(db, section='misc')
click to toggle source
# File lib/git-ds/config.rb, line 18 def initialize(db, section='misc') @db = db @section = clean(section) end
Public Instance Methods
[](key)
click to toggle source
Return the String value of the variable ‘key’.
# File lib/git-ds/config.rb, line 40 def [](key) rv = @db.repo_config[path(key)] rv ? rv : '' end
[]=(key, value)
click to toggle source
Writes the String representation of ‘value’ to the variable ‘key’.
# File lib/git-ds/config.rb, line 48 def []=(key, value) @db.repo_config[path(key)] = value.to_s end
clean(str)
click to toggle source
Clean key so it is a valid Config token
# File lib/git-ds/config.rb, line 26 def clean(str) str.gsub(/[^-[:alnum:]]/, '-') end
path(key)
click to toggle source
Return the full path to the variable for ‘key’.
# File lib/git-ds/config.rb, line 33 def path(key) @section + '.' + clean(key) end