expressir 0.2.21-x64-mingw32 → 1.0.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +7 -6
  3. data/.github/workflows/release.yml +22 -6
  4. data/.gitignore +2 -2
  5. data/demo.rb +5 -5
  6. data/exe/format +10 -73
  7. data/exe/format-test +81 -0
  8. data/expressir.gemspec +0 -1
  9. data/lib/expressir.rb +0 -1
  10. data/lib/expressir/cli.rb +0 -6
  11. data/lib/expressir/express/2.4/express_parser.so +0 -0
  12. data/lib/expressir/express/2.5/express_parser.so +0 -0
  13. data/lib/expressir/express/2.6/express_parser.so +0 -0
  14. data/lib/expressir/express/2.7/express_parser.so +0 -0
  15. data/lib/expressir/express/3.0/express_parser.so +0 -0
  16. data/lib/expressir/{express_exp → express}/cache.rb +3 -6
  17. data/lib/expressir/{express_exp → express}/formatter.rb +84 -68
  18. data/lib/expressir/express/hyperlink_formatter.rb +22 -0
  19. data/lib/expressir/express/model_visitor.rb +23 -0
  20. data/lib/expressir/{express_exp → express}/parser.rb +16 -5
  21. data/lib/expressir/express/resolve_references_model_visitor.rb +29 -0
  22. data/lib/expressir/{express_exp → express}/schema_head_formatter.rb +1 -1
  23. data/lib/expressir/{express_exp → express}/visitor.rb +67 -44
  24. data/lib/expressir/model.rb +5 -3
  25. data/lib/expressir/model/attribute.rb +13 -6
  26. data/lib/expressir/model/cache.rb +2 -2
  27. data/lib/expressir/model/constant.rb +10 -3
  28. data/lib/expressir/model/entity.rb +18 -16
  29. data/lib/expressir/model/enumeration_item.rb +8 -1
  30. data/lib/expressir/model/expressions/aggregate_initializer.rb +2 -2
  31. data/lib/expressir/model/expressions/aggregate_item.rb +2 -2
  32. data/lib/expressir/model/expressions/attribute_reference.rb +2 -2
  33. data/lib/expressir/model/expressions/binary_expression.rb +3 -3
  34. data/lib/expressir/model/expressions/call.rb +3 -3
  35. data/lib/expressir/model/expressions/entity_constructor.rb +3 -3
  36. data/lib/expressir/model/expressions/group_reference.rb +2 -2
  37. data/lib/expressir/model/expressions/index_reference.rb +3 -3
  38. data/lib/expressir/model/expressions/interval.rb +5 -5
  39. data/lib/expressir/model/expressions/query_expression.rb +6 -4
  40. data/lib/expressir/model/expressions/simple_reference.rb +5 -1
  41. data/lib/expressir/model/expressions/unary_expression.rb +2 -2
  42. data/lib/expressir/model/function.rb +23 -21
  43. data/lib/expressir/model/identifier.rb +6 -3
  44. data/lib/expressir/model/interface.rb +4 -4
  45. data/lib/expressir/model/interface_item.rb +2 -2
  46. data/lib/expressir/model/interfaced_item.rb +10 -9
  47. data/lib/expressir/model/literals/binary.rb +1 -1
  48. data/lib/expressir/model/literals/integer.rb +1 -1
  49. data/lib/expressir/model/literals/logical.rb +1 -1
  50. data/lib/expressir/model/literals/real.rb +1 -1
  51. data/lib/expressir/model/literals/string.rb +2 -2
  52. data/lib/expressir/model/model_element.rb +39 -27
  53. data/lib/expressir/model/parameter.rb +10 -3
  54. data/lib/expressir/model/procedure.rb +22 -20
  55. data/lib/expressir/model/remark_item.rb +15 -0
  56. data/lib/expressir/model/repository.rb +2 -2
  57. data/lib/expressir/model/rule.rb +27 -25
  58. data/lib/expressir/model/schema.rb +24 -20
  59. data/lib/expressir/model/schema_version.rb +15 -0
  60. data/lib/expressir/model/schema_version_item.rb +15 -0
  61. data/lib/expressir/model/statements/alias.rb +7 -5
  62. data/lib/expressir/model/statements/assignment.rb +2 -2
  63. data/lib/expressir/model/statements/call.rb +3 -3
  64. data/lib/expressir/model/statements/case.rb +4 -4
  65. data/lib/expressir/model/statements/case_action.rb +3 -3
  66. data/lib/expressir/model/statements/compound.rb +2 -2
  67. data/lib/expressir/model/statements/if.rb +5 -5
  68. data/lib/expressir/model/statements/repeat.rb +11 -9
  69. data/lib/expressir/model/statements/return.rb +1 -1
  70. data/lib/expressir/model/subtype_constraint.rb +13 -6
  71. data/lib/expressir/model/type.rb +12 -10
  72. data/lib/expressir/model/types/aggregate.rb +9 -2
  73. data/lib/expressir/model/types/array.rb +5 -5
  74. data/lib/expressir/model/types/bag.rb +3 -3
  75. data/lib/expressir/model/types/binary.rb +2 -2
  76. data/lib/expressir/model/types/enumeration.rb +5 -7
  77. data/lib/expressir/model/types/generic.rb +8 -1
  78. data/lib/expressir/model/types/generic_entity.rb +8 -1
  79. data/lib/expressir/model/types/list.rb +4 -4
  80. data/lib/expressir/model/types/real.rb +1 -1
  81. data/lib/expressir/model/types/select.rb +6 -8
  82. data/lib/expressir/model/types/set.rb +3 -3
  83. data/lib/expressir/model/types/string.rb +2 -2
  84. data/lib/expressir/model/unique_rule.rb +26 -0
  85. data/lib/expressir/model/variable.rb +10 -3
  86. data/lib/expressir/model/where_rule.rb +26 -0
  87. data/lib/expressir/version.rb +1 -1
  88. data/rakelib/cross-ruby.rake +1 -1
  89. data/spec/expressir/{express_exp → express}/cache_spec.rb +9 -9
  90. data/spec/expressir/express/formatter_spec.rb +127 -0
  91. data/spec/expressir/{express_exp → express}/parser_spec.rb +24 -24
  92. data/spec/expressir/model/model_element_spec.rb +112 -60
  93. data/{original/examples → spec}/syntax/multiple.exp +1 -1
  94. data/{original/examples → spec}/syntax/multiple.yaml +19 -5
  95. data/{original/examples → spec}/syntax/multiple_formatted.exp +1 -1
  96. data/{original/examples → spec}/syntax/multiple_hyperlink_formatted.exp +4 -4
  97. data/{original/examples → spec}/syntax/multiple_schema_head_hyperlink_formatted.exp +1 -1
  98. data/{original/examples → spec}/syntax/remark.exp +12 -10
  99. data/{original/examples → spec}/syntax/remark.yaml +36 -16
  100. data/{original/examples → spec}/syntax/remark_formatted.exp +3 -1
  101. data/spec/syntax/single.exp +4 -0
  102. data/spec/syntax/single.yaml +18 -0
  103. data/spec/syntax/single_formatted.exp +10 -0
  104. data/spec/syntax/single_formatted.yaml +36 -0
  105. data/{original/examples → spec}/syntax/syntax.exp +11 -11
  106. data/{original/examples → spec}/syntax/syntax.yaml +205 -108
  107. data/{original/examples → spec}/syntax/syntax_formatted.exp +11 -11
  108. data/spec/syntax/syntax_hyperlink_formatted.exp +902 -0
  109. data/{original/examples → spec}/syntax/syntax_schema_head_formatted.exp +1 -1
  110. metadata +41 -83
  111. data/lib/expressir/express.rb +0 -11
  112. data/lib/expressir/express/aggregate_dimension.rb +0 -38
  113. data/lib/expressir/express/attribute.rb +0 -15
  114. data/lib/expressir/express/comment.rb +0 -7
  115. data/lib/expressir/express/defined_type.rb +0 -36
  116. data/lib/expressir/express/derived.rb +0 -65
  117. data/lib/expressir/express/derived_aggregate.rb +0 -43
  118. data/lib/expressir/express/entity.rb +0 -137
  119. data/lib/expressir/express/explicit.rb +0 -70
  120. data/lib/expressir/express/explicit_aggregate.rb +0 -46
  121. data/lib/expressir/express/explicit_or_derived.rb +0 -16
  122. data/lib/expressir/express/global_rule.rb +0 -44
  123. data/lib/expressir/express/interface_specification.rb +0 -51
  124. data/lib/expressir/express/interfaced_item.rb +0 -38
  125. data/lib/expressir/express/inverse.rb +0 -46
  126. data/lib/expressir/express/inverse_aggregate.rb +0 -37
  127. data/lib/expressir/express/model_element.rb +0 -7
  128. data/lib/expressir/express/named_type.rb +0 -19
  129. data/lib/expressir/express/remark.rb +0 -8
  130. data/lib/expressir/express/repository.rb +0 -306
  131. data/lib/expressir/express/schema_definition.rb +0 -96
  132. data/lib/expressir/express/subtype_constraint.rb +0 -14
  133. data/lib/expressir/express/type.rb +0 -26
  134. data/lib/expressir/express/type_aggregate.rb +0 -42
  135. data/lib/expressir/express/type_enum.rb +0 -29
  136. data/lib/expressir/express/type_parser.rb +0 -45
  137. data/lib/expressir/express/type_select.rb +0 -82
  138. data/lib/expressir/express/unique_rule.rb +0 -35
  139. data/lib/expressir/express/where_rule.rb +0 -32
  140. data/lib/expressir/express_exp/2.4/express_parser.so +0 -0
  141. data/lib/expressir/express_exp/2.5/express_parser.so +0 -0
  142. data/lib/expressir/express_exp/2.6/express_parser.so +0 -0
  143. data/lib/expressir/express_exp/2.7/express_parser.so +0 -0
  144. data/lib/expressir/express_exp/3.0/express_parser.so +0 -0
  145. data/lib/expressir/express_exp/hyperlink_formatter.rb +0 -27
  146. data/lib/expressir/express_parser.rb +0 -30
  147. data/lib/expressir/model/informal_proposition.rb +0 -18
  148. data/lib/expressir/model/unique.rb +0 -19
  149. data/lib/expressir/model/where.rb +0 -19
  150. data/lib/expressir/parser.rb +0 -6
  151. data/lib/expressir/parser/owl_parser.rb +0 -8
  152. data/original/examples/syntax/single.exp +0 -3
  153. data/original/examples/syntax/single.yaml +0 -9
  154. data/original/examples/syntax/single_formatted.exp +0 -6
  155. data/original/examples/syntax/single_formatted.yaml +0 -19
  156. data/spec/acceptance/express_to_owl_spec.rb +0 -18
  157. data/spec/expressir/express/repository_spec.rb +0 -25
  158. data/spec/expressir/express_exp/formatter_spec.rb +0 -111
