class SchemaRD::DefaultTableCommentParser
Public Class Methods
new(comment_text)
click to toggle source
# File lib/schemard/rdoc_parser.rb, line 30 def initialize(comment_text) @hash = { relations: {} } @hash[:description] = comment_text.split("\n").map(&:strip).map{|line| if line =~ /^name\:\:/ || line =~ /^localized_name\:\:/ @hash[:localized_name] = line.match(/^[^:]*name\:\:(.+)$/)[1].strip next end %w(belongs_to has_many has_one).each do |rel_type| if line =~ /^#{rel_type}\:\:/ tables = line.match(/^#{rel_type}\:\:(.+)$/)[1].split(",").map(&:strip).select{|s| s != "" } @hash[:relations][rel_type.to_sym] = tables unless tables.empty? line = nil # skip this line (by compact) end end line }.compact.join("\n") end
Public Instance Methods
description()
click to toggle source
# File lib/schemard/rdoc_parser.rb, line 56 def description @hash[:description] end
has_description?()
click to toggle source
# File lib/schemard/rdoc_parser.rb, line 53 def has_description? !!@hash[:description] end
has_localized_name?()
click to toggle source
# File lib/schemard/rdoc_parser.rb, line 47 def has_localized_name? @hash[:localized_name] && @hash[:localized_name] != "" end
has_relation_of?(rel_type)
click to toggle source
# File lib/schemard/rdoc_parser.rb, line 59 def has_relation_of?(rel_type) !!@hash[:relations][rel_type] end
localized_name()
click to toggle source
# File lib/schemard/rdoc_parser.rb, line 50 def localized_name @hash[:localized_name] end
relation_of(rel_type)
click to toggle source
# File lib/schemard/rdoc_parser.rb, line 62 def relation_of(rel_type) @hash[:relations][rel_type] end