-
Notifications
You must be signed in to change notification settings - Fork 186
/
Rakefile
137 lines (112 loc) · 2.95 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
require "rake/testtask"
require "bundler/gem_helper"
task default: :test
namespace "gem" do
gem_helper = Bundler::GemHelper.new
gem_pkg = "#{gem_helper.gemspec.name}-#{gem_helper.gemspec.version}.gem"
desc "Build #{gem_pkg} into the pkg directory."
task "build" do
gem_helper.build_gem
end
desc "Push pkg/#{gem_pkg} to RubyGems.org."
task "push" do
sh "gem push pkg/#{gem_pkg} -V"
end
task build: "racc"
end
RACC_TARGETS = [
"lib/bcdice/arithmetic/parser.rb",
"lib/bcdice/command/parser.rb",
"lib/bcdice/common_command/add_dice/parser.rb",
"lib/bcdice/common_command/barabara_dice/parser.rb",
"lib/bcdice/common_command/tally_dice/parser.rb",
"lib/bcdice/common_command/calc/parser.rb",
"lib/bcdice/common_command/reroll_dice/parser.rb",
"lib/bcdice/common_command/upper_dice/parser.rb",
"lib/bcdice/game_system/sword_world/rating_parser.rb",
].freeze
task racc: RACC_TARGETS
rule ".rb" => ".y" do |t|
opts = [t.source,
"-o", t.name,]
opts << "--no-line-convert" unless ENV["RACC_DEBUG"]
opts << "--debug" if ENV["RACC_DEBUG"]
sh "racc", *opts
end
desc "Clean coverage resuts"
task :clean_coverage do
require "simplecov"
resultset_path = SimpleCov::ResultMerger.resultset_path
FileUtils.rm resultset_path if File.exist? resultset_path
end
namespace :test do
Rake::TestTask.new(:all) do |t|
t.description = "全てのテストを実行する"
t.test_files = [
"test/setup.rb",
"test/test_*.rb",
]
t.libs = [
"test/",
"lib/",
]
t.ruby_opts = [
"--enable-frozen-string-literal"
]
end
Rake::TestTask.new(:dicebots) do |t|
t.description = "ダイスボット"
t.test_files = [
"test/test_game_system_commands.rb",
]
t.libs = [
"test/",
"lib/",
]
t.ruby_opts = [
"--enable-frozen-string-literal"
]
end
Rake::TestTask.new(:unit) do |t|
t.description = "ユニットテスト"
t.test_files = FileList[
"test/test_*.rb",
].exclude("test/test_game_system_commands.rb")
t.libs = [
"test/",
"lib/",
]
t.ruby_opts = [
"--enable-frozen-string-literal"
]
end
task all: "racc"
task dicebots: "racc"
task unit: "racc"
end
task test: [
:clean_coverage,
"test:all",
]
require "rubocop/rake_task"
RuboCop::RakeTask.new
task test: [:rubocop] if ENV["CI"] != "true"
require "yard"
require "yard/rake/yardoc_task"
YARD::Rake::YardocTask.new
namespace :release do
gem_helper = Bundler::GemHelper.new
version = gem_helper.gemspec.version
desc "Commit BCDice #{version}"
task :commit do
changelog = File.read("CHANGELOG.md")
date = Time.now.strftime("%Y/%m/%d")
header = "## #{version} #{date}"
unless changelog.include?(header)
warn "[Error] CHANGELOG.md does not contain the header #{header.inspect}"
exit(1)
end
sh "git commit -e -m 'Release BCDice #{version}'"
sh "git tag -a 'v#{version}' -m '#{version}'"
end
end