expressir 0.2.10-x86-mingw32 → 0.2.11-x86-mingw32
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.
- checksums.yaml +4 -4
- 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/visitor.rb +4 -8
- data/lib/expressir/model/model_element.rb +16 -10
- data/lib/expressir/model/scope.rb +8 -0
- data/lib/expressir/version.rb +1 -1
- data/spec/expressir/model/model_element_spec.rb +34 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2caa21f14c104a359d1d50cd836c49ca46a8ebe459689a179d3779b1ee032ef1
|
4
|
+
data.tar.gz: 5249e67700694a5ab4ea1099d37ec7aaaf49d3feb0aa437b4e6e6aa9ad3f3f5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89c9de8f90296700a4ec3dded02e3e1dd2324d034fe9435b87c9c7a8b286f0acb317a90aa2288ea98c919b2955df57cc9c3ea3c804eecf1985b2a0674f090a76
|
7
|
+
data.tar.gz: 20ecf8de577f70ee3a9859c6d5b4606c3799d40cdf39c3e87c75f089780a9e93132ec5799b3dd55b7634674ed13e49ce6c78af684f99383306e532749d6dfe59
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -46,7 +46,7 @@ module Expressir
|
|
46
46
|
def visit(ctx)
|
47
47
|
result = super(ctx)
|
48
48
|
attach_source(ctx, result)
|
49
|
-
attach_parent(
|
49
|
+
attach_parent(result)
|
50
50
|
attach_remarks(ctx, result)
|
51
51
|
result
|
52
52
|
end
|
@@ -124,13 +124,9 @@ module Expressir
|
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
|
-
def attach_parent(
|
128
|
-
if node.class.method_defined? :
|
129
|
-
node.
|
130
|
-
if child_node.class.method_defined? :parent and !child_node.parent
|
131
|
-
child_node.parent = node
|
132
|
-
end
|
133
|
-
end
|
127
|
+
def attach_parent(node)
|
128
|
+
if node.class.method_defined? :attach_parent_to_children
|
129
|
+
node.attach_parent_to_children
|
134
130
|
end
|
135
131
|
end
|
136
132
|
|
@@ -1,16 +1,21 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
class ModelElement
|
4
|
-
CLASS_KEY = '_class'
|
4
|
+
CLASS_KEY = '_class'
|
5
|
+
SOURCE_KEY = 'source'
|
5
6
|
|
6
7
|
def to_hash(options = {})
|
7
8
|
skip_empty = options[:skip_empty]
|
9
|
+
formatter = options[:formatter]
|
8
10
|
|
9
|
-
|
11
|
+
hash = {}
|
12
|
+
hash[CLASS_KEY] = self.class.name
|
13
|
+
|
14
|
+
instance_variables.select{|x| x != :@parent}.each_with_object(hash) do |variable, result|
|
10
15
|
key = variable.to_s.sub(/^@/, '')
|
11
16
|
value = instance_variable_get(variable)
|
12
17
|
|
13
|
-
# skip
|
18
|
+
# skip empty values (nil, empty array)
|
14
19
|
if !skip_empty or !(value.nil? or (value.is_a? Array and value.count == 0))
|
15
20
|
result[key] = if value.is_a? Array
|
16
21
|
value.map do |value|
|
@@ -27,6 +32,12 @@ module Expressir
|
|
27
32
|
end
|
28
33
|
end
|
29
34
|
end
|
35
|
+
|
36
|
+
if formatter
|
37
|
+
hash[SOURCE_KEY] = formatter.format(self)
|
38
|
+
end
|
39
|
+
|
40
|
+
hash
|
30
41
|
end
|
31
42
|
|
32
43
|
def self.from_hash(hash)
|
@@ -51,13 +62,8 @@ module Expressir
|
|
51
62
|
|
52
63
|
node = Object.const_get(node_class).new(node_options)
|
53
64
|
|
54
|
-
|
55
|
-
|
56
|
-
node.children.each do |child_node|
|
57
|
-
if child_node.class.method_defined? :parent and !child_node.parent
|
58
|
-
child_node.parent = node
|
59
|
-
end
|
60
|
-
end
|
65
|
+
if node.class.method_defined? :attach_parent_to_children
|
66
|
+
node.attach_parent_to_children
|
61
67
|
end
|
62
68
|
|
63
69
|
node
|
@@ -55,6 +55,14 @@ module Expressir
|
|
55
55
|
end
|
56
56
|
end
|
57
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
|
+
|
58
66
|
def children
|
59
67
|
raise 'Not implemented'
|
60
68
|
end
|
data/lib/expressir/version.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "expressir/express_exp/parser"
|
3
|
+
require "expressir/express_exp/formatter"
|
3
4
|
|
4
5
|
RSpec.describe Expressir::Model::ModelElement do
|
5
6
|
describe ".from_hash" do
|
6
|
-
it "parses an object from hash" do
|
7
|
+
it "parses an object from a hash" do
|
7
8
|
input = {
|
8
9
|
"_class" => "Expressir::Model::Repository",
|
9
10
|
"schemas" => [{
|
@@ -21,17 +22,17 @@ RSpec.describe Expressir::Model::ModelElement do
|
|
21
22
|
expect(repo).to be_instance_of(Expressir::Model::Repository)
|
22
23
|
expect(repo.schemas).to be_instance_of(Array)
|
23
24
|
expect(repo.schemas.count).to eq(1)
|
24
|
-
expect(repo.schemas
|
25
|
-
expect(repo.schemas
|
26
|
-
expect(repo.schemas
|
27
|
-
expect(repo.schemas
|
28
|
-
expect(repo.schemas
|
29
|
-
expect(repo.schemas
|
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")
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
34
|
describe ".to_hash" do
|
34
|
-
it "exports an object to hash" do
|
35
|
+
it "exports an object to a hash" do
|
35
36
|
repo = Expressir::ExpressExp::Parser.from_exp(sample_file)
|
36
37
|
|
37
38
|
result = repo.to_hash
|
@@ -40,14 +41,31 @@ RSpec.describe Expressir::Model::ModelElement do
|
|
40
41
|
expect(result["_class"]).to eq("Expressir::Model::Repository")
|
41
42
|
expect(result["schemas"]).to be_instance_of(Array)
|
42
43
|
expect(result["schemas"].count).to eq(1)
|
43
|
-
expect(result["schemas"]
|
44
|
-
expect(result["schemas"][
|
45
|
-
expect(result["schemas"][
|
46
|
-
expect(result["schemas"][
|
47
|
-
expect(result["schemas"][
|
48
|
-
expect(result["schemas"][
|
49
|
-
expect(result["schemas"][
|
50
|
-
expect(result["schemas"][
|
44
|
+
expect(result["schemas"].first).to be_instance_of(Hash)
|
45
|
+
expect(result["schemas"].first["_class"]).to eq("Expressir::Model::Schema")
|
46
|
+
expect(result["schemas"].first["id"]).to eq("simple_schema")
|
47
|
+
expect(result["schemas"].first["entities"]).to be_instance_of(Array)
|
48
|
+
expect(result["schemas"].first["entities"].count).to eq(1)
|
49
|
+
expect(result["schemas"].first["entities"].first).to be_instance_of(Hash)
|
50
|
+
expect(result["schemas"].first["entities"].first["_class"]).to eq("Expressir::Model::Entity")
|
51
|
+
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
|
+
expect(result["schemas"].first["source"]).to eq("Oook.")
|
51
69
|
end
|
52
70
|
end
|
53
71
|
|
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.11
|
5
5
|
platform: x86-mingw32
|
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-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|