-
Notifications
You must be signed in to change notification settings - Fork 6
/
Rakefile
58 lines (53 loc) · 1.5 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
require 'bundler/setup'
require 'rake/testtask'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |task|
task.rspec_opts = "--pattern test/rspecs/**{,/*/**}/*_rspec.rb"
end
Rake::TestTask.new do |test|
test.pattern = 'test/**/*_spec.rb'
test.warning = false
test.verbose = false
end
namespace :rufo do
desc 'Validate Ruby file formatting'
task :validate => [] do
base_path = File.dirname(__FILE__)
[
File.join(base_path, 'lib'),
*Dir.glob(File.join(base_path, 'test', '**', '**', '*.rb')).find_all { |path|
!path.include?('/data/')
},
].each do |path|
if !system("rufo -c #{path}")
$stderr.puts "Files in #{path} directory require formatting!"
$stderr.puts " - Run `rake rufo:fmt`"
exit -1
end
end
end
desc 'Format Ruby files in this project'
task :fmt => [] do
base_path = File.dirname(__FILE__)
[
File.join(base_path, 'lib'),
*Dir.glob(File.join(base_path, 'test', '**', '**', '*.rb')).find_all { |path|
!path.include?('/data/')
},
].each do |path|
$stdout.puts "Formatting files in #{path}..."
system("rufo #{path}")
if $?.exitstatus != 0 && $?.exitstatus != 3
$stderr.puts "ERROR: Formatting files in #{path} failed!"
exit -1
end
end
$stdout.puts " -> File formatting complete!"
end
end
desc 'Run all tests'
task :default => [] do
Rake::Task['rufo:validate'].invoke
Rake::Task[:spec].invoke
Rake::Task[:test].invoke
end