lora-ruby 0.4.0 → 0.5.5

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: 9f225172245d7983494a2d5d498edc749e31629b811453667be8517d7624fde0
4
- data.tar.gz: 36e8d24e24003755b36abcf34354df4c7af42125d969c27c2e76de551d2cb06d
3
+ metadata.gz: b5ba0aa4fc27617800ec4053cabef91152e7aeb369c37671b5b42c8b63262191
4
+ data.tar.gz: 68db7428ccf49b03dddf70bfe430c92388269060653541819c19bcebd120db38
5
5
  SHA512:
6
- metadata.gz: 48356ff0802ae5949f2d000580779c865b793dc562d8068deb92e72eefc7a2409fa9890b7a69ff336ef8c0ba2d67c27da57f253e6db2674920715b71320f7c07
7
- data.tar.gz: 4446b8aac9ac26302ccb688784c6bd20f3e6f4ca80d6fb66525505c7022964f672cf9272876584672ce8b34a183708a50f9cc54e785ae75420394b365ecc43f2
6
+ metadata.gz: c25ead41256e9c1a7db8b9842f161d5c9efad153dc52da52323381d5eb380a9f81d616f5dba8bcc9f1e0bbca4a5010f5b57a6f0e09c048cc4ac0367bc30384a0
7
+ data.tar.gz: 891572a4890c93d4af1f92020e623724e3a7509340f29d6985f7a106e3e4ec0085c92aa08b98301219e4ca75cd45fe2062945bf51fe62f58c058ce5fd03dd08e
data/README.md CHANGED
@@ -43,10 +43,10 @@ Initialization rule:
43
43
 
44
44
  ```ruby
45
45
  scratch = LoraRuby::Database.create # in-memory
46
- persistent = LoraRuby::Database.create("./app") # persistent: directory string
46
+ persistent = LoraRuby::Database.create("app", {"database_dir": "./data"}) # persistent: ./data/app.loradb
47
47
  ```
48
48
 
49
- If you want persistence, pass a directory string to
49
+ If you want persistence, pass a database name and `database_dir` to
50
50
  `LoraRuby::Database.create(...)` or `LoraRuby::Database.new(...)`.
51
51
 
52
52
  ### Params
