optify-config 1.7.0 → 1.8.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: c39f6b23931576d844b9c6c4991a373f96198f009e4f4a78227adcb373162f2c
4
- data.tar.gz: 98cd040744bdfeab713795c276b58b472b5e9fff7d4c7bf164f5196aab94e812
3
+ metadata.gz: 987b7a6cc75f0b5ab66cf1862917aecc96c1efef0ca54a771e49f3c359694534
4
+ data.tar.gz: ea2b13f32633ca71b4d947ab71cd0dfa918891c2b796078dea1b79ad939fa2d8
5
5
  SHA512:
6
- metadata.gz: b3c2ae32795dbca9e1a9a48eebbec2b6a854e44071554693dbad9c226ec94624cab294b6ed8fa790a0bbd7bbfec5a59bc42cb4d61d475299fde1c41ff0476738
7
- data.tar.gz: 50bcc0e02ced878b270fd3d98a4f7ba46c66eb67f0b1913429e78ef4362dc30ec9045dc22c00c006424849cfe590b77c8219bac5dd8a6e7a05402f26a966b1c1
6
+ metadata.gz: f8ce4f21f5e025a0a2fef506ea348a7bd12d0d97196dd580cf87fb078cd4730a637b5796769228d20d10ee433e60f7c9e2782f5d5c3173063324306e249ad30e
7
+ data.tar.gz: e73782f6410d5e045df70ea7537f05504cea49a7bde3314a5902a9717cc6c2c9ded89ddd810eae372b8c67eab5e24f9bca1626b0f983f1186839ac5026b94e91
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "optify_ruby"
3
- version = "0.10.0"
3
+ version = "0.11.0"
4
4
  edition = "2021"
5
5
 
6
6
  description = "optify bindings for Ruby"
@@ -21,6 +21,6 @@ crate-type = ["cdylib"]
21
21
 
22
22
  [dependencies]
23
23
  magnus = "0.7.1"
24
- optify = { path = "../../../../rust/optify", version = "0.10.0" }
24
+ optify = { path = "../../../../rust/optify", version = "0.11.0" }
25
25
  rb-sys = { version = "*", default-features = false, features = ["ruby-static"] }
26
26
  serde_json = "1.0.140"
@@ -8,6 +8,7 @@ use optify::provider::OptionsRegistry;
8
8
  use optify::provider::OptionsWatcher;
9
9
  use optify::schema::metadata::OptionsMetadata;
10
10
  use std::cell::RefCell;
11
+ use std::path::Path;
11
12
 
12
13
  #[derive(Clone)]
13
14
  #[wrap(class = "Optify::GetOptionsPreferences")]
@@ -52,6 +53,23 @@ fn convert_metadata(metadata: &OptionsMetadata) -> String {
52
53
  }
53
54
 
