Class: Packageiq::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/packageiq/loader.rb

Overview

load settings from config file

Constant Summary collapse

CONFIG_DIR =
'/etc/packageiq'

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options = {})
  @config_dir   = options[:config_dir] || CONFIG_DIR
  @config_file  = options[:config_file] || nil
  @settings     = {}
end

Instance Attribute Details

#config_dirObject

Returns the value of attribute config_dir.



8
9
10
# File 'lib/packageiq/loader.rb', line 8

def config_dir
  @config_dir
end

#config_fileObject

Returns the value of attribute config_file.



8
9
10
# File 'lib/packageiq/loader.rb', line 8

def config_file
  @config_file
end

#settingsObject (readonly)

Returns the value of attribute settings.



9
10
11
# File 'lib/packageiq/loader.rb', line 9

def settings
  @settings
end

Instance Method Details

#loadObject

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