-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
103 lines (83 loc) · 2.07 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# frozen_string_literal: true
require 'rake/testtask'
require_relative 'require_app'
task :default do
puts `rake -T`
end
desc 'Run tests once'
Rake::TestTask.new(:spec) do |t|
t.pattern = 'spec/*_spec.rb'
t.warning = false
end
desc 'Keep rerunning tests upon file changes'
task :respec do
sh "rerun -c 'rake spec' --ignore 'coverage/*'"
end
task :run do
sh 'bundle exec puma'
end
namespace :db do # rubocop:disable Metrics/BlockLength
task :config do
require 'sequel'
require_relative 'config/environment'
require_relative 'spec/helpers/database_helper'
def app = PapMon::App
end
desc 'Run migrations'
task migrate: :config do
Sequel.extension :migration
puts "Migrating #{app.environment} database to latest"
Sequel::Migrator.run(app.DB, 'db/migrations')
end
desc 'Wipe records from all tables'
task wipe: :config do
if app.environment == :production
puts 'Refusing to wipe production database'
return
end
require_app('infrastructure')
require_relative 'spec/helpers/database_helper'
DatabaseHelper.wipe_database
end
desc 'Delete dev or test database file (set correct RACK_ENV)'
task drop: :config do
if app.environment == :production
puts 'Refusing to drop production database'
return
end
FileUtils.rm(app.config.DB_FILENAME)
puts "Deleted #{app.config.DB_FILENAME}"
end
end
desc 'Run application console'
task :console do
sh 'pry -r ./load_all'
end
task :rerun do
sh "rerun -c --ignore 'coverage/*' -- bundle exec puma"
end
namespace :vcr do
desc 'delete cassette fixtures'
task :wipe do
sh 'rm spec/fixtures/cassettes/*.yml' do |ok, _|
puts(ok ? 'Cassettes deleted' : 'No cassettes found')
end
end
end
namespace :quality do
only_app = 'config/ app/'
desc 'run all static-analysis quality checks'
task all: %i[rubocop flog reek]
desc 'code style linter'
task :rubocop do
sh 'rubocop'
end
desc 'complexiy analysis'
task :flog do
sh "flog -m #{only_app}"
end
desc 'code smell detector'
task :reek do
sh 'reek'
end
end