Class: NDD::UrlChecker::BlockingUrlChecker

Inherits:
AbstractUrlChecker show all
Defined in:
lib/ndd/url_checker/blocking_url_checker.rb

Overview

An URL checker using the blocking Net::HTTP class.

Author:

  • David DIDIER

Instance Method Summary collapse

Constructor Details

#initialize(maximum_redirects: 5, timeout: 5) ⇒ BlockingUrlChecker

Create a new instance.

Parameters:

  • maximum_redirects (Fixnum)

    the maximum number of redirects to follow before failing.

  • timeout (Fixnum)

    the number of seconds to wait before failing.



17
18
19
20
21
# File 'lib/ndd/url_checker/blocking_url_checker.rb', line 17

def initialize(maximum_redirects: 5, timeout: 5)
  @logger = Logging.logger[self]
  @maximum_redirects = maximum_redirects
  @timeout = timeout
end

Instance Method Details

#check(*urls) ⇒ NDD::UrlChecker::Status+

Checks that the given URLs are valid.

Parameters:

  • urls (String, Array<String>)

    the URLs to check

Returns:



27
28
29
30
31
# File 'lib/ndd/url_checker/blocking_url_checker.rb', line 27

def check(*urls)
  @logger.debug "Checking #{urls.size} URL(s)"
  return check_single(urls.first) if urls.size < 2
  urls.map { |url| check_single(url) }
end