Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 169 lines (139 sloc) 4.773 kB
d8a0242 @karmi rake task for generating rubyforge website; assets (logo, CSS)
karmi authored
1 require 'rubygems'
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
2 require 'rake/clean'
d8a0242 @karmi rake task for generating rubyforge website; assets (logo, CSS)
karmi authored
3 require 'fileutils'
5aa20ae Rakefile
Blake Mizerany authored
4
5 task :default => :test
6
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
7 # SPECS ===============================================================
8
9 desc 'Run specs with story style output'
10 task :spec do
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
11 pattern = ENV['TEST'] || '.*'
12 sh "specrb --testcase '#{pattern}' --specdox -Ilib:test test/*_test.rb"
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
13 end
14
15 desc 'Run specs with unit test style output'
a734cf3 @rtomayko I knew I shoulda taken that left turn at Hoboken
rtomayko authored
16 task :test do |t|
17 sh "specrb -Ilib:test test/*_test.rb"
18 end
19
20 desc 'Run compatibility specs'
21 task :compat do |t|
22 pattern = ENV['TEST'] || '.*'
23 sh "specrb --testcase '#{pattern}' -Ilib:test compat/*_test.rb"
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
24 end
25
26 # PACKAGING ============================================================
27
0663451 @rtomayko read gemspec in simulated github environment
rtomayko authored
28 # Load the gemspec using the same limitations as github
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
29 def spec
30 @spec ||=
0663451 @rtomayko read gemspec in simulated github environment
rtomayko authored
31 begin
32 require 'rubygems/specification'
33 data = File.read('sinatra.gemspec')
34 spec = nil
35 Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
36 spec
37 end
e31941d @rtomayko add .gemspec; remove echoe
rtomayko authored
38 end
39
40 def package(ext='')
41 "dist/sinatra-#{spec.version}" + ext
42 end
43
44 desc 'Build packages'
45 task :package => %w[.gem .tar.gz].map {|e| package(e)}
46
47 desc 'Build and install as local gem'
48 task :install => package('.gem') do
49 sh "gem install #{package('.gem')}"
50 end
51
52 directory 'dist/'
53
54 file package('.gem') => %w[dist/ sinatra.gemspec] + spec.files do |f|
55 sh "gem build sinatra.gemspec"
56 mv File.basename(f.name), f.name
57 end
58
59 file package('.tar.gz') => %w[dist/] + spec.files do |f|
60 sh "git archive --format=tar HEAD | gzip > #{f.name}"
ca9ac7b Sinatra 0.2.0 released
Blake Mizerany authored
61 end
0e367a5 @rtomayko rake task for generating rdoc with hanna template
rtomayko authored
62
ff85aaf @rtomayko rake tasks for publishing API and gems to rubyforge
rtomayko authored
63 # Rubyforge Release / Publish Tasks ==================================
64
fe1ed27 @sr rake tasks to build a simple website
sr authored
65 desc 'Publish website to rubyforge'
ff85aaf @rtomayko rake tasks for publishing API and gems to rubyforge
rtomayko authored
66 task 'publish:doc' => 'doc/api/index.html' do
67 sh 'scp -rp doc/* rubyforge.org:/var/www/gforge-projects/sinatra/'
68 end
69
70 task 'publish:gem' => [package('.gem'), package('.tar.gz')] do |t|
71 sh <<-end
72 rubyforge add_release sinatra sinatra #{spec.version} #{package('.gem')} &&
73 rubyforge add_file sinatra sinatra #{spec.version} #{package('.tar.gz')}
74 end
75 end
76
fe1ed27 @sr rake tasks to build a simple website
sr authored
77 # Website ============================================================
69293f6 @rtomayko doc/website cleanup
rtomayko authored
78 # Building docs requires HAML and the hanna gem:
79 # gem install mislav-hanna --source=http://gems.github.com
80
81 task 'doc' => ['doc:api','doc:site']
82
83 desc 'Generate Hanna RDoc under doc/api'
84 task 'doc:api' => ['doc/api/index.html']
85
86 file 'doc/api/index.html' => FileList['lib/**/*.rb','README.rdoc'] do |f|
87 rb_files = f.prerequisites
88 sh((<<-end).gsub(/\s+/, ' '))
89 hanna --charset utf8 \
90 --fmt html \
91 --inline-source \
92 --line-numbers \
93 --main README.rdoc \
94 --op doc/api \
95 --title 'Sinatra API Documentation' \
96 #{rb_files.join(' ')}
97 end
98 end
99 CLEAN.include 'doc/api'
100
fe1ed27 @sr rake tasks to build a simple website
sr authored
101 def rdoc_to_html(file_name)
102 require 'rdoc/markup/to_html'
103 rdoc = RDoc::Markup::ToHtml.new
104 rdoc.convert(File.read(file_name))
105 end
106
107 def haml(locals={})
108 require 'haml'
109 template = File.read('doc/template.haml')
110 haml = Haml::Engine.new(template, :format => :html4, :attr_wrapper => '"')
111 haml.render(Object.new, locals)
112 end
113
69293f6 @rtomayko doc/website cleanup
rtomayko authored
114 desc 'Build website HTML and stuff'
115 task 'doc:site' => ['doc/index.html', 'doc/book.html']
fe1ed27 @sr rake tasks to build a simple website
sr authored
116
69293f6 @rtomayko doc/website cleanup
rtomayko authored
117 file 'doc/index.html' => %w[README.rdoc doc/template.haml] do |file|
fe1ed27 @sr rake tasks to build a simple website
sr authored
118 File.open(file.name, 'w') do |file|
119 file << haml(:title => 'Sinatra', :content => rdoc_to_html('README.rdoc'))
120 end
121 end
69293f6 @rtomayko doc/website cleanup
rtomayko authored
122 CLEAN.include 'doc/index.html'
fe1ed27 @sr rake tasks to build a simple website
sr authored
123
69293f6 @rtomayko doc/website cleanup
rtomayko authored
124 file 'doc/book.html' => ['book/output/sinatra-book.html'] do |file|
fe1ed27 @sr rake tasks to build a simple website
sr authored
125 File.open(file.name, 'w') do |file|
69293f6 @rtomayko doc/website cleanup
rtomayko authored
126 book_content = File.read('book/output/sinatra-book.html')
fe1ed27 @sr rake tasks to build a simple website
sr authored
127 file << haml(:title => 'Sinatra Book', :content => book_content)
128 end
129 end
69293f6 @rtomayko doc/website cleanup
rtomayko authored
130 CLEAN.include 'doc/book.html'
fe1ed27 @sr rake tasks to build a simple website
sr authored
131
69293f6 @rtomayko doc/website cleanup
rtomayko authored
132 file 'book/output/sinatra-book.html' => FileList['book/**'] do |f|
133 unless File.directory?('book')
134 sh 'git clone git://github.com/cschneid/sinatra-book.git book'
fe1ed27 @sr rake tasks to build a simple website
sr authored
135 end
69293f6 @rtomayko doc/website cleanup
rtomayko authored
136 sh((<<-SH).strip.gsub(/\s+/, ' '))
137 cd book &&
138 git fetch origin &&
139 git rebase origin/master &&
140 thor book:build
141 SH
fe1ed27 @sr rake tasks to build a simple website
sr authored
142 end
69293f6 @rtomayko doc/website cleanup
rtomayko authored
143 CLEAN.include 'book/output/sinatra-book.html'
144
145 desc 'Build the Sinatra book'
146 task 'doc:book' => ['book/output/sinatra-book.html']
fe1ed27 @sr rake tasks to build a simple website
sr authored
147
8c412cf @rtomayko rake task for updating sinatra.gemspec files manifest
rtomayko authored
148 # Gemspec Helpers ====================================================
149
150 file 'sinatra.gemspec' => FileList['{lib,test,images}/**','Rakefile'] do |f|
151 # read spec file and split out manifest section
152 spec = File.read(f.name)
153 parts = spec.split(" # = MANIFEST =\n")
154 fail 'bad spec' if parts.length != 3
155 # determine file list from git ls-files
156 files = `git ls-files`.
157 split("\n").
158 sort.
159 reject{ |file| file =~ /^\./ }.
fe1ed27 @sr rake tasks to build a simple website
sr authored
160 reject { |file| file =~ /^doc/ }.
8c412cf @rtomayko rake task for updating sinatra.gemspec files manifest
rtomayko authored
161 map{ |file| " #{file}" }.
162 join("\n")
163 # piece file back together and write...
164 parts[1] = " s.files = %w[\n#{files}\n ]\n"
165 spec = parts.join(" # = MANIFEST =\n")
166 File.open(f.name, 'w') { |io| io.write(spec) }
167 puts "updated #{f.name}"
168 end
Something went wrong with that request. Please try again.