Class: Spinna::Config
- Inherits:
-
Object
- Object
- Spinna::Config
- Defined in:
- lib/spinna/config.rb
Overview
Takes care of reading the configuration file and exposing the settings.
Constant Summary collapse
- DEFAULT_HISTORY_SIZE =
Default number of albums to keep in the history.
50- DEFAULT_NUMBER_OF_PICKS =
Default number of albums to pick when spinna is run.
10
Instance Attribute Summary collapse
-
#config_file ⇒ Object
The name of the config file to load.
-
#data_dir ⇒ Object
The directory where spinna stores its data.
-
#history_size ⇒ Object
The number previously picked albums to keep in the history.
-
#number_of_picks ⇒ Object
The number of picks to fetch if not explicitly given.
-
#source_dir ⇒ Object
The directory where all the albums are stored.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(opts = {}) ⇒ Config
Returns a new instance of Config.
30 31 32 33 34 35 36 |
# File 'lib/spinna/config.rb', line 30 def initialize(opts = {}) @data_dir = opts[:data_dir] || ENV['SPINNA_DATA_DIR'] || File.join(Dir.home, '.spinna') @config_file = opts[:config_file] || 'config.yml' ensure_data_dir_exists ensure_configuration_exists parse_configuration end |
Instance Attribute Details
#config_file ⇒ Object
The name of the config file to load. (ex: config.yml)
28 29 30 |
# File 'lib/spinna/config.rb', line 28 def config_file @config_file end |
#data_dir ⇒ Object
The directory where spinna stores its data.
15 16 17 |
# File 'lib/spinna/config.rb', line 15 def data_dir @data_dir end |
#history_size ⇒ Object
The number previously picked albums to keep in the history. Defaults to DEFAULT_NUMBER_OF_PICKS.
22 23 24 |
# File 'lib/spinna/config.rb', line 22 def history_size @history_size end |
#number_of_picks ⇒ Object
The number of picks to fetch if not explicitly given.
25 26 27 |
# File 'lib/spinna/config.rb', line 25 def number_of_picks @number_of_picks end |
#source_dir ⇒ Object
The directory where all the albums are stored.
18 19 20 |
# File 'lib/spinna/config.rb', line 18 def source_dir @source_dir end |