@@ -1,4 +1,4 @@
1
- SCHEMA syntax_schema 'version';
1
+ SCHEMA syntax_schema '{ISO standard 10303 part(41) object(1) version(8)}';
2
2
 
3
3
  USE FROM contract_schema;
4
4
  USE FROM contract_schema
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expressir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.21
4
+ version: 1.0.0
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-12 00:00:00.000000000 Z
11
+ date: 2021-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: nokogiri
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.10'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.10'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: thor
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -175,53 +161,26 @@ files:
175
161
  - docs/development.md
176
162
  - exe/expressir
177
163
  - exe/format
164
+ - exe/format-test
178
165
  - exe/generate-parser
179
166
  - expressir.gemspec
180
167
  - lib/expressir.rb
181
168
  - lib/expressir/cli.rb
182
169
  - lib/expressir/cli/ui.rb
183
170
  - lib/expressir/config.rb
184
- - lib/expressir/express.rb
185
- - lib/expressir/express/aggregate_dimension.rb
186
- - lib/expressir/express/attribute.rb
187
- - lib/expressir/express/comment.rb
188
- - lib/expressir/express/defined_type.rb
189
- - lib/expressir/express/derived.rb
190
- - lib/expressir/express/derived_aggregate.rb
191
- - lib/expressir/express/entity.rb
192
- - lib/expressir/express/explicit.rb
193
- - lib/expressir/express/explicit_aggregate.rb
194
- - lib/expressir/express/explicit_or_derived.rb
195
- - lib/expressir/express/global_rule.rb
196
- - lib/expressir/express/interface_specification.rb
197
- - lib/expressir/express/interfaced_item.rb
198
- - lib/expressir/express/inverse.rb
199
- - lib/expressir/express/inverse_aggregate.rb
200
- - lib/expressir/express/model_element.rb
201
- - lib/expressir/express/named_type.rb
202
- - lib/expressir/express/remark.rb
203
- - lib/expressir/express/repository.rb
204
- - lib/expressir/express/schema_definition.rb
205
- - lib/expressir/express/subtype_constraint.rb
206
- - lib/expressir/express/type.rb
207
- - lib/expressir/express/type_aggregate.rb
208
- - lib/expressir/express/type_enum.rb
209
- - lib/expressir/express/type_parser.rb
210
- - lib/expressir/express/type_select.rb
211
- - lib/expressir/express/unique_rule.rb
212
- - lib/expressir/express/where_rule.rb
213
- - lib/expressir/express_exp/2.4/express_parser.so
214
- - lib/expressir/express_exp/2.5/express_parser.so
215
- - lib/expressir/express_exp/2.6/express_parser.so
216
- - lib/expressir/express_exp/2.7/express_parser.so
217
- - lib/expressir/express_exp/3.0/express_parser.so
218
- - lib/expressir/express_exp/cache.rb
219
- - lib/expressir/express_exp/formatter.rb
220
- - lib/expressir/express_exp/hyperlink_formatter.rb
221
- - lib/expressir/express_exp/parser.rb
222
- - lib/expressir/express_exp/schema_head_formatter.rb
223
- - lib/expressir/express_exp/visitor.rb
224
- - lib/expressir/express_parser.rb
171
+ - lib/expressir/express/2.4/express_parser.so
172
+ - lib/expressir/express/2.5/express_parser.so
173
+ - lib/expressir/express/2.6/express_parser.so
174
+ - lib/expressir/express/2.7/express_parser.so
175
+ - lib/expressir/express/3.0/express_parser.so
176
+ - lib/expressir/express/cache.rb
177
+ - lib/expressir/express/formatter.rb
178
+ - lib/expressir/express/hyperlink_formatter.rb
179
+ - lib/expressir/express/model_visitor.rb
180
+ - lib/expressir/express/parser.rb
181
+ - lib/expressir/express/resolve_references_model_visitor.rb
182
+ - lib/expressir/express/schema_head_formatter.rb
183
+ - lib/expressir/express/visitor.rb
225
184
  - lib/expressir/model.rb
