tamber 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cfed4fc6979dd3e852165d4b4f75e64447e20552
4
- data.tar.gz: 68598a45bdd2b3f228826263ed07b29fea66318a
3
+ metadata.gz: f8004eba3105bccbba37c06ea731792477a3a6a5
4
+ data.tar.gz: 4258a7685450ee4e22a553f019917068840c9fa2
5
5
  SHA512:
6
- metadata.gz: 78d65a11b8a68146796590305f45d776ed873581a8d013c30ae7eb7e24a778b50ab30ba4112337259eb15cfcb7c1a82f5a7e7350641e4cf6432b693551c4db13
7
- data.tar.gz: fc7e1eaf2f119bb440bc577a09e09340ba0afb91e0c1f6b6dc8af38e4df3af3458750b885be9dd93a0c3679b143a7f993efb2095f371479d06cb1cbc7bdd7e41
6
+ metadata.gz: a207f215cf2c5fa4a6aa7308b6d4d3bb48ff58856ae5ee7488e60cb41bf6e24078134f603f5370d24fb293fa7612ef440c58b99f836ae2074ca69c7d263d2830
7
+ data.tar.gz: 0f58d0e36a8c03fb44b6e882829d0a052e7d71538dd2eb5271abdd14b4b4f3c754ffbcae861e84e4034e84fddeae2dfae06095284dfd4e3bf9409df288f4bdbf
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  /tamber-*.gem
2
+ bin/tamber-*.gem
2
3
  /Gemfile.lock
3
4
  .rvmrc
4
5
  Gemfile.lock
data/README.md CHANGED
@@ -196,6 +196,15 @@ rescue TamberError => error
196
196
  end
197
197
  ```
198
198
 
199
+ ### Timeout Configuration
200
+
201
+ Open and read timeouts are configurable:
202
+
203
+ ```rb
204
+ Tamber.open_timeout = 1
205
+ Tamber.read_timeout = 5
206
+ ```
207
+
199
208
  See [Tests](https://github.com/tamber/tamber-ruby/tree/master/test) for more examples.
200
209
 
201
210
  [homepage]: https://tamber.com
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.9
1
+ 0.1.10
@@ -150,7 +150,35 @@ module Tamber
150
150
  end
151
151
 
152
152
  def self.handle_restclient_error(e, request_opts)
153
- parse(e)
153
+ case e
154
+ when Errno::ECONNREFUSED
155
+ message = "Could not connect to Tamber at #{api_url}. " \
156
+ "Please check that your internet connection and DNS are working by running " \
157
+ "'host tamber.com' from the command line and try again. " \
158
+ "Still borked? Email us at support@tamber.com and we'll get to the bottom of it."
159
+
160
+ when RestClient::Timeout
161
+ message = "Could not connect to Tamber at #{api_url}. " \
162
+ "Please check your internet connection and try again. " \
163
+ "Still borked? Email us at support@tamber.com and we'll get to the bottom of it."
164
+
165
+ when RestClient::SSLCertificateNotVerified
166
+ message = "Could not establish a secure connection to Tamber, you may " \
167
+ "need to upgrade your OpenSSL version. To check, try running " \
168
+ "'openssl s_client -connect api.tamber.com:443' from the " \
169
+ "command line."
170
+
171
+ when RestClient::ServerBrokeConnection
172
+ message = "Connection was broken before the request could complete (either by " \
173
+ "the Tamber server or a network failure)."
174
+
175
+ else
176
+ message = "Unexpected request error. If this problem persists, please let us know by " \
177
+ "emailing us at support@tamber.com."
178
+
179
+ end
180
+
181
+ raise NetworkError.new(message + "\n\n(#{e.message})")
154
182
  end
155
183
 
156
184
  def self.execute_request(opts)
@@ -163,7 +191,7 @@ module Tamber
163
191
  if response["success"]
164
192
  response = response["result"]
165
193
  else
166
- raise TamberError.new("Error: "+response["error"])
194
+ raise TamberError.new(response["error"])
167
195
  end
168
196
  rescue JSON::ParserError
169
197
  raise general_api_error(response.body)
@@ -182,7 +210,7 @@ module Tamber
182
210
  rescue NoMethodError => e
183
211
  # Work around RestClient bug
184
212
  if e.message =~ /\WRequestFailed\W/
185
- raise TamberError.new('Error: Unexpected HTTP response code')
213
+ raise TamberError.new('Unexpected HTTP response code')
186
214
  else
187
215
  raise
188
216
  end
@@ -5,6 +5,13 @@ module Tamber
5
5
  def initialize(message=nil)
6
6
  @message = message
7
7
  end
8
+ end
9
+
10
+ class NetworkError < StandardError
11
+ attr_reader :message
8
12
 
13
+ def initialize(message=nil)
14
+ @message = message
15
+ end
9
16
  end
10
17
  end
@@ -1,3 +1,3 @@
1
1
  module Tamber
2
- VERSION = '0.1.9'
2
+ VERSION = '0.1.10'
3
3
  end
@@ -10,6 +10,8 @@ class Test::Unit::TestCase
10
10
  setup do
11
11
  Tamber.project_key = "Mu6DUPXdDYe98cv5JIfX"
12
12
  Tamber.engine_key = "SbWYPBNdARfIDa0IIO9L"
13
+ Tamber.open_timeout = 3
14
+ Tamber.read_timeout = 2
13
15
  end
14
16
 
15
17
  teardown do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tamber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexi Robbins
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-02-28 00:00:00.000000000 Z
12
+ date: 2018-04-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client