expressir 0.2.11-arm64-darwin → 0.2.12-arm64-darwin

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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/exe/format +16 -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 +75 -89
  10. data/lib/expressir/express_exp/hyperlink_formatter.rb +25 -0
  11. data/lib/expressir/express_exp/schema_head_formatter.rb +14 -0
  12. data/lib/expressir/express_exp/visitor.rb +58 -58
  13. data/lib/expressir/model.rb +0 -1
  14. data/lib/expressir/model/attribute.rb +2 -0
  15. data/lib/expressir/model/constant.rb +2 -0
  16. data/lib/expressir/model/entity.rb +3 -2
  17. data/lib/expressir/model/enumeration_item.rb +2 -0
  18. data/lib/expressir/model/expressions/aggregate_initializer.rb +2 -0
  19. data/lib/expressir/model/expressions/aggregate_item.rb +2 -0
  20. data/lib/expressir/model/expressions/attribute_reference.rb +2 -0
  21. data/lib/expressir/model/expressions/binary_expression.rb +2 -0
  22. data/lib/expressir/model/expressions/call.rb +2 -0
  23. data/lib/expressir/model/expressions/entity_constructor.rb +2 -0
  24. data/lib/expressir/model/expressions/group_reference.rb +2 -0
  25. data/lib/expressir/model/expressions/index_reference.rb +2 -0
  26. data/lib/expressir/model/expressions/interval.rb +2 -0
  27. data/lib/expressir/model/expressions/query_expression.rb +2 -1
  28. data/lib/expressir/model/expressions/simple_reference.rb +2 -0
  29. data/lib/expressir/model/expressions/unary_expression.rb +2 -0
  30. data/lib/expressir/model/function.rb +3 -8
  31. data/lib/expressir/model/identifier.rb +0 -1
  32. data/lib/expressir/model/informal_proposition.rb +2 -0
  33. data/lib/expressir/model/interface.rb +2 -0
  34. data/lib/expressir/model/literals/binary.rb +2 -0
  35. data/lib/expressir/model/literals/integer.rb +2 -0
  36. data/lib/expressir/model/literals/logical.rb +2 -0
  37. data/lib/expressir/model/literals/real.rb +2 -0
  38. data/lib/expressir/model/literals/string.rb +2 -0
  39. data/lib/expressir/model/model_element.rb +71 -4
  40. data/lib/expressir/model/parameter.rb +2 -0
  41. data/lib/expressir/model/procedure.rb +3 -8
  42. data/lib/expressir/model/renamed_ref.rb +2 -0
  43. data/lib/expressir/model/repository.rb +2 -2
  44. data/lib/expressir/model/rule.rb +4 -9
  45. data/lib/expressir/model/schema.rb +5 -8
  46. data/lib/expressir/model/statements/alias.rb +2 -1
  47. data/lib/expressir/model/statements/assignment.rb +2 -0
  48. data/lib/expressir/model/statements/call.rb +2 -0
  49. data/lib/expressir/model/statements/case.rb +2 -0
  50. data/lib/expressir/model/statements/case_action.rb +2 -0
  51. data/lib/expressir/model/statements/compound.rb +2 -0
  52. data/lib/expressir/model/statements/if.rb +2 -0
  53. data/lib/expressir/model/statements/repeat.rb +2 -1
  54. data/lib/expressir/model/statements/return.rb +2 -0
  55. data/lib/expressir/model/subtype_constraint.rb +2 -1
  56. data/lib/expressir/model/type.rb +3 -6
  57. data/lib/expressir/model/types/aggregate.rb +2 -0
  58. data/lib/expressir/model/types/array.rb +2 -0
  59. data/lib/expressir/model/types/bag.rb +2 -0
  60. data/lib/expressir/model/types/binary.rb +2 -0
  61. data/lib/expressir/model/types/enumeration.rb +2 -0
  62. data/lib/expressir/model/types/generic.rb +2 -0
  63. data/lib/expressir/model/types/generic_entity.rb +2 -0
  64. data/lib/expressir/model/types/list.rb +2 -0
  65. data/lib/expressir/model/types/real.rb +2 -0
  66. data/lib/expressir/model/types/select.rb +2 -0
  67. data/lib/expressir/model/types/set.rb +2 -0
  68. data/lib/expressir/model/types/string.rb +2 -0
  69. data/lib/expressir/model/unique.rb +2 -0
  70. data/lib/expressir/model/variable.rb +2 -0
  71. data/lib/expressir/model/where.rb +2 -0
  72. data/lib/expressir/version.rb +1 -1
  73. data/original/examples/syntax/hyperlink.exp +8 -0
  74. data/original/examples/syntax/hyperlink_formatted.exp +19 -0
  75. data/original/examples/syntax/syntax.exp +18 -18
  76. data/original/examples/syntax/syntax_formatted.exp +32 -24
  77. data/spec/expressir/express_exp/{format_remark_spec.rb → formatter/remark_spec.rb} +2 -2
  78. data/spec/expressir/express_exp/{format_syntax_spec.rb → formatter/syntax_spec.rb} +2 -2
  79. data/spec/expressir/express_exp/hyperlink_formatter_spec.rb +24 -0
  80. data/spec/expressir/express_exp/{head_source_spec.rb → parser/head_source_spec.rb} +1 -1
  81. data/spec/expressir/express_exp/{parse_multiple_spec.rb → parser/multiple_spec.rb} +1 -1
  82. data/spec/expressir/express_exp/{parse_remark_spec.rb → parser/remark_spec.rb} +2 -2
  83. data/spec/expressir/express_exp/{source_spec.rb → parser/source_spec.rb} +1 -1
  84. data/spec/expressir/express_exp/{parse_syntax_spec.rb → parser/syntax_spec.rb} +76 -44
  85. data/spec/expressir/express_exp/schema_head_formatter_spec.rb +36 -0
  86. data/spec/expressir/model/{scope_spec.rb → model_element/find_spec.rb} +7 -2
  87. data/spec/expressir/model/{model_element_spec.rb → model_element/hash_spec.rb} +7 -18
  88. metadata +32 -13
  89. data/lib/expressir/model/scope.rb +0 -71
  90. 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::Scope 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::Scope 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
 
