yerba 0.9.0-x86_64-linux-gnu → 0.9.1-x86_64-linux-gnu

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: 031f8d3784a83809d4794cb749bc935a5f19b8322f3ef30e07be5df8540f0fcf
4
- data.tar.gz: 2dfb6274659f715b0bda9b132adf2812c3358f64303c6d6d44e0787b8e6d5b84
3
+ metadata.gz: 5cec887961387cdf44392234842745f51538df4bb563f3c896422aade6022387
4
+ data.tar.gz: 8275cc4c54bca41702a3dd83a351a4f1b2169c3f956844cd5f165ef42e40288c
5
5
  SHA512:
6
- metadata.gz: a548ec6b09a2133f73260030851a53e191c5f7855f2b915c50b44277a3d5ca5016f286433bd51cb8d2fea54fe54c26866560c84e45d9a8b6df8a57ef97b27c67
7
- data.tar.gz: 3f43e49e76bb29b7fd1bbf07c8c50636e85f8a8814188efeaf8c3a2658c913d3be0b97964de191fb56e9152733391fe2c147395aef746f11b3f83172b20541ec
6
+ metadata.gz: 7fb8433ec5ef02d4aec964897fceaf141708a2c0f2f0a0897888c24f8cea25122008fc530849f588c0d6017e9283945530c1c2fd966e9233a4afc7ffa2354bfa
7
+ data.tar.gz: 0ec6936095188c83cd21afc92b4324a225de14ad14ef37485fc19a6ad185f8f38c2fb0550c901b50a3a1d09640580ce747b64e6c722fc5ece7526ad3b2e4467c
Binary file
@@ -68,6 +68,8 @@ struct YerbaParseResult yerba_document_parse_file(const char *path);
68
68
 
69
69
  struct YerbaParseResult yerba_document_parse(const char *content);
70
70
 
71
+ uint64_t yerba_document_generation(const struct Document *document);
72
+
71
73
  void yerba_document_free(struct Document *document);
72
74
 
73
75
  struct YerbaGetResult yerba_document_get(const struct Document *document, const char *path);
data/ext/yerba/yerba.c CHANGED
@@ -339,6 +339,23 @@ static VALUE document_get_value(VALUE self, VALUE path) {
339
339
  return rb_funcall(rb_path2class("JSON"), rb_intern("parse"), 1, json_string);
340
340
  }
341
341
 
342
+ /* document.values → the whole document as Ruby objects, cached until the document changes */
343
+ static VALUE document_values(VALUE self) {
344
+ struct Document *document = get_document(self);
345
+ VALUE generation = ULL2NUM(yerba_document_generation(document));
346
+
347
+ if (rb_equal(rb_ivar_get(self, rb_intern("values_generation")), generation)) {
348
+ return rb_ivar_get(self, rb_intern("values"));
349
+ }
350
+
351
+ VALUE values = document_get_value(self, make_utf8_string(""));
352
+
353
+ rb_ivar_set(self, rb_intern("values"), values);
354
+ rb_ivar_set(self, rb_intern("values_generation"), generation);
355
+
356
+ return values;
357
+ }
358
+
342
359
  /* document.selectors → ["database", "database.host", "tags", "tags[]", ...] */
343
360
  static VALUE document_selectors(VALUE self) {
344
361
  struct Document *document = get_document(self);
@@ -1189,6 +1206,7 @@ void Init_yerba(void) {
1189
1206
  rb_define_method(rb_cDocument, "[]", document_bracket, 1);
1190
1207
  rb_define_method(rb_cDocument, "node_at", document_bracket, 1);
1191
1208
  rb_define_method(rb_cDocument, "value_at", document_get_value, 1);
1209
+ rb_define_method(rb_cDocument, "values", document_values, 0);
1192
1210
  rb_define_method(rb_cDocument, "get_all", document_get_all, 1);
1193
1211
  rb_define_method(rb_cDocument, "location", document_location, -1);
1194
1212
  rb_define_method(rb_cDocument, "locations", document_locations, 1);
Binary file
Binary file
Binary file
Binary file
data/lib/yerba/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Yerba
4
- VERSION = "0.9.0"
4
+ VERSION = "0.9.1"
5
5
  end
data/rust/Cargo.lock CHANGED
@@ -1431,7 +1431,7 @@ dependencies = [
1431
1431
 
1432
1432
  [[package]]
1433
1433
  name = "yerba"
1434
- version = "0.9.0"
1434
+ version = "0.9.1"
1435
1435
  dependencies = [
1436
1436
  "anstyle-query",
1437
1437
  "cbindgen",
data/rust/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "yerba"
3
- version = "0.9.0"
3
+ version = "0.9.1"
4
4
  edition = "2021"
5
5
  authors = ["Marco Roth <marco.roth@intergga.ch>"]
6
6
  description = "YAML Editing and Refactoring with Better Accuracy"
@@ -34,6 +34,7 @@ pub struct Args {
34
34
  /// Comma-separated map keys to separate from what follows them
35
35
  #[arg(long)]
36
36
  after: Option<String>,
37
+ /// Leave entries alone when their value is null, an empty collection, or an empty string
37
38
  #[arg(long)]
38
39
  skip_empty: bool,
39
40
  #[arg(long)]
@@ -31,6 +31,7 @@ pub struct LocatedNode {
31
31
 
32
32
  use std::fs;
33
33
  use std::path::{Path, PathBuf};
34
+ use std::sync::atomic::{AtomicU64, Ordering};
34
35
 
35
36
  use rowan::ast::AstNode;
36
37
  use rowan::{TextRange, TextSize};
@@ -126,10 +127,13 @@ pub enum InsertPosition {
126
127
  FromSortOrder(Vec<String>),
127
128
  }
128
129
 
130
+ static NEXT_GENERATION: AtomicU64 = AtomicU64::new(1);
131
+
129
132
  #[derive(Debug)]
130
133
  pub struct Document {
131
134
  root: SyntaxNode,
132
135
  path: Option<PathBuf>,
136
+ generation: u64,
133
137
  }
134
138
 
135
139
  impl Document {
@@ -138,7 +142,15 @@ impl Document {
138
142
 
139
143
  check_duplicate_keys(&tree)?;
140
144
 
141
- Ok(Document { root: tree, path: None })
145
+ Ok(Document {
146
+ root: tree,
147
+ path: None,
148
+ generation: NEXT_GENERATION.fetch_add(1, Ordering::Relaxed),
149
+ })
150
+ }
151
+
152
+ pub fn generation(&self) -> u64 {
153
+ self.generation
142
154
  }
143
155
 
144
156
  pub fn parse_file(path: impl AsRef<Path>) -> Result<Self, YerbaError> {
data/rust/src/ffi.rs CHANGED
@@ -217,6 +217,11 @@ const EMPTY_LOCATION: YerbaLocation = YerbaLocation {
217
217
  end_column: 0,
218
218
  };
219
219
 
220
+ #[no_mangle]
221
+ pub unsafe extern "C" fn yerba_document_generation(document: *const Document) -> u64 {
222
+ (*document).generation()
223
+ }
224
+
220
225
  #[no_mangle]
221
226
  pub unsafe extern "C" fn yerba_document_free(document: *mut Document) {
222
227
  if !document.is_null() {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yerba
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: x86_64-linux-gnu
6
6
  authors:
7
7
  - Marco Roth
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-08-04 00:00:00.000000000 Z
11
+ date: 2026-10-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A CLI tool for editing YAML while preserving structure, comments, and
14
14
  format.