Sha256: 917c2c215f9818c31d584356964f81fa97d5d9d4fe9c9eed392c4cee67ee74dd

Contents?: true

Size: 567 Bytes

Versions: 4

Compression:

Stored size: 567 Bytes

Contents

require 'yaml'
module Streamer
  module FactProviders
    # YamlProvider provides data from a yaml file
    class YamlProvider
      extend Forwardable
      attr_reader :data
      delegate find: :provider

      def initialize(path: nil, yaml: nil)
        load_file(path) if path
        load_yaml(yaml) if yaml
      end

      def load_file(path)
        @data = YAML.load(File.read(path))
      end

      def load_yaml(yaml)
        @data = YAML.load(yaml)
      end

      def provider
        @provider ||= HashProvider.new(data)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
streamer-0.2.1 lib/streamer/fact_providers/yaml_provider.rb
streamer-0.2.0 lib/streamer/fact_providers/yaml_provider.rb
streamer-0.1.1 lib/streamer/fact_providers/yaml_provider.rb
streamer-0.1.0 lib/streamer/fact_providers/yaml_provider.rb