amiando 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/amiando.rb +19 -2
  2. data/lib/amiando/version.rb +1 -1
  3. metadata +4 -4
@@ -2,6 +2,7 @@ require "amiando/version"
2
2
  require "typhoeus"
3
3
  require "multi_json"
4
4
  require "ostruct"
5
+ require "benchmark"
5
6
 
6
7
  module Amiando
7
8
  autoload :Request, 'amiando/request'
@@ -56,6 +57,9 @@ module Amiando
56
57
  # Timeout value (in milliseconds). Default: 15 seconds.
57
58
  attr_accessor :timeout
58
59
 
60
+ # Used for statistics (time-bandits for example)
61
+ attr_accessor :total_time, :total_requests
62
+
59
63
  URL = 'https://www.amiando.com'
60
64
  TEST_URL = 'https://test.amiando.com'
61
65
 
@@ -80,8 +84,19 @@ module Amiando
80
84
 
81
85
  # Runs all queued requests
82
86
  def run
83
- requests.each{ |request| hydra.queue(request) }
84
- hydra.run
87
+ exception = nil
88
+ requests.each { |request| hydra.queue(request) }
89
+ @total_requests += requests.size
90
+
91
+ duration = Benchmark.realtime do
92
+ begin
93
+ hydra.run
94
+ rescue Exception => exception
95
+ end
96
+ end
97
+ @total_time += duration
98
+
99
+ raise exception if exception
85
100
  ensure
86
101
  @requests = []
87
102
  end
@@ -112,4 +127,6 @@ module Amiando
112
127
  # Default timeout of 15 seconds
113
128
  self.timeout = 15000
114
129
 
130
+ self.total_time = 0.0
131
+ self.total_requests = 0
115
132
  end
@@ -1,3 +1,3 @@
1
1
  module Amiando
2
- VERSION = "0.4.4"
2
+ VERSION = "0.4.5"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amiando
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 4
10
- version: 0.4.4
9
+ - 5
10
+ version: 0.4.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jorge Dias
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-09-13 00:00:00 Z
19
+ date: 2012-09-14 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  requirement: &id001 !ruby/object:Gem::Requirement