226
185
  - lib/expressir/model/attribute.rb
227
186
  - lib/expressir/model/cache.rb
@@ -242,7 +201,6 @@ files:
242
201
  - lib/expressir/model/expressions/unary_expression.rb
243
202
  - lib/expressir/model/function.rb
244
203
  - lib/expressir/model/identifier.rb
245
- - lib/expressir/model/informal_proposition.rb
246
204
  - lib/expressir/model/interface.rb
247
205
  - lib/expressir/model/interface_item.rb
248
206
  - lib/expressir/model/interfaced_item.rb
@@ -254,9 +212,12 @@ files:
254
212
  - lib/expressir/model/model_element.rb
255
213
  - lib/expressir/model/parameter.rb
256
214
  - lib/expressir/model/procedure.rb
215
+ - lib/expressir/model/remark_item.rb
257
216
  - lib/expressir/model/repository.rb
258
217
  - lib/expressir/model/rule.rb
259
218
  - lib/expressir/model/schema.rb
219
+ - lib/expressir/model/schema_version.rb
220
+ - lib/expressir/model/schema_version_item.rb
260
221
  - lib/expressir/model/statements/alias.rb
261
222
  - lib/expressir/model/statements/assignment.rb
262
223
  - lib/expressir/model/statements/call.rb
