-
Notifications
You must be signed in to change notification settings - Fork 4
/
Rakefile
40 lines (33 loc) · 1014 Bytes
/
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
require "rake"
require "rake/testtask"
require "rubocop/rake_task"
RuboCop::RakeTask.new
# rufo must be the last: https://github.com/ruby-formatter/rufo/pull/262/files
task all: [:test, :rubocop, "rufo:check"]
task default: :all
Rake::TestTask.new(:test) do |t|
t.libs << "."
t.libs << "lib"
t.libs << "test"
t.test_files = FileList["test/**/*_test.rb"]
t.verbose = true
end
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6.0")
task rufo: ["rufo:run"]
namespace :rufo do
require "rufo"
def rufo_command(*switches, rake_args)
files_or_dirs = rake_args[:files_or_dirs] || "."
args = switches + files_or_dirs.split
Rufo::Command.run(args)
end
desc "Format Ruby code in current directory"
task :run, [:files_or_dirs] do |_task, rake_args|
rufo_command(rake_args)
end
desc "Check that no formatting changes are produced"
task :check, [:files_or_dirs] do |_task, rake_args|
rufo_command("--check", rake_args)
end
end
end