Class: Aranha::Parsers::SourceAddress
- Inherits:
-
Object
- Object
- Aranha::Parsers::SourceAddress
show all
- Defined in:
- lib/aranha/parsers/source_address.rb,
lib/aranha/parsers/source_address/file.rb,
lib/aranha/parsers/source_address/http_get.rb,
lib/aranha/parsers/source_address/hash_http_get.rb,
lib/aranha/parsers/source_address/hash_http_base.rb,
lib/aranha/parsers/source_address/hash_http_post.rb,
lib/aranha/parsers/source_address/fetch_content_error.rb,
lib/aranha/parsers/source_address/hash_http_base/headers.rb
Defined Under Namespace
Classes: FetchContentError, File, HashHttpBase, HashHttpGet, HashHttpPost, HttpGet
Constant Summary
collapse
- SUBS =
[
::Aranha::Parsers::SourceAddress::HashHttpGet,
::Aranha::Parsers::SourceAddress::HashHttpPost,
::Aranha::Parsers::SourceAddress::HttpGet,
::Aranha::Parsers::SourceAddress::File
].freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.deserialize(string) ⇒ Object
29
30
31
|
# File 'lib/aranha/parsers/source_address.rb', line 29
def deserialize(string)
new(string =~ %r{\A[a-z]+://} ? string.strip : ::YAML.load(string)) end
|
.detect_sub(source) ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/aranha/parsers/source_address.rb', line 20
def detect_sub(source)
return source.sub if source.is_a?(self)
SUBS.each do |sub|
return sub.new(source) if sub.valid_source?(source)
end
raise "No content fetcher found for source \"#{source}\""
end
|
.from_file(path) ⇒ Object
33
34
35
|
# File 'lib/aranha/parsers/source_address.rb', line 33
def from_file(path)
deserialize(::File.read(path))
end
|
Instance Method Details
#serialize ⇒ Object
46
47
48
|
# File 'lib/aranha/parsers/source_address.rb', line 46
def serialize
"#{sub.serialize.strip}\n"
end
|
#to_s ⇒ Object
42
43
44
|
# File 'lib/aranha/parsers/source_address.rb', line 42
def to_s
sub.url
end
|