You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.3 KiB

require "minitest/test_task"
task :default => :test
Minitest::TestTask.create
desc "Open a dev console"
task :console do
require_relative "lib/rank_king"
include RankKing
binding.irb
end
namespace :serve do
desc "Run a development server"
task :watch do
loop do
sh "fd . | entr -dr rackup"
end
end
end
namespace :db do
desc "Migrate DB to latest"
task :migrate, %i[version] do |t, args|
version = args.fetch(:version, nil)
version = version.to_i unless version.nil? # distinguish nil from 0
require_relative "lib/rank_king/db"
require "logger"
Sequel.extension :migration
DB.loggers << Logger.new($stdout) if DB.loggers.empty?
Sequel::Migrator.apply(DB, "migrate", version)
end
desc "Seed DB with data"
task :seed do
require_relative "lib/rank_king/models"
include RankKing
DB.transaction do
pool = Pool.create(name: "desserts")
desserts = <<~DESSERTS.lines(chomp: true)
Chocolate cake
Apple pie
Cheesecake
Brownies
DESSERTS
desserts.each do |dessert|
Item.create(pool:, title: dessert)
end
Axis.create(pool:, name: "Taste")
end
end
end
namespace :test do
desc "Run tests on source changes"
task :watch do
loop do
sh "fd . | entr -d rake test:isolated"
end
end
end