Sha256: 19413f76bf5114d087055de2b7441d496c909d3ff02cf787a286c3883a920012

Contents?: true

Size: 561 Bytes

Versions: 7

Compression:

Stored size: 561 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,
          Net::OpenTimeout => e
        if on_failure == :null
          @data = {}
        else
          raise e
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pears-0.3.5 lib/pears/provider/remote_file.rb
pears-0.3.4 lib/pears/provider/remote_file.rb
pears-0.3.2 lib/pears/provider/remote_file.rb
pears-0.3.1 lib/pears/provider/remote_file.rb
pears-0.3.0 lib/pears/provider/remote_file.rb
pears-0.2.0 lib/pears/provider/remote_file.rb
pears-0.1.4 lib/pears/provider/remote_file.rb