54
55
  impl WrappedOptionsProvider {
56
+ fn build(ruby: &Ruby, directory: String) -> Result<WrappedOptionsProvider, magnus::Error> {
57
+ match OptionsProvider::build(Path::new(&directory)) {
58
+ Ok(provider) => Ok(WrappedOptionsProvider(RefCell::new(provider))),
59
+ Err(e) => Err(magnus::Error::new(ruby.exception_runtime_error(), e)),
60
+ }
61
+ }
62
+
63
+ fn build_from_directories(
64
+ ruby: &Ruby,
65
+ directories: Vec<String>,
66
+ ) -> Result<WrappedOptionsProvider, magnus::Error> {
67
+ match OptionsProvider::build_from_directories(&directories) {
68
+ Ok(provider) => Ok(WrappedOptionsProvider(RefCell::new(provider))),
69
+ Err(e) => Err(magnus::Error::new(ruby.exception_runtime_error(), e)),
70
+ }
71
+ }
72
+
55
73
  fn get_aliases(&self) -> Vec<String> {
56
74
  self.0.borrow().get_aliases()
57
75
  }
@@ -196,6 +214,23 @@ impl WrappedOptionsProviderBuilder {
196
214
  struct WrappedOptionsWatcher(RefCell<OptionsWatcher>);
197
215
 
198
216
  impl WrappedOptionsWatcher {
217
+ fn build(ruby: &Ruby, directory: String) -> Result<WrappedOptionsWatcher, magnus::Error> {
218
+ match OptionsWatcher::build(Path::new(&directory)) {
219
+ Ok(provider) => Ok(WrappedOptionsWatcher(RefCell::new(provider))),
220
+ Err(e) => Err(magnus::Error::new(ruby.exception_runtime_error(), e)),
221
+ }
222
+ }
223
+
224
+ fn build_from_directories(
225
+ ruby: &Ruby,
226
+ directories: Vec<String>,
227
+ ) -> Result<WrappedOptionsWatcher, magnus::Error> {
228
+ match OptionsWatcher::build_from_directories(&directories) {
229
+ Ok(provider) => Ok(WrappedOptionsWatcher(RefCell::new(provider))),
230
+ Err(e) => Err(magnus::Error::new(ruby.exception_runtime_error(), e)),
231
+ }
232
+ }
233
+
199
234
  fn get_aliases(&self) -> Vec<String> {
200
235
  self.0.borrow().get_aliases()
201
236
  }
@@ -344,6 +379,11 @@ fn init(ruby: &Ruby) -> Result<(), magnus::Error> {
344
379
  builder_class.define_method("build", method!(WrappedOptionsProviderBuilder::build, 0))?;
345
380
 
346
381
  let provider_class = module.define_class("OptionsProvider", ruby.class_object())?;
382
+ provider_class.define_singleton_method("build", function!(WrappedOptionsProvider::build, 1))?;
383
+ provider_class.define_singleton_method(
384
+ "build_from_directories",
385
+ function!(WrappedOptionsProvider::build_from_directories, 1),
386
+ )?;
347
387
  provider_class.define_method("aliases", method!(WrappedOptionsProvider::get_aliases, 0))?;
348
388
  provider_class.define_method("features", method!(WrappedOptionsProvider::get_features, 0))?;
349
389
  provider_class.define_method(
@@ -419,6 +459,11 @@ fn init(ruby: &Ruby) -> Result<(), magnus::Error> {
419
459
  .define_method("build", method!(WrappedOptionsWatcherBuilder::build, 0))?;
420
460
 
421
461
  let watcher_class = module.define_class("OptionsWatcher", ruby.class_object())?;
462
+ watcher_class.define_singleton_method("build", function!(WrappedOptionsWatcher::build, 1))?;
463
+ watcher_class.define_singleton_method(
464
+ "build_from_directories",
465
+ function!(WrappedOptionsWatcher::build_from_directories, 1),
466
+ )?;
422
467
  watcher_class.define_method("aliases", method!(WrappedOptionsWatcher::get_aliases, 0))?;
423
468
  watcher_class.define_method("features", method!(WrappedOptionsWatcher::get_features, 0))?;
424
469
  watcher_class.define_method(
data/rbi/optify.rbi CHANGED
@@ -76,6 +76,20 @@ module Optify
76
76
  class OptionsRegistry
77
77
  abstract!
78
78
 
79
+ class << self
80
+ # Build using just one directory.
81
+ # @param directory The directory to build the provider from.
82
+ # @return The instance.
83
+ sig { params(directory: String).returns(OptionsRegistry) }
84
+ def build(directory); end
85
+
86
+ # Build from multiple directories.
87
+ # @param directories The directories to build the provider from.
88
+ # @return The instance.
89
+ sig { params(directories: T::Array[String]).returns(OptionsRegistry) }
90
+ def build_from_directories(directories); end
91
+ end
92
+
79
93
  # @return All of the aliases.
80
94
  sig { returns(T::Array[String]) }
81
95
  def aliases; end
data/sig/optify.rbs CHANGED
@@ -60,6 +60,16 @@ end
60
60
 
61
61
  # A registry of features that provides configurations.
62
62
  class Optify::OptionsRegistry
63
+ # Build using just one directory.
64
+ # @param directory The directory to build the provider from.
65
+ # @return The instance.
66
+ def build: (String directory) -> OptionsRegistry
67
+
68
+ # Build from multiple directories.
69
+ # @param directories The directories to build the provider from.
70
+ # @return The instance.
71
+ def build_from_directories: (::Array[String] directories) -> OptionsRegistry
72
+
63
73
  # @return All of the aliases.
64
74
  def aliases: () -> ::Array[String]
65
75
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optify-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin D. Harris
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-06-23 00:00:00.000000000 Z
10
+ date: 2025-06-30 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rb_sys