-
-
Notifications
You must be signed in to change notification settings - Fork 39
/
Rakefile
71 lines (60 loc) · 1.67 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
require 'rake/clean'
require 'rubygems'
require 'rubygems/package_task'
require 'rdoc'
require 'rdoc/task'
Rake::RDocTask.new do |rd|
rd.main = "README.md"
rd.rdoc_files.include("README.md","lib/**/*.rb","bin/**/*")
rd.title = 'mdless'
rd.markup = 'markdown'
end
spec = eval(File.read('mdless.gemspec'))
Gem::PackageTask.new(spec) do |pkg|
end
desc 'Install the gem in the current ruby'
task :install, :all do |t, args|
args.with_defaults(:all => false)
if args[:all]
sh 'rvm all do gem install pkg/*.gem'
sh 'sudo gem install pkg/*.gem'
else
sh 'gem install pkg/*.gem'
end
end
desc 'Development version check'
task :ver do
version_file = 'lib/mdless/version.rb'
content = IO.read(version_file)
m = content.match(/VERSION *= *(?<quot>['"])(?<maj>\d+)\.(?<min>\d+)\.(?<pat>\d+)(?<pre>\S+)?\k<quot>/)
puts "#{m['maj']}.#{m['min']}.#{m['pat']}#{m['pre']}"
end
desc 'Bump incremental version number'
task :bump, :type do |t, args|
args.with_defaults(type: 'inc')
version_file = 'lib/mdless/version.rb'
content = IO.read(version_file)
content.sub!(/VERSION *= *(?<quot>['"])(?<maj>\d+)\.(?<min>\d+)\.(?<pat>\d+)(?<pre>\S+)?\k<quot>/) do
m = Regexp.last_match
major = m['maj'].to_i
minor = m['min'].to_i
inc = m['pat'].to_i
pre = m['pre']
case args[:type]
when /^maj/
major += 1
minor = 0
inc = 0
when /^min/
minor += 1
inc = 0
else
inc += 1
end
$stdout.print "#{major}.#{minor}.#{inc}#{pre}"
"VERSION = '#{major}.#{minor}.#{inc}#{pre}'"
end
File.open(version_file, 'w+') { |f| f.puts content }
end
task default: %i[test features]
task build: %i[clobber rdoc package]