Sha256: ae0bda6f77c3e08b66cc0a1d8906215992db2a5ff998c9d330f576d59f18caa6

Contents?: true

Size: 846 Bytes

Versions: 16

Compression:

Stored size: 846 Bytes

Contents

# frozen_string_literal: true

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

module Pragmater
  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 "pragmater/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

16 entries across 16 versions & 1 rubygems

Version Path
pragmater-12.2.0 lib/pragmater/configuration/loader.rb
pragmater-12.1.2 lib/pragmater/configuration/loader.rb
pragmater-12.1.1 lib/pragmater/configuration/loader.rb
pragmater-12.1.0 lib/pragmater/configuration/loader.rb
pragmater-12.0.0 lib/pragmater/configuration/loader.rb
pragmater-11.5.0 lib/pragmater/configuration/loader.rb
pragmater-11.4.0 lib/pragmater/configuration/loader.rb
pragmater-11.3.0 lib/pragmater/configuration/loader.rb
pragmater-11.2.0 lib/pragmater/configuration/loader.rb
pragmater-11.1.0 lib/pragmater/configuration/loader.rb
pragmater-11.0.1 lib/pragmater/configuration/loader.rb
pragmater-11.0.0 lib/pragmater/configuration/loader.rb
pragmater-10.3.1 lib/pragmater/configuration/loader.rb
pragmater-10.3.0 lib/pragmater/configuration/loader.rb
pragmater-10.2.0 lib/pragmater/configuration/loader.rb
pragmater-10.1.0 lib/pragmater/configuration/loader.rb