Class: Yaml2erd
- Inherits:
-
Object
- Object
- Yaml2erd
- Defined in:
- lib/yaml2erd.rb,
lib/yaml2erd/version.rb
Constant Summary collapse
- TABLE_HEADER =
%w[ 物理名 論理名 型 PK FK NOT_NULL DEFAULT 説明 ].freeze
- DEFAULT_CONF =
{ global_conf: { layout: 'dot', splines: 'ortho', }, entity_conf: { shape: 'Mrecord', fontname: 'Noto Sans CJK JP Black', fontsize: 20, }, group_conf: { shape: 'Mrecord', fontname: 'Noto Sans CJK JP Black', fontsize: 40, }, arrow_map: { has_many: {}, has_one: {}, }, }.freeze
- VERSION =
"0.5.0"
Instance Attribute Summary collapse
-
#group_global_conf ⇒ Object
Returns the value of attribute group_global_conf.
Instance Method Summary collapse
- #file_save(save_path: '') ⇒ Object
-
#initialize(yaml_file_path, conf_yaml_path) ⇒ Yaml2erd
constructor
TODO: nodesとglobalの違いみたいなの調査.
- #write_erd ⇒ Object
Constructor Details
#initialize(yaml_file_path, conf_yaml_path) ⇒ Yaml2erd
TODO: nodesとglobalの違いみたいなの調査
43 44 45 46 47 48 49 50 |
# File 'lib/yaml2erd.rb', line 43 def initialize(yaml_file_path, conf_yaml_path) @yaml = ErYamlParser.new(yaml_file_path) @gv = Gviz.new @gv_id_map = GvIdMap.new @customized_conf = fetch_conf(conf_yaml_path) apply_conf(@customized_conf) end |
Instance Attribute Details
#group_global_conf ⇒ Object
Returns the value of attribute group_global_conf.
8 9 10 |
# File 'lib/yaml2erd.rb', line 8 def group_global_conf @group_global_conf end |
Instance Method Details
#file_save(save_path: '') ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/yaml2erd.rb', line 77 def file_save(save_path: '') ext = :png dir = 'erd' filename = remove_ext(@yaml.yaml_file_path) if save_path.present? dir = File.dirname(save_path) filename = remove_ext(save_path) ext = File.extname(save_path).slice!(1..-1) end @gv.save "#{dir}/#{filename}", ext end |
#write_erd ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/yaml2erd.rb', line 52 def write_erd # entityとrelation作成 @yaml.model_list.each do |model| columns = @yaml.models[model].columns relations = @yaml.models[model].relations description = @yaml.models[model].description validate_columns!(model, columns) # TODO: addとrouteの違いはなんだろう # entityの枠(model)作成 @gv.route @gv_id_map.enc(model) # entityの中身(tableタグ)作成、適用 table_tag = create_table_tag(model, columns, description) @gv.node @gv_id_map.enc(model), label: table_tag # relation適用 apply_relation(model, relations) end # group適用 apply_grouping end |