ldclient-rb 2.1.5 → 2.2.5
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.
- checksums.yaml +4 -4
- data/ldclient-rb.gemspec +1 -1
- data/lib/ldclient-rb/config.rb +10 -0
- data/lib/ldclient-rb/requestor.rb +3 -0
- data/lib/ldclient-rb/stream.rb +1 -1
- data/lib/ldclient-rb/version.rb +1 -1
- data/spec/requestor_spec.rb +53 -0
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e80f005cb0e766f2b7bc67ae26b9d33ef9f8df3
|
4
|
+
data.tar.gz: 42ce3fee3713a80d14e0f250b8e541918a50fcf0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c40490932b362914b7383a651f1fe36736eefbcacb1c1be72018420d917bf47606d21b40da8fde3033bd645a26d2c00426dba38f6a37596006625d952f96982
|
7
|
+
data.tar.gz: 1fd96aa5d3c37eeb0dd6f17a69b075a300f546b1fee31ecbd82971cdf3d81ae7537b0e99c58cc41444f3e135a133f464f32d891c37d264e1b7c1cfd36b97d489
|
data/ldclient-rb.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_runtime_dependency "net-http-persistent", "~> 2.9"
|
32
32
|
spec.add_runtime_dependency "concurrent-ruby", "~> 1.0.4"
|
33
33
|
spec.add_runtime_dependency "hashdiff", "~> 0.2"
|
34
|
-
spec.add_runtime_dependency "ld-celluloid-eventsource", "~> 0.
|
34
|
+
spec.add_runtime_dependency "ld-celluloid-eventsource", "~> 0.10.0"
|
35
35
|
spec.add_runtime_dependency "celluloid", "~> 0.18.0.pre" # transitive dep; specified here for more control
|
36
36
|
|
37
37
|
if RUBY_VERSION >= '2.2.2'
|
data/lib/ldclient-rb/config.rb
CHANGED
@@ -56,6 +56,7 @@ module LaunchDarkly
|
|
56
56
|
@stream = opts.has_key?(:stream) ? opts[:stream] : Config.default_stream
|
57
57
|
@offline = opts.has_key?(:offline) ? opts[:offline] : Config.default_offline
|
58
58
|
@poll_interval = opts.has_key?(:poll_interval) && opts[:poll_interval] > 1 ? opts[:poll_interval] : Config.default_poll_interval
|
59
|
+
@proxy = opts[:proxy] || Config.default_proxy
|
59
60
|
end
|
60
61
|
|
61
62
|
#
|
@@ -143,6 +144,11 @@ module LaunchDarkly
|
|
143
144
|
#
|
144
145
|
attr_reader :feature_store
|
145
146
|
|
147
|
+
|
148
|
+
# The proxy configuration string
|
149
|
+
#
|
150
|
+
attr_reader :proxy
|
151
|
+
|
146
152
|
#
|
147
153
|
# The default LaunchDarkly client configuration. This configuration sets
|
148
154
|
# reasonable defaults for most users.
|
@@ -184,6 +190,10 @@ module LaunchDarkly
|
|
184
190
|
2
|
185
191
|
end
|
186
192
|
|
193
|
+
def self.default_proxy
|
194
|
+
nil
|
195
|
+
end
|
196
|
+
|
187
197
|
def self.default_logger
|
188
198
|
if defined?(Rails) && Rails.respond_to?(:logger)
|
189
199
|
Rails.logger
|
@@ -30,6 +30,9 @@ module LaunchDarkly
|
|
30
30
|
req.headers["User-Agent"] = "RubyClient/" + LaunchDarkly::VERSION
|
31
31
|
req.options.timeout = @config.read_timeout
|
32
32
|
req.options.open_timeout = @config.connect_timeout
|
33
|
+
if @config.proxy
|
34
|
+
req.options.proxy = Faraday::ProxyOptions.from @config.proxy
|
35
|
+
end
|
33
36
|
end
|
34
37
|
|
35
38
|
@config.logger.debug("[LDClient] Got response from uri: #{uri}\n\tstatus code: #{res.status}\n\theaders: #{res.headers}\n\tbody: #{res.body}")
|
data/lib/ldclient-rb/stream.rb
CHANGED
@@ -33,7 +33,7 @@ module LaunchDarkly
|
|
33
33
|
'Authorization' => @sdk_key,
|
34
34
|
'User-Agent' => 'RubyClient/' + LaunchDarkly::VERSION
|
35
35
|
}
|
36
|
-
opts = {:headers => headers, :with_credentials => true}
|
36
|
+
opts = {:headers => headers, :with_credentials => true, :proxy => @config.proxy}
|
37
37
|
@es = Celluloid::EventSource.new(@config.stream_uri + "/flags", opts) do |conn|
|
38
38
|
conn.on(PUT) { |message| process_message(message, PUT) }
|
39
39
|
conn.on(PATCH) { |message| process_message(message, PATCH) }
|
data/lib/ldclient-rb/version.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "faraday"
|
3
|
+
|
4
|
+
describe LaunchDarkly::Requestor do
|
5
|
+
describe ".request_all_flags" do
|
6
|
+
describe "with a proxy" do
|
7
|
+
let(:requestor) {
|
8
|
+
LaunchDarkly::Requestor.new(
|
9
|
+
"key",
|
10
|
+
LaunchDarkly::Config.new({
|
11
|
+
:proxy => "http://proxy.com",
|
12
|
+
:base_uri => "http://ld.com"
|
13
|
+
})
|
14
|
+
)
|
15
|
+
}
|
16
|
+
it "converts the proxy option" do
|
17
|
+
faraday = Faraday.new
|
18
|
+
requestor.instance_variable_set(:@client, faraday)
|
19
|
+
allow(faraday).to receive(:get) do |*args, &block|
|
20
|
+
req = double(Faraday::Request, :headers => {}, :options => Faraday::RequestOptions.new)
|
21
|
+
block.call(req)
|
22
|
+
expect(args).to eq ['http://ld.com/sdk/latest-flags']
|
23
|
+
expect(req.options.proxy[:uri]).to eq URI("http://proxy.com")
|
24
|
+
double(body: '{"foo": "bar"}', status: 200, headers: {})
|
25
|
+
end
|
26
|
+
|
27
|
+
requestor.request_all_flags()
|
28
|
+
end
|
29
|
+
end
|
30
|
+
describe "without a proxy" do
|
31
|
+
let(:requestor) {
|
32
|
+
LaunchDarkly::Requestor.new(
|
33
|
+
"key",
|
34
|
+
LaunchDarkly::Config.new({
|
35
|
+
:base_uri => "http://ld.com"
|
36
|
+
})
|
37
|
+
)
|
38
|
+
}
|
39
|
+
it "converts the proxy option" do
|
40
|
+
faraday = Faraday.new
|
41
|
+
requestor.instance_variable_set(:@client, faraday)
|
42
|
+
allow(faraday).to receive(:get) do |*args, &block|
|
43
|
+
req = double(Faraday::Request, :headers => {}, :options => Faraday::RequestOptions.new)
|
44
|
+
block.call(req)
|
45
|
+
expect(args).to eq ['http://ld.com/sdk/latest-flags']
|
46
|
+
expect(req.options.proxy).to eq nil
|
47
|
+
double(body: '{"foo": "bar"}', status: 200, headers: {})
|
48
|
+
end
|
49
|
+
requestor.request_all_flags()
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ldclient-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LaunchDarkly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 0.
|
173
|
+
version: 0.10.0
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 0.
|
180
|
+
version: 0.10.0
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: celluloid
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -261,6 +261,7 @@ files:
|
|
261
261
|
- spec/fixtures/user.json
|
262
262
|
- spec/ldclient_spec.rb
|
263
263
|
- spec/newrelic_spec.rb
|
264
|
+
- spec/requestor_spec.rb
|
264
265
|
- spec/spec_helper.rb
|
265
266
|
- spec/store_spec.rb
|
266
267
|
- spec/stream_spec.rb
|
@@ -285,7 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
285
286
|
version: '0'
|
286
287
|
requirements: []
|
287
288
|
rubyforge_project:
|
288
|
-
rubygems_version: 2.6.
|
289
|
+
rubygems_version: 2.6.11
|
289
290
|
signing_key:
|
290
291
|
specification_version: 4
|
291
292
|
summary: LaunchDarkly SDK for Ruby
|
@@ -297,6 +298,7 @@ test_files:
|
|
297
298
|
- spec/fixtures/user.json
|
298
299
|
- spec/ldclient_spec.rb
|
299
300
|
- spec/newrelic_spec.rb
|
301
|
+
- spec/requestor_spec.rb
|
300
302
|
- spec/spec_helper.rb
|
301
303
|
- spec/store_spec.rb
|
302
304
|
- spec/stream_spec.rb
|