Class: Epodder::Configurator

Inherits:
Eclass
  • Object
show all
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

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