class Runcom::Configuration
Default gem configuration with support for custom settings.
Attributes
defaults[R]
path[R]
paths[R]
settings[R]
Public Class Methods
new(project_name:, file_name: "configuration.yml", defaults: {})
click to toggle source
# File lib/runcom/configuration.rb, line 13 def initialize project_name:, file_name: "configuration.yml", defaults: {} @path = load_path project_name, file_name @defaults = defaults @settings = defaults.deep_merge process_settings end
Public Instance Methods
merge(custom_settings)
click to toggle source
# File lib/runcom/configuration.rb, line 19 def merge custom_settings settings.deep_merge custom_settings end
to_h()
click to toggle source
# File lib/runcom/configuration.rb, line 23 def to_h settings end
Private Instance Methods
load_path(project, file)
click to toggle source
# File lib/runcom/configuration.rb, line 31 def load_path project, file paths = XDG::Configuration.computed_dirs.map { |root| Pathname "#{root}/#{project}/#{file}" } paths.find(&:exist?) end
load_settings()
click to toggle source
# File lib/runcom/configuration.rb, line 36 def load_settings yaml = YAML.load_file path yaml.is_a?(Hash) ? yaml : {} end
process_settings()
click to toggle source
# File lib/runcom/configuration.rb, line 41 def process_settings load_settings rescue Psych::SyntaxError => error raise Errors::Syntax, error.message rescue StandardError defaults end