expressir 0.2.13 → 0.2.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/exe/format +56 -11
  3. data/lib/expressir/express_exp/formatter.rb +201 -147
  4. data/lib/expressir/express_exp/hyperlink_formatter.rb +6 -4
  5. data/lib/expressir/express_exp/parser.rb +38 -25
  6. data/lib/expressir/express_exp/schema_head_formatter.rb +2 -7
  7. data/lib/expressir/express_exp/visitor.rb +27 -54
  8. data/lib/expressir/model.rb +2 -1
  9. data/lib/expressir/model/entity.rb +6 -6
  10. data/lib/expressir/model/expressions/query_expression.rb +3 -3
  11. data/lib/expressir/model/function.rb +15 -11
  12. data/lib/expressir/model/informal_proposition.rb +4 -1
  13. data/lib/expressir/model/{renamed_ref.rb → interface_item.rb} +2 -2
  14. data/lib/expressir/model/interfaced_item.rb +26 -0
  15. data/lib/expressir/model/model_element.rb +28 -7
  16. data/lib/expressir/model/procedure.rb +15 -11
  17. data/lib/expressir/model/repository.rb +3 -3
  18. data/lib/expressir/model/rule.rb +16 -12
  19. data/lib/expressir/model/schema.rb +60 -29
  20. data/lib/expressir/model/statements/alias.rb +3 -3
  21. data/lib/expressir/model/statements/repeat.rb +3 -3
  22. data/lib/expressir/model/subtype_constraint.rb +1 -6
  23. data/lib/expressir/model/type.rb +9 -5
  24. data/lib/expressir/version.rb +1 -1
  25. data/original/examples/syntax/multiple.exp +23 -0
  26. data/original/examples/syntax/multiple.yaml +184 -0
  27. data/original/examples/syntax/multiple_formatted.exp +71 -0
  28. data/original/examples/syntax/multiple_hyperlink_formatted.exp +71 -0
  29. data/original/examples/syntax/multiple_schema_head_hyperlink_formatted.exp +13 -0
  30. data/original/examples/syntax/remark.exp +41 -41
  31. data/original/examples/syntax/remark.yaml +446 -0
  32. data/original/examples/syntax/remark_formatted.exp +62 -50
  33. data/original/examples/syntax/{simple.exp → single.exp} +1 -1
  34. data/original/examples/syntax/single.yaml +9 -0
  35. data/original/examples/syntax/single_formatted.exp +6 -0
  36. data/original/examples/syntax/single_formatted.yaml +19 -0
  37. data/original/examples/syntax/single_root_path.yaml +9 -0
  38. data/original/examples/syntax/syntax.exp +29 -19
  39. data/original/examples/syntax/syntax.yaml +3439 -0
  40. data/original/examples/syntax/syntax_formatted.exp +271 -131
  41. data/original/examples/syntax/syntax_schema_head_formatted.exp +18 -0
  42. data/spec/expressir/express_exp/formatter_spec.rb +111 -0
  43. data/spec/expressir/express_exp/parser_spec.rb +121 -0
  44. data/spec/expressir/model/{model_element/find_spec.rb → model_element_spec.rb} +110 -10
  45. metadata +20 -18
  46. data/original/examples/syntax/hyperlink.exp +0 -8
  47. data/original/examples/syntax/hyperlink_formatted.exp +0 -19
  48. data/original/examples/syntax/source.exp +0 -16
  49. data/spec/expressir/express_exp/formatter/remark_spec.rb +0 -28
  50. data/spec/expressir/express_exp/formatter/syntax_spec.rb +0 -28
  51. data/spec/expressir/express_exp/hyperlink_formatter_spec.rb +0 -24
  52. data/spec/expressir/express_exp/parser/head_source_spec.rb +0 -38
  53. data/spec/expressir/express_exp/parser/multiple_spec.rb +0 -32
  54. data/spec/expressir/express_exp/parser/remark_spec.rb +0 -411
  55. data/spec/expressir/express_exp/parser/source_spec.rb +0 -29
  56. data/spec/expressir/express_exp/parser/syntax_spec.rb +0 -3080
  57. data/spec/expressir/express_exp/schema_head_formatter_spec.rb +0 -36
  58. data/spec/expressir/model/model_element/hash_spec.rb +0 -66
@@ -1,36 +0,0 @@
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,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