expressir 0.2.9-arm64-darwin → 0.2.14-arm64-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/exe/format +20 -0
  3. data/expressir.gemspec +1 -0
  4. data/lib/expressir/express_exp/2.4/express_parser.bundle +0 -0
  5. data/lib/expressir/express_exp/2.5/express_parser.bundle +0 -0
  6. data/lib/expressir/express_exp/2.6/express_parser.bundle +0 -0
  7. data/lib/expressir/express_exp/2.7/express_parser.bundle +0 -0
  8. data/lib/expressir/express_exp/3.0/express_parser.bundle +0 -0
  9. data/lib/expressir/express_exp/formatter.rb +146 -105
  10. data/lib/expressir/express_exp/hyperlink_formatter.rb +25 -0
  11. data/lib/expressir/express_exp/parser.rb +2 -0
  12. data/lib/expressir/express_exp/schema_head_formatter.rb +14 -0
  13. data/lib/expressir/express_exp/visitor.rb +132 -82
  14. data/lib/expressir/model.rb +2 -1
  15. data/lib/expressir/model/attribute.rb +5 -1
  16. data/lib/expressir/model/constant.rb +5 -1
  17. data/lib/expressir/model/entity.rb +13 -22
  18. data/lib/expressir/model/enumeration_item.rb +5 -1
  19. data/lib/expressir/model/expressions/aggregate_initializer.rb +4 -2
  20. data/lib/expressir/model/expressions/aggregate_item.rb +3 -1
  21. data/lib/expressir/model/expressions/attribute_reference.rb +3 -1
  22. data/lib/expressir/model/expressions/binary_expression.rb +3 -1
  23. data/lib/expressir/model/expressions/call.rb +4 -2
  24. data/lib/expressir/model/expressions/entity_constructor.rb +4 -2
  25. data/lib/expressir/model/expressions/group_reference.rb +3 -1
  26. data/lib/expressir/model/expressions/index_reference.rb +3 -1
  27. data/lib/expressir/model/expressions/interval.rb +3 -1
  28. data/lib/expressir/model/expressions/query_expression.rb +5 -2
  29. data/lib/expressir/model/expressions/simple_reference.rb +3 -1
  30. data/lib/expressir/model/expressions/unary_expression.rb +3 -1
  31. data/lib/expressir/model/function.rb +28 -39
  32. data/lib/expressir/model/identifier.rb +1 -3
  33. data/lib/expressir/model/informal_proposition.rb +5 -1
  34. data/lib/expressir/model/interface.rb +4 -2
  35. data/lib/expressir/model/literals/binary.rb +3 -1
  36. data/lib/expressir/model/literals/integer.rb +3 -1
  37. data/lib/expressir/model/literals/logical.rb +3 -1
  38. data/lib/expressir/model/literals/real.rb +3 -1
  39. data/lib/expressir/model/literals/string.rb +3 -1
  40. data/lib/expressir/model/model_element.rb +140 -0
  41. data/lib/expressir/model/parameter.rb +5 -1
  42. data/lib/expressir/model/procedure.rb +29 -40
  43. data/lib/expressir/model/renamed_ref.rb +3 -1
  44. data/lib/expressir/model/repository.rb +5 -5
  45. data/lib/expressir/model/rule.rb +32 -43
  46. data/lib/expressir/model/schema.rb +48 -48
  47. data/lib/expressir/model/statements/alias.rb +6 -3
  48. data/lib/expressir/model/statements/assignment.rb +3 -1
  49. data/lib/expressir/model/statements/call.rb +4 -2
  50. data/lib/expressir/model/statements/case.rb +4 -2
  51. data/lib/expressir/model/statements/case_action.rb +4 -2
  52. data/lib/expressir/model/statements/compound.rb +4 -2
  53. data/lib/expressir/model/statements/escape.rb +1 -1
  54. data/lib/expressir/model/statements/if.rb +5 -3
  55. data/lib/expressir/model/statements/null.rb +1 -1
  56. data/lib/expressir/model/statements/repeat.rb +6 -3
  57. data/lib/expressir/model/statements/return.rb +3 -1
  58. data/lib/expressir/model/statements/skip.rb +1 -1
  59. data/lib/expressir/model/subtype_constraint.rb +5 -2
  60. data/lib/expressir/model/type.rb +10 -11
  61. data/lib/expressir/model/types/aggregate.rb +5 -1
  62. data/lib/expressir/model/types/array.rb +3 -1
  63. data/lib/expressir/model/types/bag.rb +3 -1
  64. data/lib/expressir/model/types/binary.rb +3 -1
  65. data/lib/expressir/model/types/boolean.rb +1 -1
  66. data/lib/expressir/model/types/enumeration.rb +5 -3
  67. data/lib/expressir/model/types/generic.rb +5 -1
  68. data/lib/expressir/model/types/generic_entity.rb +5 -1
  69. data/lib/expressir/model/types/integer.rb +1 -1
  70. data/lib/expressir/model/types/list.rb +3 -1
  71. data/lib/expressir/model/types/logical.rb +1 -1
  72. data/lib/expressir/model/types/number.rb +1 -1
  73. data/lib/expressir/model/types/real.rb +3 -1
  74. data/lib/expressir/model/types/select.rb +5 -3
  75. data/lib/expressir/model/types/set.rb +3 -1
  76. data/lib/expressir/model/types/string.rb +3 -1
  77. data/lib/expressir/model/unique.rb +6 -2
  78. data/lib/expressir/model/variable.rb +5 -1
  79. data/lib/expressir/model/where.rb +5 -1
  80. data/lib/expressir/version.rb +1 -1
  81. data/original/examples/syntax/hyperlink.exp +8 -0
  82. data/original/examples/syntax/hyperlink_formatted.exp +19 -0
  83. data/original/examples/syntax/remark_formatted.exp +0 -5
  84. data/original/examples/syntax/simple.exp +3 -0
  85. data/original/examples/syntax/syntax.exp +197 -189
  86. data/original/examples/syntax/syntax_formatted.exp +362 -800
  87. data/spec/expressir/express_exp/{format_remark_spec.rb → formatter/remark_spec.rb} +2 -2
  88. data/spec/expressir/express_exp/{format_syntax_spec.rb → formatter/syntax_spec.rb} +2 -2
  89. data/spec/expressir/express_exp/hyperlink_formatter_spec.rb +24 -0
  90. data/spec/expressir/express_exp/{head_source_spec.rb → parser/head_source_spec.rb} +2 -5
  91. data/spec/expressir/express_exp/{parse_multiple_spec.rb → parser/multiple_spec.rb} +6 -1
  92. data/spec/expressir/express_exp/{parse_remark_spec.rb → parser/remark_spec.rb} +5 -5
  93. data/spec/expressir/express_exp/{source_spec.rb → parser/source_spec.rb} +2 -5
  94. data/spec/expressir/express_exp/{parse_syntax_spec.rb → parser/syntax_spec.rb} +1619 -1582
  95. data/spec/expressir/express_exp/schema_head_formatter_spec.rb +36 -0
  96. data/spec/expressir/model/{find_spec.rb → model_element/find_spec.rb} +7 -2
  97. data/spec/expressir/model/model_element/hash_spec.rb +66 -0
  98. metadata +34 -12
  99. data/lib/expressir/model/scope.rb +0 -66
  100. data/spec/expressir/express_exp/ap233_spec.rb +0 -22
