Class: LinkChecker::Checker
- Inherits:
-
Object
- Object
- LinkChecker::Checker
- Defined in:
- lib/ruby-link-checker/checker.rb
Direct Known Subclasses
Constant Summary
Constants included from Config
LinkChecker::Config::ATTRIBUTES
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
- #check(uri, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Checker
constructor
A new instance of Checker.
- #task_klass ⇒ Object
Methods included from Callbacks
#callbacks, #delegates, #method_missing, #on
Methods included from Config
Constructor Details
#initialize(options = {}) ⇒ Checker
Returns a new instance of Checker.
11 12 13 14 15 16 17 18 |
# File 'lib/ruby-link-checker/checker.rb', line 11 def initialize( = {}) LinkChecker::Config::ATTRIBUTES.each do |key| send("#{key}=", [key] || LinkChecker.config.send(key)) end raise ArgumentError, "Missing methods." if methods&.none? @logger ||= [:logger] || LinkChecker::Config.logger || LinkChecker::Logger.default @results = { error: [], failure: [], success: [] } unless .key?(:results) && ![:results] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class LinkChecker::Callbacks
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
8 9 10 |
# File 'lib/ruby-link-checker/checker.rb', line 8 def results @results end |
Instance Method Details
#check(uri, options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ruby-link-checker/checker.rb', line 27 def check(uri, = {}) tasks = Tasks.new( self, task_klass, uri, methods, ) tasks.on do |event, *args| results[event] << args.first if @results && %i[error failure success].include?(event) callback event, *args end tasks.execute! end |
#task_klass ⇒ Object
20 21 22 23 24 25 |
# File 'lib/ruby-link-checker/checker.rb', line 20 def task_klass @task_klass ||= begin module_name = self.class.name.split("::")[...-1].join('::') Object.const_get("#{module_name}::Task") end end |