optify-config 1.20.2 → 1.21.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: f7335de5a2522eb56b0b3a4c2ef2540eb975e4e0f10301b682c61d7b5bbab5a3
4
- data.tar.gz: 6de81291c19127c46ed8930d293e11454f4976dc70886cae002e603ae162a74a
3
+ metadata.gz: 0f5aba57c1908b188670d8868f281564791a273f3de0a118621d7205f4d808d9
4
+ data.tar.gz: 908bb31b5563fba2d0a2cee76b2fcc25add2264adf15a3c64e9972b326999be1
5
5
  SHA512:
6
- metadata.gz: d542032a0a6737744093a1b00e80e1023dd950215b6dc40d5624a028427a7261719300e5aa29757bfa9d162ec166007d296fc006a98e477948923ac2b4d2aa01
7
- data.tar.gz: b9b6e49156a7c133f20fbc60278e52a6858b2fda19537e4014089f30081a17fa271e4ba78d70b9353138036a3dad00e2ba0e05c626387dec529e7bd277363654
6
+ metadata.gz: 3d2c67fd5590b716289ba4868e6d08c6c9ce8e9f9735838d636f770f275e105710cc136080a9a7714b9cd9c2df991f5c11c4a01808378d325a52d74f831b282a
7
+ data.tar.gz: 2393060b4834d29505a8a8ad4f683ca56031e335a02746551ea4cc00ec149de4ee283a280554383e384c0ca0bf4c7286617170641cdeea0be064833cef338114
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "optify_ruby"
3
- version = "0.22.1"
3
+ version = "0.23.0"
4
4
  edition = "2021"
5
5
 
6
6
  description = "optify bindings for Ruby"
@@ -21,6 +21,7 @@ crate-type = ["cdylib"]
21
21
 
22
22
  [dependencies]
23
23
  magnus = "0.8.2"
24
- optify = "0.20.5"
24
+ # Can't put a relative path here because then others can't install the source gem: https://github.com/juharris/optify/pull/176
25
+ optify = "0.21.0"
25
26
  rb-sys = { version = "0.9.124", default-features = false, features = ["ruby-static"] }
26
27
  serde_json = "1.0.143"
@@ -290,6 +290,23 @@ impl WrappedOptionsProvider {
290
290
  fn has_conditions(&self, canonical_feature_name: String) -> bool {
291
291
  self.0.borrow().has_conditions(&canonical_feature_name)
292
292
  }
293
+
294
+ fn map_feature_names(
295
+ ruby: &Ruby,
296
+ rb_self: &Self,
297
+ feature_names: Vec<String>,
298
+ preferences: &MutGetOptionsPreferences,
299
+ ) -> Result<Vec<Option<String>>, magnus::Error> {
300
+ let preferences = &convert_preferences(preferences);
301
+ match rb_self
302
+ .0
303
+ .borrow()
304
+ .map_feature_names(&feature_names, Some(preferences))
305
+ {
306
+ Ok(features) => Ok(features),
307
+ Err(e) => Err(map_feature_error(ruby, e)),
308
+ }
309
+ }
293
310
  }
294
311
 
295
312
  #[derive(Clone)]
@@ -538,6 +555,23 @@ impl WrappedOptionsWatcher {
538
555
  fn last_modified(&self) -> std::time::SystemTime {
539
556
  self.0.borrow().last_modified()
540
557
  }
558
+
559
+ fn map_feature_names(
560
+ ruby: &Ruby,
561
+ rb_self: &Self,
562
+ feature_names: Vec<String>,
563
+ preferences: &MutGetOptionsPreferences,
564
+ ) -> Result<Vec<Option<String>>, magnus::Error> {
565
+ let preferences = &convert_preferences(preferences);
566
+ match rb_self
567
+ .0
568
+ .borrow()
569
+ .map_feature_names(&feature_names, Some(preferences))
570
+ {
571
+ Ok(features) => Ok(features),
572
+ Err(e) => Err(map_feature_error(ruby, e)),
573
+ }
574
+ }
541
575
  }
542
576
 
543
577
  #[derive(Clone)]
@@ -643,6 +677,10 @@ fn init(ruby: &Ruby) -> Result<(), magnus::Error> {
643
677
  "conditions?",
644
678
  method!(WrappedOptionsProvider::has_conditions, 1),
645
679
  )?;
680
+ provider_class.define_method(
681
+ "map_feature_names",
682
+ method!(WrappedOptionsProvider::map_feature_names, 2),
683
+ )?;
646
684
 
647
685
  // Private methods for internal use.
