-
Notifications
You must be signed in to change notification settings - Fork 7
/
Rakefile
61 lines (54 loc) · 1.63 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
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
def do_rspec(opts=["-c"])
system(*['rspec', opts, 'spec/'].flatten)
end
desc "run rspec"
task :rspec do
do_rspec
end
namespace :rspec do
desc "run rspec with coverage"
task :cov do
ENV["COV"]="1"
do_rspec
end
desc "run rspec with all of installed versions of ruby"
task :rvm do
system("rvm exec 'ruby -e \"puts %Q!=!*48\";ruby -v;rspec -c spec/'")
end
end
namespace :gem do
desc "build gem"
task :build do
system("gem build kyototycoon.gemspec")
end
desc "versioning"
task :version do
ver = ENV["VER"]
if ver.nil?
puts "version is not specified."
puts "Usage: VER=x.x.x rake ..."
exit
end
date = Time.now.strftime("%Y-%m-%d")
# Prefer GNU sed to BSD sed
sed = [`which gsed`, `which sed`].map{|s| s.strip}.join(" ").strip.split(" ").first
system("echo lib/kyototycoon.rb | xargs #{sed} -E -i \"s/VERSION = '[0-9.]+'/VERSION = '#{ver}'/g\"")
system("echo kyototycoon.gemspec | xargs #{sed} -E -i 's/s.version\s*=\s*\".*\"/s.version = \"#{ver}\"/g'")
system("echo Gemfile.lock | xargs #{sed} -E -i 's/kyototycoon \(.*?\)/kyototycoon (#{ver})/g'")
system("echo kyototycoon.gemspec | xargs #{sed} -E -i 's/s.date = .*$/s.date = %q{#{date}}/g'")
system("git add -u")
puts "= NOTICE ="
puts "ver #{ver}, edit Changes.md for what changed and commit, git tag #{ver}"
end
end
task :default => ["rspec"]