lib/pears/provider/remote_file.rb in pears-0.0.7 vs lib/pears/provider/remote_file.rb in pears-0.0.8

- old
+ new

@@ -1,13 +1,20 @@ require 'net/http' module Pears module Provider # Fetch a yaml file via HTTP - class RemoteFile < LocalFile - def initialize(remote_url) + 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 => e + if on_failure == :null + @data = {} + else + raise e + end end end end end