-
Notifications
You must be signed in to change notification settings - Fork 9
/
Rakefile
51 lines (41 loc) · 1.22 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
require 'rake/clean'
require 'fileutils'
# PACKAGING ============================================================
def source_version
line = File.read('lib/sinatra/captcha.rb')[/^\s*VERSION = .*/]
line.match(/.*VERSION = '(.*)'/)[1]
end
# Load the gemspec using the same limitations as github
def spec
@spec ||=
begin
require 'rubygems/specification'
data = File.read('sinatra-captcha.gemspec')
spec = nil
Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
spec
end
end
def package(ext='')
"pkg/sinatra-captcha-#{spec.version}" + ext
end
desc 'Build packages'
task :package => %w[.gem].map {|e| package(e)}
desc 'Build and install as local gem'
task :install => package('.gem') do
sh "gem install #{package('.gem')}"
end
directory 'pkg/'
CLOBBER.include('pkg')
file package('.gem') => %w[pkg/ sinatra-captcha.gemspec] + spec.files do |f|
mkdir_p "pkg"
sh "gem build sinatra-captcha.gemspec"
mv File.basename(f.name), f.name
end
# Rubyforge Release / Publish Tasks ==================================
desc 'Publish gem to rubyforge'
task 'release' => [package('.gem')] do |t|
sh <<-end
rubyforge add_release sinatra sinatra-captcha #{spec.version} #{package('.gem')}
end
end