optify-config 1.3.1-x86_64-linux → 1.4.0-x86_64-linux

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: 4f1dc7c9ef84b4fe1e0f9e97e5903aaa1cf1c8a44f526e754368de722210bdc7
4
- data.tar.gz: 7ba2ce83316437cf46beb1bbebb7ce3bdf822c0c076d8be4fe9fa581fdd6b8ba
3
+ metadata.gz: 34d4942fdd16516b838755a6588d185813b39895287972000ea72919249c8349
4
+ data.tar.gz: aa1a4f179fe266262a52d60b5805d825b377b512bfd74d9f0647601bcff1049b
5
5
  SHA512:
6
- metadata.gz: 92016a7ad735204fe73d56e2a53c2028afd5d159d9f7a5c5d0b888f3abac2a2272beb70de977496f3b277c42295ddae914553bbc64f429763575cc6a5ede3a31
7
- data.tar.gz: ff6fe6b43d700d400d225a46cb7ffad49687a7daba2949497daf2923a12420ec93a7bfe1961c390e0967dc2252d5244cf3359c0d0bf956bbfb1c79312ee065d0
6
+ metadata.gz: 01ee18fceeaff83882ceb2d14eb77da5e2804355cd47c4c138789806cc34e707472d03ff5c594b29d063f0509f3ed4fdab684b270be30733f7d9e1691917e777
7
+ data.tar.gz: d5546a15c032e7149646aedbc52449c73858e253c6c7d754b1df96ea2489ea18fb4253ba1e4880c3fb0da5dc5fc7b2080ccd14df42a8a0d61119491089ab8656
data/lib/optify.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  # typed: strict
3
3
 
4
4
  # The implementation to use directly Ruby and with types declared.
5
+ require_relative 'optify_ruby/get_options_preferences'
5
6
  require_relative 'optify_ruby/implementation'
6
7
  require_relative 'optify_ruby/watcher_implementation'
7
8
 
Binary file
Binary file
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+ # typed: strict
3
+
4
+ module Optify
5
+ # Preferences for `get_options`.
6
+ class GetOptionsPreferences
7
+ # @param overrides [Hash]
8
+ #: (Hash[untyped, untyped] overrides) -> void
9
+ def overrides=(overrides)
10
+ self.overrides_json = overrides.to_json
11
+ end
12
+ end
13
+ end
@@ -87,6 +87,11 @@ module Optify
87
87
  # Cache directly in Ruby instead of Rust because:
88
88
  # * Avoid any possible conversion overhead.
89
89
  # * Memory management: probably better to do it in Ruby for a Ruby app and avoid memory in Rust.
90
+ if preferences&.overrides?
91
+ Kernel.raise ArgumentError,
92
+ 'Caching when overrides are given is not supported. Do not pass cache options when using overrides in preferences.'
93
+ end
94
+
90
95
  init unless @cache
91
96
  unless preferences&.skip_feature_name_conversion
92
97
  # When there are just a few names, then it can be faster to convert them one by one in a loop to avoid working with an array in Rust.
@@ -98,6 +103,7 @@ module Optify
98
103
  result = @cache&.fetch(cache_key, NOT_FOUND_IN_CACHE_SENTINEL)
99
104
  return result unless result.equal?(NOT_FOUND_IN_CACHE_SENTINEL)
100
105
 
106
+ # TODO: Copy the preferences to avoid mutating the original object.
101
107
  preferences ||= GetOptionsPreferences.new
102
108
  preferences.skip_feature_name_conversion = true
103
109
  result = get_options(key, feature_names, config_class, nil, preferences)
data/rbi/optify.rbi CHANGED
@@ -43,8 +43,25 @@ module Optify
43
43
 
44
44
  # Preferences when getting options.
45
45
  class GetOptionsPreferences
46
- sig { params(value: T::Boolean).returns(GetOptionsPreferences) }
46
+ # Indicates if overrides are set.
47
+ sig { returns(T::Boolean) }
48
+ def overrides?; end
49
+
50
+ # Set overrides to apply after building the options based on the feature names.
51
+ # Do not provide overrides when requesting cached options.
52
+ # @param value The overrides to apply.
53
+ sig { params(value: T.nilable(T::Hash[T.untyped, T.untyped])).void }
54
+ def overrides=(value); end
55
+
56
+ # Set overrides to apply after building the options based on the feature names.
57
+ # Do not provide overrides when requesting cached options.
58
+ # @param value The overrides to apply as serialized JSON.
59
+ sig { params(value: T.nilable(String)).void }
60
+ def overrides_json=(value); end
61
+
62
+ sig { params(value: T::Boolean).void }
47
63
  def skip_feature_name_conversion=(value); end
64
+
48
65
  sig { returns(T::Boolean) }
49
66
  def skip_feature_name_conversion; end
50
67
  end
data/sig/optify.rbs CHANGED
@@ -35,7 +35,20 @@ end
35
35
 
36
36
  # Preferences when getting options.
37
37
  class Optify::GetOptionsPreferences
38
- def skip_feature_name_conversion=: (bool value) -> GetOptionsPreferences
38
+ # Indicates if overrides are set.
39
+ def overrides?: () -> bool
40
+
41
+ # Set overrides to apply after building the options based on the feature names.
42
+ # Do not provide overrides when requesting cached options.
43
+ # @param value The overrides to apply.
44
+ def overrides=: (::Hash[untyped, untyped]? value) -> void
45
+
46
+ # Set overrides to apply after building the options based on the feature names.
47
+ # Do not provide overrides when requesting cached options.
48
+ # @param value The overrides to apply as serialized JSON.
49
+ def overrides_json=: (String? value) -> void
50
+
51
+ def skip_feature_name_conversion=: (bool value) -> void
39
52
 
40
53
  def skip_feature_name_conversion: () -> bool
41
54
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optify-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Justin D. Harris
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-05-08 00:00:00.000000000 Z
11
+ date: 2025-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sorbet-runtime
@@ -106,6 +106,7 @@ files:
106
106
  - lib/optify_ruby/3.2/optify_ruby.so
107
107
  - lib/optify_ruby/3.4/optify_ruby.so
108
108
  - lib/optify_ruby/base_config.rb
109
+ - lib/optify_ruby/get_options_preferences.rb
109
110
  - lib/optify_ruby/implementation.rb
110
111
  - lib/optify_ruby/options_metadata.rb
111
112
  - lib/optify_ruby/provider_module.rb