Class: HotOrNot::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/hot-or-not/runner.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(urls, announcer) ⇒ Runner

Returns a new instance of Runner.



7
8
9
# File 'lib/hot-or-not/runner.rb', line 7

def initialize(urls, announcer)
  @urls, @announcer = urls, announcer
end

Class Method Details

.run_from(file, announcer) ⇒ Object



3
4
5
# File 'lib/hot-or-not/runner.rb', line 3

def self.run_from(file, announcer)
  new CompareUrl.load_from(file), announcer
end

Instance Method Details

#run!Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hot-or-not/runner.rb', line 11

def run!
  @announcer.starting
  @urls.each do |url|
    begin
      result = ComparisonResult.for url
      if result.success?
        @announcer.announce_success result
      else
        @announcer.announce_failure result
      end
    rescue StandardError, Exception => e
      @announcer.announce_error url, e
    end
  end
  @announcer.ending
end