yml2erd 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yml2erd/cli.rb +1 -3
- data/lib/yml2erd/diagram.rb +2 -5
- data/lib/yml2erd/schema_structure/validator.rb +1 -1
- data/lib/yml2erd/version.rb +1 -1
- data/sample.yml +47 -13
- data/sample_abnormal.yml +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eec493eb97de029cef8b42b05732a2d1b6ba1488
|
4
|
+
data.tar.gz: c61166dbdd32c0ba012a5b41d6558d9c81e94db7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5387b5c7e949e14b8c533d8c8cf28cde000afb494433699a337a15d43468eb65e4e02078f4d756cf3c086e9c6bb18e595f30be908f37776dd75eeba8720cd75c
|
7
|
+
data.tar.gz: af86f9eca39331122b73dc135939f25817d9744d13923b88a5f9883f24c19e8479c0d35ff93c8f4d1a9c8310f042548182134e3e6e69b562d03782d1d05fd26f
|
data/lib/yml2erd/cli.rb
CHANGED
@@ -5,8 +5,6 @@ require "yaml"
|
|
5
5
|
|
6
6
|
module Yml2erd
|
7
7
|
class CLI < Thor
|
8
|
-
class YmlNotFoundError < StandardError;end
|
9
|
-
|
10
8
|
desc "convert <path>", "Convert erd from yml"
|
11
9
|
option :output, aliases: :o, banner: 'FILE_PATH', desc: 'default: output.png'
|
12
10
|
option :projectname, aliases: :p, banner: 'PROJECT_NAME', desc: 'default: null'
|
@@ -32,7 +30,7 @@ module Yml2erd
|
|
32
30
|
end
|
33
31
|
|
34
32
|
# This method has a bug around `which gvpr`.
|
35
|
-
# That is because which may not exist
|
33
|
+
# That is because which command may not exist except UNIX based OS.
|
36
34
|
def abort_if_graphviz_isnt_installed
|
37
35
|
abort "GraphViz is not installed, please install graphviz from http://www.graphviz.org/Download..php \n\nOr you can get by\n $ brew install graphviz # on macOS\n $ apt-get install graphviz # on Ubuntu" unless !`which gvpr`.empty?
|
38
36
|
end
|
data/lib/yml2erd/diagram.rb
CHANGED
@@ -5,10 +5,6 @@ module Yml2erd
|
|
5
5
|
class << self
|
6
6
|
DEFAULT_OPTIONS = { output_path: './output.png' }.freeze
|
7
7
|
|
8
|
-
def table_relations(schema_structure)
|
9
|
-
schema_structure.relations
|
10
|
-
end
|
11
|
-
|
12
8
|
def create(schema_structure, opts = {})
|
13
9
|
opts = opts.merge(DEFAULT_OPTIONS)
|
14
10
|
GraphViz::options(use: 'dot')
|
@@ -28,7 +24,8 @@ module Yml2erd
|
|
28
24
|
end
|
29
25
|
|
30
26
|
table_names.each do |table_name|
|
31
|
-
|
27
|
+
if !schema_structure.relation(table_name).nil? && \
|
28
|
+
!schema_structure.relation(table_name)['belongs_to'].nil?
|
32
29
|
schema_structure.relation(table_name)['belongs_to'].each do |belongs_to|
|
33
30
|
g.add_edges(belongs_to, table_name)
|
34
31
|
end
|
@@ -48,7 +48,7 @@ module Yml2erd
|
|
48
48
|
# belongs_to or has_many is not necessary
|
49
49
|
def keyname
|
50
50
|
ss.table_names.each do |table_name|
|
51
|
-
if
|
51
|
+
if ss.columns(table_name).nil? && ss.relation(table_name).nil?
|
52
52
|
raise InvalidKeyNameError, 'you must use correct keyname'
|
53
53
|
end
|
54
54
|
end
|
data/lib/yml2erd/version.rb
CHANGED
data/sample.yml
CHANGED
@@ -1,30 +1,64 @@
|
|
1
|
-
|
1
|
+
companies:
|
2
2
|
columns:
|
3
|
+
- id: integer
|
3
4
|
- name: string
|
5
|
+
- address: string
|
6
|
+
- created_at: datetime
|
7
|
+
- updated_at: datetime
|
8
|
+
relations:
|
9
|
+
has_many:
|
10
|
+
- users
|
11
|
+
users:
|
12
|
+
columns:
|
13
|
+
- id: integer
|
14
|
+
- crypted_password: string
|
4
15
|
- email: string
|
16
|
+
- password_salt: string
|
17
|
+
- auth_token: string
|
18
|
+
- company_id: integer
|
19
|
+
- created_at: datetime
|
20
|
+
- updated_at: datetime
|
21
|
+
- deleted_at: datetime
|
22
|
+
index:
|
23
|
+
- email
|
5
24
|
relations:
|
6
25
|
belongs_to:
|
7
|
-
- user_auths
|
8
26
|
- companies
|
9
27
|
has_many:
|
10
28
|
- posts
|
11
|
-
|
12
|
-
|
13
|
-
user_auths:
|
29
|
+
- user_logs
|
30
|
+
roles:
|
14
31
|
columns:
|
15
|
-
-
|
32
|
+
- id: integer
|
33
|
+
- title: string
|
34
|
+
- user_id: intger
|
35
|
+
- created_at: datetime
|
36
|
+
- updated_at: datetime
|
16
37
|
relations:
|
17
|
-
|
38
|
+
belongs_to:
|
18
39
|
- users
|
19
|
-
|
40
|
+
user_logs:
|
20
41
|
columns:
|
21
|
-
-
|
42
|
+
- id: integer
|
43
|
+
- recently_signed_in: datetime
|
44
|
+
- user_id: integer
|
45
|
+
- created_at: datetime
|
46
|
+
- updated_at: datetime
|
22
47
|
relations:
|
23
48
|
belongs_to:
|
24
49
|
- users
|
25
|
-
|
50
|
+
posts:
|
26
51
|
columns:
|
27
|
-
-
|
28
|
-
-
|
52
|
+
- id: integer
|
53
|
+
- title: string
|
54
|
+
- body: text
|
55
|
+
- attachment_path: string
|
56
|
+
- deleted_at: datetime
|
57
|
+
- user_id: integer
|
58
|
+
- created_at: datetime
|
59
|
+
- updated_at: datetime
|
60
|
+
index:
|
61
|
+
- user_id
|
29
62
|
relations:
|
30
|
-
|
63
|
+
belongs_to:
|
64
|
+
- users
|
data/sample_abnormal.yml
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yml2erd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- asmsuechan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-graphviz
|