@@ -33,9 +33,14 @@ RSpec.describe Expressir::Model::ModelElement do
33
33
 
34
34
  describe ".to_hash" do
35
35
  it "exports an object to a hash" do
36
- repo = Expressir::ExpressExp::Parser.from_exp(sample_file)
36
+ repo = Expressir::ExpressExp::Parser.from_file(sample_file)
37
37
 
38
- result = repo.to_hash
38
+ class CustomFormatter < Expressir::ExpressExp::Formatter
39
+ def format_schema(node)
40
+ "Oook."
41
+ end
42
+ end
43
+ result = repo.to_hash(formatter: CustomFormatter)
39
44
 
40
45
  expect(result).to be_instance_of(Hash)
41
46
  expect(result["_class"]).to eq("Expressir::Model::Repository")
@@ -49,22 +54,6 @@ RSpec.describe Expressir::Model::ModelElement do
49
54
  expect(result["schemas"].first["entities"].first).to be_instance_of(Hash)
50
55
  expect(result["schemas"].first["entities"].first["_class"]).to eq("Expressir::Model::Entity")
51
56
  expect(result["schemas"].first["entities"].first["id"]).to eq("empty_entity")
52
- end
53
-
54
- it "exports an object to a hash with a custom formatter" do
55
- repo = Expressir::ExpressExp::Parser.from_exp(sample_file)
56
-
57
- class CustomFormatter < Expressir::ExpressExp::Formatter
58
- def format_schema(node)
59
- "Oook."
60
- end
61
- end
62
- result = repo.to_hash({ formatter: CustomFormatter })
63
-
64
- expect(result).to be_instance_of(Hash)
65
- expect(result["_class"]).to eq("Expressir::Model::Repository")
66
- expect(result["schemas"]).to be_instance_of(Array)
67
- expect(result["schemas"].count).to eq(1)
68
57
  expect(result["schemas"].first["source"]).to eq("Oook.")
