sdk-reforge 1.9.1 → 1.10.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c9d01ab174a9a1de737bd5791203b24fe2b4e4edc029497233e704a3475f17f
4
- data.tar.gz: 21a6556498ae0131164663d297890669b100ae3dccdaf6575a7e17b996ef988b
3
+ metadata.gz: a8f8071f99c74c0f8b10bebefcb3a15042b2276797e3696be3e8dbf16b0ce446
4
+ data.tar.gz: d51548a473a3fced6a34ca2f66453572c11c376c209178a5bdcfc3c3581a92b5
5
5
  SHA512:
6
- metadata.gz: 2c6b7c7f36252e0e9434dc77a82ffc043c39f6085b405440a988ae2b8145ca127b90eaceca1b07d63ffa66d5cded48477d53fb9b2178a9afc5825966ec2d4724
7
- data.tar.gz: f662153d281cce2fa52dbc4e8e7ad0c5864c896168a403900ca621f9e691a1e84c72c70186342b613bda714638c368c8e51074a5388f8d1a2ab542d47eff1755
6
+ metadata.gz: 92a6bbc060c11f39c99c28d6b5577049a8b7a379d6edf29408bdd40a5d78c9c6527922bc62970127cff4d3ad6373109672e4305229f0edd155aaaf5b75debc78
7
+ data.tar.gz: 4ce7e08d5789756af12148ef0921674f8c5d1bebca92b33100c888d0ee646a87de47fa5ca68a50b0543b76dab69a054eb81bc244bf64e70cda3197fae17544b9
@@ -21,6 +21,7 @@ jobs:
21
21
 
22
22
  runs-on: ubuntu-latest
23
23
  strategy:
24
+ fail-fast: false
24
25
  matrix:
25
26
  ruby-version: ['3.1','3.2','3.3','3.4']
26
27
 
data/.rubocop.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  AllCops:
2
2
  NewCops: enable
3
3
  Exclude:
4
- - prefab-cloud-ruby.gemspec
4
+ - sdk-reforge.gemspec
5
5
  - lib/prefab_pb.rb
6
6
 
7
7
  Metrics:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.10.0 - 2025-10-02
4
+
5
+ - require `base64` for newest ruby versions
6
+ - look for `REFORGE_BACKEND_SDK_KEY` and `REFORGE_DATAFILE`
7
+
8
+ ## 1.9.2 - 2025-10-02
9
+
10
+ - Fix bug in row index calculation for the evaluation summary data
11
+
3
12
  ## 1.9.1 - 2025-10-01
4
13
 
5
14
  - Fix entrypoint
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Ruby Client for Reforge Feature Flags and Config as a Service: https://launch.reforge.com
4
4
 
5
5
  ```ruby
6
- client = Reforge::Client.new
6
+ Reforge.init
7
7
 
8
8
  context = {
9
9
  user: {
@@ -14,12 +14,12 @@ context = {
14
14
  }
15
15
  }
16
16
 
17
- result = client.enabled? "my-first-feature-flag", context
17
+ result = Reforge.enabled? "my-first-feature-flag", context
18
18
 
19
19
  puts "my-first-feature-flag is: #{result}"
20
20
  ```
21
21
 
22
- See full documentation https://docs.prefab.cloud/docs/sdks/ruby
22
+ See full documentation https://docs.reforge.com/docs/sdks/ruby
23
23
 
24
24
  ## Supports
25
25
 
@@ -47,7 +47,7 @@ Many ruby web servers fork. When the process is forked, the current realtime upd
47
47
 
48
48
  ```ruby
49
49
  #config/application.rb
50
- Prefab.init # reads REFORGE_SDK_KEY env var by default
50
+ Reforge.init # reads REFORGE_BACKEND_SDK_KEY env var by default
51
51
  ```
52
52
 
