expressir 0.2.18-arm64-darwin → 0.2.19-arm64-darwin
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/lib/expressir/express_exp/2.4/express_parser.bundle +0 -0
- data/lib/expressir/express_exp/2.5/express_parser.bundle +0 -0
- data/lib/expressir/express_exp/2.6/express_parser.bundle +0 -0
- data/lib/expressir/express_exp/2.7/express_parser.bundle +0 -0
- data/lib/expressir/express_exp/parser.rb +1 -4
- data/lib/expressir/model/model_element.rb +17 -8
- data/lib/expressir/version.rb +1 -1
- data/original/examples/syntax/multiple.yaml +4 -4
- data/original/examples/syntax/remark.yaml +1 -1
- data/original/examples/syntax/single.yaml +1 -1
- data/original/examples/syntax/single_formatted.yaml +1 -1
- data/original/examples/syntax/syntax.yaml +1 -1
- data/spec/expressir/express_exp/parser_spec.rb +9 -32
- data/spec/expressir/model/model_element_spec.rb +9 -23
- metadata +1 -2
- data/original/examples/syntax/single_root_path.yaml +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 168ac92ae73844ba8179770b660d02b847613e15d73851236685030b53be3aa9
|
4
|
+
data.tar.gz: d68d1a0424984cebd9bf6712028c770489610724b8b50e9b4170cab6c1e1ca87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20be2048054c8dc1de713393b784976c2b8ff28731730e923c39fa5f6c228198b1342107b82842be24347b15b5c465d1c1225dfbefab08d64a7f24be1b09f58e
|
7
|
+
data.tar.gz: aec312699ee89bc3a661509e2f665b6a469a30ea36f53d20688be04913b1f1120c7b718635aba2a1465bc3b9631fa61aabc175f9cd11f688081102e71cb8239b
|
data/.github/workflows/rake.yml
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -5,7 +5,6 @@ rescue LoadError
|
|
5
5
|
require_relative "express_parser"
|
6
6
|
end
|
7
7
|
require 'expressir/express_exp/visitor'
|
8
|
-
require 'pathname'
|
9
8
|
|
10
9
|
=begin
|
11
10
|
char_stream = Antlr4::Runtime::CharStreams.from_string(input, 'String')
|
@@ -26,8 +25,6 @@ module Expressir
|
|
26
25
|
module ExpressExp
|
27
26
|
class Parser
|
28
27
|
def self.from_file(file, options = {})
|
29
|
-
root_path = options[:root_path]
|
30
|
-
|
31
28
|
input = File.read(file)
|
32
29
|
|
33
30
|
parser = ::ExpressParser::Parser.parse(input)
|
@@ -38,7 +35,7 @@ module Expressir
|
|
38
35
|
repository = visitor.visit(parse_tree)
|
39
36
|
|
40
37
|
repository.schemas.each do |schema|
|
41
|
-
schema.file =
|
38
|
+
schema.file = file.to_s
|
42
39
|
end
|
43
40
|
|
44
41
|
repository
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
1
3
|
module Expressir
|
2
4
|
module Model
|
3
5
|
class ModelElement
|
@@ -99,17 +101,17 @@ module Expressir
|
|
99
101
|
hash = {}
|
100
102
|
hash[CLASS_KEY] = self.class.name
|
101
103
|
if self.is_a? Schema and file
|
102
|
-
hash[FILE_KEY] = root_path ?
|
104
|
+
hash[FILE_KEY] = root_path ? Pathname.new(file).relative_path_from(root_path).to_s : file
|
103
105
|
end
|
104
106
|
|
105
|
-
model_instance_variables.
|
107
|
+
model_instance_variables.each do |variable|
|
106
108
|
key = variable.to_s.sub(/^@/, '')
|
107
109
|
value = instance_variable_get(variable)
|
108
110
|
empty = value.nil? || (value.is_a?(Array) && value.count == 0)
|
109
111
|
|
110
112
|
# skip empty values
|
111
113
|
if !empty or include_empty
|
112
|
-
|
114
|
+
hash[key] = if value.is_a? Array
|
113
115
|
value.map do |value|
|
114
116
|
if value.is_a? ModelElement
|
115
117
|
value.to_hash(options)
|
@@ -132,21 +134,28 @@ module Expressir
|
|
132
134
|
hash
|
133
135
|
end
|
134
136
|
|
135
|
-
def self.from_hash(hash)
|
137
|
+
def self.from_hash(hash, options = {})
|
138
|
+
root_path = options[:root_path]
|
139
|
+
|
136
140
|
node_class = hash[CLASS_KEY]
|
137
|
-
node_options =
|
141
|
+
node_options = {}
|
142
|
+
if node_class == 'Expressir::Model::Schema' and hash[FILE_KEY]
|
143
|
+
node_options[FILE_KEY.to_sym] = root_path ? File.expand_path("#{root_path}/#{hash[FILE_KEY]}") : hash[FILE_KEY]
|
144
|
+
end
|
145
|
+
|
146
|
+
hash.select{|x| x != CLASS_KEY && x != FILE_KEY}.each do |variable, value|
|
138
147
|
key = variable.to_sym
|
139
148
|
|
140
|
-
|
149
|
+
node_options[key] = if value.is_a? Array
|
141
150
|
value.map do |value|
|
142
151
|
if value.is_a? Hash
|
143
|
-
self.from_hash(value)
|
152
|
+
self.from_hash(value, options)
|
144
153
|
else
|
145
154
|
value
|
146
155
|
end
|
147
156
|
end
|
148
157
|
elsif value.is_a? Hash
|
149
|
-
self.from_hash(value)
|
158
|
+
self.from_hash(value, options)
|
150
159
|
else
|
151
160
|
value
|
152
161
|
end
|
data/lib/expressir/version.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
_class: Expressir::Model::Repository
|
3
3
|
schemas:
|
4
4
|
- _class: Expressir::Model::Schema
|
5
|
-
file: multiple.exp
|
5
|
+
file: original/examples/syntax/multiple.exp
|
6
6
|
id: multiple_schema1
|
7
7
|
interfaces:
|
8
8
|
- _class: Expressir::Model::Interface
|
@@ -147,7 +147,7 @@ schemas:
|
|
147
147
|
- _class: Expressir::Model::Expressions::SimpleReference
|
148
148
|
id: missing_entity
|
149
149
|
- _class: Expressir::Model::Schema
|
150
|
-
file: multiple.exp
|
150
|
+
file: original/examples/syntax/multiple.exp
|
151
151
|
id: multiple_schema2
|
152
152
|
entities:
|
153
153
|
- _class: Expressir::Model::Entity
|
@@ -159,7 +159,7 @@ schemas:
|
|
159
159
|
type:
|
160
160
|
_class: Expressir::Model::Types::Boolean
|
161
161
|
- _class: Expressir::Model::Schema
|
162
|
-
file: multiple.exp
|
162
|
+
file: original/examples/syntax/multiple.exp
|
163
163
|
id: multiple_schema3
|
164
164
|
entities:
|
165
165
|
- _class: Expressir::Model::Entity
|
@@ -171,7 +171,7 @@ schemas:
|
|
171
171
|
type:
|
172
172
|
_class: Expressir::Model::Types::Boolean
|
173
173
|
- _class: Expressir::Model::Schema
|
174
|
-
file: multiple.exp
|
174
|
+
file: original/examples/syntax/multiple.exp
|
175
175
|
id: multiple_schema4
|
176
176
|
entities:
|
177
177
|
- _class: Expressir::Model::Entity
|
@@ -9,7 +9,7 @@ RSpec.describe Expressir::ExpressExp::Parser do
|
|
9
9
|
yaml_file = Expressir.root_path.join("original", "examples", "syntax", "single.yaml")
|
10
10
|
|
11
11
|
repo = Expressir::ExpressExp::Parser.from_file(exp_file)
|
12
|
-
result = YAML.dump(repo.to_hash(skip_empty: true))
|
12
|
+
result = YAML.dump(repo.to_hash(root_path: Expressir.root_path, skip_empty: true))
|
13
13
|
# File.write(yaml_file, result)
|
14
14
|
expected_result = File.read(yaml_file)
|
15
15
|
|
@@ -21,7 +21,7 @@ RSpec.describe Expressir::ExpressExp::Parser do
|
|
21
21
|
yaml_file = Expressir.root_path.join("original", "examples", "syntax", "multiple.yaml")
|
22
22
|
|
23
23
|
repo = Expressir::ExpressExp::Parser.from_file(exp_file)
|
24
|
-
result = YAML.dump(repo.to_hash(skip_empty: true))
|
24
|
+
result = YAML.dump(repo.to_hash(root_path: Expressir.root_path, skip_empty: true))
|
25
25
|
# File.write(yaml_file, result)
|
26
26
|
expected_result = File.read(yaml_file)
|
27
27
|
|
@@ -33,7 +33,7 @@ RSpec.describe Expressir::ExpressExp::Parser do
|
|
33
33
|
yaml_file = Expressir.root_path.join("original", "examples", "syntax", "syntax.yaml")
|
34
34
|
|
35
35
|
repo = Expressir::ExpressExp::Parser.from_file(exp_file)
|
36
|
-
result = YAML.dump(repo.to_hash(skip_empty: true))
|
36
|
+
result = YAML.dump(repo.to_hash(root_path: Expressir.root_path, skip_empty: true))
|
37
37
|
# File.write(yaml_file, result)
|
38
38
|
expected_result = File.read(yaml_file)
|
39
39
|
|
@@ -45,7 +45,7 @@ RSpec.describe Expressir::ExpressExp::Parser do
|
|
45
45
|
yaml_file = Expressir.root_path.join("original", "examples", "syntax", "remark.yaml")
|
46
46
|
|
47
47
|
repo = Expressir::ExpressExp::Parser.from_file(exp_file)
|
48
|
-
result = YAML.dump(repo.to_hash(skip_empty: true))
|
48
|
+
result = YAML.dump(repo.to_hash(root_path: Expressir.root_path, skip_empty: true))
|
49
49
|
# File.write(yaml_file, result)
|
50
50
|
expected_result = File.read(yaml_file)
|
51
51
|
|
@@ -83,38 +83,15 @@ RSpec.describe Expressir::ExpressExp::Parser do
|
|
83
83
|
|
84
84
|
schemas = repo.schemas
|
85
85
|
expect(schemas.count).to eq(5)
|
86
|
-
expect(schemas[0].file).to eq(exp_files[0].
|
86
|
+
expect(schemas[0].file).to eq(exp_files[0].to_s)
|
87
87
|
expect(schemas[0].id).to eq("single_schema")
|
88
|
-
expect(schemas[1].file).to eq(exp_files[1].
|
88
|
+
expect(schemas[1].file).to eq(exp_files[1].to_s)
|
89
89
|
expect(schemas[1].id).to eq("multiple_schema1")
|
90
|
-
expect(schemas[2].file).to eq(exp_files[1].
|
90
|
+
expect(schemas[2].file).to eq(exp_files[1].to_s)
|
91
91
|
expect(schemas[2].id).to eq("multiple_schema2")
|
92
|
-
expect(schemas[3].file).to eq(exp_files[1].
|
92
|
+
expect(schemas[3].file).to eq(exp_files[1].to_s)
|
93
93
|
expect(schemas[3].id).to eq("multiple_schema3")
|
94
|
-
expect(schemas[4].file).to eq(exp_files[1].
|
95
|
-
expect(schemas[4].id).to eq("multiple_schema4")
|
96
|
-
end
|
97
|
-
|
98
|
-
it "parses multiple files with a root path (single.exp, multiple.exp)" do
|
99
|
-
exp_files = [
|
100
|
-
Expressir.root_path.join("original", "examples", "syntax", "single.exp"),
|
101
|
-
Expressir.root_path.join("original", "examples", "syntax", "multiple.exp")
|
102
|
-
]
|
103
|
-
root_path = Expressir.root_path
|
104
|
-
|
105
|
-
repo = Expressir::ExpressExp::Parser.from_files(exp_files, root_path: root_path)
|
106
|
-
|
107
|
-
schemas = repo.schemas
|
108
|
-
expect(schemas.count).to eq(5)
|
109
|
-
expect(schemas[0].file).to eq(exp_files[0].relative_path_from(root_path).to_s)
|
110
|
-
expect(schemas[0].id).to eq("single_schema")
|
111
|
-
expect(schemas[1].file).to eq(exp_files[1].relative_path_from(root_path).to_s)
|
112
|
-
expect(schemas[1].id).to eq("multiple_schema1")
|
113
|
-
expect(schemas[2].file).to eq(exp_files[1].relative_path_from(root_path).to_s)
|
114
|
-
expect(schemas[2].id).to eq("multiple_schema2")
|
115
|
-
expect(schemas[3].file).to eq(exp_files[1].relative_path_from(root_path).to_s)
|
116
|
-
expect(schemas[3].id).to eq("multiple_schema3")
|
117
|
-
expect(schemas[4].file).to eq(exp_files[1].relative_path_from(root_path).to_s)
|
94
|
+
expect(schemas[4].file).to eq(exp_files[1].to_s)
|
118
95
|
expect(schemas[4].id).to eq("multiple_schema4")
|
119
96
|
end
|
120
97
|
end
|
@@ -6,27 +6,13 @@ require "expressir/express_exp/formatter"
|
|
6
6
|
|
7
7
|
RSpec.describe Expressir::Model::ModelElement do
|
8
8
|
describe ".to_hash" do
|
9
|
-
it "exports an object with a root path (single.exp)" do
|
10
|
-
exp_file = Expressir.root_path.join("original", "examples", "syntax", "single.exp")
|
11
|
-
yaml_file = Expressir.root_path.join("original", "examples", "syntax", "single_root_path.yaml")
|
12
|
-
root_path = Expressir.root_path
|
13
|
-
|
14
|
-
repo = Expressir::ExpressExp::Parser.from_file(exp_file, root_path: root_path)
|
15
|
-
|
16
|
-
result = YAML.dump(repo.to_hash(skip_empty: true))
|
17
|
-
# File.write(yaml_file, result)
|
18
|
-
expected_result = File.read(yaml_file)
|
19
|
-
|
20
|
-
expect(result).to eq(expected_result)
|
21
|
-
end
|
22
|
-
|
23
9
|
it "exports an object with a formatter (single.exp)" do
|
24
10
|
exp_file = Expressir.root_path.join("original", "examples", "syntax", "single.exp")
|
25
11
|
yaml_file = Expressir.root_path.join("original", "examples", "syntax", "single_formatted.yaml")
|
26
12
|
|
27
13
|
repo = Expressir::ExpressExp::Parser.from_file(exp_file)
|
28
14
|
|
29
|
-
result = YAML.dump(repo.to_hash(formatter: Expressir::ExpressExp::Formatter, skip_empty: true))
|
15
|
+
result = YAML.dump(repo.to_hash(root_path: Expressir.root_path, formatter: Expressir::ExpressExp::Formatter, skip_empty: true))
|
30
16
|
# File.write(yaml_file, result)
|
31
17
|
expected_result = File.read(yaml_file)
|
32
18
|
|
@@ -39,9 +25,9 @@ RSpec.describe Expressir::Model::ModelElement do
|
|
39
25
|
yaml_file = Expressir.root_path.join("original", "examples", "syntax", "single.yaml")
|
40
26
|
|
41
27
|
input = YAML.load(File.read(yaml_file))
|
42
|
-
repo = Expressir::Model::ModelElement.from_hash(input)
|
28
|
+
repo = Expressir::Model::ModelElement.from_hash(input, root_path: Expressir.root_path)
|
43
29
|
|
44
|
-
result = YAML.dump(repo.to_hash(skip_empty: true))
|
30
|
+
result = YAML.dump(repo.to_hash(root_path: Expressir.root_path, skip_empty: true))
|
45
31
|
expected_result = File.read(yaml_file)
|
46
32
|
|
47
33
|
expect(result).to eq(expected_result)
|
@@ -51,9 +37,9 @@ RSpec.describe Expressir::Model::ModelElement do
|
|
51
37
|
yaml_file = Expressir.root_path.join("original", "examples", "syntax", "multiple.yaml")
|
52
38
|
|
53
39
|
input = YAML.load(File.read(yaml_file))
|
54
|
-
repo = Expressir::Model::ModelElement.from_hash(input)
|
40
|
+
repo = Expressir::Model::ModelElement.from_hash(input, root_path: Expressir.root_path)
|
55
41
|
|
56
|
-
result = YAML.dump(repo.to_hash(skip_empty: true))
|
42
|
+
result = YAML.dump(repo.to_hash(root_path: Expressir.root_path, skip_empty: true))
|
57
43
|
expected_result = File.read(yaml_file)
|
58
44
|
|
59
45
|
expect(result).to eq(expected_result)
|
@@ -63,9 +49,9 @@ RSpec.describe Expressir::Model::ModelElement do
|
|
63
49
|
yaml_file = Expressir.root_path.join("original", "examples", "syntax", "syntax.yaml")
|
64
50
|
|
65
51
|
input = YAML.load(File.read(yaml_file))
|
66
|
-
repo = Expressir::Model::ModelElement.from_hash(input)
|
52
|
+
repo = Expressir::Model::ModelElement.from_hash(input, root_path: Expressir.root_path)
|
67
53
|
|
68
|
-
result = YAML.dump(repo.to_hash(skip_empty: true))
|
54
|
+
result = YAML.dump(repo.to_hash(root_path: Expressir.root_path, skip_empty: true))
|
69
55
|
expected_result = File.read(yaml_file)
|
70
56
|
|
71
57
|
expect(result).to eq(expected_result)
|
@@ -75,9 +61,9 @@ RSpec.describe Expressir::Model::ModelElement do
|
|
75
61
|
yaml_file = Expressir.root_path.join("original", "examples", "syntax", "remark.yaml")
|
76
62
|
|
77
63
|
input = YAML.load(File.read(yaml_file))
|
78
|
-
repo = Expressir::Model::ModelElement.from_hash(input)
|
64
|
+
repo = Expressir::Model::ModelElement.from_hash(input, root_path: Expressir.root_path)
|
79
65
|
|
80
|
-
result = YAML.dump(repo.to_hash(skip_empty: true))
|
66
|
+
result = YAML.dump(repo.to_hash(root_path: Expressir.root_path, skip_empty: true))
|
81
67
|
expected_result = File.read(yaml_file)
|
82
68
|
|
83
69
|
expect(result).to eq(expected_result)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.19
|
5
5
|
platform: arm64-darwin
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
@@ -332,7 +332,6 @@ files:
|
|
332
332
|
- original/examples/syntax/single.yaml
|
333
333
|
- original/examples/syntax/single_formatted.exp
|
334
334
|
- original/examples/syntax/single_formatted.yaml
|
335
|
-
- original/examples/syntax/single_root_path.yaml
|
336
335
|
- original/examples/syntax/syntax.exp
|
337
336
|
- original/examples/syntax/syntax.yaml
|
338
337
|
- original/examples/syntax/syntax_formatted.exp
|