Sha256: 4013fd8f7d71700a2c427e6e7144039a079f5752d0dc1ddab5c9b32416eae199

Contents?: true

Size: 1.11 KB

Versions: 56

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'

module EacRubyUtils
  module Console
    class Configs
      class ReadEntryOptions
        enable_simple_cache
        common_constructor :options do
          self.options = options.to_h.symbolize_keys
                                .assert_valid_keys(DEFAULT_VALUES.keys).freeze
        end

        DEFAULT_VALUES = {
          before_input: nil, bool: false, list: false, noecho: false, noenv: false, noinput: false,
          required: true, store: true, validator: nil
        }.freeze

        delegate :to_h, to: :options

        def [](key)
          values.fetch(key.to_sym)
        end

        def request_input_options
          values.slice(:bool, :list, :noecho)
        end

        private

        def values_uncached
          consumer = options.to_options_consumer
          r = {}
          DEFAULT_VALUES.each do |key, default_value|
            value = consumer.consume(key)
            value = default_value if value.nil?
            r[key] = value
          end
          consumer.validate
          r
        end
      end
    end
  end
end

Version data entries

56 entries across 56 versions & 3 rubygems

Version Path
avm-tools-0.98.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb
avm-tools-0.97.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb
avm-tools-0.96.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb
eac_ruby_utils-0.63.0 lib/eac_ruby_utils/console/configs/read_entry_options.rb
avm-tools-0.95.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb
eac_ruby_utils-0.62.1 lib/eac_ruby_utils/console/configs/read_entry_options.rb
avm-tools-0.94.3 vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb
eac_ruby_utils-0.62.0 lib/eac_ruby_utils/console/configs/read_entry_options.rb
eac_ruby_utils-0.61.0 lib/eac_ruby_utils/console/configs/read_entry_options.rb
avm-tools-0.94.2 vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb
eac_ruby_utils-0.60.0 lib/eac_ruby_utils/console/configs/read_entry_options.rb
avm-tools-0.94.1 vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb
eac_ruby_utils-0.59.0 lib/eac_ruby_utils/console/configs/read_entry_options.rb
ehbrs-tools-0.20.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb
avm-tools-0.94.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb
avm-tools-0.93.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb
avm-tools-0.92.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb
avm-tools-0.91.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb
avm-tools-0.90.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb
avm-tools-0.89.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs/read_entry_options.rb