lib/aranha/parsers/source_address/http_get.rb in aranha-parsers-0.23.1 vs lib/aranha/parsers/source_address/http_get.rb in aranha-parsers-0.24.0
- old
+ new
@@ -1,40 +1,28 @@
# frozen_string_literal: true
require 'addressable'
-require 'aranha/parsers/source_address/fetch_content_error'
+require 'aranha/parsers/source_address/base'
require 'eac_envs/http/error'
require 'eac_envs/http/request'
module Aranha
module Parsers
class SourceAddress
- class HttpGet
+ class HttpGet < ::Aranha::Parsers::SourceAddress::Base
class << self
def location_uri(source_uri, location)
::Addressable::URI.join(source_uri, location).to_s
end
-
- def valid_source?(source)
- source.to_s =~ %r{\Ahttps?://}
- end
end
- attr_reader :source
+ common_constructor :source, super_args: -> { [source.to_s] }
- def initialize(source)
- @source = source.to_s
- end
-
def ==(other)
self.class == other.class && source == other.source
end
- def url
- source
- end
-
def final_url
content unless @final_url
@final_url
end
@@ -48,9 +36,19 @@
raise ::Aranha::Parsers::SourceAddress::FetchContentError.new(e.message, request)
end
def serialize
url
+ end
+
+ # @return [Addressable::URI]
+ def uri
+ source_as_uri
+ end
+
+ # @return [Boolean]
+ def valid?
+ source.to_s =~ %r{\Ahttps?://}
end
end
end
end
end