Class: StopangoTester::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/stopango_tester/fetcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path) ⇒ Fetcher

Returns a new instance of Fetcher.



12
13
14
15
16
17
# File 'lib/stopango_tester/fetcher.rb', line 12

def initialize(config_path)
  @config_path = config_path
  self.responses = Array.new
  self.reports = Array.new
  self.cache = Array.new
end

Instance Attribute Details

#cacheObject

Returns the value of attribute cache.



10
11
12
# File 'lib/stopango_tester/fetcher.rb', line 10

def cache
  @cache
end

#reportsObject

Returns the value of attribute reports.



10
11
12
# File 'lib/stopango_tester/fetcher.rb', line 10

def reports
  @reports
end

#responsesObject

Returns the value of attribute responses.



10
11
12
# File 'lib/stopango_tester/fetcher.rb', line 10

def responses
  @responses
end

Instance Method Details

#runObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/stopango_tester/fetcher.rb', line 19

def run
  # fetch test_urls
  puts "pobieram url do testow"
  urls.each do |url|
    request = hydra_request(url)

    request.on_complete do |response|
      responses << response
    end

    hydra.queue request
  end
  hydra.run

  puts "przeprowadzam test"
  # fetch every test_url page
  test_records do |record|
    request = hydra_request(record.test_url)
    
    request.on_complete do |response|
      report = Report.new(record,response)
      reports << report.to_json
      puts report
    end

    hydra.queue request
  end
  hydra.run

  # send reports
  puts "wysylam raport"
  reports.each do |report|
    request = report_request(report)

    request.on_complete do |response|
      cache << response
    end
    hydra.queue request
  end
  hydra.run
end