expressir 0.2.10-x86-linux → 0.2.15-x86-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/format +27 -0
- data/expressir.gemspec +1 -0
- data/lib/expressir/express_exp/2.4/express_parser.so +0 -0
- data/lib/expressir/express_exp/2.5/express_parser.so +0 -0
- data/lib/expressir/express_exp/2.6/express_parser.so +0 -0
- data/lib/expressir/express_exp/2.7/express_parser.so +0 -0
- data/lib/expressir/express_exp/3.0/express_parser.so +0 -0
- data/lib/expressir/express_exp/formatter.rb +90 -100
- data/lib/expressir/express_exp/hyperlink_formatter.rb +29 -0
- data/lib/expressir/express_exp/parser.rb +7 -1
- data/lib/expressir/express_exp/schema_head_formatter.rb +14 -0
- data/lib/expressir/express_exp/visitor.rb +68 -80
- data/lib/expressir/model.rb +2 -2
- data/lib/expressir/model/attribute.rb +2 -0
- data/lib/expressir/model/constant.rb +2 -0
- data/lib/expressir/model/entity.rb +3 -2
- data/lib/expressir/model/enumeration_item.rb +2 -0
- data/lib/expressir/model/expressions/aggregate_initializer.rb +2 -0
- data/lib/expressir/model/expressions/aggregate_item.rb +2 -0
- data/lib/expressir/model/expressions/attribute_reference.rb +2 -0
- data/lib/expressir/model/expressions/binary_expression.rb +2 -0
- data/lib/expressir/model/expressions/call.rb +2 -0
- data/lib/expressir/model/expressions/entity_constructor.rb +2 -0
- data/lib/expressir/model/expressions/group_reference.rb +2 -0
- data/lib/expressir/model/expressions/index_reference.rb +2 -0
- data/lib/expressir/model/expressions/interval.rb +2 -0
- data/lib/expressir/model/expressions/query_expression.rb +2 -1
- data/lib/expressir/model/expressions/simple_reference.rb +2 -0
- data/lib/expressir/model/expressions/unary_expression.rb +2 -0
- data/lib/expressir/model/function.rb +3 -8
- data/lib/expressir/model/identifier.rb +0 -1
- data/lib/expressir/model/informal_proposition.rb +2 -0
- data/lib/expressir/model/interface.rb +2 -0
- data/lib/expressir/model/{renamed_ref.rb → interface_item.rb} +4 -2
- data/lib/expressir/model/interfaced_item.rb +23 -0
- data/lib/expressir/model/literals/binary.rb +2 -0
- data/lib/expressir/model/literals/integer.rb +2 -0
- data/lib/expressir/model/literals/logical.rb +2 -0
- data/lib/expressir/model/literals/real.rb +2 -0
- data/lib/expressir/model/literals/string.rb +2 -0
- data/lib/expressir/model/model_element.rb +85 -12
- data/lib/expressir/model/parameter.rb +2 -0
- data/lib/expressir/model/procedure.rb +3 -8
- data/lib/expressir/model/repository.rb +2 -2
- data/lib/expressir/model/rule.rb +4 -9
- data/lib/expressir/model/schema.rb +45 -9
- data/lib/expressir/model/statements/alias.rb +2 -1
- data/lib/expressir/model/statements/assignment.rb +2 -0
- data/lib/expressir/model/statements/call.rb +2 -0
- data/lib/expressir/model/statements/case.rb +2 -0
- data/lib/expressir/model/statements/case_action.rb +2 -0
- data/lib/expressir/model/statements/compound.rb +2 -0
- data/lib/expressir/model/statements/if.rb +2 -0
- data/lib/expressir/model/statements/repeat.rb +2 -1
- data/lib/expressir/model/statements/return.rb +2 -0
- data/lib/expressir/model/subtype_constraint.rb +2 -1
- data/lib/expressir/model/type.rb +3 -6
- data/lib/expressir/model/types/aggregate.rb +2 -0
- data/lib/expressir/model/types/array.rb +2 -0
- data/lib/expressir/model/types/bag.rb +2 -0
- data/lib/expressir/model/types/binary.rb +2 -0
- data/lib/expressir/model/types/enumeration.rb +2 -0
- data/lib/expressir/model/types/generic.rb +2 -0
- data/lib/expressir/model/types/generic_entity.rb +2 -0
- data/lib/expressir/model/types/list.rb +2 -0
- data/lib/expressir/model/types/real.rb +2 -0
- data/lib/expressir/model/types/select.rb +2 -0
- data/lib/expressir/model/types/set.rb +2 -0
- data/lib/expressir/model/types/string.rb +2 -0
- data/lib/expressir/model/unique.rb +2 -0
- data/lib/expressir/model/variable.rb +2 -0
- data/lib/expressir/model/where.rb +2 -0
- data/lib/expressir/version.rb +1 -1
- data/original/examples/syntax/hyperlink.exp +23 -0
- data/original/examples/syntax/hyperlink_formatted.exp +51 -0
- data/original/examples/syntax/syntax.exp +18 -18
- data/original/examples/syntax/syntax_formatted.exp +32 -24
- data/spec/expressir/express_exp/{format_remark_spec.rb → formatter/remark_spec.rb} +2 -2
- data/spec/expressir/express_exp/{format_syntax_spec.rb → formatter/syntax_spec.rb} +2 -2
- data/spec/expressir/express_exp/hyperlink_formatter_spec.rb +24 -0
- data/spec/expressir/express_exp/{head_source_spec.rb → parser/head_source_spec.rb} +1 -1
- data/spec/expressir/express_exp/{parse_multiple_spec.rb → parser/multiple_spec.rb} +6 -1
- data/spec/expressir/express_exp/{parse_remark_spec.rb → parser/remark_spec.rb} +2 -2
- data/spec/expressir/express_exp/{source_spec.rb → parser/source_spec.rb} +1 -1
- data/spec/expressir/express_exp/{parse_syntax_spec.rb → parser/syntax_spec.rb} +98 -60
- data/spec/expressir/express_exp/schema_head_formatter_spec.rb +36 -0
- data/spec/expressir/model/{scope_spec.rb → model_element/find_spec.rb} +7 -2
- data/spec/expressir/model/model_element/hash_spec.rb +66 -0
- metadata +34 -14
- data/lib/expressir/model/scope.rb +0 -63
- data/spec/expressir/express_exp/ap233_spec.rb +0 -22
- data/spec/expressir/model/model_element_spec.rb +0 -59
@@ -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::
|
4
|
+
RSpec.describe Expressir::Model::ModelElement do
|
5
5
|
describe ".find" do
|
6
6
|
it "finds an object" do
|
7
|
-
repo = Expressir::ExpressExp::Parser.
|
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
|
|
@@ -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.
|
4
|
+
version: 0.2.15
|
5
5
|
platform: x86-linux
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02
|
11
|
+
date: 2021-03-02 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.so
|
202
217
|
- lib/expressir/express_exp/3.0/express_parser.so
|
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
|
@@ -225,6 +242,8 @@ files:
|
|
225
242
|
- lib/expressir/model/identifier.rb
|
226
243
|
- lib/expressir/model/informal_proposition.rb
|
227
244
|
- lib/expressir/model/interface.rb
|
245
|
+
- lib/expressir/model/interface_item.rb
|
246
|
+
- lib/expressir/model/interfaced_item.rb
|
228
247
|
- lib/expressir/model/literals/binary.rb
|
229
248
|
- lib/expressir/model/literals/integer.rb
|
230
249
|
- lib/expressir/model/literals/logical.rb
|
@@ -233,11 +252,9 @@ files:
|
|
233
252
|
- lib/expressir/model/model_element.rb
|
234
253
|
- lib/expressir/model/parameter.rb
|
235
254
|
- lib/expressir/model/procedure.rb
|
236
|
-
- lib/expressir/model/renamed_ref.rb
|
237
255
|
- lib/expressir/model/repository.rb
|
238
256
|
- lib/expressir/model/rule.rb
|
239
257
|
- lib/expressir/model/schema.rb
|
240
|
-
- lib/expressir/model/scope.rb
|
241
258
|
- lib/expressir/model/statements/alias.rb
|
242
259
|
- lib/expressir/model/statements/assignment.rb
|
243
260
|
- lib/expressir/model/statements/call.rb
|
@@ -303,6 +320,8 @@ files:
|
|
303
320
|
- original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl
|
304
321
|
- original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi
|
305
322
|
- original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml
|
323
|
+
- original/examples/syntax/hyperlink.exp
|
324
|
+
- original/examples/syntax/hyperlink_formatted.exp
|
306
325
|
- original/examples/syntax/remark.exp
|
307
326
|
- original/examples/syntax/remark_formatted.exp
|
308
327
|
- original/examples/syntax/simple.exp
|
@@ -320,16 +339,17 @@ files:
|
|
320
339
|
- spec/acceptance/express_to_owl_spec.rb
|
321
340
|
- spec/acceptance/version_spec.rb
|
322
341
|
- spec/expressir/express/repository_spec.rb
|
323
|
-
- spec/expressir/express_exp/
|
324
|
-
- spec/expressir/express_exp/
|
325
|
-
- spec/expressir/express_exp/
|
326
|
-
- spec/expressir/express_exp/head_source_spec.rb
|
327
|
-
- spec/expressir/express_exp/
|
328
|
-
- spec/expressir/express_exp/
|
329
|
-
- spec/expressir/express_exp/
|
330
|
-
- spec/expressir/express_exp/
|
331
|
-
- spec/expressir/
|
332
|
-
- spec/expressir/model/
|
342
|
+
- spec/expressir/express_exp/formatter/remark_spec.rb
|
343
|
+
- spec/expressir/express_exp/formatter/syntax_spec.rb
|
344
|
+
- spec/expressir/express_exp/hyperlink_formatter_spec.rb
|
345
|
+
- spec/expressir/express_exp/parser/head_source_spec.rb
|
346
|
+
- spec/expressir/express_exp/parser/multiple_spec.rb
|
347
|
+
- spec/expressir/express_exp/parser/remark_spec.rb
|
348
|
+
- spec/expressir/express_exp/parser/source_spec.rb
|
349
|
+
- spec/expressir/express_exp/parser/syntax_spec.rb
|
350
|
+
- spec/expressir/express_exp/schema_head_formatter_spec.rb
|
351
|
+
- spec/expressir/model/model_element/find_spec.rb
|
352
|
+
- spec/expressir/model/model_element/hash_spec.rb
|
333
353
|
- spec/expressr_spec.rb
|
334
354
|
- spec/spec_helper.rb
|
335
355
|
- spec/support/console_helper.rb
|
@@ -1,63 +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 children
|
59
|
-
raise 'Not implemented'
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
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
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "expressir/express_exp/parser"
|
3
|
-
|
4
|
-
RSpec.describe Expressir::Model::ModelElement do
|
5
|
-
describe ".from_hash" do
|
6
|
-
it "parses an object from hash" do
|
7
|
-
input = {
|
8
|
-
"_class" => "Expressir::Model::Repository",
|
9
|
-
"schemas" => [{
|
10
|
-
"_class" => "Expressir::Model::Schema",
|
11
|
-
"id" => "simple_schema",
|
12
|
-
"entities" => [{
|
13
|
-
"_class" => "Expressir::Model::Entity",
|
14
|
-
"id" => "empty_entity"
|
15
|
-
}]
|
16
|
-
}]
|
17
|
-
}
|
18
|
-
|
19
|
-
repo = Expressir::Model::ModelElement.from_hash(input)
|
20
|
-
|
21
|
-
expect(repo).to be_instance_of(Expressir::Model::Repository)
|
22
|
-
expect(repo.schemas).to be_instance_of(Array)
|
23
|
-
expect(repo.schemas.count).to eq(1)
|
24
|
-
expect(repo.schemas[0]).to be_instance_of(Expressir::Model::Schema)
|
25
|
-
expect(repo.schemas[0].id).to eq("simple_schema")
|
26
|
-
expect(repo.schemas[0].entities).to be_instance_of(Array)
|
27
|
-
expect(repo.schemas[0].entities.count).to eq(1)
|
28
|
-
expect(repo.schemas[0].entities[0]).to be_instance_of(Expressir::Model::Entity)
|
29
|
-
expect(repo.schemas[0].entities[0].id).to eq("empty_entity")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe ".to_hash" do
|
34
|
-
it "exports an object to hash" do
|
35
|
-
repo = Expressir::ExpressExp::Parser.from_exp(sample_file)
|
36
|
-
|
37
|
-
result = repo.to_hash
|
38
|
-
|
39
|
-
expect(result).to be_instance_of(Hash)
|
40
|
-
expect(result["_class"]).to eq("Expressir::Model::Repository")
|
41
|
-
expect(result["schemas"]).to be_instance_of(Array)
|
42
|
-
expect(result["schemas"].count).to eq(1)
|
43
|
-
expect(result["schemas"][0]).to be_instance_of(Hash)
|
44
|
-
expect(result["schemas"][0]["_class"]).to eq("Expressir::Model::Schema")
|
45
|
-
expect(result["schemas"][0]["id"]).to eq("simple_schema")
|
46
|
-
expect(result["schemas"][0]["entities"]).to be_instance_of(Array)
|
47
|
-
expect(result["schemas"][0]["entities"].count).to eq(1)
|
48
|
-
expect(result["schemas"][0]["entities"][0]).to be_instance_of(Hash)
|
49
|
-
expect(result["schemas"][0]["entities"][0]["_class"]).to eq("Expressir::Model::Entity")
|
50
|
-
expect(result["schemas"][0]["entities"][0]["id"]).to eq("empty_entity")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def sample_file
|
55
|
-
@sample_file ||= Expressir.root_path.join(
|
56
|
-
"original", "examples", "syntax", "simple.exp"
|
57
|
-
)
|
58
|
-
end
|
59
|
-
end
|