@@ -0,0 +1,36 @@
1
+ require "spec_helper"
2
+ require "expressir/express_exp/parser"
3
+ require "expressir/express_exp/schema_head_formatter"
4
+
5
+ RSpec.describe Expressir::ExpressExp::SchemaHeadFormatter do
6
+ describe ".format" do
7
+ it "formats schema head" do
8
+ repo = Expressir::ExpressExp::Parser.from_file(sample_file)
9
+
10
+ result = Expressir::ExpressExp::SchemaHeadFormatter.format(repo)
11
+
12
+ expect(result).to eq(<<~EXP.strip
13
+ SCHEMA syntax_schema 'version';
14
+ USE FROM contract_schema;
15
+ USE FROM contract_schema
16
+ (contract);
17
+ USE FROM contract_schema
18
+ (contract, contract2);
19
+ USE FROM contract_schema
20
+ (contract AS contract2);
21
+ REFERENCE FROM contract_schema;
22
+ REFERENCE FROM contract_schema
23
+ (contract);
24
+ REFERENCE FROM contract_schema
25
+ (contract, contract2);
26
+ REFERENCE FROM contract_schema
27
+ (contract AS contract2);
28
+ EXP
29
+ )
30
+ end
31
+ end
32
+
33
+ def sample_file
34
+ @sample_file ||= Expressir.root_path.join("original", "examples", "syntax", "syntax.exp")
35
+ end
36
+ end
@@ -1,10 +1,10 @@
1
1
  require "spec_helper"
