Sha256: 7aa68ae519c22fc0aee610b39da2aa12b23f97b121764b2720ef3eda15631781

Contents?: true

Size: 1.74 KB

Versions: 35

Compression:

Stored size: 1.74 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'

module Avm
  module Instances
    module EntryKeys
      class << self
        def all
          all_keys.to_a
        end

        def keys_consts_set(prefix, suffixes)
          if suffixes.is_a?(::Hash)
            keys_consts_set_from_hash(prefix, suffixes)
          elsif suffixes.is_a?(::Enumerable)
            keys_consts_set_from_enum(prefix, suffixes)
          else
            raise "Unmapped suffixes class: #{suffixes.class}"
          end
        end

        def key_const_set(prefix, suffix)
          key = [prefix, suffix].reject(&:blank?).join('.')
          const_set(key.gsub('.', '_').upcase, key)
          all_keys << key
        end

        private

        def all_keys
          @all_keys ||= ::Set.new
        end

        def keys_consts_set_from_enum(prefix, suffixes)
          suffixes.each { |suffix| key_const_set(prefix, suffix) }
        end

        def keys_consts_set_from_hash(prefix, suffixes)
          suffixes.each { |k, v| keys_consts_set(prefix.to_s + (k.blank? ? '' : ".#{k}"), v) }
        end
      end

      {
        '' => %w[data_fs_path fs_path host_id name source_instance_id],
        admin: %w[username password api_key],
        database: %w[id hostname limit name password port system timeout username extra],
        docker: %w[registry],
        fs: %w[url],
        mailer: {
          '' => %w[id from reply_to],
          smtp: %w[address port domain username password authentication openssl_verify_mode
                   starttls_auto tls]
        },
        ssh: %w[hostname port url username],
        web: %w[authority hostname path port scheme url userinfo]
      }.each { |prefix, suffixes| keys_consts_set(prefix, suffixes) }
    end
  end
end

Version data entries

35 entries across 35 versions & 3 rubygems

Version Path
avm-0.22.0 lib/avm/instances/entry_keys.rb
avm-tools-0.120.0 sub/avm/lib/avm/instances/entry_keys.rb
avm-0.21.0 lib/avm/instances/entry_keys.rb
avm-tools-0.119.0 sub/avm/lib/avm/instances/entry_keys.rb
avm-0.20.0 lib/avm/instances/entry_keys.rb
avm-tools-0.118.0 sub/avm/lib/avm/instances/entry_keys.rb
avm-tools-0.117.3 sub/avm/lib/avm/instances/entry_keys.rb
avm-tools-0.117.2 sub/avm/lib/avm/instances/entry_keys.rb
avm-tools-0.117.1 sub/avm/lib/avm/instances/entry_keys.rb
avm-0.19.0 lib/avm/instances/entry_keys.rb
avm-tools-0.117.0 sub/avm/lib/avm/instances/entry_keys.rb
avm-tools-0.116.2 sub/avm/lib/avm/instances/entry_keys.rb
avm-0.18.1 lib/avm/instances/entry_keys.rb
avm-0.18.0 lib/avm/instances/entry_keys.rb
avm-tools-0.116.1 sub/avm/lib/avm/instances/entry_keys.rb