class ErYamlParser
Attributes
groups[R]
groups_bgcolor_map[R]
groups_map[R]
model_list[R]
models[R]
yaml_file_path[R]
Public Class Methods
new(yaml_file_path)
click to toggle source
# File lib/yaml2erd/er_yaml_parser.rb, line 13 def initialize(yaml_file_path) @yaml_file_path = yaml_file_path # yamlファイルopen set_yaml_data # modelのリスト set_model_list # YamlModelのハッシュ set_models # groups set_groups # groups_map set_groups_map # groups_bgcolor_map set_groups_bgcolor_map end
Private Instance Methods
set_groups()
click to toggle source
# File lib/yaml2erd/er_yaml_parser.rb, line 49 def set_groups @groups = @yaml_data[:groups] end
set_groups_bgcolor_map()
click to toggle source
TODO: 複数指定で重ねたり、入れ子にしたりできるように {:group_name => [table_name1, …]}というhashを作る
# File lib/yaml2erd/er_yaml_parser.rb, line 69 def set_groups_bgcolor_map @groups_bgcolor_map = {} @groups.each do |group| @groups_bgcolor_map[group[:name].to_sym] = group[:bgcolor] end end
set_groups_map()
click to toggle source
グルーピングのmap作成
# File lib/yaml2erd/er_yaml_parser.rb, line 54 def set_groups_map @groups_map = {} @model_list.each do |model| next if @models[model].group_name.blank? group_name = @models[model].group_name.to_sym # なければ初期化 @groups_map[group_name] = [] if @groups_map[group_name].blank? @groups_map[group_name] << model end end
set_model_list()
click to toggle source
# File lib/yaml2erd/er_yaml_parser.rb, line 38 def set_model_list @model_list = @yaml_data[:models].map do |h| h[0] end end
set_models()
click to toggle source
# File lib/yaml2erd/er_yaml_parser.rb, line 42 def set_models @models = {} @model_list.each do |model_name| @models[model_name] = ErYamlModel.new(@yaml_data[:models][model_name]) end end
set_yaml_data()
click to toggle source
# File lib/yaml2erd/er_yaml_parser.rb, line 32 def set_yaml_data File.open(@yaml_file_path) do |file| @yaml_data = YAML.safe_load(file.read).deep_symbolize_keys end end