648
686
  provider_class.define_private_method(
@@ -782,6 +820,10 @@ fn init(ruby: &Ruby) -> Result<(), magnus::Error> {
782
820
  "last_modified",
783
821
  method!(WrappedOptionsWatcher::last_modified, 0),
784
822
  )?;
823
+ watcher_class.define_method(
824
+ "map_feature_names",
825
+ method!(WrappedOptionsWatcher::map_feature_names, 2),
826
+ )?;
785
827
 
786
828
  // Private methods for internal use.
787
829
  watcher_class.define_private_method(
@@ -23,7 +23,7 @@ module Optify
23
23
 
24
24
  # Initializes the cache options.
25
25
  # Defaults to a non-thread-safe unlimited size cache for backwards compatibility
26
- # with how this library was originally configured with an unbounded hash as the case.
26
+ # with how this library was originally configured with an unbounded hash as the base.
27
27
  # @param mode A value from `CacheMode`.
28
28
  #
29
29
  #: (
data/rbi/optify.rbi CHANGED
@@ -43,7 +43,7 @@ module Optify
43
43
 
44
44
  # Initializes the cache options.
45
45
  # Defaults to a non-thread-safe unlimited size cache for backwards compatibility
46
- # with how this library was originally configured with an unbounded hash as the case.
46
+ # with how this library was originally configured with an unbounded hash as the base.
47
47
  # @param mode A value from `CacheMode`.
48
48
  sig do
49
49
  params(
@@ -196,6 +196,15 @@ module Optify
196
196
  # Some of the methods shown within this module are implemented in Rust
197
197
  # and are declared in this common module to avoid duplicate declarations in different classes.
198
198
  module ProviderModule
199
+ # @param canonical_feature_name [String] A canonical feature name
200
+ # @return Whether the feature has conditions.
201
+ sig { params(canonical_feature_name: String).returns(T::Boolean) }
202
+ def conditions?(canonical_feature_name); end
203
+
204
+ # @return All of the keys and values for the the features.
205
+ sig { returns(String) }
206
+ def features_with_metadata_json; end
207
+
199
208
  # Map an alias or canonical feature name (perhaps derived from a file name) to a canonical feature name.
200
209
  # Canonical feature names map to themselves.
201
210
  #
@@ -292,11 +301,6 @@ module Optify
292
301
  end
293
302
  def get_options_json_with_preferences(key, feature_names, preferences); end
294
303
 
295
- # @param canonical_feature_name [String] A canonical feature name
296
- # @return Whether the feature has conditions.
297
- sig { params(canonical_feature_name: String).returns(T::Boolean) }
298
- def conditions?(canonical_feature_name); end
299
-
300
304
  # (Optional) Eagerly initializes the cache.
301
305
  # @return `self`.
302
306
  sig do
@@ -305,6 +309,18 @@ module Optify
305
309
  end
306
310
  def init(cache_init_options = nil); end
307
311
 
312
+ # Filters `feature_names` based on the preferences,
313
+ # such as the `preferences`'s constraints.
314
+ # Returns an array matching the input order where each element is the canonical name if the feature was kept, or nil if it was filtered out.
315
+ sig do
316
+ params(
317
+ feature_names: T::Array[String],
318
+ preferences: GetOptionsPreferences,
319
+ )
320
+ .returns(T::Array[T.nilable(String)])
321
+ end
322
+ def map_feature_names(feature_names, preferences); end
323
+
308
324
  private
309
325
 
310
326
  # Map aliases or canonical feature names (perhaps derived from a file names) to the canonical feature names.
@@ -319,10 +335,6 @@ module Optify
319
335
  # @return The metadata for the feature.
320
336
  sig { params(canonical_feature_name: String).returns(T.nilable(String)) }
321
337
  def get_feature_metadata_json(canonical_feature_name); end
322
-
323
- # @return All of the keys and values for the the features.
324
- sig { returns(String) }
325
- def features_with_metadata_json; end
326
338
  end
327
339
 
328
340
  # Provides configurations based on keys and enabled feature names.
data/sig/optify.rbs CHANGED
@@ -139,6 +139,13 @@ end
139
139
  # Some of the methods shown within this module are implemented in Rust
140
140
  # and are declared in this common module to avoid duplicate declarations in different classes.
141
141
  module Optify::ProviderModule
142
+ # @param canonical_feature_name [String] A canonical feature name
143
+ # @return Whether the feature has conditions.
144
+ def conditions?: (String canonical_feature_name) -> bool
145
+
146
+ # @return All of the keys and values for the the features.
147
+ def features_with_metadata_json: () -> String
148
+
142
149
  # Map an alias or canonical feature name (perhaps derived from a file name) to a canonical feature name.
143
150
  # Canonical feature names map to themselves.
144
151
  #
@@ -179,12 +186,10 @@ module Optify::ProviderModule
179
186
 
180
187
  def get_options_json_with_preferences: (String key, ::Array[String] feature_names, GetOptionsPreferences preferences) -> String
181
188
 
182
- # @param canonical_feature_name [String] A canonical feature name
183
- # @return Whether the feature has conditions.
184
- def conditions?: (String canonical_feature_name) -> bool
185
-
186
189
  def init: (?CacheInitOptions? cache_init_options) -> self
187
190
 
191
+ def map_feature_names: (::Array[String] feature_names, GetOptionsPreferences preferences) -> ::Array[String?]
192
+
188
193
  # Map aliases or canonical feature names (perhaps derived from a file names) to the canonical feature names.
189
194
  # Canonical feature names map to themselves.
190
195
  # This implementation calls the Rust implementation directly.
@@ -195,9 +200,6 @@ module Optify::ProviderModule
195
200
 
196
201
  # @return The metadata for the feature.
197
202
  def get_feature_metadata_json: (String canonical_feature_name) -> String?
198
-
199
- # @return All of the keys and values for the the features.
200
- def features_with_metadata_json: () -> String
201
203
  end
202
204
 
203
205
  # Provides configurations based on keys and enabled feature names.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optify-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.20.2
4
+ version: 1.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin D. Harris