Sha256: 010db02fc5bdf890d9b0d9dfac8687b2200426be12b41cf69315d5504016d9ea

Contents?: true

Size: 476 Bytes

Versions: 4

Compression:

Stored size: 476 Bytes

Contents

require 'yaml'
require 'active_support/core_ext/hash/indifferent_access'

module Pears
  module Provider
    # Used for loading simple YAML file locally.
    class LocalFile < Base
      def initialize(file_path,  on_failure: :raise)
        yaml_data = File.read(file_path)
        @data = parse_yaml(yaml_data)
      rescue Errno::ENOENT => error
        if on_failure == :null
          @data = {}
        else
          raise error
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pears-0.0.11 lib/pears/provider/local_file.rb
pears-0.0.10 lib/pears/provider/local_file.rb
pears-0.0.9 lib/pears/provider/local_file.rb
pears-0.0.8 lib/pears/provider/local_file.rb