Sha256: 49bdfda04c787e6b1170128a7d34c23040da44f9bc08b7db4cb983a2f1c42228

Contents?: true

Size: 751 Bytes

Versions: 9

Compression:

Stored size: 751 Bytes

Contents

class KuberKit::TemplateReader::Reader
  ReaderNotFoundError = Class.new(KuberKit::NotFoundError)

  def use_reader(template_reader, template_class:)
    @@readers ||= {}

    if !template_reader.is_a?(KuberKit::TemplateReader::Strategies::Abstract)
      raise ArgumentError.new("should be an instance of KuberKit::TemplateReader::Strategies::Abstract, got: #{template_reader.inspect}")
    end

    @@readers[template_class] = template_reader
  end

  Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Templates::AbstractTemplate => String
  def read(shell, template)
    reader = @@readers[template.class]

    raise ReaderNotFoundError, "Can't find reader for template #{template}" if reader.nil?

    reader.read(shell, template)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
kuber_kit-1.3.8 lib/kuber_kit/template_reader/reader.rb
kuber_kit-1.3.7 lib/kuber_kit/template_reader/reader.rb
kuber_kit-1.1.8 lib/kuber_kit/template_reader/reader.rb
kuber_kit-1.3.6 lib/kuber_kit/template_reader/reader.rb
kuber_kit-1.1.7 lib/kuber_kit/template_reader/reader.rb
kuber_kit-1.3.5 lib/kuber_kit/template_reader/reader.rb
kuber_kit-1.3.4 lib/kuber_kit/template_reader/reader.rb
kuber_kit-1.1.6 lib/kuber_kit/template_reader/reader.rb
kuber_kit-1.3.3 lib/kuber_kit/template_reader/reader.rb