Sha256: 2472ad27c42db6ef7a3b12cdfb69e2e84ea0e5f841da2610ba401bce82d966f9

Contents?: true

Size: 653 Bytes

Versions: 46

Compression:

Stored size: 653 Bytes

Contents

class KuberKit::EnvFileReader::Reader
  ReaderNotFoundError = Class.new(KuberKit::NotFoundError)
  
  def use_reader(env_file_reader, env_file_class:)
    @@readers ||= {}

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

    @@readers[env_file_class] = env_file_reader
  end

  def read(shell, env_file)
    reader = @@readers[env_file.class]

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

    reader.read(shell, env_file)
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
kuber_kit-1.3.9 lib/kuber_kit/env_file_reader/reader.rb
kuber_kit-1.3.8 lib/kuber_kit/env_file_reader/reader.rb
kuber_kit-1.3.7 lib/kuber_kit/env_file_reader/reader.rb
kuber_kit-1.1.8 lib/kuber_kit/env_file_reader/reader.rb
kuber_kit-1.3.6 lib/kuber_kit/env_file_reader/reader.rb
kuber_kit-1.1.7 lib/kuber_kit/env_file_reader/reader.rb
kuber_kit-1.3.5 lib/kuber_kit/env_file_reader/reader.rb
kuber_kit-1.3.4 lib/kuber_kit/env_file_reader/reader.rb
kuber_kit-1.1.6 lib/kuber_kit/env_file_reader/reader.rb
kuber_kit-1.3.3 lib/kuber_kit/env_file_reader/reader.rb
kuber_kit-1.3.2 lib/kuber_kit/env_file_reader/reader.rb
kuber_kit-1.1.5 lib/kuber_kit/env_file_reader/reader.rb
kuber_kit-1.3.1 lib/kuber_kit/env_file_reader/reader.rb
kuber_kit-1.3.0 lib/kuber_kit/env_file_reader/reader.rb
kuber_kit-1.1.4 lib/kuber_kit/env_file_reader/reader.rb
kuber_kit-1.2.7 lib/kuber_kit/env_file_reader/reader.rb
kuber_kit-1.2.6 lib/kuber_kit/env_file_reader/reader.rb
kuber_kit-1.2.5 lib/kuber_kit/env_file_reader/reader.rb
kuber_kit-1.2.4 lib/kuber_kit/env_file_reader/reader.rb
kuber_kit-1.2.2 lib/kuber_kit/env_file_reader/reader.rb