schemard 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.ja.md +36 -8
- data/README.md +40 -4
- data/lib/schemard/metadata.rb +2 -1
- data/lib/schemard/schema_parser.rb +4 -2
- data/lib/schemard.rb +1 -1
- data/schemard.gemspec +2 -0
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f93b6db46593a9933c132850585b4a7e03f55de2
|
4
|
+
data.tar.gz: 1b7fab78d73c880a2779ff067e1207f167db3ead
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f68a074626339cb2f12d3c570fb137cab5a5812bedf176b09393eedcdd9d7dc22cd05143fd4f5c4acb841cb4f26f117bbcf118e3ea9da84b12532cfbb173d1b
|
7
|
+
data.tar.gz: 7277d6c3a2242440ec52e0c7601edddcc8b2db6bb59e07bac25b816b8f9c992203c662f74054d03d5145b43600ea8b97e649c6777ecff76719b498876b54bcd2
|
data/README.ja.md
CHANGED
@@ -14,7 +14,7 @@ SchemaRD は、Railsアプリケーションで利用する schema.rb を元にE
|
|
14
14
|
|
15
15
|
実行:
|
16
16
|
```
|
17
|
-
$ schemard
|
17
|
+
$ schemard
|
18
18
|
```
|
19
19
|
|
20
20
|
Webブラウザで`http://localhost:10080`にアクセスすると生成されたER図を参照できます。
|
@@ -24,13 +24,21 @@ Webブラウザで`http://localhost:10080`にアクセスすると生成され
|
|
24
24
|
### レイアウト調整
|
25
25
|
|
26
26
|
デフォルトで生成されるER図では、テーブルは無作為にレイアウトされています。
|
27
|
-
|
27
|
+
例として、RubyOnRailsチュートリアル( https://railstutorial.jp/ )のschema.rbより生成したER図を示します。
|
28
|
+
|
29
|
+
<img src="https://raw.githubusercontent.com/wiki/xketanaka/schemard/images/init_layout_ja.png" width="700px" >
|
30
|
+
|
31
|
+
図の左上の「テーブルの位置を編集」をチェックし、テーブルをドラッグすることでテーブルの配置場所を調整することができます。
|
32
|
+
|
33
|
+
<img src="https://raw.githubusercontent.com/wiki/xketanaka/schemard/images/edit_layout_ja.png" width="700px" >
|
34
|
+
|
28
35
|
|
29
36
|
### リレーション追加
|
30
37
|
|
31
38
|
デフォルトで生成されるER図には、テーブル同士のリレーション情報がありません。
|
32
39
|
ER図にリレーションを追加するには、別途リレーション情報を与える必要があります。
|
33
|
-
|
40
|
+
|
41
|
+
リレーション情報を与える方法はいくつかありますが、ここではRailsアプリケーションのモデル情報を元にリレーション情報を追加する手順を説明します。先程と同様に、RubyOnRailsチュートリアルのソースコードを用いて説明します。
|
34
42
|
|
35
43
|
1. 以下のコマンドでリレーション情報を抽出します。ここでは`db/relatoin.metadata`に出力します。
|
36
44
|
```
|
@@ -38,12 +46,32 @@ ER図にリレーションを追加するには、別途リレーション情報
|
|
38
46
|
$ schemard gen-relation > db/relation.metadata
|
39
47
|
```
|
40
48
|
|
41
|
-
2.
|
49
|
+
2. `db/relatoin.metadata`には以下の内容が出力されます。
|
42
50
|
```
|
43
|
-
|
51
|
+
---
|
52
|
+
tables:
|
53
|
+
users:
|
54
|
+
has_many:
|
55
|
+
- microposts
|
56
|
+
- relationships
|
57
|
+
- relationships
|
58
|
+
relationships:
|
59
|
+
belongs_to:
|
60
|
+
- users
|
61
|
+
- users
|
62
|
+
microposts:
|
63
|
+
belongs_to:
|
64
|
+
- users
|
44
65
|
```
|
45
66
|
|
46
|
-
3.
|
67
|
+
3. 抽出したリレーション情報を読み込ませるには以下のようにオプションを指定して実行します。
|
68
|
+
```
|
69
|
+
$ schemard -f db/relation.metadata
|
70
|
+
```
|
71
|
+
|
72
|
+
4. Webブラウザで`http://localhost:10080`にアクセスするとER図にリレーションが追加されて表示されます。
|
73
|
+
|
74
|
+
<img src="https://raw.githubusercontent.com/wiki/xketanaka/schemard/images/relation_added.png" width="700px" >
|
47
75
|
|
48
76
|
### 日本語化
|
49
77
|
|
@@ -67,10 +95,10 @@ ja:
|
|
67
95
|
|
68
96
|
2. 以下のようにオプションで辞書ファイルを指定して実行します。
|
69
97
|
```
|
70
|
-
$ schemard -
|
98
|
+
$ schemard -f db/relation.metadata -f config/locale/ja.yml
|
71
99
|
```
|
72
100
|
|
73
|
-
3. Webブラウザで `http://localhost:10080`
|
101
|
+
3. Webブラウザで `http://localhost:10080` にアクセスするとテーブル名・カラム名が辞書ファイルに記述された表示名で表示されます。
|
74
102
|
|
75
103
|
## オプション
|
76
104
|
|
data/README.md
CHANGED
@@ -24,15 +24,23 @@ And browse `http://localhost:10080`
|
|
24
24
|
### Edit Layout
|
25
25
|
|
26
26
|
In the ERD generated by default, the tables are laid out at random.
|
27
|
+
The figure below is the table schema which has generated from schema.rb of the Ruby On Rails Tutorial( https://www.railstutorial.org/ ).
|
28
|
+
|
29
|
+
<img src="https://raw.githubusercontent.com/wiki/xketanaka/schemard/images/init_layout.png" width="700px" >
|
30
|
+
|
27
31
|
You can adjust the position by checking "Edit table position" at the top left of the figure,
|
28
32
|
And dragging the table.
|
29
33
|
|
34
|
+
<img src="https://raw.githubusercontent.com/wiki/xketanaka/schemard/images/edit_layout.png" width="700px" >
|
35
|
+
|
30
36
|
### Add Relation
|
31
37
|
|
32
38
|
In the ERD generated by default, there is no relation information between tables.
|
33
39
|
To add a relation to the ERD, You need to create relation information and load it.
|
34
|
-
There are several ways to give a relation information.
|
40
|
+
There are several ways to give a relation information.
|
41
|
+
|
35
42
|
This section explains how to add relation information based on model information of Rails application.
|
43
|
+
Just as before, we will explain the procedure with the source code of Ruby On Rails Tutorial.
|
36
44
|
|
37
45
|
1. Extract relation information with the following command. In this example, it outputs to `db/relatoin.metadata`.
|
38
46
|
```
|
@@ -40,17 +48,45 @@ This section explains how to add relation information based on model information
|
|
40
48
|
$ schemard gen-relation > db/relation.metadata
|
41
49
|
```
|
42
50
|
|
43
|
-
2.
|
51
|
+
2. The following contents are output to `db/relatoin.metadata`.
|
52
|
+
```
|
53
|
+
---
|
54
|
+
tables:
|
55
|
+
users:
|
56
|
+
has_many:
|
57
|
+
- microposts
|
58
|
+
- relationships
|
59
|
+
- relationships
|
60
|
+
relationships:
|
61
|
+
belongs_to:
|
62
|
+
- users
|
63
|
+
- users
|
64
|
+
microposts:
|
65
|
+
belongs_to:
|
66
|
+
- users
|
67
|
+
```
|
68
|
+
|
69
|
+
3. To load the extracted relationship information, execute with the following command option.
|
44
70
|
```
|
45
|
-
$ schemard -
|
71
|
+
$ schemard -f db/relation.metadata
|
46
72
|
```
|
47
73
|
|
48
|
-
|
74
|
+
4. When accessing `http://localhost:10080` in the Web browser, relations are added to the ERD.
|
75
|
+
|
76
|
+
<img src="https://raw.githubusercontent.com/wiki/xketanaka/schemard/images/relation_added.png" width="700px" >
|
77
|
+
|
49
78
|
|
50
79
|
### Localization
|
51
80
|
|
52
81
|
## Options
|
53
82
|
|
83
|
+
The following command line options can be specified.
|
84
|
+
|
54
85
|
### Sub Command
|
55
86
|
|
87
|
+
The following sub-commands can be specified.
|
88
|
+
|
56
89
|
## Configuration
|
90
|
+
|
91
|
+
Instead of specifying it with command line options, you can specify options in the configuration file.
|
92
|
+
Place the configuration file as `.schemard.config` in the` schemard` command execution directory. The following entries can be specified.
|
data/lib/schemard/metadata.rb
CHANGED
@@ -4,7 +4,8 @@ require_relative 'rdoc_parser'
|
|
4
4
|
|
5
5
|
module SchemaRD
|
6
6
|
module Metadata
|
7
|
-
|
7
|
+
# "config", "lang", "schema" must be assigned, but ruby2.0 needs default value.
|
8
|
+
def self.load(config: nil, lang: "ja", schema: nil)
|
8
9
|
metadata = Parser.new(config.output_file, *config.metadata_files).parse()
|
9
10
|
localizer = SchemaRD::Utils::SchemaLocalizer.new(lang, metadata)
|
10
11
|
# localized_name を設定
|
@@ -26,7 +26,8 @@ module SchemaRD
|
|
26
26
|
CODE
|
27
27
|
end
|
28
28
|
alias_method :numeric, :decimal
|
29
|
-
|
29
|
+
# "with_comment" must be assigned, but ruby2.0 needs default value.
|
30
|
+
def initialize(table, with_comment: false)
|
30
31
|
@table = table
|
31
32
|
@parse_db_comment = with_comment
|
32
33
|
end
|
@@ -48,7 +49,8 @@ module SchemaRD
|
|
48
49
|
@table.indexes << SchemaRD::TableIndex.new(options.merge({ columns: column_name }))
|
49
50
|
end
|
50
51
|
end
|
51
|
-
|
52
|
+
# "with_comment" must be assigned, but ruby2.0 needs default value.
|
53
|
+
def initialize(schema, with_comment: false)
|
52
54
|
@schema = schema
|
53
55
|
@parse_db_comment = with_comment
|
54
56
|
end
|
data/lib/schemard.rb
CHANGED
data/schemard.gemspec
CHANGED
@@ -22,6 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
end
|
23
23
|
spec.executables = ["schemard"]
|
24
24
|
spec.require_paths = ["lib"]
|
25
|
+
# This gem will work with 2.0 or greater...
|
26
|
+
spec.required_ruby_version = '>= 2.0'
|
25
27
|
|
26
28
|
spec.add_development_dependency "bundler", "~> 1.0"
|
27
29
|
spec.add_development_dependency "rake", "~> 0.9"
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schemard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken TANAKA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0.9'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.9'
|
41
41
|
description: |2
|
@@ -48,7 +48,7 @@ executables:
|
|
48
48
|
extensions: []
|
49
49
|
extra_rdoc_files: []
|
50
50
|
files:
|
51
|
-
-
|
51
|
+
- .gitignore
|
52
52
|
- Gemfile
|
53
53
|
- LICENSE.txt
|
54
54
|
- README.ja.md
|
@@ -84,17 +84,17 @@ require_paths:
|
|
84
84
|
- lib
|
85
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
89
|
+
version: '2.0'
|
90
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
|
-
- -
|
92
|
+
- - '>='
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.0.14.1
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: SchemaRD is a ERD Viewer for schema.rb.
|