Module: Metapage
- Defined in:
- lib/metapage.rb,
lib/metapage/version.rb
Defined Under Namespace
Classes: ContentTypeError, HTTPResponseError, Metadata, ResolveError
Constant Summary
collapse
- ERROR_CLASSES =
[ResolveError, HTTPResponseError, ContentTypeError]
- VERSION =
"0.3.0"
Class Method Summary
collapse
Class Method Details
27
28
29
|
# File 'lib/metapage.rb', line 27
def (text)
(text).map {|url| fetch(url.gsub(/[\.\,]+\Z/, '')) }.compact
end
|
31
32
33
|
# File 'lib/metapage.rb', line 31
def (text)
(text).map {|url| fetch!(url.gsub(/[\.\,]+\Z/, '')) }.compact
end
|
35
36
37
38
39
40
|
# File 'lib/metapage.rb', line 35
def (text)
processed_text = text.
gsub(/([^\/])www\./, '\1http://www.').
gsub(/\Awww\./, 'http://www.')
URI. processed_text, ['http', 'https']
end
|
.fetch(url) ⇒ Object
17
18
19
20
21
|
# File 'lib/metapage.rb', line 17
def fetch(url)
fetch! url
rescue *ERROR_CLASSES => err
nil
end
|
.fetch!(url) ⇒ Object
23
24
25
|
# File 'lib/metapage.rb', line 23
def fetch!(url)
Metadata.new(url)
end
|