Sha256: 014753e2c9448078b6f835d5bdaf287c71c701d1f16cc55cfd8e4249de07e321

Contents?: true

Size: 848 Bytes

Versions: 21

Compression:

Stored size: 848 Bytes

Contents

# frozen_string_literal: true

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

module Pennyworth
  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 "pennyworth/configuration.yml", defaults: DEFAULTS

      def self.call = new.call

      def self.with_defaults = new(client: DEFAULTS)

      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

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
pennyworth-14.3.0 lib/pennyworth/configuration/loader.rb
pennyworth-14.2.1 lib/pennyworth/configuration/loader.rb
pennyworth-14.2.0 lib/pennyworth/configuration/loader.rb
pennyworth-14.1.2 lib/pennyworth/configuration/loader.rb
pennyworth-14.1.1 lib/pennyworth/configuration/loader.rb
pennyworth-14.1.0 lib/pennyworth/configuration/loader.rb
pennyworth-14.0.0 lib/pennyworth/configuration/loader.rb
pennyworth-13.8.0 lib/pennyworth/configuration/loader.rb
pennyworth-13.7.0 lib/pennyworth/configuration/loader.rb
pennyworth-13.6.0 lib/pennyworth/configuration/loader.rb
pennyworth-13.5.0 lib/pennyworth/configuration/loader.rb
pennyworth-13.4.0 lib/pennyworth/configuration/loader.rb
pennyworth-13.3.0 lib/pennyworth/configuration/loader.rb
pennyworth-13.2.0 lib/pennyworth/configuration/loader.rb
pennyworth-13.1.0 lib/pennyworth/configuration/loader.rb
pennyworth-13.0.1 lib/pennyworth/configuration/loader.rb
pennyworth-13.0.0 lib/pennyworth/configuration/loader.rb
pennyworth-12.3.1 lib/pennyworth/configuration/loader.rb
pennyworth-12.3.0 lib/pennyworth/configuration/loader.rb
pennyworth-12.2.0 lib/pennyworth/configuration/loader.rb