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"
2 years ago
task :default => :test
2 years ago
Minitest::TestTask.create
2 years ago
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
2 years ago
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