Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 98 lines (80 sloc) 2.696 kB
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
1 require 'rake/clean'
5aa20ae Rakefile
Blake Mizerany authored
2
3 task :default => :test
4
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
5 # SPECS ===============================================================
6
7 desc 'Run specs with story style output'
8 task :spec do
9 sh 'specrb --specdox -Ilib:test test/*_test.rb'
10 end
11
12 desc 'Run specs with unit test style output'
13 task :test => FileList['test/*_test.rb'] do |t|
14 suite = t.prerequisites.map{|f| "-r#{f.chomp('.rb')}"}.join(' ')
15 sh "ruby -Ilib:test #{suite} -e ''", :verbose => false
16 end
17
18 # PACKAGING ============================================================
19
0663451 @rtomayko read gemspec in simulated github environment
rtomayko authored
20 # Load the gemspec using the same limitations as github
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
21 def spec
22 @spec ||=
0663451 @rtomayko read gemspec in simulated github environment
rtomayko authored
23 begin
24 require 'rubygems/specification'
25 data = File.read('sinatra.gemspec')
26 spec = nil
27 Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
28 spec
29 end
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
30 end
31
32 def package(ext='')
33 "dist/sinatra-#{spec.version}" + ext
34 end
35
36 desc 'Build packages'
37 task :package => %w[.gem .tar.gz].map {|e| package(e)}
38
39 desc 'Build and install as local gem'
40 task :install => package('.gem') do
41 sh "gem install #{package('.gem')}"
42 end
43
44 directory 'dist/'
45
46 file package('.gem') => %w[dist/ sinatra.gemspec] + spec.files do |f|
47 sh "gem build sinatra.gemspec"
48 mv File.basename(f.name), f.name
49 end
50
51 file package('.tar.gz') => %w[dist/] + spec.files do |f|
52 sh "git archive --format=tar HEAD | gzip > #{f.name}"
ca9ac7b Sinatra 0.2.0 released
Blake Mizerany authored
53 end
0e367a5 @rtomayko rake task for generating rdoc with hanna template
rtomayko authored
54
8c412cf @rtomayko rake task for updating sinatra.gemspec files manifest
rtomayko authored
55 # Gemspec Helpers ====================================================
56
57 file 'sinatra.gemspec' => FileList['{lib,test,images}/**','Rakefile'] do |f|
58 # read spec file and split out manifest section
59 spec = File.read(f.name)
60 parts = spec.split(" # = MANIFEST =\n")
61 fail 'bad spec' if parts.length != 3
62 # determine file list from git ls-files
63 files = `git ls-files`.
64 split("\n").
65 sort.
66 reject{ |file| file =~ /^\./ }.
67 map{ |file| " #{file}" }.
68 join("\n")
69 # piece file back together and write...
70 parts[1] = " s.files = %w[\n#{files}\n ]\n"
71 spec = parts.join(" # = MANIFEST =\n")
72 File.open(f.name, 'w') { |io| io.write(spec) }
73 puts "updated #{f.name}"
74 end
75
0e367a5 @rtomayko rake task for generating rdoc with hanna template
rtomayko authored
76 # Hanna RDoc =========================================================
77 #
78 # Building docs requires the hanna gem:
79 # gem install mislav-hanna --source=http://gems.github.com
80
81 desc 'Generate Hanna RDoc under doc/api'
82 task :doc => ['doc/api/index.html']
83
84 file 'doc/api/index.html' => FileList['lib/**/*.rb','README.rdoc'] do |f|
85 rb_files = f.prerequisites
86 sh((<<-end).gsub(/\s+/, ' '))
87 hanna --charset utf8 \
88 --fmt html \
89 --inline-source \
90 --line-numbers \
91 --main README.rdoc \
92 --op doc/api \
93 --title 'Sinatra API Documentation' \
94 #{rb_files.join(' ')}
95 end
96 end
97 CLEAN.include 'doc/api'
Something went wrong with that request. Please try again.