2
2
  require "expressir/express_exp/parser"
3
3
 
4
- RSpec.describe Expressir::Model do
4
+ RSpec.describe Expressir::Model::ModelElement do
5
5
  describe ".find" do
6
6
  it "finds an object" do
7
- repo = Expressir::ExpressExp::Parser.from_exp(sample_file)
7
+ repo = Expressir::ExpressExp::Parser.from_file(sample_file)
8
8
 
9
9
  # universal scope
10
10
  expect(repo.find('remark_schema')).to be_instance_of(Expressir::Model::Schema)
@@ -112,6 +112,11 @@ RSpec.describe Expressir::Model do
112
112
  expect(rule.find('remark_variable')).to be_instance_of(Expressir::Model::Variable)
113
113
  expect(rule.find('WR1')).to be_instance_of(Expressir::Model::Where)
114
114
  expect(rule.find('wr:WR1')).to be_instance_of(Expressir::Model::Where)
115
+
116
+ # retry search in parent scope
117
+ expect(entity.find('remark_type')).to be_instance_of(Expressir::Model::Type)
118
+ expect(entity.find('remark_type.WR1')).to be_instance_of(Expressir::Model::Where)
119
+ expect(entity.find('remark_type.wr:WR1')).to be_instance_of(Expressir::Model::Where)
115
120
  end
116
121
  end
117
122
 
@@ -0,0 +1,66 @@
1
+ require "spec_helper"
2
+ require "expressir/express_exp/parser"
3
+ require "expressir/express_exp/formatter"
4
+
5
+ RSpec.describe Expressir::Model::ModelElement do
6
+ describe ".from_hash" do
7
+ it "parses an object from a hash" do
8
+ input = {
9
+ "_class" => "Expressir::Model::Repository",
10
+ "schemas" => [{
11
+ "_class" => "Expressir::Model::Schema",
12
+ "id" => "simple_schema",
13
+ "entities" => [{
14
+ "_class" => "Expressir::Model::Entity",
15
+ "id" => "empty_entity"
16
+ }]
17
+ }]
18
+ }
19
+
20
+ repo = Expressir::Model::ModelElement.from_hash(input)
21
+
22
+ expect(repo).to be_instance_of(Expressir::Model::Repository)
23
+ expect(repo.schemas).to be_instance_of(Array)
24
+ expect(repo.schemas.count).to eq(1)
25
+ expect(repo.schemas.first).to be_instance_of(Expressir::Model::Schema)
26
+ expect(repo.schemas.first.id).to eq("simple_schema")
27
+ expect(repo.schemas.first.entities).to be_instance_of(Array)
28
+ expect(repo.schemas.first.entities.count).to eq(1)
29
+ expect(repo.schemas.first.entities.first).to be_instance_of(Expressir::Model::Entity)
30
+ expect(repo.schemas.first.entities.first.id).to eq("empty_entity")
31
+ end
32
+ end
33
+
34
+ describe ".to_hash" do
35
+ it "exports an object to a hash" do
36
+ repo = Expressir::ExpressExp::Parser.from_file(sample_file)
37
+
38
+ class CustomFormatter < Expressir::ExpressExp::Formatter
39
+ def format_schema(node)
40
+ "Oook."
41
+ end
42
+ end
43
+ result = repo.to_hash(formatter: CustomFormatter)
44
+
45
+ expect(result).to be_instance_of(Hash)
46
+ expect(result["_class"]).to eq("Expressir::Model::Repository")
47
+ expect(result["schemas"]).to be_instance_of(Array)
48
+ expect(result["schemas"].count).to eq(1)
49
+ expect(result["schemas"].first).to be_instance_of(Hash)
50
+ expect(result["schemas"].first["_class"]).to eq("Expressir::Model::Schema")
51
+ expect(result["schemas"].first["id"]).to eq("simple_schema")
52
+ expect(result["schemas"].first["entities"]).to be_instance_of(Array)
53
+ expect(result["schemas"].first["entities"].count).to eq(1)
54
+ expect(result["schemas"].first["entities"].first).to be_instance_of(Hash)
55
+ expect(result["schemas"].first["entities"].first["_class"]).to eq("Expressir::Model::Entity")
56
+ expect(result["schemas"].first["entities"].first["id"]).to eq("empty_entity")
57
+ expect(result["schemas"].first["source"]).to eq("Oook.")
58
+ end
59
+ end
60
+
61
+ def sample_file
62
+ @sample_file ||= Expressir.root_path.join(
63
+ "original", "examples", "syntax", "simple.exp"
64
+ )
65
+ end
66
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expressir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.14
5
5
  platform: arm64-darwin
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-05 00:00:00.000000000 Z
11
+ date: 2021-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.12.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '11.1'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '11.1'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rake
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -160,6 +174,7 @@ files:
160
174
  - demo.rb
