Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 97 lines (80 sloc) 2.838 kb
15c7d3f @rtomayko use Rake's test runner
authored
1 require 'rake/testtask'
3cc6357 @rtomayko port unit tests to Test::Unit + contest
authored
2 task :default => :test
137cd54 @rtomayko Tilt!
authored
3
4 # SPECS =====================================================================
5
6 desc 'Generate test coverage report'
7 task :rcov do
8 sh "rcov -Ilib:test test/*_test.rb"
9 end
531c141 @rtomayko add Tilt::VERSION and update gemspec
authored
10
15c7d3f @rtomayko use Rake's test runner
authored
11 desc 'Run tests (default)'
12 Rake::TestTask.new(:test) do |t|
13 t.test_files = FileList['test/*_test.rb']
14 t.ruby_opts = ['-rubygems'] if defined? Gem
137cd54 @rtomayko Tilt!
authored
15 end
16
17 # PACKAGING =================================================================
18
531c141 @rtomayko add Tilt::VERSION and update gemspec
authored
19 require 'rubygems/specification'
20 $spec ||= eval(File.read('tilt.gemspec'))
137cd54 @rtomayko Tilt!
authored
21
22 def package(ext='')
23 "dist/tilt-#{$spec.version}" + ext
24 end
25
26 desc 'Build packages'
27 task :package => %w[.gem .tar.gz].map {|e| package(e)}
28
29 desc 'Build and install as local gem'
30 task :install => package('.gem') do
31 sh "gem install #{package('.gem')}"
32 end
33
34 directory 'dist/'
35
36 file package('.gem') => %w[dist/ tilt.gemspec] + $spec.files do |f|
37 sh "gem build tilt.gemspec"
38 mv File.basename(f.name), f.name
39 end
40
41 file package('.tar.gz') => %w[dist/] + $spec.files do |f|
42 sh "git archive --format=tar HEAD | gzip > #{f.name}"
43 end
44
45 desc 'Upload gem and tar.gz distributables to rubyforge'
46 task :release => [package('.gem'), package('.tar.gz')] do |t|
47 sh <<-SH
1009d16 @rtomayko tilt gems are published under the sinatra project
authored
48 rubyforge add_release sinatra tilt #{$spec.version} #{package('.gem')} &&
49 rubyforge add_file sinatra tilt #{$spec.version} #{package('.tar.gz')}
137cd54 @rtomayko Tilt!
authored
50 SH
51 end
52
53 # GEMSPEC ===================================================================
54
55 file 'tilt.gemspec' => FileList['{lib,test}/**','Rakefile'] do |f|
531c141 @rtomayko add Tilt::VERSION and update gemspec
authored
56 # read version from tilt.rb
57 version = File.read('lib/tilt.rb')[/VERSION = '(.*)'/] && $1
137cd54 @rtomayko Tilt!
authored
58 # read spec file and split out manifest section
531c141 @rtomayko add Tilt::VERSION and update gemspec
authored
59 spec = File.
60 read(f.name).
61 sub(/s\.version\s*=\s*'.*'/, "s.version = '#{version}'")
137cd54 @rtomayko Tilt!
authored
62 parts = spec.split(" # = MANIFEST =\n")
63 # determine file list from git ls-files
64 files = `git ls-files`.
65 split("\n").sort.reject{ |file| file =~ /^\./ }.
66 map{ |file| " #{file}" }.join("\n")
67 # piece file back together and write...
68 parts[1] = " s.files = %w[\n#{files}\n ]\n"
69 spec = parts.join(" # = MANIFEST =\n")
70 spec.sub!(/s.date = '.*'/, "s.date = '#{Time.now.strftime("%Y-%m-%d")}'")
71 File.open(f.name, 'w') { |io| io.write(spec) }
72 puts "updated #{f.name}"
73 end
74
75 # DOC =======================================================================
76
77 # requires the hanna gem:
78 # gem install mislav-hanna --source=http://gems.github.com
79 desc 'Build API documentation (doc/api)'
80 task 'rdoc' => 'rdoc/index.html'
81 file 'rdoc/index.html' => FileList['lib/**/*.rb'] do |f|
82 rm_rf 'rdoc'
83 sh((<<-SH).gsub(/[\s\n]+/, ' ').strip)
84 hanna
85 --op doc/api
86 --promiscuous
87 --charset utf8
88 --fmt html
89 --inline-source
90 --line-numbers
91 --accessor option_accessor=RW
92 --main Tilt
93 --title 'Tilt API Documentation'
94 #{f.prerequisites.join(' ')}
95 SH
96 end
Something went wrong with that request. Please try again.