ldclient-rb 0.8.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
1
  require "spec_helper"
2
+ require 'ostruct'
2
3
 
3
4
  describe LaunchDarkly::InMemoryFeatureStore do
4
5
  subject { LaunchDarkly::InMemoryFeatureStore }
@@ -32,56 +33,13 @@ end
32
33
  describe LaunchDarkly::StreamProcessor do
33
34
  subject { LaunchDarkly::StreamProcessor }
34
35
  let(:config) { LaunchDarkly::Config.new }
35
- let(:processor) { subject.new("api_key", config) }
36
- describe '#start' do
37
- it "will check if the reactor has started" do
38
- expect(processor).to receive(:start_reactor).and_return false
39
- expect(EM).to_not receive(:defer)
40
- processor.start
41
- end
42
- it "will check if the stream processor has already started" do
43
- expect(processor).to receive(:start_reactor).and_return true
44
- processor.instance_variable_get(:@started).make_true
45
- expect(EM).to_not receive(:defer)
46
- processor.start
47
- end
48
- it "will boot the stream processor" do
49
- expect(processor).to receive(:start_reactor).and_return true
50
- expect(EM).to receive(:defer)
51
- processor.start
52
- end
53
- end
54
-
55
- describe '#boot_event_manager' do
56
- let(:message) { "asdf" }
57
- before do
58
- processor.instance_variable_get(:@config).instance_variable_set(:@stream_uri, "http://example.com/streaming")
59
- expect_any_instance_of(EM::EventSource).to receive(:start)
60
- source = processor.send(:boot_event_manager)
61
- @req = source.instance_variable_get "@req"
62
- # It seems testing EventManager is hard/impossible
63
- end
64
- it "will start" do
65
- end
66
- xit "will process put messages" do
67
- expect(processor).to receive(:process_message).with(message, LaunchDarkly::PUT)
68
- @req.stream_data("data: #{message}\nevent:#{LaunchDarkly::PUT}\n")
69
- end
70
- xit "will process patch messages" do
71
- expect(processor).to receive(:process_message).with(message, LaunchDarkly::PATCH)
72
- end
73
- xit "will process delete messages" do
74
- expect(processor).to receive(:process_message).with(message, LaunchDarkly::DELETE)
75
- end
76
- xit "will process errors" do
77
- expect(processor).to receive(:set_disconnected)
78
- end
79
- end
36
+ let(:requestor) { LaunchDarkly::Requestor.new("sdk_key", config)}
37
+ let(:processor) { subject.new("sdk_key", config, requestor) }
80
38
 
81
39
  describe '#process_message' do
82
- let(:put_message) { '{"key": {"value": "asdf"}}' }
83
- let(:patch_message) { '{"path": "akey", "data": {"value": "asdf", "version": 1}}' }
84
- let(:delete_message) { '{"path": "akey", "version": 2}' }
40
+ let(:put_message) { OpenStruct.new({data: '{"key": {"value": "asdf"}}'}) }
41
+ let(:patch_message) { OpenStruct.new({data: '{"path": "akey", "data": {"value": "asdf", "version": 1}}'}) }
42
+ let(:delete_message) { OpenStruct.new({data: '{"path": "akey", "version": 2}'}) }
85
43
  it "will accept PUT methods" do
86
44
  processor.send(:process_message, put_message, LaunchDarkly::PUT)
87
45
  expect(processor.instance_variable_get(:@store).get("key")).to eq(value: "asdf")
@@ -100,19 +58,5 @@ describe LaunchDarkly::StreamProcessor do
100
58
  processor.send(:process_message, put_message, "get")
101
59
  end
102
60
  end
103
-
104
- describe '#should_fallback_update' do
105
- it "will return true if the stream is disconnected for more than 120 seconds" do
106
- processor.send(:set_disconnected)
107
- future_time = Time.now + 200
108
- expect(Time).to receive(:now).and_return(future_time)
109
- value = processor.send(:should_fallback_update)
110
- expect(value).to eq true
111
- end
112
- it "will return false otherwise" do
113
- processor.send(:set_connected)
114
- value = processor.send(:should_fallback_update)
115
- expect(value).to eq false
116
- end
117
- end
118
61
  end
