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