Class: Milestoner::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/milestoner/configuration.rb

Overview

Default configuration for gem with support for custom settings.

Instance Method Summary collapse

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_pathObject



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_pathObject



13
14
15
# File 'lib/milestoner/configuration.rb', line 13

def global_file_path
  File.join ENV["HOME"], file_name
end

#local_file_pathObject



9
10
11
# File 'lib/milestoner/configuration.rb', line 9

def local_file_path
  File.join Dir.pwd, file_name
end

#settingsObject



21
22
23
# File 'lib/milestoner/configuration.rb', line 21

def settings
  defaults.merge(load_settings).reject { |_, value| value.nil? }
end