leptris 1.1.2 → 1.2.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: 949fe73711448bd7857072004c75d6201b06829e9eb632124ae922a2fb7ff3f1
4
- data.tar.gz: 259bbac7ce3e90389cce4f0e79dc979e7bc8ca844caa7745680ba352c010ba86
3
+ metadata.gz: 28a6d0b01b14207e6a928eead2f38f84bf2dda03b9c7ae4a3c6bcc3163f2760d
4
+ data.tar.gz: e23962a817090c8707dc691fe58276f25da7075e1b0b64bb1fa39774cd113d4e
5
5
  SHA512:
6
- metadata.gz: cdab285d1fe462fcf7bc66681ebfbe1af74748ae99a8f0eebe1e502dfd72313b4429ac5943a18ebebd5706a308b135c33dfd7e8aab4bd313e383adcd91bb682f
7
- data.tar.gz: 18240f20ed093b9e6434d0f9036ab93545b6af47237aa5ee72f616f3b10836148a3850fec5332fb2e44f416a53d25523d69f8bc4e4e1bb17c1f1181f16515f98
6
+ metadata.gz: 83e9f30fd09ded2f909d651423db46be8a6baca9f39f310e9b8c3632f5fd7cd5627d193cd57c80d6191a2c00145858b87d9454a72df12e96a28fbd928864a663
7
+ data.tar.gz: 5991c97a7ea5b8a3462c62492fd70808f4094d2758525ce2ec6ac47a9ffe61bb318c71d1999c95081e5e48ce10cc98d9e671ea8c52400c3a90b01e4f9a5b3ce1
data/CHANGELOG.md CHANGED
@@ -5,6 +5,40 @@ All notable changes to Leptris will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.2.0] - 2026-08-23
9
+
10
+ Lockstep with libleptris 1.2.0.
11
+
12
+ ### Added
13
+
14
+ - `Leptris::XML::Document.create` — empty document with its own memory
15
+ pool (backs `leptris_document_create`); elements are created against
16
+ it via the factories and attached with `root=`.
17
+ - `Document#root=` — attach an element as the document root
18
+ (`leptris_document_set_root`). Companion to the moxml Leptris
19
+ adapter (lutaml/moxml#96).
20
+ - `Attr#to_xml` — serialized `name="value"` form with the five XML
21
+ special characters escaped.
22
+
23
+ ### Fixed
24
+
25
+ - `Node#text` / `#inner_text` now dispatch to `#content` instead of
26
+ aliasing the base implementation — the alias snapshot meant subclass
27
+ overrides (`Text#content`, `Comment#content`, …) were never seen
28
+ through `text`.
29
+ - `Element#namespace` carries the element's own prefix, so consumers
30
+ can distinguish `{"p" => "urn:p"}` from the default namespace.
31
+ - CI/Rakefile pin libleptris v1.2.0, whose fixes resolve leptris#477
32
+ (mixed-nodeset kinds, `node_name`/`node_value` on non-element
33
+ entries, and `//node()` now including the context root). NodeSet
34
+ keeps its per-index fallback for the still-under-copying batch
35
+ accessor.
36
+
37
+ ### Unbound v1.2.0 surface (follow-up)
38
+
39
+ Namespace-bound XPath (`leptris_xpath_ns_set_*`, `leptris_xpath_eval_ns`)
40
+ and error introspection (`leptris_error_message`, `leptris_last_error`).
41
+
8
42
  ## [1.1.1] - 2026-08-22
9
43
 
10
44
  ### Added
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ RSpec::Core::RakeTask.new(:spec)
8
8
  # Pin for `rake compile` and the platform-gem builds. Keep in lockstep
9
9
  # with .github/workflows/build.yml (which calls `rake compile`) and the
10
10
  # CHANGELOG when libleptris releases.
11
- LIBLEPTRIS_VERSION = "1.1.1"
11
+ LIBLEPTRIS_VERSION = "1.2.0"
12
12
 
13
13
  CMAKE_FLAGS = %w[
14
14
  -DCMAKE_BUILD_TYPE=Release
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leptris
4
- VERSION = "1.1.2"
4
+ VERSION = "1.2.0"
5
5
  end
@@ -29,6 +29,17 @@ class Leptris::XML::Attr
29
29
  def to_s; @value; end
30
30
  def to_str; @value; end
31
31
 
32
+ # Serialized attribute form: name="value" with the five XML special
33
+ # characters escaped in the value.
34
+ def to_xml
35
+ escaped = @value.to_s.gsub("&", "&")
36
+ .gsub("<", "&lt;")
37
+ .gsub(">", "&gt;")
38
+ .gsub('"', "&quot;")
39
+ .gsub("'", "&apos;")
40
+ "#{@name}=\"#{escaped}\""
41
+ end
42
+
32
43
  def ==(other)
33
44
  other.is_a?(Leptris::XML::Attr) &&
34
45
  @name == other.name && @value == other.value &&
@@ -66,6 +66,16 @@ class Leptris::XML::Document
66
66
  wrap(raw)
67
67
  end
68
68
 
69
+ # Create an empty document (no root element) backed by its own memory
70
+ # pool. Elements for the tree are created against it via
71
+ # #create_element and friends, then attached with #root=.
72
+ def self.create
73
+ raw = Leptris::XML::FFI.leptris_document_create
74
+ raise Leptris::XML::Error,
75
+ "leptris_document_create failed" if raw.null?
76
+ wrap(raw)
77
+ end
78
+
69
79
  # Convert a raw LeptrisDocument pointer into a Ruby Document with safe
70
80
  # GC lifetime management. The finalizer captures the raw address
71
81
  # integer (not the Document or Pointer object — those would prevent
@@ -107,6 +117,17 @@ class Leptris::XML::Document
107
117
  Leptris::XML::Node.wrap(ptr, self)
108
118
  end
109
119
 
120
+ # Attach +element+ as the document's root element. The element must
121
+ # have been created against this document and must not already have
122
+ # a parent. Any previous root is left detached (still owned by the
123
+ # document's pool until #free).
124
+ def root=(element)
125
+ raise Leptris::XML::UseAfterFreeError if @freed.state == :freed
126
+ Leptris::XML::FFI.check_status(
127
+ Leptris::XML::FFI.leptris_document_set_root(@c_ptr, element.c_ptr))
128
+ element
129
+ end
130
+
110
131
  def create_element(name)
111
132
  ptr = Leptris::XML::FFI.leptris_element_create(@c_ptr, name)
112
133
  raise Leptris::XML::Error, "leptris_element_create failed" if ptr.null?
@@ -191,7 +191,12 @@ class Leptris::XML::Element < Leptris::XML::Node
191
191
  def namespace
192
192
  uri = Leptris::XML::FFI.leptris_element_namespace(@c_ptr)
193
193
  return nil if uri.nil? || uri.empty?
194
- Leptris::XML::Namespace.new(self, uri)
194
+ # The resolved namespace is reached via this element's own prefix,
195
+ # so carry it through: consumers that distinguish
196
+ # {"p" => "urn:p"} from the default {"nil => "urn:p"} need it.
197
+ prefix = Leptris::XML::FFI.leptris_element_prefix(@c_ptr)
198
+ prefix = nil if prefix.nil? || prefix.empty?
199
+ Leptris::XML::Namespace.new(self, uri, prefix: prefix)
195
200
  end
196
201
 
197
202
  def namespace_definitions
@@ -66,6 +66,10 @@ module Leptris
66
66
  [:string, :pointer], :pointer
67
67
  attach_function :leptris_document_free,
68
68
  [:leptris_document], :void
69
+ attach_function :leptris_document_create,
70
+ [], :leptris_document
71
+ attach_function :leptris_document_set_root,
72
+ [:leptris_document, :leptris_element], :leptris_status
69
73
  attach_function :leptris_document_root,
70
74
  [:leptris_document], :leptris_element
71
75
  attach_function :leptris_document_encoding,
@@ -45,8 +45,17 @@ class Leptris::XML::Node
45
45
  def content
46
46
  raise NotImplementedError, "#{self.class}#content not implemented"
47
47
  end
48
- alias_method :text, :content
49
- alias_method :inner_text, :content
48
+
49
+ # Dispatching defs, not alias_method: an alias snapshots this base
50
+ # #content (the raise), so subclass overrides would never be seen
51
+ # through the alias. A plain method resolves #content per-call.
52
+ def text
53
+ content
54
+ end
55
+
56
+ def inner_text
57
+ content
58
+ end
50
59
 
51
60
  def type
52
61
  Leptris::XML::FFI.leptris_node_get_type(@c_ptr)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.