lib/retriever/target.rb in rubyretriever-1.4.5 vs lib/retriever/target.rb in rubyretriever-1.4.6
- old
+ new
@@ -4,20 +4,21 @@
module Retriever
#
class Target
HTTP_RE = Regexp.new(/^http/i).freeze
- attr_reader :host, :target, :host_re, :source, :file_re, :scheme
+ attr_reader :host, :target, :host_re, :source, :file_re, :scheme, :port
def initialize(url, file_re = nil)
fail 'Bad URL' unless url.include?('.')
url = "http://#{url}" unless HTTP_RE =~ url
target_uri = Addressable::URI.parse(Addressable::URI.encode(url))
@target = target_uri.to_s
@host = target_uri.host
@host_re = Regexp.new(@host.sub('www.', ''))
@file_re ||= file_re
@scheme = target_uri.scheme
+ @port = target_uri.port
end
def source
resp = open(@target)
resp_url = resp.base_uri.to_s