UNCOV
1
|
class WebsiteFetcher |
× |
UNCOV
2
|
require 'http_request'
|
× |
3 |
|
|
UNCOV
4
|
class << self |
× |
UNCOV
5
|
def supports_url?(url) |
× |
UNCOV
6
|
HttpRequest.valid_url?(url)
|
× |
UNCOV
7
|
end
|
× |
UNCOV
8
|
end
|
× |
9 |
|
|
UNCOV
10
|
def initialize(params) |
× |
UNCOV
11
|
@url = params['url'] |
× |
UNCOV
12
|
end
|
× |
13 |
|
|
UNCOV
14
|
def fetch_content |
× |
UNCOV
15
|
res = HttpRequest.get(@url) |
× |
UNCOV
16
|
if res.is_a? Net::HTTPSuccess |
× |
UNCOV
17
|
sanitize(res.body) |
× |
UNCOV
18
|
else
|
× |
UNCOV
19
|
''
|
× |
UNCOV
20
|
end
|
× |
UNCOV
21
|
end
|
× |
22 |
|
|
UNCOV
23
|
private |
× |
24 |
|
|
UNCOV
25
|
def sanitize(html_string) |
× |
26 |
# https://apidock.com/rails/ActionView/Helpers/SanitizeHelper/strip_tags
|
|
UNCOV
27
|
ActionController::Base.helpers.strip_tags(html_string) |
× |
UNCOV
28
|
end
|
× |
UNCOV
29
|
end
|
× |