Sha256: 4f7355f177cd82443e0cf3a9fda0f9a200be5a315efcb37a20d0ec52dfb2e6c4

Contents?: true

Size: 853 Bytes

Versions: 3

Compression:

Stored size: 853 Bytes

Contents

# frozen_string_literal: true

require "pathname"
require "refinements/hashes"
require "refinements/structs"
require "runcom"
require "yaml"

module Rubysmith
  module CLI
    module Configuration
      # Represents the fully assembled Command Line Interface (CLI) configuration.
      class Loader
        using Refinements::Hashes
        using Refinements::Structs

        DEFAULTS = YAML.load_file(Pathname(__dir__).join("defaults.yml")).freeze
        CLIENT = Runcom::Config.new "#{Identity::NAME}/configuration.yml", defaults: DEFAULTS

        def self.call = new.call

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

        def call = content.merge(**client.to_h.flatten_keys)

        private

        attr_reader :content, :client
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubysmith-0.12.0 lib/rubysmith/cli/configuration/loader.rb
rubysmith-0.11.0 lib/rubysmith/cli/configuration/loader.rb
rubysmith-0.10.0 lib/rubysmith/cli/configuration/loader.rb