Class: Waw::Crawler::Listener

Inherits:
Object
  • Object
show all
Defined in:
lib/waw/crawler/crawler_listener.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Listener

Creates a listener instance



10
11
12
13
# File 'lib/waw/crawler/crawler_listener.rb', line 10

def initialize(output)
  @highline = HighLine.new(STDIN, output)
  @verbosity = 1
end

Instance Attribute Details

#highlineObject (readonly)

Returns the value of attribute highline.



6
7
8
# File 'lib/waw/crawler/crawler_listener.rb', line 6

def highline
  @highline
end

#verbosityObject

Returns the value of attribute verbosity.



7
8
9
# File 'lib/waw/crawler/crawler_listener.rb', line 7

def verbosity
  @verbosity
end

Instance Method Details

#checking(page, &block) ⇒ Object



15
16
17
18
19
20
# File 'lib/waw/crawler/crawler_listener.rb', line 15

def checking(page, &block)
  if verbosity > 0
    highline.say page.uri.to_s
  end
  block.call
end

#crawl_skipped(referer_page, location) ⇒ Object



28
29
30
31
32
# File 'lib/waw/crawler/crawler_listener.rb', line 28

def crawl_skipped(referer_page, location)
  if verbosity > 1
    highline.say '  + crawling skipped: ' + highline.color(location, :magenta)
  end
end

#doc_skipped(to_check) ⇒ Object



22
23
24
25
26
# File 'lib/waw/crawler/crawler_listener.rb', line 22

def doc_skipped(to_check)
  if verbosity > 1
    highline.say highline.color(to_check.uri, :magenta)
  end
end

#ping_ok(referer_page, location) ⇒ Object



34
35
36
37
38
# File 'lib/waw/crawler/crawler_listener.rb', line 34

def ping_ok(referer_page, location)
  if verbosity > 1
    highline.say '  + ping ok: ' + highline.color(location, :green)
  end
end

#ping_skipped(referer_page, location) ⇒ Object



40
41
42
43
44
# File 'lib/waw/crawler/crawler_listener.rb', line 40

def ping_skipped(referer_page, location)
  if verbosity > 1
    highline.say '  + ping skipped: ' + highline.color(location, :magenta)
  end
end

#reach_failure(referer_page, location, ex) ⇒ Object



46
47
48
# File 'lib/waw/crawler/crawler_listener.rb', line 46

def reach_failure(referer_page, location, ex)
  highline.say '  + reach failure: ' + highline.color(location, :red)
end

#scheme_failure(referer_page, location, ex) ⇒ Object



50
51
52
53
54
# File 'lib/waw/crawler/crawler_listener.rb', line 50

def scheme_failure(referer_page, location, ex)
  if verbosity > 1
    highline.say '  + scheme failure: ' + highline.color(location, :magenta)
  end
end

#socket_error(referer_page, location, ex) ⇒ Object



56
57
58
59
60
# File 'lib/waw/crawler/crawler_listener.rb', line 56

def socket_error(referer_page, location, ex)
  if verbosity > 1
    highline.say '  + socket failure: ' + highline.color(location, :magenta)
  end
end