Class: Milestoner::Configuration
- Inherits:
-
Object
- Object
- Milestoner::Configuration
- Defined in:
- lib/milestoner/configuration.rb
Overview
Default configuration for gem with support for custom settings.
Instance Method Summary collapse
- #computed_file_path ⇒ Object
- #global_file_path ⇒ Object
-
#initialize(file_name = ".unknownrc", defaults: {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #local_file_path ⇒ Object
- #settings ⇒ Object
Constructor Details
#initialize(file_name = ".unknownrc", defaults: {}) ⇒ Configuration
Returns a new instance of Configuration.
4 5 6 7 |
# File 'lib/milestoner/configuration.rb', line 4 def initialize file_name = ".unknownrc", defaults: {} @file_name = file_name @defaults = defaults end |
Instance Method Details
#computed_file_path ⇒ Object
17 18 19 |
# File 'lib/milestoner/configuration.rb', line 17 def computed_file_path File.exist?(local_file_path) ? local_file_path : global_file_path end |
#global_file_path ⇒ Object
13 14 15 |
# File 'lib/milestoner/configuration.rb', line 13 def global_file_path File.join ENV["HOME"], file_name end |
#local_file_path ⇒ Object
9 10 11 |
# File 'lib/milestoner/configuration.rb', line 9 def local_file_path File.join Dir.pwd, file_name end |
#settings ⇒ Object
21 22 23 |
# File 'lib/milestoner/configuration.rb', line 21 def settings defaults.merge(load_settings).reject { |_, value| value.nil? } end |