69
58
  end
70
59
  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.11
4
+ version: 0.2.12
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-09 00:00:00.000000000 Z
11
+ date: 2021-02-24 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
@@ -237,7 +254,6 @@ files:
237
254
  - lib/expressir/model/repository.rb
238
255
  - lib/expressir/model/rule.rb
239
256
  - lib/expressir/model/schema.rb
240
- - lib/expressir/model/scope.rb
241
257
  - lib/expressir/model/statements/alias.rb
242
258
  - lib/expressir/model/statements/assignment.rb
243
259
  - lib/expressir/model/statements/call.rb
@@ -303,6 +319,8 @@ files:
303
319
  - original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl
304
320
  - original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi
305
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
306
324
  - original/examples/syntax/remark.exp
307
325
  - original/examples/syntax/remark_formatted.exp
308
326
  - original/examples/syntax/simple.exp
@@ -320,16 +338,17 @@ files:
320
338
  - spec/acceptance/express_to_owl_spec.rb
321
339
  - spec/acceptance/version_spec.rb
322
340
  - spec/expressir/express/repository_spec.rb
323
- - spec/expressir/express_exp/ap233_spec.rb
324
- - spec/expressir/express_exp/format_remark_spec.rb
325
- - spec/expressir/express_exp/format_syntax_spec.rb
326
- - spec/expressir/express_exp/head_source_spec.rb
327
- - spec/expressir/express_exp/parse_multiple_spec.rb
328
- - spec/expressir/express_exp/parse_remark_spec.rb
329
- - spec/expressir/express_exp/parse_syntax_spec.rb
330
- - spec/expressir/express_exp/source_spec.rb
331
- - spec/expressir/model/model_element_spec.rb
332
- - spec/expressir/model/scope_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
333
352
  - spec/expressr_spec.rb
334
353
  - spec/spec_helper.rb
335
354
  - spec/support/console_helper.rb
@@ -1,71 +0,0 @@
1
- module Expressir
2
- module Model
3
- module Scope
4
- def find(path)
5
- current_path, _, rest = path.partition(".")
6
-
7
- # ignore prefix
8
- _, _, current_path = current_path.rpartition(":")
9
-
10
- current_path = current_path.downcase
11
- child = children.find{|x| x.id and x.id.downcase == current_path}
12
-
13
- if !rest.empty? and child.class.method_defined? :find
14
- child.find(rest)
15
- else
16
- child
17
- end
18
- end
19
-
20
- def find_or_create(path)
21
- child = find(path)
22
-
23
- if !child
24
- # check if path should create implicit informal proposal
25
- # see https://github.com/lutaml/expressir/issues/50
26
- rest, _, current_path = path.rpartition(".")
27
-
28
- if !rest.empty?
29
- child = find(rest)
30
- else
31
- child = self
32
- end
33
-
34
- if child.class.method_defined? :informal_propositions
35
- # ignore prefix
36
- _, _, current_path = current_path.rpartition(":")
37
-
38
- # match informal proposition id
39
- informal_proposition_id = current_path.match(/^IP\d+$/).to_a[0]
40
-
41
- if informal_proposition_id
42
- # create implicit informal proposition
43
- informal_proposition = Model::InformalProposition.new({
44
- id: informal_proposition_id
45
- })
46
- informal_proposition.parent = child
47
-
48
- child.informal_propositions << informal_proposition
49
-
50
- informal_proposition
51
- end
52
- end
53
- else
54
- child
55
- end
56
- end
57
-
58
- def attach_parent_to_children
59
- children.each do |child_node|
60
- if child_node.class.method_defined? :parent and !child_node.parent
61
- child_node.parent = self
62
- end
63
- end
64
- end
65
-
66
- def children
67
- raise 'Not implemented'
68
- end
69
- end
70
- end
71
- 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