Class: Webhookdb::Tasks::Annotate

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/webhookdb/tasks/annotate.rb

Instance Method Summary collapse

Constructor Details

#initializeAnnotate

Returns a new instance of Annotate.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/webhookdb/tasks/annotate.rb', line 11

def initialize
  super()
  desc "Update model annotations"
  task :annotate do
    unless `git diff`.blank?
      puts "Cannot annotate while there is any git diff."
      puts "Please commit or revert any diff and try again."
      exit(1)
    end

    require "webhookdb"
    Webhookdb.load_app
    files = []
    Webhookdb::Postgres.each_model_class do |cls|
      files << "lib/#{cls.name.underscore}.rb" if cls.name
    end

    require "sequel/annotate"
    Sequel::Annotate.annotate(files, border: true)
    puts "Finished annotating:"
    files.each { |f| puts "  #{f}" }
    puts "Please commit the changes."
  end
end