53
53
  ```ruby
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.9.1
1
+ 1.10.0
@@ -80,10 +80,6 @@ module Reforge
80
80
  )
81
81
  end
82
82
 
83
- def set_rails_loggers
84
- warn '[DEPRECATION] `set_rails_loggers` is deprecated since 1.6. Please use semantic_logger or `Prefab.log_filter` instead.'
85
- end
86
-
87
83
  def on_update(&block)
88
84
  resolver.on_update(&block)
89
85
  end
@@ -227,11 +227,23 @@ module Reforge
227
227
  row.values.each_with_index do |conditional_value, value_index|
228
228
  next unless all_criteria_match?(conditional_value, properties)
229
229
 
230
+ # we compute the row index here as if the @config.rows were sorted with the default environment (id=0) last. the client would only ever see one or two rows
231
+ # 2 rows if there's a default env rule and a targed env rule
232
+ # 1 row if there's only a default env rule or only a target env rule
233
+ config_row_index = if @config.rows.length == 1
234
+ 0
235
+ elsif row.project_env_id != 0
236
+ 0
237
+ else
238
+ 1
239
+ end
240
+
241
+
230
242
  return Reforge::Evaluation.new(
231
243
  config: @config,
232
244
  value: conditional_value.value,
233
245
  value_index: value_index,
234
- config_row_index: index,
246
+ config_row_index: config_row_index,
235
247
  context: properties,
236
248
  resolver: @resolver
237
249
  )
@@ -5,7 +5,7 @@ module Reforge
5
5
  class InvalidSdkKeyError < Reforge::Error
6
6
  def initialize(key)
7
7
  if key.nil? || key.empty?
8
- message = 'No SDK key. Set REFORGE_SDK_KEY env var or use PREFAB_DATASOURCES=LOCAL_ONLY'
8
+ message = 'No SDK key. Set REFORGE_BACKEND_SDK_KEY env var or use REFORGE_DATAFILE'
9
9
 
10
10
  super(message)
11
11
  else
@@ -46,7 +46,7 @@ module Reforge
46
46
 
47
47
  private def init(
48
48
  sources: nil,
49
- sdk_key: ENV['SDK_API_KEY'] || ENV['PREFAB_API_KEY'],
49
+ sdk_key: ENV['REFORGE_BACKEND_SDK_KEY'] || ENV['PREFAB_API_KEY'],
50
50
  namespace: '',
51
51
  reforge_api_url: nil,
52
52
  on_no_default: ON_NO_DEFAULT::RAISE, # options :raise, :warn_and_return_nil,
@@ -61,7 +61,7 @@ module Reforge
61
61
  collect_evaluation_summaries: true,
62
62
  collect_max_evaluation_summaries: DEFAULT_MAX_EVAL_SUMMARIES,
63
63
  allow_telemetry_in_local_mode: false,
64
- datafile: ENV['PREFAB_DATAFILE'],
64
+ datafile: ENV['REFORGE_DATAFILE'] || ENV['PREFAB_DATAFILE'],
65
65
  x_datafile: nil, # DEPRECATED in favor of `datafile`
66
66
  x_use_local_cache: false,
67
67
  symbolize_json_names: false,
@@ -7,7 +7,7 @@ module Reforge
7
7
 
8
8
  def self.init(options = Reforge::Options.new)
9
9
  unless @singleton.nil?
10
- LOG.warn 'Prefab already initialized.'
10
+ LOG.warn 'Reforge already initialized.'
11
11
  return @singleton
12
12
  end
13
13
 
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
+ require 'base64'
2
3
 
3
4
  module Reforge
4
- class SSEConfigClient
5
+ class SSEConfigClient
5
6
  class Options
6
7
  attr_reader :sse_read_timeout, :seconds_between_new_connection,
7
8
  :sse_default_reconnect_time, :sleep_delay_for_new_connection_check,
data/sdk-reforge.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: sdk-reforge 1.9.1 ruby lib
5
+ # stub: sdk-reforge 1.10.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "sdk-reforge".freeze
9
- s.version = "1.9.1"
9
+ s.version = "1.10.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Jeff Dwyer".freeze]
14
- s.date = "2025-10-01"
14
+ s.date = "2025-10-02"
15
15
  s.description = "Feature Flags, Live Config as a service".freeze
16
16
  s.email = "jeff.dwyer@reforge.com.cloud".freeze
17
17
  s.extra_rdoc_files = [
@@ -102,7 +102,7 @@ module CommonHelpers
102
102
 
103
103
  FakeResponse = Struct.new(:status, :body)
104
104
 
105
- def wait_for(condition, max_wait: 2, sleep_time: 0.01)
105
+ def wait_for(condition, max_wait: 10, sleep_time: 0.01)
106
106
  wait_time = 0
107
107
  while !condition.call
108
108
  wait_time += sleep_time
@@ -137,7 +137,21 @@ module CommonHelpers
137
137
  def assert_summary(client, data)
138
138
  raise 'Evaluation summary aggregator not enabled' unless client.evaluation_summary_aggregator
139
139
 
140
- assert_equal data, client.evaluation_summary_aggregator.data
140
+ actual = client.evaluation_summary_aggregator.data
141
+
142
+ # Compare keys first (order independent)
143
+ assert_equal data.keys.sort_by(&:to_s), actual.keys.sort_by(&:to_s), "Summary keys mismatch"
144
+
145
+ # Then compare each nested hash (order independent)
146
+ data.each do |key, expected_counters|
147
+ actual_counters = actual[key]
148
+
149
+ # Convert to sets for order-independent comparison
150
+ expected_set = expected_counters.to_a.to_set
151
+ actual_set = actual_counters.to_a.to_set
152
+
153
+ assert_equal expected_set, actual_set, "Counter mismatch for #{key}"
154
+ end
141
155
  end
142
156
 
143
157
  def assert_example_contexts(client, data)
data/test/test_client.rb CHANGED
@@ -106,7 +106,7 @@ class TestClient < Minitest::Test
106
106
  [KEY, :CONFIG] => {
107
107
  {
108
108
  config_id: config.id,
109
- config_row_index: 1,
109
+ config_row_index: 0,
110
110
  selected_value: DESIRED_VALUE_CONFIG,
111
111
  conditional_value_index: 0,
112
112
  weighted_value_index: nil,
@@ -131,7 +131,7 @@ class TestClient < Minitest::Test
131
131
  [KEY, :CONFIG] => {
132
132
  {
133
133
  config_id: config.id,
134
- config_row_index: 1,
134
+ config_row_index: 0,
135
135
  selected_value: DESIRED_VALUE_CONFIG,
136
136
  conditional_value_index: 0,
137
137
  weighted_value_index: nil,
@@ -181,7 +181,7 @@ class TestClient < Minitest::Test
181
181
  [KEY, :CONFIG] => {
182
182
  {
183
183
  config_id: config.id,
184
- config_row_index: 1,
184
+ config_row_index: 0,
185
185
  selected_value: PrefabProto::ConfigValue.new(string: 'abc'),
186
186
  conditional_value_index: 0,
187
187
  weighted_value_index: 0,
@@ -190,7 +190,7 @@ class TestClient < Minitest::Test
190
190
 
191
191
  {
192
192
  config_id: config.id,
193
- config_row_index: 1,
193
+ config_row_index: 0,
194
194
  selected_value: PrefabProto::ConfigValue.new(string: 'def'),
195
195
  conditional_value_index: 0,
196
196
  weighted_value_index: 1,
@@ -199,7 +199,7 @@ class TestClient < Minitest::Test
199
199
 
200
200
  {
201
201
  config_id: config.id,
202
- config_row_index: 1,
202
+ config_row_index: 0,
203
203
  selected_value: PrefabProto::ConfigValue.new(string: 'ghi'),
204
204
  conditional_value_index: 0,
205
205
  weighted_value_index: 2,
@@ -278,9 +278,9 @@ class TestClient < Minitest::Test
278
278
  weighted_value_index: nil, selected_index: nil } => 1
279
279
  },
280
280
  [KEY, :NOT_SET_CONFIG_TYPE] => {
281
- { config_id: 0, config_row_index: 0, conditional_value_index: 0, selected_value: DEFAULT_VALUE_CONFIG,
281
+ { config_id: 0, config_row_index: 1, conditional_value_index: 0, selected_value: DEFAULT_VALUE_CONFIG,
282
282
  weighted_value_index: nil, selected_index: nil } => 2,
283
- { config_id: 0, config_row_index: 1, conditional_value_index: 0, selected_value: DESIRED_VALUE_CONFIG,
283
+ { config_id: 0, config_row_index: 0, conditional_value_index: 0, selected_value: DESIRED_VALUE_CONFIG,
284
284
  weighted_value_index: nil, selected_index: nil } => 1
285
285
  }
286
286
  }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdk-reforge
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Dwyer
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-10-01 00:00:00.000000000 Z
10
+ date: 2025-10-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: concurrent-ruby