-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Rakefile
85 lines (73 loc) · 2.08 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
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rdoc/task'
require 'standard/rake'
require 'yard'
Rake::RDocTask.new do |rd|
rd.main = "README.rdoc"
rd.rdoc_files.include("README.rdoc", "lib/**/*.rb", "bin/**/*")
rd.title = 'Snibbets'
end
YARD::Rake::YardocTask.new do |t|
t.files = ['lib/na/*.rb']
t.options = ['--markup-provider=redcarpet', '--markup=markdown', '--no-private', '-p', 'yard_templates']
# t.stats_options = ['--list-undoc']
end
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = "--pattern {spec,lib}/**/*_spec.rb"
end
task default: %i[test]
desc 'Alias for build'
task :package => :build
task test: "spec"
task lint: "standard"
task format: "standard:fix"
desc "Open an interactive ruby console"
task :console do
require "irb"
require "bundler/setup"
require "snibbets"
ARGV.clear
IRB.start
end
desc 'Development version check'
task :ver do
gver = `git ver`
cver = IO.read(File.join(File.dirname(__FILE__), 'CHANGELOG.md')).match(/^#+ (\d+\.\d+\.\d+(\w+)?)/)[1]
res = `grep VERSION lib/snibbets/version.rb`
version = res.match(/VERSION *= *['"](\d+\.\d+\.\d+(\w+)?)/)[1]
puts "git tag: #{gver}"
puts "version.rb: #{version}"
puts "changelog: #{cver}"
end
desc 'Changelog version check'
task :cver do
puts IO.read(File.join(File.dirname(__FILE__), 'CHANGELOG.md')).match(/^#+ (\d+\.\d+\.\d+(\w+)?)/)[1]
end
desc 'Bump incremental version number'
task :bump, :type do |_, args|
args.with_defaults(type: 'inc')
version_file = 'lib/snibbets/version.rb'
content = IO.read(version_file)
content.sub!(/VERSION = '(?<major>\d+)\.(?<minor>\d+)\.(?<inc>\d+)(?<pre>\S+)?'/) do
m = Regexp.last_match
major = m['major'].to_i
minor = m['minor'].to_i
inc = m['inc'].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.puts "At version #{major}.#{minor}.#{inc}#{pre}"
"VERSION = '#{major}.#{minor}.#{inc}#{pre}'"
end
File.open(version_file, 'w+') { |f| f.puts content }
end