Class: LockJar::Config
- Inherits:
-
Object
- Object
- LockJar::Config
- Defined in:
- lib/lock_jar/config.rb
Overview
Global configuration for LockJar
Constant Summary collapse
- CONFIG_ENV =
'LOCKJAR_CONFIG'.freeze
- DEFAULT_FILENAME =
'.lockjar'.freeze
Instance Attribute Summary collapse
-
#repositories ⇒ Object
readonly
Returns the value of attribute repositories.
Class Method Summary collapse
-
.load_config_file ⇒ Object
Load .lockjar YAML config file from ENV, current_dir, or home dir.
Instance Method Summary collapse
-
#initialize(config) ⇒ Config
constructor
{ ‘repositories’ => { ‘:url’ => { ‘username’ => ” ‘password’ => ” } } }.
Constructor Details
#initialize(config) ⇒ Config
{
'repositories' => {
':url' => {
'username' => ''
'password' => ''
}
}
}
37 38 39 |
# File 'lib/lock_jar/config.rb', line 37 def initialize(config) @repositories = config['repositories'] || {} end |
Instance Attribute Details
#repositories ⇒ Object (readonly)
Returns the value of attribute repositories.
9 10 11 |
# File 'lib/lock_jar/config.rb', line 9 def repositories @repositories end |
Class Method Details
.load_config_file ⇒ Object
Load .lockjar YAML config file from ENV, current_dir, or home dir.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/lock_jar/config.rb', line 14 def load_config_file local_config_paths = [Dir.pwd, Dir.home] .map { |path| File.join(path, DEFAULT_FILENAME) } config_path = ([ENV[CONFIG_ENV]] + local_config_paths) .compact .find { |path| File.exist? path } new(YAML.load_file(config_path)) if config_path end |