expressir 0.2.16 → 0.2.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +5 -0
- data/.github/workflows/release.yml +31 -3
- data/README.adoc +3 -3
- data/exe/format +66 -12
- data/ext/express-parser/extconf.rb +2 -0
- data/lib/expressir/express_exp/cache.rb +48 -0
- data/lib/expressir/express_exp/formatter.rb +185 -135
- data/lib/expressir/express_exp/parser.rb +33 -29
- data/lib/expressir/express_exp/schema_head_formatter.rb +1 -4
- data/lib/expressir/express_exp/visitor.rb +29 -23
- data/lib/expressir/model.rb +3 -1
- data/lib/expressir/model/attribute.rb +12 -5
- data/lib/expressir/model/cache.rb +13 -0
- data/lib/expressir/model/constant.rb +9 -2
- data/lib/expressir/model/entity.rb +15 -13
- data/lib/expressir/model/enumeration_item.rb +7 -0
- data/lib/expressir/model/expressions/aggregate_initializer.rb +1 -1
- data/lib/expressir/model/expressions/aggregate_item.rb +2 -2
- data/lib/expressir/model/expressions/attribute_reference.rb +2 -2
- data/lib/expressir/model/expressions/binary_expression.rb +3 -3
- data/lib/expressir/model/expressions/call.rb +2 -2
- data/lib/expressir/model/expressions/entity_constructor.rb +2 -2
- data/lib/expressir/model/expressions/group_reference.rb +2 -2
- data/lib/expressir/model/expressions/index_reference.rb +3 -3
- data/lib/expressir/model/expressions/interval.rb +5 -5
- data/lib/expressir/model/expressions/query_expression.rb +7 -5
- data/lib/expressir/model/expressions/simple_reference.rb +1 -1
- data/lib/expressir/model/expressions/unary_expression.rb +2 -2
- data/lib/expressir/model/function.rb +27 -21
- data/lib/expressir/model/identifier.rb +6 -3
- data/lib/expressir/model/interface.rb +3 -3
- data/lib/expressir/model/interface_item.rb +2 -2
- data/lib/expressir/model/interfaced_item.rb +11 -3
- data/lib/expressir/model/literals/binary.rb +1 -1
- data/lib/expressir/model/literals/integer.rb +1 -1
- data/lib/expressir/model/literals/logical.rb +1 -1
- data/lib/expressir/model/literals/real.rb +1 -1
- data/lib/expressir/model/literals/string.rb +2 -2
- data/lib/expressir/model/model_element.rb +54 -19
- data/lib/expressir/model/parameter.rb +9 -2
- data/lib/expressir/model/procedure.rb +26 -20
- data/lib/expressir/model/{informal_proposition.rb → remark_item.rb} +3 -3
- data/lib/expressir/model/repository.rb +4 -4
- data/lib/expressir/model/rule.rb +29 -23
- data/lib/expressir/model/schema.rb +63 -54
- data/lib/expressir/model/statements/alias.rb +7 -5
- data/lib/expressir/model/statements/assignment.rb +2 -2
- data/lib/expressir/model/statements/call.rb +2 -2
- data/lib/expressir/model/statements/case.rb +3 -3
- data/lib/expressir/model/statements/case_action.rb +2 -2
- data/lib/expressir/model/statements/compound.rb +1 -1
- data/lib/expressir/model/statements/if.rb +3 -3
- data/lib/expressir/model/statements/repeat.rb +11 -9
- data/lib/expressir/model/statements/return.rb +1 -1
- data/lib/expressir/model/subtype_constraint.rb +9 -7
- data/lib/expressir/model/type.rb +14 -8
- data/lib/expressir/model/types/aggregate.rb +8 -1
- data/lib/expressir/model/types/array.rb +5 -5
- data/lib/expressir/model/types/bag.rb +3 -3
- data/lib/expressir/model/types/binary.rb +2 -2
- data/lib/expressir/model/types/enumeration.rb +4 -4
- data/lib/expressir/model/types/generic.rb +7 -0
- data/lib/expressir/model/types/generic_entity.rb +7 -0
- data/lib/expressir/model/types/list.rb +4 -4
- data/lib/expressir/model/types/real.rb +1 -1
- data/lib/expressir/model/types/select.rb +5 -5
- data/lib/expressir/model/types/set.rb +3 -3
- data/lib/expressir/model/types/string.rb +2 -2
- data/lib/expressir/model/unique.rb +8 -1
- data/lib/expressir/model/variable.rb +9 -2
- data/lib/expressir/model/where.rb +8 -1
- data/lib/expressir/version.rb +1 -1
- data/original/examples/syntax/{hyperlink.exp → multiple.exp} +8 -8
- data/original/examples/syntax/multiple.yaml +184 -0
- data/original/examples/syntax/multiple_formatted.exp +71 -0
- data/original/examples/syntax/multiple_hyperlink_formatted.exp +71 -0
- data/original/examples/syntax/multiple_schema_head_hyperlink_formatted.exp +13 -0
- data/original/examples/syntax/remark.exp +52 -50
- data/original/examples/syntax/remark.yaml +452 -0
- data/original/examples/syntax/remark_formatted.exp +64 -50
- data/original/examples/syntax/{simple.exp → single.exp} +1 -1
- data/original/examples/syntax/single.yaml +9 -0
- data/original/examples/syntax/single_formatted.exp +6 -0
- data/original/examples/syntax/single_formatted.yaml +19 -0
- data/original/examples/syntax/syntax.exp +29 -19
- data/original/examples/syntax/syntax.yaml +3439 -0
- data/original/examples/syntax/syntax_formatted.exp +271 -131
- data/original/examples/syntax/syntax_schema_head_formatted.exp +18 -0
- data/spec/expressir/express_exp/cache_spec.rb +64 -0
- data/spec/expressir/express_exp/formatter_spec.rb +111 -0
- data/spec/expressir/express_exp/parser_spec.rb +98 -0
- data/spec/expressir/model/{model_element/find_spec.rb → model_element_spec.rb} +96 -10
- metadata +21 -17
- data/original/examples/syntax/hyperlink_formatted.exp +0 -51
- data/original/examples/syntax/source.exp +0 -16
- data/spec/expressir/express_exp/formatter/remark_spec.rb +0 -28
- data/spec/expressir/express_exp/formatter/syntax_spec.rb +0 -28
- data/spec/expressir/express_exp/hyperlink_formatter_spec.rb +0 -28
- data/spec/expressir/express_exp/parser/multiple_spec.rb +0 -37
- data/spec/expressir/express_exp/parser/remark_spec.rb +0 -411
- data/spec/expressir/express_exp/parser/source_spec.rb +0 -29
- data/spec/expressir/express_exp/parser/syntax_spec.rb +0 -3086
- data/spec/expressir/express_exp/schema_head_formatter_spec.rb +0 -40
- data/spec/expressir/model/model_element/hash_spec.rb +0 -66
@@ -1,40 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "expressir/express_exp/parser"
|
3
|
-
require "expressir/express_exp/formatter"
|
4
|
-
require "expressir/express_exp/schema_head_formatter"
|
5
|
-
|
6
|
-
RSpec.describe Expressir::ExpressExp::SchemaHeadFormatter do
|
7
|
-
describe ".format" do
|
8
|
-
it "formats schema head" do
|
9
|
-
repo = Expressir::ExpressExp::Parser.from_file(sample_file)
|
10
|
-
|
11
|
-
class CustomFormatter < Expressir::ExpressExp::Formatter
|
12
|
-
include Expressir::ExpressExp::SchemaHeadFormatter
|
13
|
-
end
|
14
|
-
result = CustomFormatter.format(repo)
|
15
|
-
|
16
|
-
expect(result).to eq(<<~EXP.strip
|
17
|
-
SCHEMA syntax_schema 'version';
|
18
|
-
USE FROM contract_schema;
|
19
|
-
USE FROM contract_schema
|
20
|
-
(contract);
|
21
|
-
USE FROM contract_schema
|
22
|
-
(contract, contract2);
|
23
|
-
USE FROM contract_schema
|
24
|
-
(contract AS contract2);
|
25
|
-
REFERENCE FROM contract_schema;
|
26
|
-
REFERENCE FROM contract_schema
|
27
|
-
(contract);
|
28
|
-
REFERENCE FROM contract_schema
|
29
|
-
(contract, contract2);
|
30
|
-
REFERENCE FROM contract_schema
|
31
|
-
(contract AS contract2);
|
32
|
-
EXP
|
33
|
-
)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def sample_file
|
38
|
-
@sample_file ||= Expressir.root_path.join("original", "examples", "syntax", "syntax.exp")
|
39
|
-
end
|
40
|
-
end
|
@@ -1,66 +0,0 @@
|
|
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
|