Method: Gonzui::HTTPFetcher#initialize
- Defined in:
- lib/gonzui/fetcher.rb
#initialize(config, source_uri, options) ⇒ HTTPFetcher
Returns a new instance of HTTPFetcher.
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/gonzui/fetcher.rb', line 152 def initialize(config, source_uri, ) super(config, source_uri, ) begin open(source_uri.to_s) {|f| @content = f.read @content_type = f.content_type @base_uri = f.base_uri } rescue OpenURI::HTTPError => e raise FetchFailed.new("#{source_uri.to_s}: #{e.message}") end # http://example.com/foo/index.html => http://example.com/foo/ unless /\/$/.match(@base_uri.path) #/ @base_uri.path = File.dirname(@base_uri.path) + "/" end set_temporary_directory(@config.temporary_directory) end |