yaml2erd 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bd5696521ec49d8752a8b85cdf0eac256ccfd2e7b807031b956d454cc9bc4c8b
4
+ data.tar.gz: 3b9308df9411151cec2cb7f0dd358ad859db04446e174efd46f700b3df4123ea
5
+ SHA512:
6
+ metadata.gz: b0ff3fd25fa6751e68fc1b806e19fda231126cd683623b0364e4928de5e457469ab29fa9de8b417028c365f6a6851607b8d82e0afd4ec06600051132ee8525c8
7
+ data.tar.gz: a28aaeb33320bc7943e37d97beb109b6988b3a15b84627ca64f5869272cc936a70021cf446196d4c56fe5caa3f8da34dea9757425ade63942f03e51fd3cbef7d
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+ before_install: gem install bundler -v 1.17.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at TODO: Write your email address. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in yaml2erd.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,52 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ yaml2erd (0.1.0)
5
+ activesupport (~> 5.2)
6
+ gviz (~> 0.3.5)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (5.2.1)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 0.7, < 2)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ concurrent-ruby (1.1.3)
17
+ diff-lcs (1.3)
18
+ gviz (0.3.5)
19
+ thor
20
+ i18n (1.1.1)
21
+ concurrent-ruby (~> 1.0)
22
+ minitest (5.11.3)
23
+ rake (10.5.0)
24
+ rspec (3.8.0)
25
+ rspec-core (~> 3.8.0)
26
+ rspec-expectations (~> 3.8.0)
27
+ rspec-mocks (~> 3.8.0)
28
+ rspec-core (3.8.0)
29
+ rspec-support (~> 3.8.0)
30
+ rspec-expectations (3.8.2)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.8.0)
33
+ rspec-mocks (3.8.0)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.8.0)
36
+ rspec-support (3.8.0)
37
+ thor (0.20.3)
38
+ thread_safe (0.3.6)
39
+ tzinfo (1.2.5)
40
+ thread_safe (~> 0.1)
41
+
42
+ PLATFORMS
43
+ ruby
44
+
45
+ DEPENDENCIES
46
+ bundler (~> 1.17)
47
+ rake (~> 10.0)
48
+ rspec (~> 3.0)
49
+ yaml2erd!
50
+
51
+ BUNDLED WITH
52
+ 1.17.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # Yaml2erd
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/yaml2erd`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'yaml2erd'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install yaml2erd
22
+
23
+ ## Usage
24
+
25
+ ### step1. you should install `graphviz` and `fonts`
26
+ **〜recommend using docker〜**
27
+
28
+ ex.
29
+
30
+ ```
31
+ apt-get install -y graphviz task-japanese fonts-ipafont fonts-noto-cjk
32
+ ```
33
+
34
+ ### step2. create yaml (required)
35
+ examle: https://github.com/rh-taro/dockerized_yaml2erd#sample
36
+
37
+ sample path
38
+ `erd/table.yaml`
39
+
40
+ ### step3. create conf (not required)
41
+ ex: https://github.com/rh-taro/dockerized_yaml2erd/blob/master/config/gv_conf.yaml
42
+
43
+ sample path
44
+ `config/gv_conf.yaml`
45
+
46
+ ### step4. execute
47
+ ```
48
+ mkdir erd
49
+ bin/yaml2erd erd/table.yaml -c config/gv_conf.yaml -o erd/table.png
50
+ ```
51
+
52
+ - `-c` option is config path
53
+ - `-o` option is outputed path
54
+
55
+ ## Development
56
+
57
+ 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.
58
+
59
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
60
+
61
+ ## Contributing
62
+
63
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/yaml2erd. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
64
+
65
+ ## License
66
+
67
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
68
+
69
+ ## Code of Conduct
70
+
71
+ Everyone interacting in the Yaml2erd project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/yaml2erd/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "yaml2erd"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bin/yaml2erd ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'yaml2erd'
5
+
6
+ options = {}
7
+ OptionParser.new do |opt|
8
+ opt.on('-c [VALUE]', 'config path') { |v| options[:c] = v }
9
+ opt.on('-o [VALUE]', 'output path') { |v| options[:o] = v }
10
+ opt.parse!(ARGV)
11
+ end
12
+
13
+ parser = Yaml2erd.new(ARGV[0], options[:c])
14
+ # gvizへ書き出し
15
+ parser.write_erd
16
+ # 保存
17
+ parser.file_save(save_path: options[:o])
@@ -0,0 +1,36 @@
1
+ class ErYamlModel
2
+ def initialize(yaml_model)
3
+ @yaml_model = yaml_model
4
+
5
+ parse_columns
6
+ end
7
+
8
+ def columns
9
+ @yaml_model[:columns]
10
+ end
11
+
12
+ def parsed_columns
13
+ @yaml_model[:parsed_columns]
14
+ end
15
+
16
+ def relations
17
+ # TODO: 同じassociationのtypeまとめる形の方がいいかも yamlの構造を変えるかここで変換するか
18
+ @yaml_model[:relations]
19
+ end
20
+
21
+ def group_name
22
+ @yaml_model[:group]
23
+ end
24
+
25
+ def description
26
+ @yaml_model[:description]
27
+ end
28
+
29
+ private
30
+
31
+ def parse_columns
32
+ @yaml_model[:parsed_columns] = @yaml_model[:columns].map do |column|
33
+ { column_name: column[0], column_detail: column[1] }
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,75 @@
1
+ require 'yaml'
2
+ require 'active_support/all'
3
+ require 'yaml2erd/er_yaml_model'
4
+
5
+ class ErYamlParser
6
+ attr_reader :yaml_file_path
7
+ attr_reader :models
8
+ attr_reader :groups
9
+ attr_reader :model_list
10
+ attr_reader :groups_map
11
+ attr_reader :groups_bgcolor_map
12
+
13
+ def initialize(yaml_file_path)
14
+ @yaml_file_path = yaml_file_path
15
+
16
+ # yamlファイルopen
17
+ set_yaml_data
18
+ # modelのリスト
19
+ set_model_list
20
+ # YamlModelのハッシュ
21
+ set_models
22
+ # groups
23
+ set_groups
24
+ # groups_map
25
+ set_groups_map
26
+ # groups_bgcolor_map
27
+ set_groups_bgcolor_map
28
+ end
29
+
30
+ private
31
+
32
+ def set_yaml_data
33
+ File.open(@yaml_file_path) do |file|
34
+ @yaml_data = YAML.safe_load(file.read).deep_symbolize_keys
35
+ end
36
+ end
37
+
38
+ def set_model_list
39
+ @model_list = @yaml_data[:models].map do |h| h[0] end
40
+ end
41
+
42
+ def set_models
43
+ @models = {}
44
+ @model_list.each do |model_name|
45
+ @models[model_name] = ErYamlModel.new(@yaml_data[:models][model_name])
46
+ end
47
+ end
48
+
49
+ def set_groups
50
+ @groups = @yaml_data[:groups]
51
+ end
52
+
53
+ # グルーピングのmap作成
54
+ def set_groups_map
55
+ @groups_map = {}
56
+ @model_list.each do |model|
57
+ next if @models[model].group_name.blank?
58
+
59
+ group_name = @models[model].group_name.to_sym
60
+
61
+ # なければ初期化
62
+ @groups_map[group_name] = [] if @groups_map[group_name].blank?
63
+ @groups_map[group_name] << model
64
+ end
65
+ end
66
+ # TODO: 複数指定で重ねたり、入れ子にしたりできるように
67
+ # {:group_name => [table_name1, ...]}というhashを作る
68
+
69
+ def set_groups_bgcolor_map
70
+ @groups_bgcolor_map = {}
71
+ @groups.each do |group|
72
+ @groups_bgcolor_map[group[:name].to_sym] = group[:bgcolor]
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,3 @@
1
+ class Yaml2erd
2
+ VERSION = "0.1.1"
3
+ end
data/lib/yaml2erd.rb ADDED
@@ -0,0 +1,226 @@
1
+ require 'gviz'
2
+ require 'rails/all'
3
+ require 'yaml2erd/version'
4
+ require 'yaml2erd/er_yaml_parser'
5
+
6
+ class Yaml2erd
7
+ attr_accessor :group_global_conf
8
+
9
+ ARROW_MAP = {
10
+ has_many: { arrowhead: 'crow', arrowtail: 'tee', arrowsize: 5, dir: 'both', minlen: 5, penwidth: 10 },
11
+ has_one: { arrowhead: 'tee', arrowtail: 'tee', arrowsize: 5, dir: 'both', minlen: 5, penwidth: 10 }
12
+ }.freeze
13
+
14
+ TABLE_HEADER = %w[
15
+ 物理名
16
+ 論理名
17
+
18
+ PK
19
+ FK
20
+ NOT_NULL
21
+ DEFAULT
22
+ 説明
23
+ ].freeze
24
+
25
+ DEFAULT_CONF = {
26
+ global_conf: {
27
+ layout: 'dot'
28
+ },
29
+ entity_conf: {
30
+ shape: 'Mrecord',
31
+ fontname: 'Noto Sans CJK JP Black',
32
+ fontsize: 50
33
+ },
34
+ group_conf: {
35
+ shape: 'Mrecord',
36
+ fontname: 'Noto Sans CJK JP Black',
37
+ fontsize: 120
38
+ }
39
+ }.freeze
40
+
41
+ # TODO: nodesとglobalの違いみたいなの調査
42
+ def initialize(yaml_file_path, conf_yaml_path)
43
+ @yaml = ErYamlParser.new(yaml_file_path)
44
+ @gv = Gviz.new
45
+
46
+ apply_conf(conf_yaml_path)
47
+ end
48
+
49
+ def write_erd
50
+ # entityとrelation作成
51
+ @yaml.model_list.each do |model|
52
+ columns = @yaml.models[model].columns
53
+ relations = @yaml.models[model].relations
54
+ description = @yaml.models[model].description
55
+
56
+ validate_columns!(model, columns)
57
+
58
+ # TODO: addとrouteの違いはなんだろう
59
+ # entityの枠(model)作成
60
+ @gv.route model
61
+
62
+ # entityの中身(tableタグ)作成、適用
63
+ table_tag = create_table_tag(model, columns, description)
64
+ @gv.node model, label: table_tag
65
+
66
+ # relation適用
67
+ apply_relation(model, relations)
68
+ end
69
+
70
+ # group適用
71
+ apply_grouping
72
+ end
73
+
74
+ def file_save(save_path: '')
75
+ ext = :png
76
+ dir = 'erd'
77
+ filename = remove_ext(@yaml.yaml_file_path)
78
+
79
+ if save_path.present?
80
+ dir = File.dirname(save_path)
81
+ filename = remove_ext(save_path)
82
+ ext = File.extname(save_path).slice!(1..-1)
83
+ end
84
+
85
+ @gv.save "#{dir}/#{filename}", ext
86
+ end
87
+
88
+ private
89
+
90
+ def apply_conf(conf_yaml_path)
91
+ conf = DEFAULT_CONF
92
+ custom_conf = {}
93
+ if conf_yaml_path.present?
94
+ File.open(conf_yaml_path) do |file|
95
+ custom_conf = YAML.safe_load(file.read).deep_symbolize_keys
96
+ end
97
+ end
98
+
99
+ # DEFAULT_CONFとキー重複しているものだけ適用
100
+ custom_conf.each do |custom_key, custom_details|
101
+ if conf.keys.include?(custom_key)
102
+ custom_details.each do |custom_detail_key, custom_val|
103
+ if conf[custom_key].keys.include?(custom_detail_key)
104
+ conf[custom_key][custom_detail_key] = custom_val
105
+ end
106
+ end
107
+ end
108
+ end
109
+
110
+ # 適用
111
+ @group_global_conf = conf[:group_conf]
112
+ @nodes_conf = conf[:entity_conf]
113
+
114
+ @gv.global conf[:global_conf]
115
+ @gv.nodes @nodes_conf
116
+ end
117
+
118
+ def validate_columns!(db_table_name, db_columns)
119
+ # ささやかなバリデーション
120
+ return if db_columns.class == Hash
121
+ p "#{db_table_name} columns error"
122
+ exit
123
+ end
124
+
125
+ def create_table_tag(db_table_name, db_columns, db_table_description)
126
+ table_tag = "<table border='0' cellborder='1' cellpadding='8'>"
127
+
128
+ # DBのテーブル名
129
+ table_tag += "<tr><td bgcolor='lightblue' colspan='#{TABLE_HEADER.size}'>#{db_table_name}</td></tr>"
130
+ # ヘッダ(TABLE_HEADERから生成)
131
+ table_tag += create_table_header
132
+ # ボディ(DBのテーブルの各カラムのデータ)
133
+ table_tag += create_table_body(db_columns)
134
+ # フッタ
135
+ table_tag += "<tr><td bgcolor='lightblue' colspan='#{TABLE_HEADER.size}'>#{nl2br(db_table_description)}</td></tr>"
136
+
137
+ table_tag += '</table>'
138
+ table_tag
139
+ end
140
+
141
+ def create_table_header
142
+ table_header = '<tr>'
143
+ TABLE_HEADER.each do |head|
144
+ table_header += "<td bgcolor='lightblue'>#{head}</td>"
145
+ end
146
+ table_header += '</tr>'
147
+ table_header
148
+ end
149
+
150
+ def create_table_body(db_columns)
151
+ table_body = ''
152
+ db_columns.each do |db_column, db_column_info|
153
+ db_column_logical_name = db_column_info[:logical_name].presence || ''
154
+ db_column_description = db_column_info[:description].presence || ''
155
+ db_column_options = db_column_info[:options].presence || {}
156
+
157
+ # 表示する値とalignの指定
158
+ table_columns = [
159
+ { val: db_column, align: :left },
160
+ { val: db_column_logical_name, align: :left },
161
+ { val: db_column_info[:type], align: :left },
162
+ { val: convert_check_mark(db_column_options[:primary_key]), align: :center },
163
+ { val: convert_check_mark(db_column_options[:foreign_key]), align: :center },
164
+ { val: convert_check_mark(db_column_options[:not_null]), align: :center },
165
+ { val: db_column_options[:default], align: :left },
166
+ { val: nl2br(db_column_description), align: :left }
167
+ ]
168
+
169
+ table_body += create_table_line(table_columns)
170
+ end
171
+ table_body
172
+ end
173
+
174
+ def convert_check_mark(val)
175
+ # TODO: 指定なし/指定ありtrue/指定ありfalseを考慮
176
+ val.present? ? '✔︎' : ''
177
+ end
178
+
179
+ def nl2br(str)
180
+ str.gsub(/\r\n|\r|\n/, '<br />')
181
+ end
182
+
183
+ def create_table_line(table_columns)
184
+ table_line = '<tr>'
185
+ table_columns.each do |table_column|
186
+ table_line += "<td bgcolor='white' align='#{table_column[:align]}'>#{table_column[:val]}</td>" \
187
+ end
188
+ table_line += '</tr>'
189
+ table_line
190
+ end
191
+
192
+ def apply_relation(model, relations)
193
+ # リレーションのマッピング
194
+ return if relations.blank?
195
+ relations.each do |relation|
196
+ relation.each do |rel_type, rel_model|
197
+ next if rel_type == :belongs_to
198
+ @gv.edge "#{model}_#{rel_model}", ARROW_MAP[rel_type]
199
+ end
200
+ end
201
+ end
202
+
203
+ def apply_grouping
204
+ # グループ内に適用するために再度@nodes_confをあてる
205
+ nodes_conf = @nodes_conf
206
+ group_conf = @group_global_conf
207
+
208
+ # mapをもとにグルーピング
209
+ @yaml.groups_map.each do |group_name, models|
210
+ group_bgcolor = @yaml.groups_bgcolor_map[group_name.to_sym]
211
+
212
+ @gv.subgraph do
213
+ global group_conf.merge(label: group_name, bgcolor: group_bgcolor)
214
+ nodes nodes_conf
215
+ # model割り当て
216
+ models.each do |model|
217
+ node model
218
+ end
219
+ end
220
+ end
221
+ end
222
+
223
+ def remove_ext(file_name)
224
+ File.basename(file_name, '.*')
225
+ end
226
+ end
data/yaml2erd.gemspec ADDED
@@ -0,0 +1,43 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "yaml2erd/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "yaml2erd"
8
+ spec.version = Yaml2erd::VERSION
9
+ spec.authors = ["rh-taro"]
10
+ spec.email = [""]
11
+
12
+ spec.summary = %q{ERD create from yaml}
13
+ spec.description = %q{assist design and maintenance}
14
+ spec.homepage = "https://github.com/rh-taro/yaml2erd"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata["homepage_uri"] = spec.homepage
21
+ spec.metadata["source_code_uri"] = "https://github.com/rh-taro/yaml2erd"
22
+ spec.metadata["changelog_uri"] = "https://github.com/rh-taro/yaml2erd"
23
+ else
24
+ raise "RubyGems 2.0 or newer is required to protect against " \
25
+ "public gem pushes."
26
+ end
27
+
28
+ # Specify which files should be added to the gem when it is released.
29
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
30
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
31
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
+ end
33
+ spec.bindir = "bin"
34
+ spec.executables = "yaml2erd"
35
+ spec.require_paths = ["lib"]
36
+
37
+ spec.add_dependency 'activesupport', '~> 5.2'
38
+ spec.add_dependency 'gviz', '~> 0.3.5'
39
+
40
+ spec.add_development_dependency "bundler", "~> 1.17"
41
+ spec.add_development_dependency "rake", "~> 10.0"
42
+ spec.add_development_dependency "rspec", "~> 3.0"
43
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yaml2erd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - rh-taro
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-11-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: gviz
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.3.5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.3.5
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.17'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.17'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description: assist design and maintenance
84
+ email:
85
+ - ''
86
+ executables:
87
+ - yaml2erd
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
+ - CODE_OF_CONDUCT.md
95
+ - Gemfile
96
+ - Gemfile.lock
97
+ - LICENSE.txt
98
+ - README.md
99
+ - Rakefile
100
+ - bin/console
101
+ - bin/setup
102
+ - bin/yaml2erd
103
+ - lib/yaml2erd.rb
104
+ - lib/yaml2erd/er_yaml_model.rb
105
+ - lib/yaml2erd/er_yaml_parser.rb
106
+ - lib/yaml2erd/version.rb
107
+ - yaml2erd.gemspec
108
+ homepage: https://github.com/rh-taro/yaml2erd
109
+ licenses:
110
+ - MIT
111
+ metadata:
112
+ homepage_uri: https://github.com/rh-taro/yaml2erd
113
+ source_code_uri: https://github.com/rh-taro/yaml2erd
114
+ changelog_uri: https://github.com/rh-taro/yaml2erd
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.7.8
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: ERD create from yaml
135
+ test_files: []