Class: ValidateWebsite::Crawl

Inherits:
Core
  • Object
show all
Defined in:
lib/validate_website/crawl.rb

Overview

Class for http website validation

Constant Summary

Constants inherited from Core

ValidateWebsite::Core::EXIT_FAILURE_MARKUP, ValidateWebsite::Core::EXIT_FAILURE_MARKUP_NOT_FOUND, ValidateWebsite::Core::EXIT_FAILURE_NOT_FOUND, ValidateWebsite::Core::EXIT_SUCCESS, ValidateWebsite::Core::START_MESSAGE

Instance Attribute Summary collapse

Attributes inherited from Core

#errors_count, #host, #not_founds_count, #options, #site

Instance Method Summary collapse

Methods inherited from Core

#default_cookies, #errors?, #exit_status, #not_founds?

Methods included from ColorfulMessages

#color, #error, #info, #note, #success, #warning

Constructor Details

#initialize(options = {}, validation_type = :crawl) ⇒ Crawl

Returns a new instance of Crawl.



11
12
13
14
# File 'lib/validate_website/crawl.rb', line 11

def initialize(options = {}, validation_type = :crawl)
  super
  start_message(@site)
end

Instance Attribute Details

#crawlerObject (readonly)

Returns the value of attribute crawler.



9
10
11
# File 'lib/validate_website/crawl.rb', line 9

def crawler
  @crawler
end

Instance Method Details

#crawl(options = {}) ⇒ Object

Parameters:

  • options (Hash) (defaults to: {})

    :color [Boolean] color output (true, false) :exclude [String] a String used by Regexp.new :markup [Boolean] Check the markup validity :not_found [Boolean] Check for not found page (404)



26
27
28
29
30
31
32
33
34
35
# File 'lib/validate_website/crawl.rb', line 26

def crawl(options = {})
  @options = @options.merge(options)
  @options[:ignore_links] = @options[:exclude] if @options[:exclude]

  @crawler = spidr_crawler(@site, @options)
  print_status_line(@crawler.history.size,
                    @crawler.failures.size,
                    @not_founds_count,
                    @errors_count)
end

#history_countObject



16
17
18
# File 'lib/validate_website/crawl.rb', line 16

def history_count
  crawler.history.size
end