Sha256: 90aec0d1884f7a7d9a4fefc25eb06eb01c1a8a243f770d908c0044b95d9de78e

Contents?: true

Size: 533 Bytes

Versions: 5

Compression:

Stored size: 533 Bytes

Contents

require 'net/http'

module Pears
  module Provider
    # Fetch a yaml file via HTTP
    class RemoteFile < Base
      def initialize(remote_url, on_failure: :raise)
        yaml_data = Net::HTTP.get(URI(remote_url))
        @data = parse_yaml(yaml_data)

      rescue SocketError,
          InvalidProviderData,
          Errno::ECONNREFUSED,
          Errno::EHOSTUNREACH,
          Errno::EADDRNOTAVAIL => e
        if on_failure == :null
          @data = {}
        else
          raise e
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pears-0.1.3 lib/pears/provider/remote_file.rb
pears-0.1.2 lib/pears/provider/remote_file.rb
pears-0.1.1 lib/pears/provider/remote_file.rb
pears-0.1.0 lib/pears/provider/remote_file.rb
pears-0.0.11 lib/pears/provider/remote_file.rb