optify-config 1.15.2-arm64-darwin → 1.16.1-arm64-darwin

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: 9a0c1fbad5bbf75a91223091a05241e3328f4863b82be6b614697c456febfef7
4
- data.tar.gz: 8bd0c840eaa52325e39b857b05eb80a4db9083c98f79f07041bdf96d30287c1c
3
+ metadata.gz: a14f2876dd13f7c71a874930c897ba31460c81460b12865433a4941e1c8dc3e1
4
+ data.tar.gz: aeadb9a296e169a5e48789be5d550b5a60a69698b2b66e756f8a1b916f485d35
5
5
  SHA512:
6
- metadata.gz: 17d3c8d8a6bd9edaceb34171fcb0745147ddf8568a89b688e59c45de72638abb5a2022531fdeca6bfbdf5e178777e839fca1a069888964f246da2bacc6b0281d
7
- data.tar.gz: 47068d0497f5e9281180dd6d74207b85079da7fc422f10a54cced951b00d54e59727e063a1ccfd9f64f3ff56b4c3cbe43189f4d6fc145399c6eb2897b55cacdb
6
+ metadata.gz: 26a3f2ae7f88b07fd50f31fcf7d2b3c7e93f2d1ef7004ec160d92d21247672f5af1dba65e98acde006793303e30f038ec8449192a3efc12710b3a3e665d28fe2
7
+ data.tar.gz: 30735a598f9e63cef63ad721f6184fd71d1c350e610ab66b65f4f4c050e47f89f56dc2a68e3e0e553f4d733ed4660823d099d6c2dd3a475d2cc892039a011628
data/lib/optify.rb CHANGED
@@ -15,7 +15,7 @@ require_relative 'optify_ruby/watcher_implementation'
15
15
  # but that doesn't work when building for multiple versions of Ruby.
16
16
  # So we have to do this which is similar to something from 'https://github.com/matsadler/halton-rb/blob/main/lib/halton.rb'.
17
17
  begin
18
- ruby_version = T.must(RUBY_VERSION.match(/\d+\.\d+/))[0]
18
+ ruby_version = RUBY_VERSION.match(/\d+\.\d+/)&.[](0)
19
19
  require_relative "optify_ruby/#{ruby_version}/optify_ruby"
20
20
  rescue LoadError
21
21
  begin
Binary file
Binary file
@@ -6,8 +6,6 @@ require 'sorbet-runtime'
6
6
  module Optify
7
7
  # @!visibility private
8
8
  module ProviderModule
9
- extend T::Sig
10
-
11
9
  #: (Array[String] feature_names) -> Array[String]
12
10
  def get_canonical_feature_names(feature_names)
13
11
  # Try to optimize a typical case where there are just a few features.
@@ -40,7 +38,7 @@ module Optify
40
38
  end
41
39
  result.freeze
42
40
 
43
- @features_with_metadata = T.let(result, T.nilable(T::Hash[String, OptionsMetadata]))
41
+ @features_with_metadata = result
44
42
  result
45
43
  end
46
44
 
@@ -71,13 +69,14 @@ module Optify
71
69
  get_options_json(key, feature_names)
72
70
  end
73
71
  hash = JSON.parse(options_json)
74
- T.unsafe(config_class).from_hash(hash)
72
+ config_class #: as untyped
73
+ .from_hash(hash)
75
74
  end
76
75
 
77
76
  #: -> void
78
77
  def _init
79
- @cache = T.let({}, T.nilable(T::Hash[T.untyped, T.untyped]))
80
- @features_with_metadata = T.let(nil, T.nilable(T::Hash[String, OptionsMetadata]))
78
+ @cache = {} #: Hash[untyped, untyped]?
79
+ @features_with_metadata = nil #: Hash[String, OptionsMetadata]?
81
80
  end
82
81
 
83
82
  NOT_FOUND_IN_CACHE_SENTINEL = Object.new
@@ -93,28 +92,31 @@ module Optify
93
92
  end
94
93
 
95
94
  init unless @cache
96
- feature_names = get_canonical_feature_names(feature_names) unless preferences&.skip_feature_name_conversion
97
95
 
98
- cache_key = [key, feature_names, preferences&.constraints_json, config_class]
99
- result = @cache&.fetch(cache_key, NOT_FOUND_IN_CACHE_SENTINEL)
96
+ if preferences.nil?
97
+ feature_names = get_filtered_features(feature_names, GetOptionsPreferences.new)
98
+ elsif !preferences.skip_feature_name_conversion || preferences.constraints_json
99
+ feature_names = get_filtered_features(feature_names, preferences)
100
+ end
101
+
102
+ # Features are filtered, so we don't need the constraints in the cache key.
103
+ cache_key = [key, feature_names, config_class]
104
+ result = @cache #: as !nil
105
+ .fetch(cache_key, NOT_FOUND_IN_CACHE_SENTINEL)
100
106
  return result unless result.equal?(NOT_FOUND_IN_CACHE_SENTINEL)