@@ -287,11 +248,9 @@ files:
287
248
  - lib/expressir/model/types/select.rb
288
249
  - lib/expressir/model/types/set.rb
289
250
  - lib/expressir/model/types/string.rb
290
- - lib/expressir/model/unique.rb
251
+ - lib/expressir/model/unique_rule.rb
291
252
  - lib/expressir/model/variable.rb
292
- - lib/expressir/model/where.rb
293
- - lib/expressir/parser.rb
294
- - lib/expressir/parser/owl_parser.rb
253
+ - lib/expressir/model/where_rule.rb
295
254
  - lib/expressir/version.rb
296
255
  - original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp
297
256
  - original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl
@@ -322,22 +281,6 @@ files:
322
281
  - original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl
323
282
  - original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi
324
283
  - original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml
325
- - original/examples/syntax/multiple.exp
326
- - original/examples/syntax/multiple.yaml
327
- - original/examples/syntax/multiple_formatted.exp
328
- - original/examples/syntax/multiple_hyperlink_formatted.exp
329
- - original/examples/syntax/multiple_schema_head_hyperlink_formatted.exp
330
- - original/examples/syntax/remark.exp
331
- - original/examples/syntax/remark.yaml
332
- - original/examples/syntax/remark_formatted.exp
333
- - original/examples/syntax/single.exp
334
- - original/examples/syntax/single.yaml
335
- - original/examples/syntax/single_formatted.exp
336
- - original/examples/syntax/single_formatted.yaml
337
- - original/examples/syntax/syntax.exp
338
- - original/examples/syntax/syntax.yaml
339
- - original/examples/syntax/syntax_formatted.exp
340
- - original/examples/syntax/syntax_schema_head_formatted.exp
341
284
  - original/exp2ruby.rb
