public
Description: Generic interface to multiple Ruby template engines
Homepage: http://github.com/rtomayko/tilt
Clone URL: git://github.com/rtomayko/tilt.git
tilt / Rakefile
100644 100 lines (82 sloc) 2.824 kb
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
100
task :default => :spec
 
# SPECS =====================================================================
 
desc 'Generate test coverage report'
task :rcov do
  sh "rcov -Ilib:test test/*_test.rb"
end
 
desc 'Run specs with unit test style output'
task :test do |t|
  sh 'bacon -qa'
end
 
desc 'Run specs with story style output'
task :spec do |t|
  sh 'bacon -a'
end
 
# PACKAGING =================================================================
 
require 'rubygems/specification'
$spec ||= eval(File.read('tilt.gemspec'))
 
def package(ext='')
  "dist/tilt-#{$spec.version}" + ext
end
 
desc 'Build packages'
task :package => %w[.gem .tar.gz].map {|e| package(e)}
 
desc 'Build and install as local gem'
task :install => package('.gem') do
  sh "gem install #{package('.gem')}"
end
 
directory 'dist/'
 
file package('.gem') => %w[dist/ tilt.gemspec] + $spec.files do |f|
  sh "gem build tilt.gemspec"
  mv File.basename(f.name), f.name
end
 
file package('.tar.gz') => %w[dist/] + $spec.files do |f|
  sh "git archive --format=tar HEAD | gzip > #{f.name}"
end
 
desc 'Upload gem and tar.gz distributables to rubyforge'
task :release => [package('.gem'), package('.tar.gz')] do |t|
  sh <<-SH
rubyforge add_release sinatra tilt #{$spec.version} #{package('.gem')} &&
rubyforge add_file sinatra tilt #{$spec.version} #{package('.tar.gz')}
SH
end
 
# GEMSPEC ===================================================================
 
file 'tilt.gemspec' => FileList['{lib,test}/**','Rakefile'] do |f|
  # read version from tilt.rb
  version = File.read('lib/tilt.rb')[/VERSION = '(.*)'/] && $1
  # read spec file and split out manifest section
  spec = File.
    read(f.name).
    sub(/s\.version\s*=\s*'.*'/, "s.version = '#{version}'")
  parts = spec.split(" # = MANIFEST =\n")
  # determine file list from git ls-files
  files = `git ls-files`.
    split("\n").sort.reject{ |file| file =~ /^\./ }.
    map{ |file| " #{file}" }.join("\n")
  # piece file back together and write...
  parts[1] = " s.files = %w[\n#{files}\n ]\n"
  spec = parts.join(" # = MANIFEST =\n")
  spec.sub!(/s.date = '.*'/, "s.date = '#{Time.now.strftime("%Y-%m-%d")}'")
  File.open(f.name, 'w') { |io| io.write(spec) }
  puts "updated #{f.name}"
end
 
# DOC =======================================================================
 
# requires the hanna gem:
# gem install mislav-hanna --source=http://gems.github.com
desc 'Build API documentation (doc/api)'
task 'rdoc' => 'rdoc/index.html'
file 'rdoc/index.html' => FileList['lib/**/*.rb'] do |f|
  rm_rf 'rdoc'
  sh((<<-SH).gsub(/[\s\n]+/, ' ').strip)
hanna
--op doc/api
--promiscuous
--charset utf8
--fmt html
--inline-source
--line-numbers
--accessor option_accessor=RW
--main Tilt
--title 'Tilt API Documentation'
#{f.prerequisites.join(' ')}
SH
end