Class: SLA::Checker
Instance Attribute Summary collapse
-
#check_external ⇒ Object
Returns the value of attribute check_external.
-
#checked_links ⇒ Object
Returns the value of attribute checked_links.
-
#ignore ⇒ Object
Returns the value of attribute ignore.
-
#max_depth ⇒ Object
Returns the value of attribute max_depth.
Instance Method Summary collapse
- #check(link, depth = 1) {|link| ... } ⇒ Object
- #count ⇒ Object
-
#initialize ⇒ Checker
constructor
A new instance of Checker.
Constructor Details
#initialize ⇒ Checker
Returns a new instance of Checker.
7 8 9 10 11 12 |
# File 'lib/sla/checker.rb', line 7 def initialize @max_depth = 10 @checked_links = [] @check_external = false @ignore = [] end |
Instance Attribute Details
#check_external ⇒ Object
Returns the value of attribute check_external.
5 6 7 |
# File 'lib/sla/checker.rb', line 5 def check_external @check_external end |
#checked_links ⇒ Object
Returns the value of attribute checked_links.
5 6 7 |
# File 'lib/sla/checker.rb', line 5 def checked_links @checked_links end |
#ignore ⇒ Object
Returns the value of attribute ignore.
5 6 7 |
# File 'lib/sla/checker.rb', line 5 def ignore @ignore end |
#max_depth ⇒ Object
Returns the value of attribute max_depth.
5 6 7 |
# File 'lib/sla/checker.rb', line 5 def max_depth @max_depth end |
Instance Method Details
#check(link, depth = 1) {|link| ... } ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sla/checker.rb', line 18 def check(link, depth=1, &block) link = Link.new link, depth: depth if link.is_a? String return if link.external? && !check_external ignore.each do |ignored| return if link.ident.start_with? ignored end link.validate yield link if block_given? return if checked_links.include? link.url checked_links.push link.url return if link.external? return unless link.valid? return if depth >= max_depth link.sublinks.each do |sublink| check sublink, depth+1, &block end end |
#count ⇒ Object
14 15 16 |
# File 'lib/sla/checker.rb', line 14 def count checked_links.count end |