forked from mojombo/god
/
Rakefile
77 lines (67 loc) · 1.93 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
require 'rubygems'
require 'rake'
require 'date'
def source_version
line = File.read('lib/god.rb')[/^\s*VERSION = .*/]
line.match(/.*VERSION = '(.*)'/)[1]
end
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/**/test_*.rb'
test.verbose = true
end
task :default => :test
desc "Open an irb session preloaded with this library"
task :console do
sh "irb -rubygems -r ./lib/god.rb"
end
desc "Upload site to Rubyforge"
task :site do
sh "scp -r site/* mojombo@god.rubyforge.org:/var/www/gforge-projects/god"
end
desc "Upload site to Rubyforge"
task :site_edge do
sh "scp -r site/* mojombo@god.rubyforge.org:/var/www/gforge-projects/god/edge"
end
desc "Run rcov"
task :coverage do
`rm -fr coverage`
`rcov test/test_*.rb`
`open coverage/index.html`
end
require 'rake/rdoctask'
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "god #{source_version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
if defined?(Gem)
task 'build' do
sh 'mkdir -p pkg'
sh 'gem build god.gemspec'
sh 'mv *.gem pkg'
end
task 'god.gemspec' do |f|
# read spec file and split out manifest section
spec = File.read(f.name)
head, manifest, tail = spec.split(" # = MANIFEST =\n")
# replace version and date
head.sub!(/\.version = '.*'/, ".version = '#{source_version}'")
head.sub!(/\.date = '.*'/, ".date = '#{Date.today.to_s}'")
# determine file list from git ls-files
files = `git ls-files`.
split("\n").
sort.
reject { |file| file =~ /^\./ }.
reject { |file| file =~ /^(ideas|init|site)/ }.
map { |file| " #{file}" }.
join("\n")
# piece file back together and write...
manifest = " s.files = %w[\n#{files}\n ]\n"
spec = [head, manifest, tail].join(" # = MANIFEST =\n")
File.open(f.name, 'w') { |io| io.write(spec) }
puts "updated #{f.name}"
end
end