Class: LinkChecker::Tasks
- Inherits:
-
Object
- Object
- LinkChecker::Tasks
- Includes:
- Callbacks
- Defined in:
- lib/ruby-link-checker/tasks.rb
Instance Attribute Summary collapse
-
#original_uri ⇒ Object
readonly
Returns the value of attribute original_uri.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize(checker, task_klass, uri, methods, options = {}) ⇒ Tasks
constructor
A new instance of Tasks.
- #new_task(uri, method, original_uri, options) ⇒ Object
Methods included from Callbacks
#callbacks, #delegates, #method_missing, #on
Constructor Details
#initialize(checker, task_klass, uri, methods, options = {}) ⇒ Tasks
Returns a new instance of Tasks.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ruby-link-checker/tasks.rb', line 7 def initialize(checker, task_klass, uri, methods, = {}) @uri = uri @retries_left = checker.retries @methods_left = methods.dup @methods = methods.dup @task_klass = task_klass @checker = checker @logger = checker.logger @redirects = [uri] @options = raise ArgumentError, :tasks_klass unless @task_klass && @task_klass < ::LinkChecker::Task end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class LinkChecker::Callbacks
Instance Attribute Details
#original_uri ⇒ Object (readonly)
Returns the value of attribute original_uri.
5 6 7 |
# File 'lib/ruby-link-checker/tasks.rb', line 5 def original_uri @original_uri end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
5 6 7 |
# File 'lib/ruby-link-checker/tasks.rb', line 5 def result @result end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
5 6 7 |
# File 'lib/ruby-link-checker/tasks.rb', line 5 def uri @uri end |
Instance Method Details
#execute! ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ruby-link-checker/tasks.rb', line 24 def execute! if retry? @retries_left -= 1 retry! @result _queue_task(uri, method, original_uri || uri, ) elsif methods_left.any? @method = methods_left.shift @uri = URI(@uri) unless @uri.is_a?(URI) _queue_task(uri, method, original_uri || uri, ) elsif @result && result.error? error! @result else failure! @result end rescue StandardError => e logger.error("#{self}##{__method__}") { e } _handle_result ResultError.new(uri, method, original_uri || uri, e, ) end |
#new_task(uri, method, original_uri, options) ⇒ Object
20 21 22 |
# File 'lib/ruby-link-checker/tasks.rb', line 20 def new_task(uri, method, original_uri, ) task_klass.new(checker, uri, method, original_uri, ) end |