sauce-connect 3.6.1 → 3.6.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sauce/connect.rb +35 -10
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc8a2218111865bb0670b851cbc325f83abb22c7
4
- data.tar.gz: d41b9285fe3fc9039201eb65a83d971e40cba6af
3
+ metadata.gz: 8e56f0e098b6b876d3190333c6cb082263201e1c
4
+ data.tar.gz: dd32b2cafdd18a958ca2cdb67fc30a34e9fc814b
5
5
  SHA512:
6
- metadata.gz: 9d334b97fded3edbd49ec1db40a81a444e9443588e54eff637649d704a3fa0f5966edc80bafd4f6518f982a1cc431b370e444b116cf06357770e0899ea4dc1bc
7
- data.tar.gz: fe5387816660f34f1c59192eaaa1614f3905224fa4cb40a7d3555ac620c8eca7caa224d121c5febf18bbb189d5b76a58db6a448914f98f169db655a93ce510dd
6
+ metadata.gz: 2fdca2ab4ed85bcaa83a4d3bb50b27bf88652654a8f5fb771a4c64c1d95a0dba6b49606925c4539c92aaab1e2b493a882c51db6c83cd693a6a691758bb309c13
7
+ data.tar.gz: 30ec0d104a39d3998b34c0f3977ebb5ce09308cab795e6b180b9c1487fa460d9abb8dfb15537bd3233ad5322e6ecc39c3952d852eab696a996ba75dd12db9fa2
@@ -1,4 +1,3 @@
1
- require 'sauce/config'
2
1
  require 'net/http'
3
2
  require 'socket'
4
3
 
@@ -10,26 +9,52 @@ module Sauce
10
9
  TIMEOUT = 90
11
10
 
12
11
  attr_reader :status, :error
12
+ attr_accessor :username, :access_key
13
13
 
14
14
  def initialize(options={})
15
15
  @ready = false
16
16
  @status = "uninitialized"
17
17
  @error = nil
18
+
19
+ extract_config options
20
+
21
+ error_on_missing_creds
22
+ error_on_missing_executable
23
+ end
24
+
25
+ # extract options from the options hash with highest priority over Sauce.config
26
+ # but fall back on Sauce.config otherwise
27
+ def extract_config options
28
+ @username = options[:username]
29
+ @access_key = options[:access_key]
30
+ @cli_options = options[:connect_options]
31
+ @sc4_executable = options[:sauce_connect_4_executable]
32
+ @skip_connection_test = options[:skip_connection_test]
18
33
  @quiet = options[:quiet]
19
34
  @timeout = options.fetch(:timeout) { TIMEOUT }
20
- @config = Sauce::Config.new(options)
21
- @skip_connection_test = @config[:skip_connection_test]
22
- @cli_options = @config[:connect_options]
23
- @sc4_executable = @config[:sauce_connect_4_executable]
24
35
 
25
- if @config.username.nil?
36
+ unless options.fetch(:skip_sauce_config, false)
37
+ require 'sauce/config'
38
+ @config = Sauce::Config.new(options)
39
+ @username ||= @config.username
40
+ @access_key ||= @config.access_key
41
+ @cli_options ||= @config[:connect_options]
42
+ @sc4_executable ||= @config[:sauce_connect_4_executable]
43
+ @skip_connection_test = @config[:skip_connection_test]
44
+ end
45
+ end
46
+
47
+ def error_on_missing_creds
48
+ if @username.nil?
26
49
  raise ArgumentError, "Username required to launch Sauce Connect. Please set the environment variable $SAUCE_USERNAME"
27
50
  end
28
51
 
29
- if @config.access_key.nil?
52
+ if @access_key.nil?
30
53
  raise ArgumentError, "Access key required to launch Sauce Connect. Please set the environment variable $SAUCE_ACCESS_KEY"
31
54
  end
55
+ end
32
56
 
57
+ def error_on_missing_executable
33
58
  if @sc4_executable.nil?
34
59
  raise TunnelNotPossibleException, Sauce::Connect.plzGetSC4
35
60
  end
@@ -37,11 +62,11 @@ module Sauce
37
62
 
38
63
  def ensure_connection_is_possible
39
64
  $stderr.puts "[Checking REST API is contactable...]" unless @quiet
40
- uri = URI("http://saucelabs.com/rest/v1/#{@config[:username]}/tunnels")
65
+ uri = URI("http://saucelabs.com/rest/v1/#{@username}/tunnels")
41
66
 
42
67
  response = Net::HTTP.start(uri.host, uri.port) do |http|
43
68
  request = Net::HTTP::Get.new uri.request_uri
44
- request.basic_auth(@config[:username], @config[:access_key])
69
+ request.basic_auth(@username, @access_key)
45
70
  response = http.request request
46
71
  end
47
72
 
@@ -69,7 +94,7 @@ module Sauce
69
94
 
70
95
  formatted_cli_options = array_of_formatted_cli_options_from_hash(cli_options)
71
96
 
72
- command_args = ['-u', @config.username, '-k', @config.access_key]
97
+ command_args = ['-u', @username, '-k', @access_key]
73
98
  command_args << formatted_cli_options
74
99
 
75
100
  command = "exec #{find_sauce_connect} #{command_args.join(' ')} 2>&1"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sauce-connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.1
4
+ version: 3.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - R. Tyler Croy
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-07-25 00:00:00.000000000 Z
14
+ date: 2015-07-30 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: sauce