amon 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,7 +3,7 @@ Ruby Client for the AMEE AMON API
3
3
 
4
4
  This is a Ruby client library for the [AMEE](http://www.amee.com/) <abbr title="AMEE Monitoring Object Notation">AMON</abbr> <abbr title="Application Programming Interface">API</abbr>. _More details and links to be inserted once information about the API is publicly available_.
5
5
 
6
- This is version 0.11.0 and is built to support AMON V3: https://github.com/AMEE/amon
6
+ This is version 0.12.0 and is built to support AMON V3: https://github.com/AMEE/amon
7
7
 
8
8
  ## Installation ##
9
9
 
@@ -22,7 +22,7 @@ module AMON
22
22
  # at regular intervals. Alternatively, you can use {Session#clear_cache} and keep the same
23
23
  # session.
24
24
  class Session
25
-
25
+
26
26
  # @return [Hash] The hash of configuration options to be used when making requests
27
27
  attr_reader :options
28
28
 
@@ -122,12 +122,28 @@ module AMON
122
122
  end
123
123
 
124
124
  def get(url, params = {})
125
- JSON.parse(client[url].get(:params => params))
125
+ @max_retries = 2
126
+ begin
127
+ json = client[url].get(:params => params)
128
+ rescue => error
129
+ unless error.http_code == 502
130
+ raise error
131
+ end
132
+ @retries ||= 0
133
+ if @retries < @max_retries
134
+ @retries += 1
135
+ clear_cache
136
+ sleep 3
137
+ retry
138
+ else
139
+ raise error
140
+ end
141
+ end
142
+ JSON.parse(json)
126
143
  end
127
144
 
128
145
  def client
129
146
  raise ArgumentError, "Can't make a request without :base_uri option" unless options[:base_uri]
130
-
131
147
  @client ||= RestClient::Resource.new(
132
148
  options[:base_uri],
133
149
  :user => options[:user],
@@ -2,7 +2,7 @@ module AMON
2
2
  # Provides details about the version of the AMON library in use.
3
3
  module Version
4
4
  MAJOR = 0
5
- MINOR = 11
5
+ MINOR = 12
6
6
  TINY = 0
7
7
 
8
8
  STRING = "#{MAJOR}.#{MINOR}.#{TINY}"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amon
3
3
  version: !ruby/object:Gem::Version
4
- hash: 51
4
+ hash: 47
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 11
8
+ - 12
9
9
  - 0
10
- version: 0.11.0
10
+ version: 0.12.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - AMEE
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-11-05 00:00:00 Z
18
+ date: 2012-12-11 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: json