161
175
  - docs/development.md
162
176
  - exe/expressir
177
+ - exe/format
163
178
  - exe/generate-parser
164
179
  - expressir.gemspec
165
180
  - lib/expressir.rb
@@ -201,7 +216,9 @@ files:
201
216
  - lib/expressir/express_exp/2.7/express_parser.bundle
202
217
  - lib/expressir/express_exp/3.0/express_parser.bundle
203
218
  - lib/expressir/express_exp/formatter.rb
219
+ - lib/expressir/express_exp/hyperlink_formatter.rb
204
220
  - lib/expressir/express_exp/parser.rb
221
+ - lib/expressir/express_exp/schema_head_formatter.rb
205
222
  - lib/expressir/express_exp/visitor.rb
206
223
  - lib/expressir/express_parser.rb
207
224
  - lib/expressir/model.rb
@@ -230,13 +247,13 @@ files:
230
247
  - lib/expressir/model/literals/logical.rb
231
248
  - lib/expressir/model/literals/real.rb
232
249
  - lib/expressir/model/literals/string.rb
250
+ - lib/expressir/model/model_element.rb
233
251
  - lib/expressir/model/parameter.rb
234
252
  - lib/expressir/model/procedure.rb
235
253
  - lib/expressir/model/renamed_ref.rb
236
254
  - lib/expressir/model/repository.rb
237
255
  - lib/expressir/model/rule.rb
238
256
  - lib/expressir/model/schema.rb
239
- - lib/expressir/model/scope.rb
240
257
  - lib/expressir/model/statements/alias.rb
241
258
  - lib/expressir/model/statements/assignment.rb
242
259
  - lib/expressir/model/statements/call.rb
@@ -302,8 +319,11 @@ files:
302
319
  - original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl
303
320
  - original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi
304
321
  - original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml
322
+ - original/examples/syntax/hyperlink.exp
323
+ - original/examples/syntax/hyperlink_formatted.exp
305
324
  - original/examples/syntax/remark.exp
306
325
  - original/examples/syntax/remark_formatted.exp
326
+ - original/examples/syntax/simple.exp
307
327
  - original/examples/syntax/source.exp
308
328
  - original/examples/syntax/syntax.exp
309
329
  - original/examples/syntax/syntax_formatted.exp
@@ -318,15 +338,17 @@ files:
318
338
  - spec/acceptance/express_to_owl_spec.rb
319
339
  - spec/acceptance/version_spec.rb
320
340
  - spec/expressir/express/repository_spec.rb
