-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
107 lines (82 loc) · 2.04 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
# -*- coding: utf-8 -*-
# add "lib" directory to load path
$:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "lib"))
require 'pp'
require 'find'
require 'open-uri'
require 'yaml'
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require 'colorize'
require 'msh/version'
require 'msh/color'
include Msh::Color
CLEAN.include("*.gem")
desc 'Builds the gem'
task :build do
sh "gem build msh.gemspec"
end
Rake::TestTask.new(:test) do |test|
test.libs << 'test' << 'lib'
test.pattern = 'test/**/test_*.rb'
end
# Document output
require 'yard'
require 'yard/rake/yardoc_task'
YARD::Rake::YardocTask.new do |t|
t.files = ['lib/**/*.rb', 'lib/msh/help/help*']
t.options = []
t.options << '--debug' << '--verbose' if $trace
end
def confirm(msg)
while(true)
puts msg
yn = $stdin.gets
yn.chomp!
break if yn =~ /[yYnN]/
end
return yn =~ /[yY]/
end
def get_version
Msh::VERSION
end
def bump_version(field=:major) # :major, :minor, or :patch
# update msh/version.rb
puts "Current Version: " + notice(`rake version:show:thisdir`.chomp!)
path = File.join(File.dirname(File.expand_path(__FILE__)), "lib", "msh", "version.rb")
f = File.open(path, "r+")
code = f.read
f.close
const = "VERSION_" + field.to_s.upcase
next_version = eval("Msh::" + const) + 1
code.gsub!(/#{const} = \d+/, "#{const} = #{next_version}")
f = File.open(path, "w")
f.write(code)
f.close
puts "Bumped Version: " + important(`rake version:show:thisdir`.chomp!)
end
namespace :version do
namespace :show do
desc 'show the version of this directory'
task :thisdir do
puts important(get_version)
end
end
namespace :bump do
desc 'bump major version (ex: 1.y.z to 2.y.z)'
task :major do
bump_version(:major)
end
desc 'bump minor version (ex: x.1.z to x.2.z)'
task :minor do
bump_version(:minor)
end
desc 'bump patch level (ex: x.y.0 to x.y.1)'
task :patch do
bump_version(:patch)
end
end
end
task :default => [:test, :build]