Sha256: 47defd88b2354059d524c7aba990ef4e01f7e01e901c744390fde16001765a5e

Contents?: true

Size: 450 Bytes

Versions: 1

Compression:

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pears-0.0.9 lib/pears/provider/remote_file.rb