pvoutput 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aabffd834f87c5ca43ed5d0c04c952fe4969b99c
4
- data.tar.gz: d52c7cb268ad9608ce3c6503dd2e3b5cb38ff244
3
+ metadata.gz: fd666b46f2d458278fa5cc61a27098d80c4598ec
4
+ data.tar.gz: 65282209af3a86141553ad69ea734f6a71e19b83
5
5
  SHA512:
6
- metadata.gz: 25b9b1b49b10ca564cb9d23233a16505a17d7703d40a01ca0c48d25f1f0cd8f5328aeff11273aa777b358d20bf453ceaf0f5b91bee36063f7ef46fb820c1d411
7
- data.tar.gz: 0a8fa6e7d7841d52a0657489d5ac5b9aedcd4b2105201f63fd5cebef3dfcc92b8664a52b19a8cc129dcf3a7213b26754c77817dfa0eca6596d6987289e814a33
6
+ metadata.gz: 4763db564c14712d118676a008aea7a0e5d7d2c35b4ce4b04266766924df7e6d3bfc3c22ba896e169872ae249d08fd499edbae1a3457fb123cae923fd14d8a9e
7
+ data.tar.gz: 4fa1bd913875d28af09952b240aa9251c91bf6189bb672e426e80aa7c1dbc09e8cdc64480c5c3a54cd959793900adefc73c9fee1f49453c936fbd32fe2c61dde
@@ -18,6 +18,9 @@ Metrics/MethodLength:
18
18
  Metrics/LineLength:
19
19
  Max: 120
20
20
 
21
+ RSpec/ExampleLength:
22
+ Max: 15
23
+
21
24
  Style/ModuleFunction:
22
25
  Enabled: false
23
26
 
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ # 0.4.0 (20160911)
4
+
5
+ * Add retries to batch_output (@jwillemsen)
6
+
3
7
  # 0.3.0 (20160229)
4
8
 
5
9
  * Add donation mode (@jwillemsen)
@@ -17,6 +17,24 @@ module PVOutput
17
17
  self.class.headers 'X-Pvoutput-Apikey' => @api_key, 'X-Pvoutput-SystemId' => @system_id
18
18
  end
19
19
 
20
+ # Helper method to post batch request to pvout that retries at the moment we get
21
+ # a 400 error back with body containing 'Load in progress'
22
+ def post_request(path, options = {}, &block)
23
+ loop do
24
+ response = self.class.post(path, options, &block)
25
+
26
+ if response.code == 400 && response.body =~ /Load in progress/
27
+ # We can't send data too fast, when the previous request is still loaded we
28
+ # have to wait so sleep 10 seconds and try again
29
+ sleep(10)
30
+ elsif response.code == 200
31
+ return
32
+ else
33
+ raise('Bad Post')
34
+ end
35
+ end
36
+ end
37
+
20
38
  # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
21
39
  def add_status(options)
22
40
  time = options[:when] || Time.now
@@ -84,9 +102,7 @@ module PVOutput
84
102
  :data => data.chop,
85
103
  }
86
104
 
87
- response = self.class.post('/service/r2/addbatchoutput.jsp', :body => params)
88
-
89
- raise('Bad Post') unless response.code == 200
105
+ post_request('/service/r2/addbatchoutput.jsp', :body => params)
90
106
  end
91
107
  end
92
108
  # rubocop:enable Metrics/AbcSize
@@ -1,3 +1,3 @@
1
1
  module PVOutput
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pvoutput
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Ferlito
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-29 00:00:00.000000000 Z
11
+ date: 2016-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -207,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
207
  version: '0'
208
208
  requirements: []
209
209
  rubyforge_project:
210
- rubygems_version: 2.4.5.1
210
+ rubygems_version: 2.5.1
211
211
  signing_key:
212
212
  specification_version: 4
213
213
  summary: Library to speak to the PVOutput API