@@ -148,16 +148,16 @@ db.execute(
148
148
 
149
149
  ## Persistence
150
150
 
151
- `LoraRuby::Database.create("./app")` and
152
- `LoraRuby::Database.new("./app")` open or create a WAL-backed
153
- persistent database rooted at that directory. Reopening the same path
151
+ `LoraRuby::Database.create("app", {"database_dir": "./data"})` and
152
+ `LoraRuby::Database.new("app", { database_dir: "./data" })` open or create
153
+ an archive-backed persistent database at `./data/app.loradb`. Reopening the same path
154
154
  replays committed writes before returning the handle.
155
155
 
156
- Call `db.close` before reopening the same WAL directory inside one
156
+ Call `db.close` before reopening the same archive inside one
157
157
  process.
158
158
 
159
159
  This first Ruby persistence slice intentionally stays small: the
160
- binding exposes WAL-backed initialization plus the existing snapshot
160
+ binding exposes archive-backed initialization plus the existing snapshot
161
161
  APIs, but not checkpoint, truncate, status, or sync-mode controls.
162
162
 
163
163
  ## Concurrency (GVL release)
@@ -10,5 +10,5 @@ module LoraRuby
10
10
  # Guard against redefinition so re-requiring this file (or loading
11
11
  # both paths) doesn't emit a "warning: already initialized constant"
12
12
  # when the native extension loads second with the identical value.
13
- VERSION = "0.4.0" unless const_defined?(:VERSION)
13
+ VERSION = "0.5.5" unless const_defined?(:VERSION)
14
14
  end
data/src/lib.rs CHANGED
@@ -24,8 +24,8 @@ use magnus::{
24
24
  };
25
25
 
26
26
  use lora_database::{
27
- Database as InnerDatabase, ExecuteOptions, InMemoryGraph, LoraValue, QueryResult, ResultFormat,
28
- WalConfig,
27
+ Database as InnerDatabase, DatabaseOpenOptions, ExecuteOptions, InMemoryGraph, LoraValue,
28
+ QueryResult, ResultFormat,
29
29
  };
30
30
  use lora_store::{
31
31
  LoraDate, LoraDateTime, LoraDuration, LoraLocalDateTime, LoraLocalTime, LoraPoint, LoraTime,
@@ -138,8 +138,9 @@ impl Database {
138
138
  // singletons so callers can use whichever idiom they prefer; both are
139
139
  // cost-equivalent.
140
140
  fn database_new(ruby: &Ruby, args: &[Value]) -> Result<Database, MagnusError> {
141
- let wal_dir = optional_wal_dir_arg(ruby, args)?;
142
- let db = without_gvl(move || open_database(wal_dir)).map_err(|e| query_error(ruby, e))?;
141
+ let (database_name, options) = database_open_args(ruby, args)?;
142
+ let db = without_gvl(move || open_database(database_name, options))
143
+ .map_err(|e| query_error(ruby, e))?;
143
144
  Ok(Database::from_db(db))
144
145
  }
145
146
 
@@ -233,28 +234,50 @@ fn snapshot_meta_to_rhash(
233
234
  Ok(h)
234
235
  }
235
236
 
236
- fn optional_wal_dir_arg(ruby: &Ruby, args: &[Value]) -> Result<Option<String>, MagnusError> {
237
+ fn database_open_args(
238
+ ruby: &Ruby,
239
+ args: &[Value],
240
+ ) -> Result<(Option<String>, DatabaseOpenOptions), MagnusError> {
237
241
  match args.len() {
238
- 0 => Ok(None),
242
+ 0 => Ok((None, DatabaseOpenOptions::default())),
239
243
  1 => {
240
244
  if args[0].is_nil() {
241
- Ok(None)
245
+ Ok((None, DatabaseOpenOptions::default()))
246
+ } else {
247
+ Ok((
248
+ Some(RString::try_convert(args[0])?.to_string()?),
249
+ DatabaseOpenOptions::default(),
250
+ ))
251
+ }
252
+ }
253
+ 2 => {
254
+ let database_name = if args[0].is_nil() {
255
+ None
242
256
  } else {
243
- Ok(Some(RString::try_convert(args[0])?.to_string()?))
257
+ Some(RString::try_convert(args[0])?.to_string()?)
258
+ };
259
+ let mut options = DatabaseOpenOptions::default();
260
+ let hash = RHash::try_convert(args[1])?;
261
+ if let Some(dir) = hash_get_either(ruby, hash, "database_dir")
262
+ .or_else(|| hash_get_either(ruby, hash, "databaseDir"))
263
+ {
264
+ options.database_dir = RString::try_convert(dir)?.to_string()?.into();
244
265
  }
266
+ Ok((database_name, options))
245
267
  }
246
268
  n => Err(MagnusError::new(
247
269
  ruby.exception_arg_error(),
248
- format!("wrong number of arguments (given {n}, expected 0..1)"),
270
+ format!("wrong number of arguments (given {n}, expected 0..2)"),
249
271
  )),
250
272
  }
251
273
  }
252
274
 
253
- fn open_database(wal_dir: Option<String>) -> Result<Arc<InnerDatabase<InMemoryGraph>>, String> {
254
- let db = match wal_dir {
255
- Some(dir) => {
256
- InnerDatabase::open_with_wal(WalConfig::enabled(dir)).map_err(|e| e.to_string())?
257
- }
275
+ fn open_database(
276
+ database_name: Option<String>,
277
+ options: DatabaseOpenOptions,
278
+ ) -> Result<Arc<InnerDatabase<InMemoryGraph>>, String> {
279
+ let db = match database_name {
280
+ Some(name) => InnerDatabase::open_named(name, options).map_err(|e| e.to_string())?,
258
281
  None => InnerDatabase::in_memory(),
259
282
  };
260
283
  Ok(Arc::new(db))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lora-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - LoraDB, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-25 00:00:00.000000000 Z
11
+ date: 2026-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb_sys