Sha256: 214273d03a14986b1349c475cec9c303243947e0960379665a8a2eddaf473e4c

Contents?: true

Size: 957 Bytes

Versions: 10

Compression:

Stored size: 957 Bytes

Contents

module Tdc
  module YamlReaders
    #
    # Knows how to create the appropriate YAML reader.
    #
    class YamlReaderFactory
      def initialize(catalog_root_directory, path_elements)
        @catalog_root_directory = catalog_root_directory
        @path_elements = path_elements
      end

      def create
        if yaml_reader_with_expansion.applies?
          yaml_reader_with_expansion
        elsif yaml_reader.applies?
          yaml_reader
        else
          null_reader
        end
      end

      private

      def yaml_reader_with_expansion
        @_yaml_reader_with_expansion ||=
          Tdc::YamlReaders::YamlReaderWithExpansion.new(@catalog_root_directory, @path_elements)
      end

      def null_reader
        @_null_reader ||= Tdc::YamlReaders::NullYamlReader.new
      end

      def yaml_reader
        @_yaml_reader ||= Tdc::YamlReaders::YamlReader.new(@catalog_root_directory, @path_elements)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
tdc-1.0 lib/tdc/yaml_readers/yaml_reader_factory.rb
tdc-0.6.2 lib/tdc/yaml_readers/yaml_reader_factory.rb
tdc-0.6.1 lib/tdc/yaml_readers/yaml_reader_factory.rb
tdc-0.6.0 lib/tdc/yaml_readers/yaml_reader_factory.rb
tdc-0.5.0 lib/tdc/yaml_readers/yaml_reader_factory.rb
tdc-0.4.7 lib/tdc/yaml_readers/yaml_reader_factory.rb
tdc-0.4.6.1 lib/tdc/yaml_readers/yaml_reader_factory.rb
tdc-0.4.6 lib/tdc/yaml_readers/yaml_reader_factory.rb
tdc-0.4.4.1 lib/tdc/yaml_readers/yaml_reader_factory.rb
tdc-0.4.4 lib/tdc/yaml_readers/yaml_reader_factory.rb