Class: SLA::Checker
- Inherits:
-
Object
- Object
- SLA::Checker
- Defined in:
- lib/sla/checker.rb
Instance Attribute Summary collapse
-
#check_external ⇒ Object
readonly
Returns the value of attribute check_external.
-
#ignore ⇒ Object
readonly
Returns the value of attribute ignore.
-
#max_depth ⇒ Object
readonly
Returns the value of attribute max_depth.
Instance Method Summary collapse
- #check(page) {|[:source, page]| ... } ⇒ Object
-
#initialize(max_depth: 5, ignore: nil, check_external: false) ⇒ Checker
constructor
A new instance of Checker.
Constructor Details
#initialize(max_depth: 5, ignore: nil, check_external: false) ⇒ Checker
Returns a new instance of Checker.
5 6 7 8 9 |
# File 'lib/sla/checker.rb', line 5 def initialize(max_depth: 5, ignore: nil, check_external: false) @max_depth = max_depth @ignore = ignore @check_external = check_external end |
Instance Attribute Details
#check_external ⇒ Object (readonly)
Returns the value of attribute check_external.
3 4 5 |
# File 'lib/sla/checker.rb', line 3 def check_external @check_external end |
#ignore ⇒ Object (readonly)
Returns the value of attribute ignore.
3 4 5 |
# File 'lib/sla/checker.rb', line 3 def ignore @ignore end |
#max_depth ⇒ Object (readonly)
Returns the value of attribute max_depth.
3 4 5 |
# File 'lib/sla/checker.rb', line 3 def max_depth @max_depth end |
Instance Method Details
#check(page) {|[:source, page]| ... } ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sla/checker.rb', line 11 def check(page, &block) return if skip? page yield [:source, page] if block pages = page_list page pages.each do |next_page| if checked.has_key?(next_page.url) || ignore?(next_page) yield [:skip, next_page] if block else checked[next_page.url] = true yield [:check, next_page] if block end end pages.each do |next_page| next if deeply_checked.has_key? next_page.url deeply_checked[next_page.url] = true next if next_page.external? check next_page, &block end end |