Class: Parklife::Crawler

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, route_set) ⇒ Crawler

Returns a new instance of Crawler.



12
13
14
15
16
# File 'lib/parklife/crawler.rb', line 12

def initialize(config, route_set)
  @config = config
  @route_set = route_set
  @browser = Browser.new(config.app, config.base)
end

Instance Attribute Details

#browserObject (readonly)

Returns the value of attribute browser.



10
11
12
# File 'lib/parklife/crawler.rb', line 10

def browser
  @browser
end

#configObject (readonly)

Returns the value of attribute config.



10
11
12
# File 'lib/parklife/crawler.rb', line 10

def config
  @config
end

#route_setObject (readonly)

Returns the value of attribute route_set.



10
11
12
# File 'lib/parklife/crawler.rb', line 10

def route_set
  @route_set
end

Instance Method Details

#get(path) ⇒ Object



18
19
20
# File 'lib/parklife/crawler.rb', line 18

def get(path)
  browser.get(path)
end

#startObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/parklife/crawler.rb', line 22

def start
  @routes = route_set.to_a
  @visited = Set.new

  while (route = @routes.shift)
    processed = process_route(route)
    config.reporter.print('.') if processed
  end

  config.reporter.puts
end