yaml2erd 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +17 -1
- data/lib/yaml2erd/gv_id_map.rb +17 -0
- data/lib/yaml2erd/version.rb +1 -1
- data/lib/yaml2erd.rb +9 -6
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0c951305aba9df6d52d9ee4cd03a37315600bddb6ad784d513989a6cd59a49f
|
4
|
+
data.tar.gz: 0d5056f95c9bc2ace3ae549ee3c7e0a35ce51822c4614cb37334b049136831ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4dc611ca29259d56d984881e787ab8a7bc523df072c23772bb54f6939402fb54aff54c0c754a15f0e5fc398497fada7d171bf97247f5c86552c214f08163b213
|
7
|
+
data.tar.gz: e4010ff0d1a4433e71d60efb3827f124df5bd1113c59cb8427618c2c0179bebc5b8434929872dba4d4703149b4c26636b3787f366d966fbf247285c6c9b73ecd
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -46,12 +46,28 @@ sample path
|
|
46
46
|
### step4. execute
|
47
47
|
```
|
48
48
|
mkdir erd
|
49
|
-
|
49
|
+
yaml2erd erd/table.yaml -c config/gv_conf.yaml -o erd/table.png
|
50
50
|
```
|
51
51
|
|
52
52
|
- `-c` option is config path
|
53
53
|
- `-o` option is outputed path
|
54
54
|
|
55
|
+
## you can notice the difference between ERD and DDL
|
56
|
+
- step1. get column info from yaml
|
57
|
+
|
58
|
+
```
|
59
|
+
parser = ErYamlParser.new('erd/table.yaml')
|
60
|
+
columns_hash_yaml = parser.models[:Post].columns
|
61
|
+
```
|
62
|
+
|
63
|
+
- step2. get column info from ActiveRecord
|
64
|
+
|
65
|
+
```
|
66
|
+
columns_hash_ar = Post.column_names
|
67
|
+
```
|
68
|
+
|
69
|
+
- step3. Write test code to compare these two
|
70
|
+
|
55
71
|
## Development
|
56
72
|
|
57
73
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/yaml2erd/version.rb
CHANGED
data/lib/yaml2erd.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'gviz'
|
2
|
-
require '
|
2
|
+
require 'active_support/all'
|
3
3
|
require 'yaml2erd/version'
|
4
4
|
require 'yaml2erd/er_yaml_parser'
|
5
|
+
require 'yaml2erd/gv_id_map'
|
5
6
|
|
6
7
|
class Yaml2erd
|
7
8
|
attr_accessor :group_global_conf
|
@@ -42,6 +43,7 @@ class Yaml2erd
|
|
42
43
|
def initialize(yaml_file_path, conf_yaml_path)
|
43
44
|
@yaml = ErYamlParser.new(yaml_file_path)
|
44
45
|
@gv = Gviz.new
|
46
|
+
@gv_id_map = GvIdMap.new
|
45
47
|
|
46
48
|
apply_conf(conf_yaml_path)
|
47
49
|
end
|
@@ -57,11 +59,11 @@ class Yaml2erd
|
|
57
59
|
|
58
60
|
# TODO: addとrouteの違いはなんだろう
|
59
61
|
# entityの枠(model)作成
|
60
|
-
@gv.route model
|
62
|
+
@gv.route @gv_id_map.enc(model)
|
61
63
|
|
62
64
|
# entityの中身(tableタグ)作成、適用
|
63
65
|
table_tag = create_table_tag(model, columns, description)
|
64
|
-
@gv.node model, label: table_tag
|
66
|
+
@gv.node @gv_id_map.enc(model), label: table_tag
|
65
67
|
|
66
68
|
# relation適用
|
67
69
|
apply_relation(model, relations)
|
@@ -195,7 +197,7 @@ class Yaml2erd
|
|
195
197
|
relations.each do |relation|
|
196
198
|
relation.each do |rel_type, rel_model|
|
197
199
|
next if rel_type == :belongs_to
|
198
|
-
@gv.edge "#{model}_#{rel_model}", ARROW_MAP[rel_type]
|
200
|
+
@gv.edge "#{@gv_id_map.enc(model)}_#{@gv_id_map.enc(rel_model)}", ARROW_MAP[rel_type]
|
199
201
|
end
|
200
202
|
end
|
201
203
|
end
|
@@ -208,13 +210,14 @@ class Yaml2erd
|
|
208
210
|
# mapをもとにグルーピング
|
209
211
|
@yaml.groups_map.each do |group_name, models|
|
210
212
|
group_bgcolor = @yaml.groups_bgcolor_map[group_name.to_sym]
|
213
|
+
alias_models = models.map do |model| @gv_id_map.enc(model) end
|
211
214
|
|
212
215
|
@gv.subgraph do
|
213
216
|
global group_conf.merge(label: group_name, bgcolor: group_bgcolor)
|
214
217
|
nodes nodes_conf
|
215
218
|
# model割り当て
|
216
|
-
|
217
|
-
node
|
219
|
+
alias_models.each do |alias_model|
|
220
|
+
node alias_model
|
218
221
|
end
|
219
222
|
end
|
220
223
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yaml2erd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rh-taro
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- lib/yaml2erd.rb
|
104
104
|
- lib/yaml2erd/er_yaml_model.rb
|
105
105
|
- lib/yaml2erd/er_yaml_parser.rb
|
106
|
+
- lib/yaml2erd/gv_id_map.rb
|
106
107
|
- lib/yaml2erd/version.rb
|
107
108
|
- yaml2erd.gemspec
|
108
109
|
homepage: https://github.com/rh-taro/yaml2erd
|