Class: NDD::UrlChecker::StatusDecorator
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- NDD::UrlChecker::StatusDecorator
- Defined in:
- lib/ndd/url_checker/status_decorator.rb
Overview
Decorate a [Status] for reporting.
Instance Method Summary collapse
Instance Method Details
#code_as_css ⇒ Object
10 11 12 |
# File 'lib/ndd/url_checker/status_decorator.rb', line 10 def code_as_css code.to_s.gsub(/_/, '-') end |
#details_body ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ndd/url_checker/status_decorator.rb', line 30 def details_body case code when :direct then nil when :redirected then uris.map { |uri| "- #{uri}\n" }.join when :failed then return nil unless error return error.body if error.kind_of?(Net::HTTPResponse) return error.to_s when :too_many_redirects then uris.map { |uri| "- #{uri}\n" }.join when :unknown_host then uris.map { |uri| "- #{uri}\n" }.join end end |
#details_body_as_html ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ndd/url_checker/status_decorator.rb', line 47 def details_body_as_html body = " <p><em>Status:</em> \#{code}</p>\n <p><em>URIs:</em><p>\n <ol>\#{uris.map { |uri| \"<li>\#{uri}</li>\" }.join}</ol>\n HTML\n\n if error\n body += \"<p><em>Error:</em> \#{error.class.to_s}</p>\"\n body += \"<p><pre>\#{error.body}</pre></p>\" if error.kind_of?(Net::HTTPResponse)\n end\n\n body\nend\n".gsub(/^ +/, '') |
#details_title ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ndd/url_checker/status_decorator.rb', line 14 def details_title case code when :direct then nil when :redirected then uris.size - 1 when :failed then return nil unless error return error.class.to_s when :too_many_redirects then uris.size - 1 when :unknown_host then return uris.last end end |