Sha256: aec9dbfd276333ecaa8fcbfd9ac536cf06cf74e3a44fe7b5d306b64c8b964281

Contents?: true

Size: 1.84 KB

Versions: 20

Compression:

Stored size: 1.84 KB

Contents

# frozen_string_literal: true

require 'eac_config/entries'
require 'eac_config/entry'
require 'eac_config/entry_path'
require 'eac_config/load_path'
require 'eac_config/load_nodes_search'
require 'eac_config/node_entry'
require 'eac_config/node_uri'
require 'eac_ruby_utils/core_ext'
require 'eac_ruby_utils/context'

module EacConfig
  module Node
    class << self
      def context
        @context ||= ::EacRubyUtils::Context.new
      end
    end

    attr_accessor :write_node

    common_concern do
      acts_as_abstract :self_entries
      include ::Comparable
    end

    # @return [Array<EacConfig::Entries>]
    def entries(path)
      ::EacConfig::Entries.new(self, path)
    end

    def entry(path)
      ::EacConfig::Entry.new(self, path)
    end

    # @return [[EacConfig::IncludePath]]
    def load_path
      @load_path ||= ::EacConfig::LoadPath.new(self)
    end

    # @return [Addressable::URI]
    def url
      raise_abstract_method(__method__)
    end

    # Return a entry which search values only in the self node.
    # @return [EacConfig::NodeEntry]
    def self_entry(path)
      self_entry_class.new(self, path)
    end

    def self_entry_class
      self.class.const_get('Entry')
    end

    # @return [Array<EacConfig::Node>]
    def self_loaded_nodes
      load_path.paths.flat_map { |node_path| load_nodes(node_path) }
    end

    # @return [Array<EacConfig::Node>]
    def recursive_loaded_nodes
      ::EacConfig::LoadNodesSearch.new(self).result
    end

    # @return [EacConfig::PrefixedPathNode]
    def with_prefix(path_prefix)
      require 'eac_config/prefixed_path_node'
      ::EacConfig::PrefixedPathNode.new(self, path_prefix)
    end

    private

    # @param node_path [String]
    # @return [Array<EacConfig::Node>]
    def load_nodes(node_path)
      ::EacConfig::NodeUri.new(node_path, url).instanciate
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
eac_config-0.14.3 lib/eac_config/node.rb
eac_tools-0.97.2 sub/eac_config/lib/eac_config/node.rb
eac_config-0.14.2 lib/eac_config/node.rb
eac_tools-0.82.0 sub/eac_config/lib/eac_config/node.rb
eac_tools-0.81.0 sub/eac_config/lib/eac_config/node.rb
eac_tools-0.80.0 sub/eac_config/lib/eac_config/node.rb
eac_tools-0.79.0 sub/eac_config/lib/eac_config/node.rb
eac_config-0.14.1 lib/eac_config/node.rb
eac_tools-0.78.0 sub/eac_config/lib/eac_config/node.rb
eac_tools-0.77.1 sub/eac_config/lib/eac_config/node.rb
eac_tools-0.77.0 sub/eac_config/lib/eac_config/node.rb
eac_tools-0.76.1 sub/eac_config/lib/eac_config/node.rb
eac_tools-0.76.0 sub/eac_config/lib/eac_config/node.rb
eac_tools-0.75.2 sub/eac_config/lib/eac_config/node.rb
eac_tools-0.75.1 sub/eac_config/lib/eac_config/node.rb
eac_tools-0.75.0 sub/eac_config/lib/eac_config/node.rb
eac_tools-0.74.1 sub/eac_config/lib/eac_config/node.rb
eac_tools-0.74.0 sub/eac_config/lib/eac_config/node.rb
eac_config-0.14.0 lib/eac_config/node.rb
eac_tools-0.73.0 sub/eac_config/lib/eac_config/node.rb