Class: Rubysmith::Configuration::Loader

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

Overview

Represents the fully assembled Command Line Interface (CLI) configuration.

Constant Summary collapse

DEFAULTS =
YAML.load_file(Pathname(__dir__).join("defaults.yml")).freeze
CLIENT =
Runcom::Config.new "rubysmith/configuration.yml", defaults: DEFAULTS

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content: Content.new, client: CLIENT, enhancers: Enhancers::Container) ⇒ Loader

Returns a new instance of Loader.



23
24
25
26
27
# File 'lib/rubysmith/configuration/loader.rb', line 23

def initialize content: Content.new, client: CLIENT, enhancers: Enhancers::Container
  @content = content
  @client = client
  @enhancers = enhancers
end

Class Method Details

.callObject



19
# File 'lib/rubysmith/configuration/loader.rb', line 19

def self.call(...) = new(...).call

.with_defaultsObject



21
# File 'lib/rubysmith/configuration/loader.rb', line 21

def self.with_defaults = new(client: DEFAULTS, enhancers: {})

Instance Method Details

#callObject



29
30
31
32
33
# File 'lib/rubysmith/configuration/loader.rb', line 29

def call
  enhancers.each
           .reduce(preload_content) { |preload, (_key, enhancer)| enhancer.call preload }
           .freeze
end