-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
69 lines (56 loc) · 1.28 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
# frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rubocop/rake_task'
require 'yard'
require 'ruff/version'
YARDOPTS = [
'--output-dir=docs',
"--title=Ruff #{Ruff::VERSION} Documentation",
'--markup-provider=redcarpet',
'--markup=markdown',
'--charset=utf-8',
'--no-private'
].freeze
RuboCop::RakeTask.new
YARD::Rake::YardocTask.new do |doc|
doc.name = 'doc'
YARDOPTS.each { |opt| doc.options << opt }
doc.files = FileList.new('lib/**/*.rb').exclude('**/util.rb')
end
desc 'new version'
task(:newver, %i[major minor patch]) do |_, args|
f = File.open('version', 'r+')
v = f.read.gsub(/[^a-zA-Z0-9\-_\.]/, '').split '.'
newv = args.to_a.dup
begin
case newv[0]
when '-'
newv[0] = v[0]
case newv[1]
when '-'
newv[1] = v[1]
case newv[2]
when '+'
newv[2] = v[2].to_i + 1
end
when '+'
newv[1] = v[1].to_i + 1
newv[2] = 0
else
newv[2] = 0
end
when '+'
newv[0] = v[0].to_i + 1
newv[1] = 0
newv[2] = 0
end
rescue StandardError => e
puts e
end
p "#{v.join '.'} => #{newv.join '.'}"
f.seek(0, IO::SEEK_SET)
f.write newv.join '.'
f.close
sh 'bash lib/ruff/version.gen.sh > lib/ruff/version.rb'
end
task default: :spec