sauce_overage 1.0.0 → 1.0.1

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: 45b05667ec4e6f4f7aeeeb2ecfe4c2c6442e93bd
4
- data.tar.gz: 761ba3ea9602ad07a9a949f9ff5d9597d9cda55e
3
+ metadata.gz: 73ee30fe101effb3c25c8a509db9a41b0a0bfdc1
4
+ data.tar.gz: 4e53ae919a64d2db9c693d035f45d4b4d7e1cae8
5
5
  SHA512:
6
- metadata.gz: 99060f962a1fd5ab8b125a712205f8c19aeff8f6bb9a7fa90032fba99b796adf467fd28dda502fd7cf73642075950ac397889350c73ce9dc1f020e9157a53885
7
- data.tar.gz: b959cf87fc6e2b19a51af43d705ebcc17f2001ca7d3e71740aeb3c567e205bbd65218711cf463a16bf137a142e5afbcf83b0c1b1ae7f6f0d699ee2ca8c0383d7
6
+ metadata.gz: dac69c99e7959be26a97035f4e3fe80239727617d6c061c48bd9326e646c9ddf18fc9a04f5dae7e318501a8db992d1cdb3268ceba81a1b38340c46b0df942646
7
+ data.tar.gz: 71a6cfbe78074c7ba00c43a8ef91470a75c100f7f8bc12d369e4fe570a72cf1133a32bb2abe3786ef901c8d2e733ab481056aed16a63af8f6f6816c11e2c7d19
@@ -18,3 +18,5 @@ Style/AccessorMethodName:
18
18
  Enabled: false
19
19
  Metrics/AbcSize:
20
20
  Enabled: false
21
+ Style/RescueModifier:
22
+ Enabled: false
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
- require 'curb'
3
- require 'json'
2
+ require 'hurley'
3
+ require 'multi_json'
4
4
  require 'webdriver_utils'
5
5
 
6
6
  require_relative 'sauce_overage/version'
@@ -12,20 +12,38 @@ module SauceOverage
12
12
  @key = key.strip
13
13
  end
14
14
 
15
+ MUTEX = Mutex.new
16
+
17
+ def hurley_client
18
+ MUTEX.synchronize do
19
+ return @hurley_client if @hurley_client
20
+ client = @hurley_client = Hurley::Client.new 'https://saucelabs.com/rest/v1/'
21
+ client.header[:content_type] = 'application/json'
22
+ client.request_options.timeout = 2 * 60
23
+ client.request_options.open_timeout = 2 * 60
24
+ client.url.user = user
25
+ client.url.password = key
26
+
27
+ # Ensure body JSON string is parsed into a hash
28
+ # Detect errors and fail so wait_true will retry the request
29
+ client.after_call do |response|
30
+ response.body = MultiJson.load(response.body) rescue {}
31
+
32
+ client_server_error = %i(client_error server_error).include? response.status_type
33
+ body_error = response.body['error']
34
+
35
+ if client_server_error || body_error
36
+ response_error = body_error || ''
37
+ fail(::Errno::ECONNREFUSED, response_error)
38
+ end
39
+ end
40
+
41
+ @hurley_client
42
+ end
43
+ end
44
+
15
45
  def get_user
16
- get = Curl::Easy.new("https://saucelabs.com/rest/v1/users/#{user}")
17
- get.http_auth_types = :basic
18
- get.username = user
19
- get.password = key
20
- get.verbose = true # display more info on errors
21
- # Work around
22
- # /.rvm/gems/ruby-2.2.2/gems/curb-0.8.8/lib/curl/easy.rb:72:in `perform': SSL connect error (Curl::Err::SSLConnectError)
23
- # by retrying for two minutes
24
- wait(120) { get.perform }
25
-
26
- result = JSON.parse(get.body_str || '{}')
27
- fail result['error'] if result['error']
28
- result
46
+ wait(2 * 60) { hurley_client.get("users/#{user}").body }
29
47
  end
30
48
 
31
49
  def minutes
@@ -1,4 +1,4 @@
1
1
  module SauceOverage
2
- VERSION = '1.0.0' unless defined? ::SauceOverage::VERSION
3
- DATE = '2015-09-28' unless defined? ::SauceOverage::DATE
2
+ VERSION = '1.0.1' unless defined? ::SauceOverage::VERSION
3
+ DATE = '2015-10-13' unless defined? ::SauceOverage::DATE
4
4
  end
@@ -1,3 +1,9 @@
1
+ #### v1.0.1 2015-10-13
2
+
3
+ - [9bd0d57](https://github.com/bootstraponline/sauce_overage/commit/9bd0d5792b483a9d3b61b4242d0f72c31f359f04) Release 1.0.1
4
+ - [b3a5e74](https://github.com/bootstraponline/sauce_overage/commit/b3a5e7434984dca5bd8b4447fa52d8f9c7bb0f53) Use hurley and multi_json. Remove curb and json
5
+
6
+
1
7
  #### v1.0.0 2015-09-28
2
8
 
3
9
  - [4df608e](https://github.com/bootstraponline/sauce_overage/commit/4df608e280a36d5dcc0774a8817daba445d2fcf8) Release 1.0.0
@@ -22,8 +22,8 @@ SUMMARY
22
22
  f.match(%r{^(test|spec|features)/})
23
23
  end
24
24
 
25
- spec.add_runtime_dependency 'curb', '~> 0.8.8'
26
- spec.add_runtime_dependency 'json', '~> 1.8.3'
25
+ spec.add_runtime_dependency 'hurley', '~> 0.2'
26
+ spec.add_runtime_dependency 'multi_json', '~> 1.11.2'
27
27
  spec.add_runtime_dependency 'webdriver_utils', '~> 1.0.2'
28
28
 
29
29
  spec.add_development_dependency 'webmock', '~> 1.21.0'
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sauce_overage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - code@bootstraponline.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-28 00:00:00.000000000 Z
11
+ date: 2015-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: curb
14
+ name: hurley
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.8.8
19
+ version: '0.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.8.8
26
+ version: '0.2'
27
27
  - !ruby/object:Gem::Dependency
28
- name: json
28
+ name: multi_json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.8.3
33
+ version: 1.11.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.8.3
40
+ version: 1.11.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: webdriver_utils
43
43
  requirement: !ruby/object:Gem::Requirement