62
+
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: 0.8.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - LaunchDarkly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-13 00:00:00.000000000 Z
11
+ date: 2016-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -165,24 +165,39 @@ dependencies:
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0.2'
167
167
  - !ruby/object:Gem::Dependency
168
- name: ld-em-eventsource
168
+ name: ld-celluloid-eventsource
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ~>
172
172
  - !ruby/object:Gem::Version
173
- version: '0.2'
173
+ version: '0.5'
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - ~>
179
+ - !ruby/object:Gem::Version
180
+ version: '0.5'
181
+ - !ruby/object:Gem::Dependency
182
+ name: waitutil
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - '='
186
+ - !ruby/object:Gem::Version
187
+ version: '0.2'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - '='
179
193
  - !ruby/object:Gem::Version
180
194
  version: '0.2'
181
195
  description: Official LaunchDarkly SDK for Ruby
182
196
  email:
183
197
  - team@launchdarkly.com
184
198
  executables: []
185
- extensions: []
199
+ extensions:
200
+ - ext/mkrf_conf.rb
186
201
  extra_rdoc_files: []
187
202
  files:
188
203
  - .gitignore
@@ -190,19 +205,25 @@ files:
190
205
  - .rspec
191
206
  - .rubocop.yml
192
207
  - .simplecov
208
+ - CHANGELOG.md
193
209
  - CONTRIBUTING.md
194
210
  - Gemfile
195
211
  - LICENSE.txt
196
212
  - README.md
197
213
  - Rakefile
198
214
  - circle.yml
215
+ - ext/mkrf_conf.rb
199
216
  - ldclient-rb.gemspec
200
217
  - lib/ldclient-rb.rb
218
+ - lib/ldclient-rb/cache_store.rb
201
219
  - lib/ldclient-rb/config.rb
220
+ - lib/ldclient-rb/evaluation.rb
221
+ - lib/ldclient-rb/events.rb
222
+ - lib/ldclient-rb/feature_store.rb
202
223
  - lib/ldclient-rb/ldclient.rb
203
224
  - lib/ldclient-rb/newrelic.rb
204
- - lib/ldclient-rb/settings.rb
205
- - lib/ldclient-rb/store.rb
225
+ - lib/ldclient-rb/polling.rb
226
+ - lib/ldclient-rb/requestor.rb
206
227
  - lib/ldclient-rb/stream.rb
207
228
  - lib/ldclient-rb/version.rb
208
229
  - spec/config_spec.rb
@@ -1,40 +0,0 @@
1
- module LaunchDarkly
2
-
3
- #
4
- # Module to manage user flag settings
5
- #
6
- module Settings
7
- #
8
- # Specifically enable or disable a feature flag for a user based
9
- # on their key.
10
- #
11
- # @param user_key [String] the key of the user
12
- # @param flag_key [String] the unique feature key for the feature flag, as shown
13
- # on the LaunchDarkly dashboard
14
- # @param setting [Boolean] the new setting, one of:
15
- # true: the feature is always on
16
- # false: the feature is never on
17
- # nil: remove the setting (assign user per defined rules)
18
- def update_user_flag_setting(user_key, flag_key, setting=nil)
19
- unless user_key
20
- @config.logger.error("[LDClient] Must specify user")
21
- return
22
- end
23
-
24
- res = log_timings('update_user_flag_setting') do
25
- @client.put("#{@config.base_uri}/api/users/#{user_key}/features/#{flag_key}") do |req|
26
- req.headers['Authorization'] = "api_key #{@api_key}"
27
- req.headers['User-Agent'] = "RubyClient/#{LaunchDarkly::VERSION}"
28
- req.headers['Content-Type'] = 'application/json'
29
- req.body = {setting: setting}.to_json
30
- req.options.timeout = @config.read_timeout
31
- req.options.open_timeout = @config.connect_timeout
32
- end
33
- end
34
-
35
- unless res.success?
36
- @config.logger.error("[LDClient] Failed to change setting, status: #{res.status}")
37
- end
38
- end
39
- end
40
- end