latticerb 0.4.0-aarch64-linux → 0.4.1-aarch64-linux
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 +4 -4
- data/README.md +1 -1
- data/lib/lattice/3.2/lattice_native.so +0 -0
- data/lib/lattice/3.3/lattice_native.so +0 -0
- data/lib/lattice/3.4/lattice_native.so +0 -0
- data/lib/lattice/4.0/lattice_native.so +0 -0
- data/lib/lattice/parser.rb +3 -0
- data/lib/lattice/schema_text.rb +35 -15
- data/lib/lattice/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aa814c7b049af3c64d16b0dbdf7b76de58695d73036698df2751506a96703f8d
|
|
4
|
+
data.tar.gz: f31db2b1799ea2c6fb298cb46972e549db1934d06170b6f3f48968f08662b61d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fb86672498c324d324fa8845dc076c1beb94e35532da2d32d9c7d3df6ead37cb4c2c57d04b1d3a699ba0ae3b894228de4e1c72aa22c0acbc3b536bfc93a11a5d
|
|
7
|
+
data.tar.gz: 2bdcf8ee0b180a774d92859460bbf3e4c3afb54199eed8b6ae1ab2560170a081dae1c9d87bf42243dcc5cf37745ecabdb717a1e552c7c45b94e2531373cf22a5
|
data/README.md
CHANGED
|
@@ -108,7 +108,7 @@ Every value in a schema (the model name, parameter names and values, and constra
|
|
|
108
108
|
- Unquoted `yes`, `no`, `on`, `off`, `true` and `false` (lowercase, Capitalized or UPPERCASE) become `true` / `false`, and an empty value, `~` or `null` becomes `null`. Quote them (`"yes"`) to keep the word.
|
|
109
109
|
- JSON integers are written in plain decimal form (`-0` becomes `0`).
|
|
110
110
|
|
|
111
|
-
`strength` must be a whole number, and `weights` decimal numbers such as `0.7` or `1e-3`. Anchors, aliases and `<<` merge keys work; a key written twice, more than one YAML document, or a tag other than YAML's standard ones is an error.
|
|
111
|
+
`strength` must be a whole number, and `weights` decimal numbers such as `0.7` or `1e-3`. Anchors, aliases and `<<` merge keys work, up to 100,000 values once aliases are expanded; a key written twice, more than one YAML document, or a tag other than YAML's standard ones is an error.
|
|
112
112
|
|
|
113
113
|
Changed in 0.3.0: earlier versions converted unquoted numbers and dates, so `0x1F` became `31`, `1.10` became `1.1`, and some values (`.inf`, timestamps) came out differently in the Ruby and Python implementations.
|
|
114
114
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/lattice/parser.rb
CHANGED
|
@@ -88,6 +88,9 @@ module Lattice
|
|
|
88
88
|
errors = []
|
|
89
89
|
loaders.each do |loader|
|
|
90
90
|
return loader == :json ? SchemaText.load_json(text) : SchemaText.load_yaml(text)
|
|
91
|
+
rescue SchemaText::TooLarge => e
|
|
92
|
+
# Not a syntax error, so the other loader's complaint would only mislead.
|
|
93
|
+
raise ModelIOError, "Unable to parse model from `#{source_name}`: #{e.message}"
|
|
91
94
|
rescue StandardError => e
|
|
92
95
|
errors << e.message
|
|
93
96
|
end
|
data/lib/lattice/schema_text.rb
CHANGED
|
@@ -21,6 +21,18 @@ module Lattice
|
|
|
21
21
|
|
|
22
22
|
class SyntaxError < StandardError; end
|
|
23
23
|
|
|
24
|
+
# Raised when YAML aliases would expand the schema past MAX_VALUES values
|
|
25
|
+
# (the "billion laughs" pattern). Every value counts once per place it
|
|
26
|
+
# appears after expansion, so the limit holds however the aliases nest.
|
|
27
|
+
class TooLarge < StandardError; end
|
|
28
|
+
|
|
29
|
+
MAX_VALUES = 100_000
|
|
30
|
+
TOO_LARGE = "schema expands to more than #{MAX_VALUES} values (check YAML aliases)".freeze
|
|
31
|
+
|
|
32
|
+
# Anchors seen so far, as anchor => [value, size] once built (nil while
|
|
33
|
+
# still being built), and the running count of expanded values.
|
|
34
|
+
Expansion = Struct.new(:anchors, :count)
|
|
35
|
+
|
|
24
36
|
TRUE_WORDS = %w[yes Yes YES true True TRUE on On ON].freeze
|
|
25
37
|
FALSE_WORDS = %w[no No NO false False FALSE off Off OFF].freeze
|
|
26
38
|
NULL_WORDS = ["", "~", "null", "Null", "NULL"].freeze
|
|
@@ -57,7 +69,7 @@ module Lattice
|
|
|
57
69
|
raise SyntaxError, "expected a single YAML document, found #{documents.length}" if documents.length > 1
|
|
58
70
|
return nil if documents.empty?
|
|
59
71
|
|
|
60
|
-
yaml_value(documents.first.root, {})
|
|
72
|
+
yaml_value(documents.first.root, Expansion.new({}, 0))
|
|
61
73
|
end
|
|
62
74
|
|
|
63
75
|
private
|
|
@@ -71,31 +83,39 @@ module Lattice
|
|
|
71
83
|
end
|
|
72
84
|
end
|
|
73
85
|
|
|
74
|
-
#
|
|
75
|
-
#
|
|
76
|
-
def yaml_value(node,
|
|
77
|
-
return yaml_alias(node,
|
|
86
|
+
# An anchor still being built (nil in `anchors`) means an alias points
|
|
87
|
+
# back into itself.
|
|
88
|
+
def yaml_value(node, expansion)
|
|
89
|
+
return yaml_alias(node, expansion) if node.is_a?(Psych::Nodes::Alias)
|
|
78
90
|
|
|
79
|
-
|
|
91
|
+
start = expansion.count
|
|
92
|
+
add_values(expansion, 1)
|
|
93
|
+
expansion.anchors[node.anchor] = nil if node.anchor
|
|
80
94
|
value =
|
|
81
95
|
case node
|
|
82
96
|
when Psych::Nodes::Scalar then yaml_scalar(node)
|
|
83
97
|
when Psych::Nodes::Sequence
|
|
84
98
|
check_tag(node.tag, SEQUENCE_TAGS)
|
|
85
|
-
node.children.map { |child| yaml_value(child,
|
|
86
|
-
when Psych::Nodes::Mapping then yaml_mapping(node,
|
|
99
|
+
node.children.map { |child| yaml_value(child, expansion) }
|
|
100
|
+
when Psych::Nodes::Mapping then yaml_mapping(node, expansion)
|
|
87
101
|
end
|
|
88
|
-
anchors[node.anchor] = [value] if node.anchor
|
|
102
|
+
expansion.anchors[node.anchor] = [value, expansion.count - start] if node.anchor
|
|
89
103
|
value
|
|
90
104
|
end
|
|
91
105
|
|
|
92
|
-
def yaml_alias(node,
|
|
93
|
-
built = anchors.fetch(node.anchor) { raise SyntaxError, "unknown alias `*#{node.anchor}`" }
|
|
106
|
+
def yaml_alias(node, expansion)
|
|
107
|
+
built = expansion.anchors.fetch(node.anchor) { raise SyntaxError, "unknown alias `*#{node.anchor}`" }
|
|
94
108
|
raise SyntaxError, "recursive alias" if built.nil?
|
|
95
109
|
|
|
110
|
+
add_values(expansion, built.last)
|
|
96
111
|
built.first
|
|
97
112
|
end
|
|
98
113
|
|
|
114
|
+
def add_values(expansion, values)
|
|
115
|
+
expansion.count += values
|
|
116
|
+
raise TooLarge, TOO_LARGE if expansion.count > MAX_VALUES
|
|
117
|
+
end
|
|
118
|
+
|
|
99
119
|
def yaml_scalar(node)
|
|
100
120
|
check_tag(node.tag, [nil, "!"] + SCALAR_TAGS)
|
|
101
121
|
return node.value unless node.style == Psych::Nodes::Scalar::PLAIN && !STR_TAGS.include?(node.tag)
|
|
@@ -108,20 +128,20 @@ module Lattice
|
|
|
108
128
|
|
|
109
129
|
# Keys from `<<` merges come first, earlier sources winning; the
|
|
110
130
|
# mapping's own keys then override them. A key written twice is an error.
|
|
111
|
-
def yaml_mapping(node,
|
|
131
|
+
def yaml_mapping(node, expansion)
|
|
112
132
|
check_tag(node.tag, MAPPING_TAGS)
|
|
113
133
|
merged = {}
|
|
114
134
|
own = {}
|
|
115
135
|
seen_merge = false
|
|
116
136
|
node.children.each_slice(2) do |key_node, value_node|
|
|
117
|
-
key = yaml_value(key_node,
|
|
137
|
+
key = yaml_value(key_node, expansion)
|
|
118
138
|
raise SyntaxError, "mapping keys must be scalars" if key.is_a?(Enumerable)
|
|
119
139
|
|
|
120
140
|
if merge_key?(key_node)
|
|
121
141
|
raise SyntaxError, "duplicate key `<<`" if seen_merge
|
|
122
142
|
|
|
123
143
|
seen_merge = true
|
|
124
|
-
merge_sources(yaml_value(value_node,
|
|
144
|
+
merge_sources(yaml_value(value_node, expansion)).each do |source|
|
|
125
145
|
source.each { |merged_key, merged_value| merged[merged_key] = merged_value unless merged.key?(merged_key) }
|
|
126
146
|
end
|
|
127
147
|
next
|
|
@@ -129,7 +149,7 @@ module Lattice
|
|
|
129
149
|
|
|
130
150
|
raise SyntaxError, "duplicate key `#{Lattice.normalize_scalar(key)}`" if own.key?(key)
|
|
131
151
|
|
|
132
|
-
own[key] = yaml_value(value_node,
|
|
152
|
+
own[key] = yaml_value(value_node, expansion)
|
|
133
153
|
end
|
|
134
154
|
merged.merge(own)
|
|
135
155
|
end
|
data/lib/lattice/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: latticerb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.1
|
|
5
5
|
platform: aarch64-linux
|
|
6
6
|
authors:
|
|
7
7
|
- Tyler Klose
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: csv
|