Sha256: 771be31c36b56972a0a667098ea97d74a9dd024da73847069f32aa20c8624043

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

Stored size: 1.33 KB

Contents

desc "Load application environment"
task :environment do
  A9n.root.join("config/environment.rb").tap do |path|
    require path if path.exist?
  end
end

desc "Run application console"
task console: :environment do
  require "irb"
  ARGV.clear
  IRB.start
end

desc "Ensure that task is not run in production environment"
task fail_if_prod: :environment do
  fail "Task cannot be run in production environment!" if A9n.env.production?
end

desc "Setup database"
task "db:setup" => ["fail_if_prod", "db:create", "db:schema:load"]

desc "Generate new migration with name given, e.g. rake generate:migration[CreateUsers]"
namespace :generate do
  task :migration, [:name] do |name, args|
    klass     = args[:name].camelize
    number    = ActiveRecord::Migration.next_migration_number(0)
    file_name = "#{number}_#{args[:name].underscore}.rb"
    file_path = A9n.root.join("db/migrate", file_name)
    content   = <<-CONTENT
      |class #{klass} < ActiveRecord::Migration[#{ActiveRecord::Migration.current_version}]
      |  def change
      |  end
      |end
    CONTENT
    File.open(file_path, "w+") { |f| f.write(content.gsub(/( +\|)/, '')) }
  end
end

begin
  require "rspec/core/rake_task"
  RSpec::Core::RakeTask.new(:spec)
rescue LoadError
  # ignore
end

begin
  require "rubocop/rake_task"
  RuboCop::RakeTask.new
rescue LoadError
  # ignore
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fishplate-0.2.0 lib/fishplate/tasks.rake
fishplate-0.1.1 lib/fishplate/tasks.rake
fishplate-0.1.0 lib/fishplate/tasks.rake