Class Hawler
In: lib/hawler.rb  (CVS)
Parent: Object

Methods

generate_hawlee   new   start  

Attributes

brute  [RW] 
debug  [RW] 
depth  [RW] 
force  [RW] 
headers  [RW] 
help  [RW] 
peek  [RW] 
proxy  [RW] 
proxyport  [RW] 
recurse  [RW] 
sleep  [RW] 
types  [RW] 
verbose  [RW] 

Public Class methods

[Source]

# File lib/hawler.rb, line 69
  def initialize(uri, block)
    unless (uri =~ /^https?:\/\//) 
      uri = "http://#{uri}"
    end
    @uri = uri
    @block = block
    @links = {}
    @recurse = false
    @verbose = false
    @debug = false
    @depth = nil 
    @sleep = 0
    @done = false
    @force = false
    @brute = false
    @peek = false
    @types = Hash[ *%w(text/html text/xml application/xml).collect { |v| [v,1] }.flatten ]
    @headers = {}
    @proxy = nil
    @proxyport = nil
    # register some signal handlers.  halt on ctrl-c, enable verbose on SIGUSR1
    # and enable debug on SIGUSR2
    Signal.trap("INT", lambda { @done = true and puts "Terminating -- ctrl-c" })
    Signal.trap("USR1", lambda { @verbose = !@verbose and puts "Enabling verbose mode" })
    Signal.trap("USR2", lambda { @debug = !@debug and puts "Enabling debug mode" })
  end

Public Instance methods

Simple helper to create a new Hawlee

[Source]

# File lib/hawler.rb, line 64
  def generate_hawlee(link, hawlee)
    print_debug("Queuing #{link} for processing")
    Hawlee.new(link, hawlee.uri, hawlee.depth + 1)
  end

Start the Hawler.

[Source]

# File lib/hawler.rb, line 100
  def start
    if (!@recurse)
      @depth = 0 
    end
    @uri = HawlerHelper.valid_uri(@uri) or exit(1)
    hawl(@uri)
  end

[Validate]