class Nutrella::Configuration
Knows the location and format of the configuration.
Constants
- INITIAL_CONFIGURATION
- NULOGY_ORGANIZATION_ID
Attributes
path[R]
values[R]
Public Class Methods
new(path)
click to toggle source
# File lib/nutrella/configuration.rb, line 33 def initialize(path) @path = path load_configuration unless configuration_missing? end
values(path)
click to toggle source
# File lib/nutrella/configuration.rb, line 29 def self.values(path) new(path).values end
Private Instance Methods
configuration()
click to toggle source
# File lib/nutrella/configuration.rb, line 57 def configuration @_configuration ||= YAML.load_file(path) end
configuration_missing?()
click to toggle source
# File lib/nutrella/configuration.rb, line 61 def configuration_missing? return false if File.exist?(path) write_initial_configuration abort configuration_missing_message end
configuration_missing_message()
click to toggle source
# File lib/nutrella/configuration.rb, line 72 def configuration_missing_message <<~TEXT I see that you don't have a config file '#{path}'. So, I created one for you. You still need to enter your Trello API keys into the config file. See https://github.com/amckinnell/nutrella for instructions. TEXT end
load_configuration()
click to toggle source
# File lib/nutrella/configuration.rb, line 41 def load_configuration # rubocop:disable Metrics/AbcSize, Metrics/MethodLength @values = { key: configuration.fetch("key"), secret: configuration.fetch("secret"), token: configuration.fetch("token"), organization: configuration.fetch("organization", NULOGY_ORGANIZATION_ID), launch_command: configuration.fetch("launch_command", "open $url$"), enable_trello_app: configuration.fetch("enable_trello_app", "false"), enable_logging: configuration.fetch("enable_logging", "false"), cache_capacity: configuration.fetch("cache_capacity", 5), cache_first: to_reg_exp("cache_first") } rescue => e abort "#{path} #{e}" end
to_reg_exp(key)
click to toggle source
# File lib/nutrella/configuration.rb, line 83 def to_reg_exp(key) Regexp.new(configuration.fetch(key, '^PM-\d+'), Regexp::IGNORECASE) end
write_initial_configuration()
click to toggle source
# File lib/nutrella/configuration.rb, line 68 def write_initial_configuration File.write(path, INITIAL_CONFIGURATION) end