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 +1 -1
- data/lib/amon/session.rb +19 -3
- data/lib/amon/version.rb +1 -1
- metadata +4 -4
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.
|
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
|
|
data/lib/amon/session.rb
CHANGED
@@ -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
|
-
|
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],
|
data/lib/amon/version.rb
CHANGED
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:
|
4
|
+
hash: 47
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 12
|
9
9
|
- 0
|
10
|
-
version: 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
|
18
|
+
date: 2012-12-11 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: json
|