342
285
  - original/expsm.rb
343
286
  - original/mapping_owl.rb
@@ -346,16 +289,31 @@ files:
346
289
  - original/mapping_uml2_eclipse.rb
347
290
  - original/reeper.rb
348
291
  - rakelib/cross-ruby.rake
349
- - spec/acceptance/express_to_owl_spec.rb
350
292
  - spec/acceptance/version_spec.rb
351
- - spec/expressir/express/repository_spec.rb
352
- - spec/expressir/express_exp/cache_spec.rb
353
- - spec/expressir/express_exp/formatter_spec.rb
354
- - spec/expressir/express_exp/parser_spec.rb
293
+ - spec/expressir/express/cache_spec.rb
294
+ - spec/expressir/express/formatter_spec.rb
295
+ - spec/expressir/express/parser_spec.rb
355
296
  - spec/expressir/model/model_element_spec.rb
356
297
  - spec/expressr_spec.rb
357
298
  - spec/spec_helper.rb
358
299
  - spec/support/console_helper.rb
300
+ - spec/syntax/multiple.exp
301
+ - spec/syntax/multiple.yaml
302
+ - spec/syntax/multiple_formatted.exp
303
+ - spec/syntax/multiple_hyperlink_formatted.exp
304
+ - spec/syntax/multiple_schema_head_hyperlink_formatted.exp
305
+ - spec/syntax/remark.exp
306
+ - spec/syntax/remark.yaml
307
+ - spec/syntax/remark_formatted.exp
308
+ - spec/syntax/single.exp
309
+ - spec/syntax/single.yaml
310
+ - spec/syntax/single_formatted.exp
311
+ - spec/syntax/single_formatted.yaml
312
+ - spec/syntax/syntax.exp
313
+ - spec/syntax/syntax.yaml
314
+ - spec/syntax/syntax_formatted.exp
315
+ - spec/syntax/syntax_hyperlink_formatted.exp
316
+ - spec/syntax/syntax_schema_head_formatted.exp
359
317
  homepage: https://github.com/lutaml/expressir
360
318
  licenses:
361
319
  - MIT
