-
Notifications
You must be signed in to change notification settings - Fork 12
/
Rakefile
66 lines (57 loc) · 1.31 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
require 'bundler/gem_helper'
require "rspec/core/rake_task"
if /darwin/ =~ RUBY_PLATFORM
task :spec do
sh "rsdl -S rspec #{ENV['SPEC_OPTS']} #{ENV['SPEC']}"
end
task :guard do
rspec_path = 'spec/rspec'
File.open(rspec_path, 'w') do |f|
f.write(<<-EOS)
#!/bin/sh
bundle exec rsdl -S rspec $@
EOS
end
chmod(0755, rspec_path)
begin
sh "bundle exec guard"
ensure
rm_rf(rspec_path)
end
end
else
RSpec::Core::RakeTask.new(:spec)
task :guard do
sh "bundle exec guard"
end
end
task :rubocop do
files = `git ls-files | grep -e '.rb$'`
sh "rubocop #{files.split(/\s+/m).join(' ')}"
end
namespace :gem do
Bundler::GemHelper.install_tasks
end
task :build do
Rake::Task['gem:build'].invoke
end
task :release do
Rake::Task['gem:release'].invoke
require 'dxruby_sdl/version'
next_version = DXRubySDL::VERSION.split('.').tap { |versions|
versions[-1] = (versions[-1].to_i + 1).to_s
}.join('.')
File.open('lib/dxruby_sdl/version.rb', 'r+') do |f|
lines = []
while line = f.gets
line = "#{$1} '#{next_version}'\n" if /(\s*VERSION = )/.match(line)
lines << line
end
f.rewind
f.write(lines.join)
end
sh 'git add lib/dxruby_sdl/version.rb'
sh "git commit -m #{next_version}"
sh 'git push'
end
task :default => [:spec]