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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5174add01b6b7053e2317d479e746ba330901c6bdc547d5ba7429ea46889ae3
4
- data.tar.gz: 66bd27f4a626a956e840f90013bbe5ce7dc6817f127c554bccf5cb413cbd2981
3
+ metadata.gz: e6cda48af3f6a3d844c896622b39a79c31631c9b164f5f727d2841d85decb1ec
4
+ data.tar.gz: 375c96471483ed06f43272785520d5f6c763687a03f104dd1d5049636c010948
5
5
  SHA512:
6
- metadata.gz: 6aa415b0bd88d3cf5bd95d3786b01dff6f66e00e13ca95a3a19755f1e60cc17163800841fd9f7ea21d98acee505c0b67ae1ef6a3e3e032394cfb848395b1295d
7
- data.tar.gz: ce39ba436ff04bf239e16744625c2e989b75db1674ffed24314d9fb75ae393e0f3b9ca8f0ab9263a47cd79572807e958f29ebfcedc88c42f00e886c9dd75a14f
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
- TOKEN = /->|<-|<=|=>|[{}\[\]()=:|!,*\/]|'(?:''|[^'])*'|\w+(?:\.\w+)?/
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
- issues.concat(check_step(step, pos, prev, last_qualified, by_name))
156
- prev = step if step.name
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
@@ -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 { |aa| [aa.attribute, aa.aimelt] }
140
- end.compact
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]
@@ -3,6 +3,6 @@ module Expressir
3
3
  # autoload it (Ruby autoload only works for module/class constants, not
4
4
  # for string constants like `Expressir::VERSION`).
5
5
  module Version
6
- VERSION = "2.4.19".freeze
6
+ VERSION = "2.4.20".freeze
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expressir
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.19
4
+ version: 2.4.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.