Sha256: 15007f1bb2f1f4d03db483b121666534affa3d8354422ffd7edd75372ce54104

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

namespace :db do
  task :migrate do
    $rake_ahnnotate_config ||= Ahnnotate::Config.load(root: Rails.root)

    if $rake_ahnnotate_config["rake_db_autorun"]
      Rake::Task["ahnnotate:all"].reenable
      Rake::Task["ahnnotate:all"].invoke
    end
  end

  task :rollback do
    $rake_ahnnotate_config ||= Ahnnotate::Config.load(root: Rails.root)

    if $rake_ahnnotate_config["rake_db_autorun"]
      Rake::Task["ahnnotate:all"].reenable
      Rake::Task["ahnnotate:all"].invoke
    end
  end
end

namespace :ahnnotate do
  desc "Run ahnnotate"
  task :all do
    require "ahnnotate/cli"
    require "shellwords"

    # This should either be `rails` or `rake` (since newer versions of Rails
    # can call rake tasks with either executable)
    exe_name = File.basename($0)

    argv = ENV.fetch("COMMENTATE", "--fix")
    argv = Shellwords.split(argv)

    puts "Commentating models..."

    cli = Ahnnotate::Cli.new(name: "#{exe_name} ahnnotate")
    cli.run(argv, $rake_ahnnotate_config)

    puts "Done!"
  end
end

desc "Run rake task `ahnnotate:all`"
task ahnnotate: "ahnnotate:all"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ahnnotate-0.2.0 lib/ahnnotate/rails.rake