-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
83 lines (69 loc) · 1.8 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
# frozen_string_literal: true
require 'rake/testtask'
require './require_app'
task :print_env do
puts "Environment: #{ENV['RACK_ENV'] || 'development'}"
end
desc 'Run application console (pry)'
task :console => :print_env do
sh 'pry -r ./spec/test_load_all'
end
desc 'Test all the specs'
Rake::TestTask.new(:spec) do |t|
t.pattern = 'spec/**/*_spec.rb'
t.warning = false
end
desc 'Rerun tests on live code changes'
task :respec do
sh 'rerun -c rake spec'
end
desc 'Run rubocop to check style'
task :style => :spec do
sh 'rubocop .'
end
desc 'Update vulnerabilities lit and audit gems'
task :audit do
sh 'bundle audit check --update'
end
desc 'Checks for release'
task :release => [:spec, :style, :audit] do
puts "\nReady for release!"
end
namespace :run do
# Run in development mode
desc 'Run Web App in development mode'
task :dev => :print_env do
sh 'puma -p 9292'
end
end
task :load_lib do
require_app('lib')
end
namespace :generate do
desc 'Create rbnacl key'
task :msg_key => :load_lib do
puts "New MSG_KEY (base64): #{SecureMessage.generate_key}"
end
desc 'Create cookie secret'
task :session_secret => :load_lib do
puts "New SESSION_SECRET (base64): #{SecureSession.generate_secret}"
end
end
namespace :url do
# usage: $ rake url:integrity URL=http://example.org/script.js
desc 'Generate integrity hash for a URL (argument: URL=...)'
task :integrity do
sha384 = `curl -L -s #{ENV['URL']} | openssl dgst -sha384 -binary | \
openssl enc -base64`
puts "sha384-#{sha384}"
end
end
namespace :session do
desc 'Wipe all sessions stored in Redis'
task :wipe => :load_lib do
require 'redis'
puts 'Deleting all sessions from Redis session store'
wiped = SecureSession.wipe_redis_sessions
puts "#{wiped.count} sessions deleted"
end
end