Sha256: 7ffa2fc50ba22e853d8a1b4427ccd81f24e2678e665ba09e191671d635012c6a

Contents?: true

Size: 848 Bytes

Versions: 18

Compression:

Stored size: 848 Bytes

Contents

# frozen_string_literal: true

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

module Milestoner
  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 "milestoner/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

18 entries across 18 versions & 1 rubygems

Version Path
milestoner-15.3.0 lib/milestoner/configuration/loader.rb
milestoner-15.2.2 lib/milestoner/configuration/loader.rb
milestoner-15.2.1 lib/milestoner/configuration/loader.rb
milestoner-15.2.0 lib/milestoner/configuration/loader.rb
milestoner-15.1.0 lib/milestoner/configuration/loader.rb
milestoner-15.0.0 lib/milestoner/configuration/loader.rb
milestoner-14.5.0 lib/milestoner/configuration/loader.rb
milestoner-14.4.0 lib/milestoner/configuration/loader.rb
milestoner-14.3.0 lib/milestoner/configuration/loader.rb
milestoner-14.2.0 lib/milestoner/configuration/loader.rb
milestoner-14.1.0 lib/milestoner/configuration/loader.rb
milestoner-14.0.2 lib/milestoner/configuration/loader.rb
milestoner-14.0.1 lib/milestoner/configuration/loader.rb
milestoner-14.0.0 lib/milestoner/configuration/loader.rb
milestoner-13.3.1 lib/milestoner/configuration/loader.rb
milestoner-13.3.0 lib/milestoner/configuration/loader.rb
milestoner-13.2.0 lib/milestoner/configuration/loader.rb
milestoner-13.1.0 lib/milestoner/configuration/loader.rb