101
107
 
102
108
  # Handle a cache miss.
103
109
 
104
- # We can avoid converting the features names because they're already converted, if that was desired.
105
- if preferences.nil?
106
- preferences = GetOptionsPreferences.new
107
- preferences.skip_feature_name_conversion = true
108
- else
109
- # Indeed the copying of preferences could be wasteful, but this only happens on a cache miss
110
- # and when no custom preferences are provided.
111
- preferences = preferences.dup
112
- preferences.skip_feature_name_conversion = true
113
- end
110
+ # We can avoid converting the features names because they're already converted from filtering above, if that was desired.
111
+ # We don't need the constraints because we filtered the features above.
112
+ # We already know there are no overrides because we checked above.
113
+ preferences = GetOptionsPreferences.new
114
+ preferences.skip_feature_name_conversion = true
114
115
 
115
116
  result = get_options(key, feature_names, config_class, nil, preferences)
116
117
 
117
- T.must(@cache)[cache_key] = result
118
+ @cache #: as !nil
119
+ .[]= cache_key, result
118
120
  end
119
121
  end
120
122
  end
@@ -33,7 +33,7 @@ module Optify
33
33
  #: -> OptionsWatcher
34
34
  def init
35
35
  _init
36
- @cache_creation_time = T.let(Time.now, T.nilable(Time))
36
+ @cache_creation_time = Time.now #: Time?
37
37
  self
38
38
  end
39
39
 
data/rbi/optify.rbi CHANGED
@@ -183,6 +183,18 @@ module Optify
183
183
  sig { params(canonical_feature_name: String).returns(T.nilable(OptionsMetadata)) }
184
184
  def get_feature_metadata(canonical_feature_name); end
185
185
 
186
+ # Filters `feature_names` based on the preferences,
187
+ # such as the `preferences`'s constraints.
188
+ # Also converts the feature names to canonical feature names if `preferences.skip_feature_name_conversion` is `false`.
189
+ sig do
190
+ params(
191
+ feature_names: T::Array[String],
192
+ preferences: GetOptionsPreferences
193
+ )
194
+ .returns(T::Array[String])
195
+ end
196
+ def get_filtered_features(feature_names, preferences); end
197
+
186
198
  # Fetches options based on the provided key and feature names.
187
199
  #
188
200
  # @param key The key to fetch options for.
data/sig/optify.rbs CHANGED
@@ -142,6 +142,8 @@ module Optify::ProviderModule
142
142
  # @return The metadata for the feature.
143
143
  def get_feature_metadata: (String canonical_feature_name) -> OptionsMetadata?
144
144
 
145
+ def get_filtered_features: (::Array[String] feature_names, GetOptionsPreferences preferences) -> ::Array[String]
146
+
145
147
  def get_options: [Config] (String key, ::Array[String] feature_names, T::Class[Config] config_class, ?CacheOptions? cache_options, ?Optify::GetOptionsPreferences? preferences) -> Config
146
148
 
147
149
  # Fetches options in JSON format based on the provided key and feature names.
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optify-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.15.2
4
+ version: 1.16.1
5
5
  platform: arm64-darwin
6
6
  authors:
7
7
  - Justin D. Harris
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-09-03 00:00:00.000000000 Z
11
+ date: 2025-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sorbet-runtime
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0.5'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: 0.6.12477
22
+ version: '1'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '0.5'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: 0.6.12477
32
+ version: '1'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rake-compiler
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -56,16 +62,22 @@ dependencies:
56
62
  name: sorbet
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - "~>"
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0.5'
68
+ - - "<"
60
69
  - !ruby/object:Gem::Version
61
- version: 0.6.12477
70
+ version: '1'
62
71
  type: :development
63
72
  prerelease: false
64
73
  version_requirements: !ruby/object:Gem::Requirement
65
74
  requirements:
66
- - - "~>"
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0.5'
78
+ - - "<"
67
79
  - !ruby/object:Gem::Version
68
- version: 0.6.12477
80
+ version: '1'
69
81
  - !ruby/object:Gem::Dependency
70
82
  name: tapioca
71
83
  requirement: !ruby/object:Gem::Requirement