Class: Pears::Provider::RemoteFile
- Defined in:
- lib/pears/provider/remote_file.rb
Overview
Fetch a yaml file via HTTP
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(remote_url, on_failure: :raise) ⇒ RemoteFile
constructor
A new instance of RemoteFile.
Methods inherited from Base
Constructor Details
#initialize(remote_url, on_failure: :raise) ⇒ RemoteFile
Returns a new instance of RemoteFile.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/pears/provider/remote_file.rb', line 7 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 |