gun_broker 1.0.0 → 1.1.0

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: a517e51292b8753425fa0f70ae8444060fd8e57f
4
- data.tar.gz: 654ba8ac24476fa3cdc2a51b22712d4dd9e801e2
3
+ metadata.gz: 7046dc9d7cbc2b209e3c1a15423531d13adac8cc
4
+ data.tar.gz: ac669bb18a1bd17e4c34fecf85ecb0addf9c9e67
5
5
  SHA512:
6
- metadata.gz: 5c165ef0ab1de7d551a5ba6b9147211cfe56c860ebffdb6c1c78f2d64000fb3e8adf8e0fe7bd2a8060ed0916b753d3b30bc6470a970dd14ee919d4362ead06ab
7
- data.tar.gz: 5b0b04203500bb8aa0113054897fc222daa13e0a26415f8e08cc213e437ecfa75564e1ec0ed17c7907c08ff1bde6833a83d229a62544fdfd68d066bd54e98aeb
6
+ metadata.gz: 9aeac94a7394482cca0fa09fc85e3d37d98cb59d288d38e37910ab38afb73fff63e4b6f5e9e1e41617989790f5d2db0b88d190fda85867a51106c5afe3eaeabe
7
+ data.tar.gz: 866709353845783cc78faaeb6215841070794a86aa7e7aee82d08add0feba03ef08450b2f1925ef27f4072b04110ac394dc2c615458cfd561028752b5f2fa6cb
data/bin/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "gun_broker"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require "pry"
10
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ bundle install
data/gun_broker.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "pry", "~> 0.10.4"
22
23
  spec.add_development_dependency "rake", "~> 10.0"
23
24
  spec.add_development_dependency "rspec", "~> 3.1"
24
25
  spec.add_development_dependency "simplecov", "~> 0.9"
data/lib/gun_broker.rb CHANGED
@@ -27,8 +27,8 @@ module GunBroker
27
27
 
28
28
  # Sets the developer key obtained from GunBroker.com.
29
29
  # @param dev_key [String]
30
- def self.dev_key=(dev_key)
31
- @@dev_key = dev_key
30
+ def self.dev_key=(_dev_key)
31
+ @@dev_key = _dev_key
32
32
  end
33
33
 
34
34
  # Returns the set developer key, or raises GunBroker::Error if not set.
@@ -39,10 +39,28 @@ module GunBroker
39
39
  @@dev_key
40
40
  end
41
41
 
42
+ # Set URL for remote proxy (including host, port, user, and password)
43
+ # @return [String] Defaults to `nil`.
44
+ def self.proxy_url=(_proxy_url)
45
+ @@proxy_url = _proxy_url
46
+ end
47
+
48
+ # Fully-qualified URL for remote proxy (including host, port, user, and password)
49
+ # @return [String] Defaults to `nil`.
50
+ def self.proxy_url
51
+ defined?(@@proxy_url) ? @@proxy_url : nil
52
+ end
53
+
54
+ # Convenience method for finding out if a proxy_url has been set
55
+ # @return [Boolean] Defaults to `false`.
56
+ def self.proxy_url?
57
+ !! defined?(@@proxy_url) || false
58
+ end
59
+
42
60
  # Determines if this library will use the production API or the 'sandbox' API.
43
61
  # @param sandbox [Boolean]
44
- def self.sandbox=(sandbox)
45
- @@sandbox = sandbox
62
+ def self.sandbox=(_sandbox)
63
+ @@sandbox = _sandbox
46
64
  end
47
65
 
48
66
  # If `true`, this library will use the 'sandbox' GunBroker API.
@@ -127,7 +127,7 @@ module GunBroker
127
127
  # using std-lib Timeout module
128
128
  # The GunBroker API is so fickle that the 'read_timeout' option might never even get a chance
129
129
  Timeout.timeout(GunBroker.timeout) do
130
- Net::HTTP.start(uri.host, uri.port, net_http_options) do |http|
130
+ net_http_class.start(uri.host, uri.port, net_http_options) do |http|
131
131
  http.ssl_version = :TLSv1
132
132
  http.ciphers = ['RC4-SHA']
133
133
  http.request(request)
@@ -137,6 +137,15 @@ module GunBroker
137
137
  raise GunBroker::Error::TimeoutError.new("waited for #{GunBroker.timeout} seconds with no response (#{uri}) #{e.inspect}")
138
138
  end
139
139
 
140
+ def net_http_class
141
+ if GunBroker.proxy_url?
142
+ proxy_uri = URI.parse(GunBroker.proxy_url)
143
+ Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password)
144
+ else
145
+ Net::HTTP
146
+ end
147
+ end
148
+
140
149
  def net_http_options
141
150
  {
142
151
  use_ssl: uri.scheme == 'https',
@@ -1,3 +1,3 @@
1
1
  module GunBroker
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gun_broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dale Campbell
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.10.4
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.10.4
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -97,7 +111,9 @@ dependencies:
97
111
  description: ''
98
112
  email:
99
113
  - oshuma@gmail.com
100
- executables: []
114
+ executables:
115
+ - console
116
+ - setup
101
117
  extensions: []
102
118
  extra_rdoc_files: []
103
119
  files:
@@ -110,6 +126,8 @@ files:
110
126
  - LICENSE.txt
111
127
  - README.md
112
128
  - Rakefile
129
+ - bin/console
130
+ - bin/setup
113
131
  - gun_broker.gemspec
114
132
  - lib/gun_broker.rb
115
133
  - lib/gun_broker/api.rb