Class: Annotated::Models

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/annotated/models.rb

Constant Summary collapse

STRONG_ANNOTATION =
%q|generated by 'annotated-rails' gem|
ANNOTATION =
%Q|#{STRONG_ANNOTATION}, please do not remove this line and content %s, instead use `bundle exec annotate-rails -d` command|
NOT_NULL =
'not null'
PRIMARY_KEY_MARK =
'*'
DEFAULT =
'default %s'

Instance Method Summary collapse

Instance Method Details

#annotate!(options = {}) ⇒ Object



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/annotated/models.rb', line 138

def annotate! options = {}
  print_message "Annotating: "

  annotators.each do |annotator|
    next unless annotator.annotatable?

    print_message annotator.model.to_s+' '

    content = File.read(annotator.path).gsub(annotator.remove_regexp, "\n")
    content.gsub!(annotator.add_regexp, annotator.annotation)

    write_file annotator.path, content
  end

  puts_message "\n"
end

#denotate!Object



155
156
157
158
159
160
# File 'lib/annotated/models.rb', line 155

def denotate!
  annotators.each do |annotator|
    content = File.read(annotator.path).gsub(annotator.remove_regexp, "\n")
    write_file annotator.path, content
  end
end