Class: Bookworm::Configuration
- Inherits:
-
Object
- Object
- Bookworm::Configuration
- Defined in:
- lib/bookworm/configuration.rb
Constant Summary collapse
- SYSTEM_CONFIGURATION_RUBY_FILE =
Allow for programmatic configuration override
'/usr/local/etc/bookworm/configuration.rb'.freeze
- SYSTEM_CONTRIB_DIR =
'/usr/local/etc/bookworm/contrib'.freeze
Instance Attribute Summary collapse
-
#source_dirs ⇒ Object
readonly
Returns the value of attribute source_dirs.
-
#system_contrib_dir ⇒ Object
readonly
Returns the value of attribute system_contrib_dir.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/bookworm/configuration.rb', line 25 def initialize begin load SYSTEM_CONFIGURATION_RUBY_FILE rescue LoadError # puts "No configuration found at #{SYSTEM_CONFIGURATION_RUBY_FILE}" config = {} end begin config = YAML.load_file "#{Dir.home}/.bookworm.yml" rescue StandardError config = {} end @system_contrib_dir = SYSTEM_CONTRIB_DIR if Bookworm::Configuration.const_defined?(:DEFAULT_SOURCE_DIRS) @source_dirs ||= DEFAULT_SOURCE_DIRS end if Bookworm::Configuration.const_defined?(:DEFAULT_DEBUG) @debug ||= DEFAULT_DEBUG end @system_contrib_dir = config['system_contrib_dir'] if config['system_contrib_dir'] @source_dirs = config['source_dirs'] if config['source_dirs'] @debug = config['debug'] if config['debug'] @source_dirs ||= [] end |
Instance Attribute Details
#source_dirs ⇒ Object (readonly)
Returns the value of attribute source_dirs.
18 19 20 |
# File 'lib/bookworm/configuration.rb', line 18 def source_dirs @source_dirs end |
#system_contrib_dir ⇒ Object (readonly)
Returns the value of attribute system_contrib_dir.
19 20 21 |
# File 'lib/bookworm/configuration.rb', line 19 def system_contrib_dir @system_contrib_dir end |