Skip to content

HTTPS clone URL

Subversion checkout URL

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