forked from ttscoff/searchlink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
99 lines (85 loc) · 2.52 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
require 'rake/clean'
require 'rubygems'
require 'rubygems/package_task'
require 'rdoc'
require 'rdoc/task'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'yard'
require 'tty-spinner'
task default: %i[test yard]
desc 'Run test suite'
# task test: %i[rubocop spec]
task test: %i[spec]
spec = eval(File.read('searchlink.gemspec'))
Gem::PackageTask.new(spec) do |pkg|
end
RSpec::Core::RakeTask.new
RuboCop::RakeTask.new do |t|
t.formatters = %w[progress]
end
YARD::Rake::YardocTask.new
# desc 'Update Services'
# task :update_services do
# new_contents = IO.read('searchlink.rb')
# services = ['SearchLink', 'SearchLink File']
# services.each do |file|
# wflow = "/Users/ttscoff/Library/Services/#{file}.workflow/Contents/document.wflow"
# $stderr.puts "Updating #{wflow}"
# contents = IO.read(wflow)
# contents.sub!(%r{(<key>COMMAND_STRING</key>.*?<string>).*?(\n</string>)}m, "\\1#{new_contents.strip}\\2")
# puts contents
# File.open(wflow, 'w') do |f|
# f.puts contents
# end
# end
# $stderr.puts "Services updated: #{services.join(", ")}"
# 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/searchlink/version.rb`
version = res.match(/VERSION *= *['"](\d+\.\d+\.\d+(\w+)?)/)[1]
puts "git tag: #{gver}"
puts "version.rb: #{version}"
puts "changelog: #{cver}"
end
desc 'Get Script Version'
task :sver do
res = `grep VERSION lib/searchlink/version.rb`
version = res.match(/VERSION *= *['"](\d+\.\d+\.\d+(\w+)?)/)[1]
print version
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/searchlink/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
task default: %i[ver]