Class: RhetButler::Stasis::HTTPLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/rhet-butler/stasis/http-loader.rb

Instance Method Summary collapse

Constructor Details

#initializeHTTPLoader

Returns a new instance of HTTPLoader.



5
6
7
# File 'lib/rhet-butler/stasis/http-loader.rb', line 5

def initialize
  require 'net/http'
end

Instance Method Details

#load(source_uri) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/rhet-butler/stasis/http-loader.rb', line 9

def load(source_uri)
  response = Net::HTTP.get_response(URI(source_uri.to_s))
  Document.new.tap do |doc|
    doc.body = response.body
    doc.source_uri = source_uri
    doc.type = response["Content-Type"]
  end
end