-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
82 lines (69 loc) · 1.93 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
# frozen_string_literal: true
require 'rake/testtask'
require 'find'
desc 'Rubocop, bye_emacs, test, and super_git all in one'
task :super, [:message] do |_, args|
Rake::Task[:rubocop].execute
Rake::Task[:bye_emacs].execute
Rake::Task[:test].execute
Rake::Task[:super_git].execute(message: args.message)
end
desc 'Run tests'
task default: :test
Rake::TestTask.new(:test) do |t|
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/*_test.rb']
end
Rake::TestTask.new(:test_signed_in) do |t|
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/*_in_test.rb']
end
Rake::TestTask.new(:test_signed_out) do |t|
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/*_out_test.rb']
end
desc 'Display inventory of all visible files in the project'
task :inventory do
sh 'tree -CF --dirsfirst'
end
desc 'Alias of inventory'
task tree: :inventory
desc 'Automatically fix simple errors with rubocop'
task :rubocop, [:option] do |_, args|
case args[:option]
when 'no-fix' then sh 'rubocop .'
else sh 'rubocop -a .'
end
rescue RuntimeError => e
abort unless e.message =~ /Command failed with status/
end
desc 'Give wc info for all files in the project that I wrote.'
task :wc do
files = %w[Rakefile
Gemfile
Procfile
config.ru
README.md
time_manager.rb
data/test.yml
public/stylesheets/time_manager.css] +
Dir['test/*.rb'] +
Dir['lib/*.rb'] +
Dir['views/*.erb']
sh "wc #{files.join(' ')}"
end
desc 'Remove all emacs backup files'
task :bye_emacs do
files = Dir['**/*~'].join(' ')
sh "rm #{files}" unless files.empty?
end
desc 'Add all files and commit with message, pushing to remote repos.'
task :super_git, [:message] do |_, args|
remotes = `git remote`.split
sh 'git add .'
sh %(git commit -m "#{args[:message]}")
remotes.each { |remote| sh "git push #{remote}" }
end