Class: Packageiq::Loader
- Inherits:
-
Object
- Object
- Packageiq::Loader
- Defined in:
- lib/packageiq/loader.rb
Overview
load settings from config file
Constant Summary collapse
- CONFIG_DIR =
'/etc/packageiq'
Instance Attribute Summary collapse
-
#config_dir ⇒ Object
Returns the value of attribute config_dir.
-
#config_file ⇒ Object
Returns the value of attribute config_file.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Loader
constructor
can accept options hash from CLI class.
-
#load ⇒ Object
load config file settings return hash of all settings.
Constructor Details
#initialize(options = {}) ⇒ Loader
can accept options hash from CLI class
12 13 14 15 16 |
# File 'lib/packageiq/loader.rb', line 12 def initialize( = {}) @config_dir = [:config_dir] || CONFIG_DIR @config_file = [:config_file] || nil @settings = {} end |
Instance Attribute Details
#config_dir ⇒ Object
Returns the value of attribute config_dir.
8 9 10 |
# File 'lib/packageiq/loader.rb', line 8 def config_dir @config_dir end |
#config_file ⇒ Object
Returns the value of attribute config_file.
8 9 10 |
# File 'lib/packageiq/loader.rb', line 8 def config_file @config_file end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
9 10 11 |
# File 'lib/packageiq/loader.rb', line 9 def settings @settings end |
Instance Method Details
#load ⇒ Object
load config file settings return hash of all settings
20 21 22 23 24 25 26 27 28 |
# File 'lib/packageiq/loader.rb', line 20 def load if config_file full_path = full_path(config_dir, config_file) load_file(full_path) else load_dir(config_dir) end settings end |