321
- - spec/expressir/express_exp/ap233_spec.rb
322
- - spec/expressir/express_exp/format_remark_spec.rb
323
- - spec/expressir/express_exp/format_syntax_spec.rb
324
- - spec/expressir/express_exp/head_source_spec.rb
325
- - spec/expressir/express_exp/parse_multiple_spec.rb
326
- - spec/expressir/express_exp/parse_remark_spec.rb
327
- - spec/expressir/express_exp/parse_syntax_spec.rb
328
- - spec/expressir/express_exp/source_spec.rb
329
- - spec/expressir/model/find_spec.rb
341
+ - spec/expressir/express_exp/formatter/remark_spec.rb
342
+ - spec/expressir/express_exp/formatter/syntax_spec.rb
343
+ - spec/expressir/express_exp/hyperlink_formatter_spec.rb
344
+ - spec/expressir/express_exp/parser/head_source_spec.rb
345
+ - spec/expressir/express_exp/parser/multiple_spec.rb
346
+ - spec/expressir/express_exp/parser/remark_spec.rb
347
+ - spec/expressir/express_exp/parser/source_spec.rb
348
+ - spec/expressir/express_exp/parser/syntax_spec.rb
349
+ - spec/expressir/express_exp/schema_head_formatter_spec.rb
350
+ - spec/expressir/model/model_element/find_spec.rb
351
+ - spec/expressir/model/model_element/hash_spec.rb
330
352
  - spec/expressr_spec.rb
331
353
  - spec/spec_helper.rb
332
354
  - spec/support/console_helper.rb
@@ -1,66 +0,0 @@
1
- module Expressir
2
- module Model
3
- module Scope
4
- attr_accessor :source
5
-
6
- def find(path)
7
- current_path, _, rest = path.partition(".")
8
-
9
- # ignore prefix
10
- _, _, current_path = current_path.rpartition(":")
11
-
12
- current_path = current_path.downcase
13
- child = children.find{|x| x.id and x.id.downcase == current_path}
14
-
15
- if !rest.empty? and child.class.method_defined? :find
16
- child.find(rest)
17
- else
18
- child
19
- end
20
- end
21
-
22
- def find_or_create(path)
23
- child = find(path)
24
-
25
- if !child
26
- # check if path should create implicit informal proposal
27
- # see https://github.com/lutaml/expressir/issues/50
28
- rest, _, current_path = path.rpartition(".")
29
-
30
- if !rest.empty?
31
- child = find(rest)
32
- else
33
- child = self
34
- end
35
-
36
- if child.class.method_defined? :informal_propositions
37
- # ignore prefix
38
- _, _, current_path = current_path.rpartition(":")
39
-
40
- # match informal proposition id
41
- informal_proposition_id = current_path.match(/^IP\d+$/).to_a[0]
42
-
43
- if informal_proposition_id
44
- # create implicit informal proposition
45
- informal_proposition = Model::InformalProposition.new({
46
- id: informal_proposition_id
47
- })
48
- informal_proposition.parent = child
49
-
50
- child.informal_propositions ||= []
51
- child.informal_propositions << informal_proposition
52
-
53
- informal_proposition
54
- end
55
- end
56
- else
57
- child
58
- end
59
- end
60
-
61
- def children
62
- raise 'Not implemented'
63
- end
64
- end
65
- end
66
- end
@@ -1,22 +0,0 @@
1
- require "spec_helper"
2
- require "expressir/express_exp/parser"
3
-
4
- RSpec.describe Expressir::ExpressExp::Parser do
5
- describe ".from_file" do
6
- it "build an instance from a file" do
7
- repo = Expressir::ExpressExp::Parser.from_exp(sample_file)
8
-
9
- schemas = repo.schemas
10
- expect(schemas.count).to eq(1)
11
-
12
- schema = schemas.first
13
- expect(schema.id).to eq("Ap233_systems_engineering_arm_LF")
14
- end
15
- end
16
-
17
- def sample_file
18
- @sample_file ||= Expressir.root_path.join(
19
- "original", "examples", "ap233", "ap233e1_arm_lf_stepmod-2010-11-12.exp"
20
- )
21
- end
22
- end