Skip to content

Commit 5ef6d7d

Browse files
authored
remove deprecated code (#24) (#30)
* remove deprecated code (#24) * version 7.0.0 * coverage fix
1 parent 2a73dfc commit 5ef6d7d

File tree

7 files changed

+43
-295
lines changed

7 files changed

+43
-295
lines changed

.github/workflows/ruby-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ jobs:
5252
bundler-cache: true
5353
- name: Run tests with coverage
5454
run: bundle exec rake
55-
env:
56-
COV: true
55+
- name: Upload coverage to Codecov
56+
uses: codecov/codecov-action@v3
5757

5858
publish:
5959
needs: coverage

lib/configcat.rb

Lines changed: 0 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -24,164 +24,4 @@ def ConfigCat.get(sdk_key, options = nil)
2424
def ConfigCat.close_all
2525
ConfigCatClient.close_all
2626
end
27-
28-
def ConfigCat.create_client(sdk_key, data_governance: DataGovernance::GLOBAL)
29-
#
30-
# Create an instance of ConfigCatClient and setup Auto Poll mode with default options
31-
#
32-
# :param sdk_key: ConfigCat SDK Key to access your configuration.
33-
# :param data_governance:
34-
# Default: Global. Set this parameter to be in sync with the Data Governance preference on the Dashboard:
35-
# https://app.configcat.com/organization/data-governance
36-
# (Only Organization Admins have access)
37-
#
38-
return create_client_with_auto_poll(sdk_key, data_governance: data_governance)
39-
end
40-
41-
# Create an instance of ConfigCatClient and setup Auto Poll mode with custom options
42-
#
43-
# :param sdk_key: ConfigCat SDK Key to access your configuration.
44-
# :param poll_interval_seconds: The client's poll interval in seconds. Default: 60 seconds.
45-
# :param on_configuration_changed_callback: You can subscribe to configuration changes with this callback
46-
# :param max_init_wait_time_seconds: maximum waiting time for first configuration fetch in polling mode.
47-
# :param config_cache: If you want to use custom caching instead of the client's default,
48-
# You can provide an implementation of ConfigCache.
49-
# :param base_url: You can set a base_url if you want to use a proxy server between your application and ConfigCat
50-
# :param proxy_address: Proxy address
51-
# :param proxy_port: Proxy port
52-
# :param proxy_user: username for proxy authentication
53-
# :param proxy_pass: password for proxy authentication
54-
# :param open_timeout_seconds: The number of seconds to wait for the server to make the initial connection. Default: 10 seconds.
55-
# :param read_timeout_seconds: The number of seconds to wait for the server to respond before giving up. Default: 30 seconds.
56-
# :param flag_overrides: A FlagOverrides implementation used to override feature flags & settings.
57-
# :param data_governance:
58-
# Default: Global. Set this parameter to be in sync with the Data Governance preference on the Dashboard:
59-
# https://app.configcat.com/organization/data-governance
60-
# (Only Organization Admins have access)
61-
def ConfigCat.create_client_with_auto_poll(sdk_key,
62-
poll_interval_seconds: 60,
63-
max_init_wait_time_seconds: 5,
64-
on_configuration_changed_callback: nil,
65-
config_cache: nil,
66-
base_url: nil,
67-
proxy_address: nil,
68-
proxy_port: nil,
69-
proxy_user: nil,
70-
proxy_pass: nil,
71-
open_timeout_seconds: 10,
72-
read_timeout_seconds: 30,
73-
flag_overrides: nil,
74-
data_governance: DataGovernance::GLOBAL)
75-
options = ConfigCatOptions.new(
76-
base_url: base_url,
77-
polling_mode: PollingMode.auto_poll(poll_interval_seconds: poll_interval_seconds, max_init_wait_time_seconds: max_init_wait_time_seconds),
78-
config_cache: config_cache,
79-
proxy_address: proxy_address,
80-
proxy_port: proxy_port,
81-
proxy_user: proxy_user,
82-
proxy_pass: proxy_pass,
83-
open_timeout_seconds: open_timeout_seconds,
84-
read_timeout_seconds: read_timeout_seconds,
85-
flag_overrides: flag_overrides,
86-
data_governance: data_governance
87-
)
88-
ConfigCat.logger.warn('create_client_with_auto_poll is deprecated. Create the ConfigCat Client as a Singleton object with `configcatclient.get()` instead')
89-
client = ConfigCatClient.get(sdk_key, options)
90-
client.hooks.add_on_config_changed(on_configuration_changed_callback) if on_configuration_changed_callback
91-
return client
92-
end
93-
94-
# Create an instance of ConfigCatClient and setup Lazy Load mode with custom options
95-
#
96-
# :param sdk_key: ConfigCat SDK Key to access your configuration.
97-
# :param cache_time_to_live_seconds: The cache TTL.
98-
# :param config_cache: If you want to use custom caching instead of the client's default,
99-
# You can provide an implementation of ConfigCache.
100-
# :param base_url: You can set a base_url if you want to use a proxy server between your application and ConfigCat
101-
# :param proxy_address: Proxy address
102-
# :param proxy_port: Proxy port
103-
# :param proxy_user: username for proxy authentication
104-
# :param proxy_pass: password for proxy authentication
105-
# :param open_timeout_seconds: The number of seconds to wait for the server to make the initial connection. Default: 10 seconds.
106-
# :param read_timeout_seconds: The number of seconds to wait for the server to respond before giving up. Default: 30 seconds.
107-
# :param flag_overrides: A FlagOverrides implementation used to override feature flags & settings.
108-
# :param data_governance:
109-
# Default: Global. Set this parameter to be in sync with the Data Governance preference on the Dashboard:
110-
# https://app.configcat.com/organization/data-governance
111-
# (Only Organization Admins have access)
112-
def ConfigCat.create_client_with_lazy_load(sdk_key,
113-
cache_time_to_live_seconds: 60,
114-
config_cache: nil,
115-
base_url: nil,
116-
proxy_address: nil,
117-
proxy_port: nil,
118-
proxy_user: nil,
119-
proxy_pass: nil,
120-
open_timeout_seconds: 10,
121-
read_timeout_seconds: 30,
122-
flag_overrides: nil,
123-
data_governance: DataGovernance::GLOBAL)
124-
options = ConfigCatOptions.new(
125-
base_url: base_url,
126-
polling_mode: PollingMode.lazy_load(cache_refresh_interval_seconds: cache_time_to_live_seconds),
127-
config_cache: config_cache,
128-
proxy_address: proxy_address,
129-
proxy_port: proxy_port,
130-
proxy_user: proxy_user,
131-
proxy_pass: proxy_pass,
132-
open_timeout_seconds: open_timeout_seconds,
133-
read_timeout_seconds: read_timeout_seconds,
134-
flag_overrides: flag_overrides,
135-
data_governance: data_governance
136-
)
137-
ConfigCat.logger.warn('create_client_with_lazy_load is deprecated. Create the ConfigCat Client as a Singleton object with `configcatclient.get()` instead')
138-
client = ConfigCatClient.get(sdk_key, options)
139-
return client
140-
end
141-
142-
# Create an instance of ConfigCatClient and setup Manual Poll mode with custom options
143-
#
144-
# :param sdk_key: ConfigCat SDK Key to access your configuration.
145-
# :param config_cache: If you want to use custom caching instead of the client's default,
146-
# You can provide an implementation of ConfigCache.
147-
# :param base_url: You can set a base_url if you want to use a proxy server between your application and ConfigCat
148-
# :param proxy_address: Proxy address
149-
# :param proxy_port: Proxy port
150-
# :param proxy_user: username for proxy authentication
151-
# :param proxy_pass: password for proxy authentication
152-
# :param open_timeout_seconds: The number of seconds to wait for the server to make the initial connection. Default: 10 seconds.
153-
# :param read_timeout_seconds: The number of seconds to wait for the server to respond before giving up. Default: 30 seconds.
154-
# :param flag_overrides: A FlagOverrides implementation used to override feature flags & settings.
155-
# :param data_governance:
156-
# Default: Global. Set this parameter to be in sync with the Data Governance preference on the Dashboard:
157-
# https://app.configcat.com/organization/data-governance
158-
# (Only Organization Admins have access)
159-
def ConfigCat.create_client_with_manual_poll(sdk_key,
160-
config_cache: nil,
161-
base_url: nil,
162-
proxy_address: nil,
163-
proxy_port: nil,
164-
proxy_user: nil,
165-
proxy_pass: nil,
166-
open_timeout_seconds: 10,
167-
read_timeout_seconds: 30,
168-
flag_overrides: nil,
169-
data_governance: DataGovernance::GLOBAL)
170-
options = ConfigCatOptions.new(
171-
base_url: base_url,
172-
polling_mode: PollingMode.manual_poll(),
173-
config_cache: config_cache,
174-
proxy_address: proxy_address,
175-
proxy_port: proxy_port,
176-
proxy_user: proxy_user,
177-
proxy_pass: proxy_pass,
178-
open_timeout_seconds: open_timeout_seconds,
179-
read_timeout_seconds: read_timeout_seconds,
180-
flag_overrides: flag_overrides,
181-
data_governance: data_governance
182-
)
183-
ConfigCat.logger.warn('create_client_with_manual_poll is deprecated. Create the ConfigCat Client as a Singleton object with `configcatclient.get()` instead')
184-
client = ConfigCatClient.get(sdk_key, options)
185-
return client
186-
end
18727
end

lib/configcat/configcatclient.rb

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -146,52 +146,6 @@ def get_all_keys
146146
return settings.keys
147147
end
148148

149-
# Gets the Variation ID (analytics) of a feature flag or setting based on it's key.
150-
#
151-
# :param key [String] the identifier of the feature flag or setting.
152-
# :param default_variation_id in case of any failure, this value will be returned.
153-
# :param user [User] the user object to identify the caller.
154-
# :return the variation ID.
155-
def get_variation_id(key, default_variation_id, user = nil)
156-
ConfigCat.logger.warn("get_variation_id is deprecated and will be removed in a future major version. " \
157-
"Please use [get_value_details] instead.")
158-
159-
settings, fetch_time = _get_settings()
160-
if settings === nil
161-
message = "Config JSON is not present when evaluating setting '#{key}'. Returning the `default_variation_id` parameter that you specified in your application: '#{default_variation_id}'."
162-
@log.error(1000, message)
163-
@hooks.invoke_on_flag_evaluated(EvaluationDetails.from_error(key, nil, error: message,
164-
variation_id: default_variation_id))
165-
return default_variation_id
166-
end
167-
details = _evaluate(key, user, nil, default_variation_id, settings, fetch_time)
168-
return details.variation_id
169-
end
170-
171-
# Gets the Variation IDs (analytics) of all feature flags or settings.
172-
#
173-
# :param user [User] the user object to identify the caller.
174-
# :return list of variation IDs
175-
def get_all_variation_ids(user = nil)
176-
ConfigCat.logger.warn("get_all_variation_ids is deprecated and will be removed in a future major version. " \
177-
"Please use [get_value_details] instead.")
178-
179-
settings, _ = _get_settings()
180-
if settings === nil
181-
@log.error(1000, "Config JSON is not present. Returning empty list.")
182-
return []
183-
end
184-
185-
variation_ids = []
186-
for key in settings.keys
187-
variation_id = get_variation_id(key, nil, user)
188-
if !variation_id.equal?(nil)
189-
variation_ids.push(variation_id)
190-
end
191-
end
192-
return variation_ids
193-
end
194-
195149
# Gets the key of a setting, and it's value identified by the given Variation ID (analytics)
196150
#
197151
# :param variation_id [String] variation ID

lib/configcat/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module ConfigCat
2-
VERSION = "6.1.0"
2+
VERSION = "7.0.0"
33
end

spec/configcat/configcatclient_spec.rb

Lines changed: 4 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -211,51 +211,6 @@ def details_by_key(all_details, key)
211211
client.close
212212
end
213213

214-
it "test_default_user_get_variation_id" do
215-
client = ConfigCatClient.get('test', ConfigCatOptions.new(polling_mode: PollingMode.manual_poll,
216-
config_cache: ConfigCacheMock.new))
217-
user1 = User.new("test@test1.com")
218-
user2 = User.new("test@test2.com")
219-
220-
client.set_default_user(user1)
221-
expect(client.get_variation_id("testStringKey", "")).to eq("id1")
222-
expect(client.get_variation_id("testStringKey", "", user2)).to eq("id2")
223-
224-
client.clear_default_user
225-
expect(client.get_variation_id("testStringKey", "")).to eq("id")
226-
227-
client.close
228-
end
229-
230-
it "test_default_user_get_all_variation_ids" do
231-
client = ConfigCatClient.get('test', ConfigCatOptions.new(polling_mode: PollingMode.manual_poll,
232-
config_cache: ConfigCacheMock.new))
233-
user1 = User.new("test@test1.com")
234-
user2 = User.new("test@test2.com")
235-
236-
client.set_default_user(user1)
237-
result = client.get_all_variation_ids
238-
expect(result.length).to eq(3)
239-
expect(result).to include('id1')
240-
expect(result).to include('fakeId1')
241-
expect(result).to include('fakeId2')
242-
243-
result = client.get_all_variation_ids(user2)
244-
expect(result.length).to eq(3)
245-
expect(result).to include('id2')
246-
expect(result).to include('fakeId1')
247-
expect(result).to include('fakeId2')
248-
249-
client.clear_default_user
250-
result = client.get_all_variation_ids
251-
expect(result.length).to eq(3)
252-
expect(result).to include('id')
253-
expect(result).to include('fakeId1')
254-
expect(result).to include('fakeId2')
255-
256-
client.close
257-
end
258-
259214
it "test_online_offline" do
260215
stub_request = WebMock.stub_request(:get, Regexp.new('https://.*')).to_return(status: 200, body: TEST_OBJECT_JSON, headers: {})
261216

@@ -309,32 +264,22 @@ def details_by_key(all_details, key)
309264
it "test_get_variation_id" do
310265
client = ConfigCatClient.get("test", ConfigCatOptions.new(polling_mode: PollingMode.manual_poll,
311266
config_cache: ConfigCacheMock.new))
312-
expect(client.get_variation_id("key1", nil)).to eq "fakeId1"
313-
expect(client.get_variation_id("key2", nil)).to eq "fakeId2"
267+
expect(client.get_value_details("key1", nil).variation_id).to eq "fakeId1"
268+
expect(client.get_value_details("key2", nil).variation_id).to eq "fakeId2"
314269
client.close()
315270
end
316271

317272
it "test_get_variation_id_not_found" do
318273
client = ConfigCatClient.get("test", ConfigCatOptions.new(polling_mode: PollingMode.manual_poll,
319274
config_cache: ConfigCacheMock.new))
320-
expect(client.get_variation_id("nonexisting", "default_variation_id")).to eq "default_variation_id"
275+
expect(client.get_value_details("nonexisting", "default_value").variation_id).to be_nil
321276
client.close()
322277
end
323278

324279
it "test_get_variation_id_empty_config" do
325280
client = ConfigCatClient.get("test", ConfigCatOptions.new(polling_mode: PollingMode.manual_poll,
326281
config_cache: ConfigCacheMock.new))
327-
expect(client.get_variation_id("nonexisting", "default_variation_id")).to eq "default_variation_id"
328-
client.close()
329-
end
330-
331-
it "test_get_all_variation_ids" do
332-
client = ConfigCatClient.get("test", ConfigCatOptions.new(polling_mode: PollingMode.manual_poll,
333-
config_cache: ConfigCacheMock.new))
334-
result = client.get_all_variation_ids()
335-
expect(result.size).to eq 3
336-
expect(result.include?("fakeId1")).to eq true
337-
expect(result.include?("fakeId2")).to eq true
282+
expect(client.get_value_details("nonexisting", "default_value").variation_id).to be_nil
338283
client.close()
339284
end
340285

0 commit comments

Comments
 (0)