expressir 2.4.19 → 2.4.20
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/lib/expressir/mapping/refpath.rb +43 -3
- data/lib/expressir/mapping.rb +10 -2
- data/lib/expressir/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e6cda48af3f6a3d844c896622b39a79c31631c9b164f5f727d2841d85decb1ec
|
|
4
|
+
data.tar.gz: 375c96471483ed06f43272785520d5f6c763687a03f104dd1d5049636c010948
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f64857ddcef1a8bd7896ee1c5c8ed6050ba263e2ab8aa2df2bc8a02e98f3e55c8cf2e6b186760dbda9a37e513882292fe3569eb5ded9eee471978e3ef4580a9e
|
|
7
|
+
data.tar.gz: 8e6f94bc7c441f0fd1394c7cff8d512e20247c5f07291b2d969bdfcdef1af5cadf6230b4b2512cc273ca08d9de3ef906e4762fad6cbbcaa273f3667429355dea
|
|
@@ -15,6 +15,10 @@ module Expressir
|
|
|
15
15
|
# link := "->" | "<-" | "<=" | "=>" | "=" NAME
|
|
16
16
|
# (relation to the previous node)
|
|
17
17
|
# node := NAME ["." ATTRIBUTE]
|
|
18
|
+
# | LINK (<<express:SCHEMA.ITEM,ITEM>>,
|
|
19
|
+
# #460: a link may stand
|
|
20
|
+
# wherever a declaration
|
|
21
|
+
# is referenced)
|
|
18
22
|
# index := "[" ("i" | DIGITS) "]"
|
|
19
23
|
# MARKER := "{" | "}" | "[" | "]" | "(" | ")" | ":" | "|" | "!"
|
|
20
24
|
# | "," | "/" | "*" (grouping/annotation; no
|
|
@@ -42,6 +46,8 @@ module Expressir
|
|
|
42
46
|
attribute :attribute, :string
|
|
43
47
|
attribute :index, :string
|
|
44
48
|
attribute :literal, :string
|
|
49
|
+
# annotated EXPRESS link form: <<express:SCHEMA.ITEM,ITEM>>
|
|
50
|
+
attribute :link, :string
|
|
45
51
|
|
|
46
52
|
key_value do
|
|
47
53
|
map "operator", to: :operator
|
|
@@ -49,6 +55,7 @@ module Expressir
|
|
|
49
55
|
map "attribute", to: :attribute
|
|
50
56
|
map "index", to: :index
|
|
51
57
|
map "literal", to: :literal
|
|
58
|
+
map "link", to: :link
|
|
52
59
|
end
|
|
53
60
|
end
|
|
54
61
|
|
|
@@ -62,7 +69,10 @@ module Expressir
|
|
|
62
69
|
end
|
|
63
70
|
end
|
|
64
71
|
|
|
65
|
-
|
|
72
|
+
EXPRESS_LINK_PATH = /\A<<express:([^,>]+)(?:,[^>]+)?>>\z/
|
|
73
|
+
private_constant :EXPRESS_LINK_PATH
|
|
74
|
+
|
|
75
|
+
TOKEN = /<<express:[^,>]+(?:,[^>]+)?>>|->|<-|<=|=>|[{}\[\]()=:|!,*\/]|'(?:''|[^'])*'|\w+(?:\.\w+)?/
|
|
66
76
|
MARKERS = ["{", "}", "[", "]", "(", ")", ":", "|", "!", ",", "/",
|
|
67
77
|
"*", "MAPPING_OF"].freeze
|
|
68
78
|
LINKS = ["->", "<-", "<=", "=>"].freeze
|
|
@@ -109,6 +119,10 @@ module Expressir
|
|
|
109
119
|
end
|
|
110
120
|
when *MARKERS
|
|
111
121
|
steps << Step.new(operator: token)
|
|
122
|
+
when /\A<<express:/
|
|
123
|
+
steps << Step.new(operator: pending_link, link: token)
|
|
124
|
+
pending_link = nil
|
|
125
|
+
pending_type_assign = false
|
|
112
126
|
else
|
|
113
127
|
name, _, attribute = token.partition(".")
|
|
114
128
|
operator = pending_link || ("=" if pending_type_assign)
|
|
@@ -152,8 +166,12 @@ module Expressir
|
|
|
152
166
|
# markers never break the running link, mirroring parse
|
|
153
167
|
next if MARKERS.include?(step.operator)
|
|
154
168
|
|
|
155
|
-
|
|
156
|
-
|
|
169
|
+
if step.link
|
|
170
|
+
issues.concat(check_link_step(step, pos, repository))
|
|
171
|
+
else
|
|
172
|
+
issues.concat(check_step(step, pos, prev, last_qualified, by_name))
|
|
173
|
+
end
|
|
174
|
+
prev = step if step.name || step.link
|
|
157
175
|
last_qualified = step if step.name && step.attribute
|
|
158
176
|
end
|
|
159
177
|
issues
|
|
@@ -175,6 +193,28 @@ module Expressir
|
|
|
175
193
|
index
|
|
176
194
|
end
|
|
177
195
|
|
|
196
|
+
# Annotated EXPRESS link node: <<express:SCHEMA.ITEM,ITEM>>
|
|
197
|
+
# (item part optional) resolves against the repository (#460).
|
|
198
|
+
def check_link_step(step, pos, repository)
|
|
199
|
+
parts = step.link.match(EXPRESS_LINK_PATH)
|
|
200
|
+
return [Issue.new(step: pos, message: "malformed link '#{step.link}'")] unless parts
|
|
201
|
+
|
|
202
|
+
schema_id, item_id = parts[1].split(".", 2).compact
|
|
203
|
+
schema = repository.schemas
|
|
204
|
+
.find { |s| s.id&.safe_downcase == schema_id&.safe_downcase }
|
|
205
|
+
unless schema
|
|
206
|
+
return [Issue.new(step: pos,
|
|
207
|
+
message: "unknown schema '#{schema_id}' in #{step.link}")]
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
return [] if item_id.nil?
|
|
211
|
+
return [] if Expressir::Mapping.item_declared?(schema, item_id)
|
|
212
|
+
|
|
213
|
+
[Issue.new(step: pos,
|
|
214
|
+
message: "schema '#{schema_id}' does not declare " \
|
|
215
|
+
"'#{item_id}' (#{step.link})")]
|
|
216
|
+
end
|
|
217
|
+
|
|
178
218
|
def check_step(step, pos, prev, last_qualified, by_name)
|
|
179
219
|
found = by_name[step.name&.safe_downcase]
|
|
180
220
|
return [Issue.new(step: pos, message: "unknown type '#{step.name}'")] unless found
|
data/lib/expressir/mapping.rb
CHANGED
|
@@ -136,8 +136,16 @@ module Expressir
|
|
|
136
136
|
def values(document)
|
|
137
137
|
document.ae.to_a.flat_map do |element|
|
|
138
138
|
[element.entity, element.aimelt] +
|
|
139
|
-
element.aa.to_a.flat_map
|
|
140
|
-
|
|
139
|
+
element.aa.to_a.flat_map do |aa|
|
|
140
|
+
[aa.attribute, aa.aimelt, aa.assertion_to]
|
|
141
|
+
end
|
|
142
|
+
end.compact + subtype_constraint_values(document)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Every declaration reference in the sc entries (#460): the
|
|
146
|
+
# constraint name and the entity it constrains.
|
|
147
|
+
def subtype_constraint_values(document)
|
|
148
|
+
document.sc.to_a.flat_map { |sc| [sc.constraint, sc.entity] }.compact
|
|
141
149
|
end
|
|
142
150
|
|
|
143
151
|
# Every reference path in the document as [location, content]
|
data/lib/expressir/version.rb
CHANGED