Class: Epodder::Configurator
- Defined in:
- lib/configuration/configurator.rb
Constant Summary collapse
- @@default_path =
'~/.epodder/'
- @@db_path =
'epodder.db'
- @@yaml_path =
'epodder.yaml'
- @@default =
{ path_to_db: 'epodder.db', path_to_download: '~/podcasts' }
Instance Method Summary collapse
-
#initialize(args) ⇒ Configurator
constructor
A new instance of Configurator.
- #load_config! ⇒ Object
Constructor Details
#initialize(args) ⇒ Configurator
Returns a new instance of Configurator.
12 13 14 15 16 17 18 19 |
# File 'lib/configuration/configurator.rb', line 12 def initialize(args) @args = args load_working_dir! @args.path load_config! start_logging load_download_dir! load_database! end |
Instance Method Details
#load_config! ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/configuration/configurator.rb', line 22 def load_config! # Check to see if we have a config file or if we need to create it if !File.exists? @@yaml_path begin File.open(@@yaml_path, 'w') do |io| YAML.dump(@@default, io) end rescue SystemCallError, NameError => error puts "Could not load #{@@yaml_path}: #{error}" exit end end @conf = YAML.load_file(@@yaml_path) end |