Sha256: 328107aef2c2186715830793484963f42cf1140707eefb46eebf761ba7d6028d

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 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 "Generate new migration with name given, example: rake generate:migration[CreateUsers]"
namespace :generate do
  task :migration, [:name] do |name, args|
    klass = args[:name].tr('-', '_').camelize
    number = ActiveRecord::Migration.next_migration_number(0)
    file_name = "#{number}_#{klass.underscore}.rb"
    relative_file_path = File.join("db/migrate", file_name)
    file_path = A9n.root.join(relative_file_path)
    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(/( +\|)/, '')) }
    puts "Created migration file: #{relative_file_path}"
  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

2 entries across 2 versions & 1 rubygems

Version Path
fishplate-1.0.6 lib/fishplate/tasks.rake
fishplate-1.0.5 lib/fishplate/tasks.rake