yaml2erd 0.2.0 → 0.3.0
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/Gemfile.lock +5 -5
- data/lib/yaml2erd.rb +42 -23
- data/lib/yaml2erd/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c07d6b5fd4e512e61815f61e3ad4b2bb011aa9bcda3d9e831601c9b2d856ae45
|
4
|
+
data.tar.gz: 9bd8dc74f363c71d443e371c9141d1a936426c0d0c99bfcd8d9d9c640e52e838
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: def24be6c39babaea1f83c9cd5dfd59e66b8fefe93f45781bc3cfb0831b4844789e01ed875b17d6d73907498169b472c8167878cfec2301947f9fd0ce850fb7b
|
7
|
+
data.tar.gz: 99c3ae3cfa1ca336c5e7f28897d7f135a05792f53030589094fe1821c28a6581225f2626c9bb0e7d6256901710d1cdc7cda41dc5144faae729402b5c21d85315
|
data/Gemfile.lock
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
yaml2erd (0.
|
4
|
+
yaml2erd (0.3.0)
|
5
5
|
activesupport (~> 5.2)
|
6
6
|
gviz (~> 0.3.5)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (5.2.
|
11
|
+
activesupport (5.2.2)
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
13
|
i18n (>= 0.7, < 2)
|
14
14
|
minitest (~> 5.1)
|
15
15
|
tzinfo (~> 1.1)
|
16
|
-
concurrent-ruby (1.1.
|
16
|
+
concurrent-ruby (1.1.4)
|
17
17
|
diff-lcs (1.3)
|
18
18
|
gviz (0.3.5)
|
19
19
|
thor
|
20
|
-
i18n (1.
|
20
|
+
i18n (1.5.2)
|
21
21
|
concurrent-ruby (~> 1.0)
|
22
22
|
minitest (5.11.3)
|
23
23
|
rake (10.5.0)
|
@@ -49,4 +49,4 @@ DEPENDENCIES
|
|
49
49
|
yaml2erd!
|
50
50
|
|
51
51
|
BUNDLED WITH
|
52
|
-
1.17.
|
52
|
+
1.17.3
|
data/lib/yaml2erd.rb
CHANGED
@@ -7,11 +7,6 @@ require 'yaml2erd/gv_id_map'
|
|
7
7
|
class Yaml2erd
|
8
8
|
attr_accessor :group_global_conf
|
9
9
|
|
10
|
-
ARROW_MAP = {
|
11
|
-
has_many: { arrowhead: 'crow', arrowtail: 'tee', arrowsize: 5, dir: 'both', minlen: 5, penwidth: 10 },
|
12
|
-
has_one: { arrowhead: 'tee', arrowtail: 'tee', arrowsize: 5, dir: 'both', minlen: 5, penwidth: 10 }
|
13
|
-
}.freeze
|
14
|
-
|
15
10
|
TABLE_HEADER = %w[
|
16
11
|
物理名
|
17
12
|
論理名
|
@@ -23,19 +18,30 @@ class Yaml2erd
|
|
23
18
|
説明
|
24
19
|
].freeze
|
25
20
|
|
26
|
-
|
21
|
+
CUSTOMIZABLE_CONF = {
|
27
22
|
global_conf: {
|
28
23
|
layout: 'dot'
|
29
24
|
},
|
30
25
|
entity_conf: {
|
31
26
|
shape: 'Mrecord',
|
32
27
|
fontname: 'Noto Sans CJK JP Black',
|
33
|
-
fontsize:
|
28
|
+
fontsize: 20
|
34
29
|
},
|
35
30
|
group_conf: {
|
36
31
|
shape: 'Mrecord',
|
37
32
|
fontname: 'Noto Sans CJK JP Black',
|
38
|
-
fontsize:
|
33
|
+
fontsize: 40
|
34
|
+
},
|
35
|
+
arrow_map: {
|
36
|
+
has_many: { arrowsize: 3, minlen: 2, penwidth: 4 },
|
37
|
+
has_one: { arrowsize: 3, minlen: 2, penwidth: 4 }
|
38
|
+
}
|
39
|
+
}.freeze
|
40
|
+
|
41
|
+
NOT_CUSTOMIZABLE_CONF = {
|
42
|
+
arrow_map: {
|
43
|
+
has_many: { arrowhead: 'crow', arrowtail: 'tee', dir: 'both' },
|
44
|
+
has_one: { arrowhead: 'tee', arrowtail: 'tee', dir: 'both' }
|
39
45
|
}
|
40
46
|
}.freeze
|
41
47
|
|
@@ -45,7 +51,8 @@ class Yaml2erd
|
|
45
51
|
@gv = Gviz.new
|
46
52
|
@gv_id_map = GvIdMap.new
|
47
53
|
|
48
|
-
|
54
|
+
@customized_conf = fetch_conf(conf_yaml_path)
|
55
|
+
apply_conf(@customized_conf)
|
49
56
|
end
|
50
57
|
|
51
58
|
def write_erd
|
@@ -89,26 +96,38 @@ class Yaml2erd
|
|
89
96
|
|
90
97
|
private
|
91
98
|
|
92
|
-
def
|
93
|
-
|
94
|
-
custom_conf = {}
|
99
|
+
def fetch_conf(conf_yaml_path)
|
100
|
+
user_conf = {}
|
95
101
|
if conf_yaml_path.present?
|
96
102
|
File.open(conf_yaml_path) do |file|
|
97
|
-
|
103
|
+
user_conf = YAML.safe_load(file.read).deep_symbolize_keys
|
98
104
|
end
|
99
105
|
end
|
100
106
|
|
101
|
-
#
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
107
|
+
# CUSTOMIZABLE_CONFとキー重複しているものだけ適用
|
108
|
+
customized_conf = merge_keep_struct(CUSTOMIZABLE_CONF.dup, user_conf)
|
109
|
+
|
110
|
+
# ユーザ設定取り込んで、固定値をマージして返す
|
111
|
+
customized_conf.deep_merge(NOT_CUSTOMIZABLE_CONF)
|
112
|
+
end
|
113
|
+
|
114
|
+
def merge_keep_struct(base_hash, input_hash)
|
115
|
+
input_hash.each do |key, val|
|
116
|
+
# input_hashのネストが深すぎる時にエラーになるからtry
|
117
|
+
next unless base_hash.try(:keys).try(:include?, key)
|
118
|
+
|
119
|
+
if val.is_a?(Hash)
|
120
|
+
base_hash[key] = merge_keep_struct(base_hash[key], input_hash[key])
|
121
|
+
else
|
122
|
+
# input_hashのネストが浅すぎる時(inputは底までついたけどbaseはまだhashの時)はスルーするように
|
123
|
+
next if base_hash[key].is_a?(Hash)
|
124
|
+
base_hash[key] = val
|
109
125
|
end
|
110
126
|
end
|
127
|
+
base_hash
|
128
|
+
end
|
111
129
|
|
130
|
+
def apply_conf(conf)
|
112
131
|
# 適用
|
113
132
|
@group_global_conf = conf[:group_conf]
|
114
133
|
@nodes_conf = conf[:entity_conf]
|
@@ -196,8 +215,8 @@ class Yaml2erd
|
|
196
215
|
return if relations.blank?
|
197
216
|
relations.each do |relation|
|
198
217
|
relation.each do |rel_type, rel_model|
|
199
|
-
next if rel_type
|
200
|
-
@gv.edge "#{@gv_id_map.enc(model)}_#{@gv_id_map.enc(rel_model)}",
|
218
|
+
next if rel_type != :has_one && rel_type != :has_many
|
219
|
+
@gv.edge "#{@gv_id_map.enc(model)}_#{@gv_id_map.enc(rel_model)}", @customized_conf[:arrow_map][rel_type]
|
201
220
|
end
|
202
221
|
end
|
203
222
|
end
|
data/lib/yaml2erd/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yaml2erd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rh-taro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -128,8 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
- !ruby/object:Gem::Version
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
|
-
|
132
|
-
rubygems_version: 2.7.8
|
131
|
+
rubygems_version: 3.0.2
|
133
132
|
signing_key:
|
134
133
|
specification_version: 4
|
135
134
|
summary: ERD create from yaml
|