Sha256: b9b18eb6e1a91a3cc76874dbe7b085b8f6b7271c5501d7cbc820b8b6442f366e

Contents?: true

Size: 514 Bytes

Versions: 11

Compression:

Stored size: 514 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,
          Pears::InvalidProviderData => error
        if on_failure == :null
          @data = {}
        else
          raise error
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pears-0.3.5 lib/pears/provider/local_file.rb
pears-0.3.4 lib/pears/provider/local_file.rb
pears-0.3.2 lib/pears/provider/local_file.rb
pears-0.3.1 lib/pears/provider/local_file.rb
pears-0.3.0 lib/pears/provider/local_file.rb
pears-0.2.0 lib/pears/provider/local_file.rb
pears-0.1.4 lib/pears/provider/local_file.rb
pears-0.1.3 lib/pears/provider/local_file.rb
pears-0.1.2 lib/pears/provider/local_file.rb
pears-0.1.1 lib/pears/provider/local_file.rb
pears-0.1.0 lib/pears/provider/local_file.rb