Class: Waw::Commands::CrawlCommand

Inherits:
Command show all
Defined in:
lib/waw/commands/crawl_command.rb

Instance Attribute Summary

Attributes inherited from Command

#trace, #verbosity

Instance Method Summary collapse

Methods inherited from Command

#exit, #info, #initialize, #options, #run, #shell_exec, #verbose

Constructor Details

This class inherits a constructor from Waw::Commands::Command

Instance Method Details

#__run(requester_file, arguments) ⇒ Object

Runs the sub-class defined command



35
36
37
38
39
40
41
42
# File 'lib/waw/commands/crawl_command.rb', line 35

def __run(requester_file, arguments)
  exit(nil, true) unless (arguments.size == 1)
  @crawler.root_uri = arguments[0]
  @crawler.listener.verbosity = @verbosity
  @crawler.crawl
rescue Interrupt => ex
  info "waw-crawl stopping now... ciao!" if verbose
end

#add_options(options) ⇒ Object

Adds the options



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/waw/commands/crawl_command.rb', line 18

def add_options(options)
  @crawler = Waw::Crawler.new(nil)
  options.on("--[no-]check-externals", "[Don't] ping any external link") do |value|
    @crawler.check_externals = value
  end
  options.on("--[no-]check-img", "[Don't] check image <img src='...'>") do |value|
    @crawler.ping_on('img/@src', value)
  end
  options.on("--[no-]check-link", "[Don't] check <link href='...'>") do |value|
    @crawler.ping_on('link/@href', value)
  end
  options.on("--[no-]check-script", "[Don't] check <script src='...'>") do |value|
    @crawler.ping_on('script/@src', value)
  end
end


6
7
8
9
10
# File 'lib/waw/commands/crawl_command.rb', line 6

def banner
  <<-EOF
    Usage: waw-crawl [options] WEB_SITE_URI
  EOF
end

#check_command_policyObject

Start command is always safe



13
14
15
# File 'lib/waw/commands/crawl_command.rb', line 13

def check_command_policy
  true
end