@@ -1,11 +0,0 @@
1
- require "nokogiri"
2
- require "expressir/express/repository"
3
- require "expressir/express/schema_definition"
4
-
5
- module Expressir
6
- module Express
7
- def self.from_xml(file)
8
- Expressir::Express::Repository.from_xml(file)
9
- end
10
- end
11
- end
@@ -1,38 +0,0 @@
1
- module Expressir
2
- module Express
3
- class AggregateDimension
4
- attr_accessor :aggrtype, :lower, :upper, :isUnique, :isOptionalArray
5
-
6
- def initialize(options = {})
7
- @aggrtype = "SET"
8
- @lower = "0"
9
- @upper = "?"
10
- @isUnique = false
11
- @isOptionalArray = false
12
-
13
- @options = options
14
- end
15
-
16
- def parse
17
- document = @options.fetch(:document, nil)
18
- extract_attributes(document) if document
19
-
20
- self
21
- end
22
-
23
- def self.parse(document)
24
- new(document: document).parse
25
- end
26
-
27
- private
28
-
29
- def extract_attributes(document)
30
- @aggrtype = document.attributes["type"]
31
- @lower = document.attributes["lower"]
32
- @upper = document.attributes["upper"]
33
- @isUnique = document.attributes["unique"] == "YES"
34
- @isOptionalArray = document.attributes["optional"] == "YES"
35
- end
36
- end
37
- end
38
- end
@@ -1,15 +0,0 @@
1
- require "expressir/express/model_element"
2
-
3
- module Expressir
4
- module Express
5
- class Attribute < ModelElement
6
- attr_accessor :name, :entity, :domain, :redeclare_entity,
7
- :redeclare_oldname
8
-
9
- def initialize
10
- @redeclare_entity = nil
11
- @redeclare_oldname = nil
12
- end
13
- end
14
- end
15
- end
@@ -1,7 +0,0 @@
1
- module Expressir
2
- module Express
3
- class Comment
4
- attr_accessor :comment, :ModelElement
5
- end
6
- end
7
- end
@@ -1,36 +0,0 @@
1
- require "expressir/express/named_type"
2
-
3
- module Expressir
4
- module Express
5
- class DefinedType < NamedType
6
- def initialize(options = {})
7
- @options = options
8
- @schema = options.fetch(:schema)
9
- end
10
-
11
- def parse
12
- document = @options.fetch(:document)
13
- extract_type_attributes(document)
14
-
15
- self
16
- end
17
-
18
- def self.parse(document, schema)
19
- new(document: document, schema: schema).parse
20
- end
21
-
22
- private
23
-
24
- def extract_type_attributes(document)
25
- @name = document.attributes["name"].to_s
26
- @wheres = extract_where_rules(document)
27
- end
28
-
29
- def extract_where_rules(document)
30
- document.xpath("where").map do |where|
31
- Express::WhereRule.parse(where)
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,65 +0,0 @@
1
- module Expressir
2
- module Express
3
- class Derived < ExplicitOrDerived
4
- attr_accessor :expression
5
-
6
- def initialize(options = {})
7
- @options = options
8
- @entity = options.fetch(:entity, nil)
9
- end
10
-
11
- def parse
12
- document = @options.fetch(:document, nil)
13
- extract_common_attributes(document)
14
- extract_type_specific_attributes(document)
15
-
16
- self
17
- end
18
-
19
- def self.parse(document, entity)
20
- new(document: document, entity: entity).parse
21
- end
22
-
23
- private
24
-
25
- def extract_type_specific_attributes(document); end
26
-
27
- def extract_common_attributes(document)
28
- @name = document.attributes["name"].to_s
29
- @expression = document.attributes["expression"].to_s
30
- @domain = extract_domain_name(document.xpath("typename"))
31
-
32
- extract_builtintype_attributes(document)
33
- extract_redeclaration_attributes(document)
34
- end
35
-
36
- def extract_domain_name(typename)
37
- unless typename.empty?
38
- typename.first.attributes["name"].to_s
39
- end
40
- end
41
-
42
- def extract_redeclaration_attributes(document)
43
- redeclaration = document.xpath("redeclaration").first
44
-
45
- if redeclaration
46
- @redeclare_entity = redeclaration.attributes["entity-ref"].to_s
47
- old_name = redeclaration.attributes["old_name"]
48
- @redeclare_oldname = old_name.to_s if old_name
49
- end
50
- end
51
-
52
- def extract_builtintype_attributes(document)
53
- builtin_type = document.xpath("builtintype").first
54
-
55
- if builtin_type
56
- @isBuiltin = true
57
- @domain = builtin_type.attributes["type"].to_s
58
- @width = builtin_type.attributes["width"].to_s
59
- @fixed = builtin_type.attributes["fixed"] == "YES"
60
- @precision = builtin_type.attributes["precision"].to_s
61
- end
62
- end
63
- end
64
- end
65
- end
@@ -1,43 +0,0 @@
1
- module Expressir
2
- module Express
3
- class DerivedAggregate < Derived
4
- attr_accessor :rank, :dimensions
5
-
6
- def initialize(options = {})
7
- @rank = 0
8
- @dimensions = []
9
-
10
- super(options)
11
- end
12
-
13
- private
14
-
15
- def extract_type_specific_attributes(document)
16
- @dimensions = document.xpath("aggregate").map do |aggregate|
17
- Express::AggregateDimension.parse(aggregate)
18
- end
19
-
20
- @rank = @dimensions.size
21
- extract_inverse_aggregate(document)
22
- end
23
-
24
- # @todo: Non existance attributes
25
- #
26
- # In the codebase, they are trying to add couple of aggregate
27
- # dimensions related attributes that was never a part of the
28
- # Explict class, but for consistency we are keeping those as
29
- # it is for now. let's revist those later and fix it.
30
- #
31
- def extract_inverse_aggregate(document)
32
- aggregates = document.xpath("inverse.aggregate")
33
-
34
- if !aggregates.empty?
35
- dimension = Express::AggregateDimension.parse(aggregates.first)
36
- @aggrtype = dimension.aggrtype
37
- @lower = dimension.lower
38
- @upper = dimension.upper
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,137 +0,0 @@
1
- require "expressir/express/explicit"
2
- require "expressir/express/inverse"
3
- require "expressir/express/derived"
4
- require "expressir/express/named_type"
5
- require "expressir/express/where_rule"
6
- require "expressir/express/unique_rule"
7
-
8
- require "expressir/express/explicit_aggregate"
9
- require "expressir/express/inverse_aggregate"
10
- require "expressir/express/derived_aggregate"
11
-
12
- module Expressir
13
- module Express
14
- class Entity < NamedType
15
- attr_accessor :supertypes, :attributes, :isAbs, :superexpression,
16
- :uniques, :subtypes_array, :supertypes_array, :attributes_all_array,
17
- :supertypes_all
18
-
19
- def initialize(document: nil, schema: nil, **options)
20
- @isAbs = false
21
- @attributes = []
22
- @uniques = []
23
- @wheres = []
24
- @subtypes_array = []
25
- @supertypes_array = []
26
- @attributes_all_array = []
27
- @supertypes = nil
28
- @supertypes_all = nil
29
- @superexpression = nil
30
- @selectedBy = []
31
-
32
- @schema = schema
33
- @document = document
34
- @options = options
35
- end
36
-
37
- def find_attr_by_name( attrname )
38
- for attribute in attributes
39
- if attrname == attribute.name
40
- return attribute
41
- end
42
- end
43
- return nil
44
- end
45
-
46
- def find_attr_by_name_full( attrname )
47
- attr = find_attr_by_name( attrname )
48
- if attr != nil
49
- return attr
50
- end
51
- for supertype in supertypes_array
52
- attr = supertype.find_attr_by_name_full (attrname)
53
- if attr != nil
54
- return attr
55
- end
56
- end
57
- end
58
-
59
- def parse
60
- extract_attributes(@document, @schema)
61
- self
62
- end
63
-
64
- def self.parse(document, schema)
65
- new(document: document, schema: schema).parse
66
- end
67
-
68
- private
69
-
70
- def extract_attributes(document, schema)
71
- @name = document.attributes["name"].to_s
72
- @supertypes = document.attributes["supertypes"]
73
- @superexpression = document.attributes["super.expression"]
74
-
75
- @wheres = extract_where_rules(document)
76
- @uniques = extract_unique_rules(document)
77
-
78
- @isAbs = document.attributes["supertypes"] == "YES" ||
79
- document.attributes["abstract.entity"] == "YES"
80
-
81
- @attributes = [
82
- extract_eplicits(document),
83
- extract_inverses(document),
84
- extract_derivedes(document),
85
- ].flatten
86
- end
87
-
88
- def extract_eplicits(document)
89
- document.xpath("explicit").map do |explicit|
90
- explicit_type = Express::Explicit
91
-
92
- if !explicit.xpath("aggregate").empty?
93
- explicit_type = Express::ExplicitAggregate
94
- end
95
-
96
- explicit_type.parse(explicit, self)
97
- end
98
- end
99
-
100
- def extract_inverses(document)
101
- document.xpath("inverse").map do |inverse|
102
- inverse_type = Express::Inverse
103
-
104
- if !inverse.xpath("inverse.aggregate").empty?
105
- inverse_type = Express::InverseAggregate
106
- end
107
-
108
- inverse_type.parse(inverse, self)
109
- end
110
- end
111
-
112
- def extract_derivedes(document)
113
- document.xpath("derived").map do |derived|
114
- derived_type = Express::Derived
115
-
116
- if !derived.xpath("aggregate").empty?
117
- derived_type = Express::DerivedAggregate
118
- end
119
-
120
- derived_type.parse(derived, self)
121
- end
122
- end
123
-
124
- def extract_unique_rules(document)
125
- document.xpath("unique").map do |unique|
126
- Express::UniqueRule.parse(unique)
127
- end
128
- end
129
-
130
- def extract_where_rules(document)
131
- document.xpath("where").map do |where|
132
- Express::WhereRule.parse(where)
133
- end
134
- end
135
- end
136
- end
137
- end