Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 415 lines (350 sloc) 12.503 kb
addce2f Natalie Weizenbaum A saner way of separating the benchmark task.
nex3 authored
1 # ----- Benchmarking -----
2
c8f6765 Natalie Weizenbaum Clean up the Rakefile.
nex3 authored
3 desc <<END
3f0c221 Natalie Weizenbaum Replacing HAML with Haml.
nex3 authored
4 Benchmark haml against ERb.
c8f6765 Natalie Weizenbaum Clean up the Rakefile.
nex3 authored
5 TIMES=n sets the number of runs. Defaults to 1000.
addce2f Natalie Weizenbaum A saner way of separating the benchmark task.
nex3 authored
6 END
7 task :benchmark do
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
8 sh "ruby test/benchmark.rb #{ENV['TIMES']}"
485197a Natalie Weizenbaum Rake tasks no longer collide with each other.
nex3 authored
9 end
10
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
11 # ----- Default: Testing ------
ad712a6 Proudly presenting excellent test coverage for HAML.
hcatlin authored
12
74d8a56 Chris Eppstein Test haml & sass against multiple versions of rails.
chriseppstein authored
13 if ENV["RUN_CODE_RUN"] == "true"
14 task :default => :"test:rails_compatibility"
15 else
16 task :default => :test
17 end
addce2f Natalie Weizenbaum A saner way of separating the benchmark task.
nex3 authored
18
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
19 require 'rake/testtask'
35f7e17 Initial upload.
hcatlin authored
20
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
21 Rake::TestTask.new do |t|
22 t.libs << 'lib'
0f49933 Natalie Weizenbaum Make sure we don't run linked Rails tests.
nex3 authored
23 test_files = FileList['test/**/*_test.rb']
24 test_files.exclude('test/rails/*')
c83b358 Natalie Weizenbaum [Haml] Support loading of Rails plugins for testing.
nex3 authored
25 test_files.exclude('test/plugins/*')
97caaba Natalie Weizenbaum [Haml] Don't run tests in the haml-spec package.
nex3 authored
26 test_files.exclude('test/haml/spec/*')
0f49933 Natalie Weizenbaum Make sure we don't run linked Rails tests.
nex3 authored
27 t.test_files = test_files
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
28 t.verbose = true
29 end
30 Rake::Task[:test].send(:add_comment, <<END)
243f46d Natalie Weizenbaum Add a comment about using alternate Rails versions to the test task desc...
nex3 authored
31 To run with an alternate version of Rails, make test/rails a symlink to that version.
32 END
35f7e17 Initial upload.
hcatlin authored
33
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
34 # ----- Packaging -----
b88841e Natalie Weizenbaum Gemification for 1.5dev.
nex3 authored
35
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
36 require 'rake/gempackagetask'
37 load 'haml.gemspec'
c0a88ed Natalie Weizenbaum Make sure revision version information is preserved when installing Haml...
nex3 authored
38
39da4e4 Natalie Weizenbaum Build tarballs etc. when packaging for a release.
nex3 authored
39 Rake::GemPackageTask.new(HAML_GEMSPEC) do |pkg|
40 if Rake.application.top_level_tasks.include?('release')
41 pkg.need_tar_gz = true
42 pkg.need_tar_bz2 = true
43 pkg.need_zip = true
44 end
45 end
1a2040b Added a Rake task for benchmarking. Use with rake benchmark (TIMES=n)
packagethief authored
46
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
47 task :revision_file do
6fc675e Natalie Weizenbaum Don't load Haml in the Rakefile unless it's necessary.
nex3 authored
48 require 'lib/haml'
49
1a0b452 Natalie Weizenbaum Add a Rake task for packaging a special edge gem.
nex3 authored
50 release = Rake.application.top_level_tasks.include?('release') || File.exist?('EDGE_GEM_VERSION')
51 if Haml.version[:rev] && !release
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
52 File.open('REVISION', 'w') { |f| f.puts Haml.version[:rev] }
1a0b452 Natalie Weizenbaum Add a Rake task for packaging a special edge gem.
nex3 authored
53 elsif release
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
54 File.open('REVISION', 'w') { |f| f.puts "(release)" }
55 else
56 File.open('REVISION', 'w') { |f| f.puts "(unknown)" }
c0a88ed Natalie Weizenbaum Make sure revision version information is preserved when installing Haml...
nex3 authored
57 end
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
58 end
59 Rake::Task[:package].prerequisites.insert(0, :revision_file)
6248ca3 Natalie Weizenbaum Try to make sure submodules get checked out before packaging.
nex3 authored
60 Rake::Task[:package].prerequisites.insert(0, :submodules)
c0a88ed Natalie Weizenbaum Make sure revision version information is preserved when installing Haml...
nex3 authored
61
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
62 # We also need to get rid of this file after packaging.
e8142f3 Natalie Weizenbaum Since REVISION is always generated when running Rake, always get rid of ...
nex3 authored
63 at_exit { File.delete('REVISION') rescue nil }
c0a88ed Natalie Weizenbaum Make sure revision version information is preserved when installing Haml...
nex3 authored
64
59f5b54 Natalie Weizenbaum Make the install and release Rake tasks visible.
nex3 authored
65 desc "Install Haml as a gem."
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
66 task :install => [:package] do
67 sudo = RUBY_PLATFORM =~ /win32/ ? '' : 'sudo'
5e09c48 Stefan Penner Modify the Rakefile to support a jgem install.
stefanpenner authored
68 gem = RUBY_PLATFORM =~ /java/ ? 'jgem' : 'gem'
69 sh %{#{sudo} #{gem} install --no-ri pkg/haml-#{File.read('VERSION').strip}}
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
70 end
5c09bf1 Natalie Weizenbaum Added an install task to the Rakefiles in trunk and stable.
nex3 authored
71
3bcee42 Natalie Weizenbaum Add a Rake task for releasing haml- and sass-mode to ELPA.
nex3 authored
72 desc "Release a new Haml package to Rubyforge."
73 task :release => [:check_release, :release_elpa, :package] do
7518015 Natalie Weizenbaum Add a VERSION_NAME file.
nex3 authored
74 name = File.read("VERSION_NAME").strip
75 version = File.read("VERSION").strip
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
76 sh %{rubyforge add_release haml haml "#{name} (v#{version})" pkg/haml-#{version}.gem}
77 sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.gz}
78 sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.bz2}
79 sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.zip}
d8a7bd4 Natalie Weizenbaum Add a Gemcutter push to the release process.
nex3 authored
80 sh %{gem push pkg/haml-#{version}.gem}
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
81 end
7a1ebe0 Natalie Weizenbaum Added a "release" rake task.
nex3 authored
82
3bcee42 Natalie Weizenbaum Add a Rake task for releasing haml- and sass-mode to ELPA.
nex3 authored
83 # Releases haml-mode.el and sass-mode.el to ELPA.
84 task :release_elpa do
85 require 'tlsmail'
86 require 'time'
87
88 version = File.read("VERSION").strip
89
90 haml_unchanged = mode_unchanged?(:haml, version)
91 sass_unchanged = mode_unchanged?(:sass, version)
92 next if haml_unchanged && sass_unchanged
93 raise "haml-mode.el and sass-mode.el are out of sync." if haml_unchanged ^ sass_unchanged
94
941210a Natalie Weizenbaum Fix a typo.
nex3 authored
95 if sass_unchanged && File.read("extra/sass-mode.el").
96 include?(";; Package-Requires: ((haml-mode #{sass_unchanged.inspect}))")
93f99f0 Natalie Weizenbaum Raise an error when releasing to ELPA if the Sass requirement of Haml is...
nex3 authored
97 raise "sass-mode.el doesn't require the same version of haml-mode."
98 end
99
3bcee42 Natalie Weizenbaum Add a Rake task for releasing haml- and sass-mode to ELPA.
nex3 authored
100 rev = File.read('.git/HEAD').strip
101 if rev =~ /^ref: (.*)$/
102 rev = File.read(".git/#{$1}").strip
103 end
104
9d268e5 Natalie Weizenbaum Strip the from email in the ELPA task.
nex3 authored
105 from = `git config user.email`.strip
dcc399f Natalie Weizenbaum Make the from email for releasing to ELPA a little more configurable.
nex3 authored
106 raise "Don't know how to send emails except via Gmail" unless from =~ /@gmail.com$/
107
3bcee42 Natalie Weizenbaum Add a Rake task for releasing haml- and sass-mode to ELPA.
nex3 authored
108 to = "elpa@tromey.com"
109 Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
110 Net::SMTP.start('smtp.gmail.com', 587, 'gmail.com', from, read_password("GMail Password"), :login) do |smtp|
111 smtp.send_message(<<CONTENT, from, to)
112 From: Nathan Weizenbaum <#{from}>
113 To: #{to}
114 Subject: Submitting haml-mode and sass-mode #{version}
115 Date: #{Time.now.rfc2822}
116
117 haml-mode and sass-mode #{version} are packaged and ready to be included in ELPA.
118 They can be downloaded from:
119
120 http://github.com/nex3/haml/raw/#{rev}/extra/haml-mode.el
121 http://github.com/nex3/haml/raw/#{rev}/extra/sass-mode.el
122 CONTENT
123 end
124 end
125
126 # Ensures that the version have been updated for a new release.
127 task :check_release do
128 version = File.read("VERSION").strip
129 raise "There have been changes since current version (#{version})" if changed_since?(version)
130 raise "VERSION_NAME must not be 'Bleeding Edge'" if File.read("VERSION_NAME") == "Bleeding Edge"
131 end
132
133 # Reads a password from the command line.
134 #
135 # @param name [String] The prompt to use to read the password
136 def read_password(prompt)
137 require 'readline'
138 system "stty -echo"
139 Readline.readline("#{prompt}: ").strip
140 ensure
141 system "stty echo"
142 puts
143 end
144
145 # Returns whether or not the repository, or specific files,
146 # has/have changed since a given revision.
147 #
148 # @param rev [String] The revision to check against
149 # @param files [Array<String>] The files to check.
150 # If this is empty, checks the entire repository
151 def changed_since?(rev, *files)
152 IO.popen("git diff --exit-code #{rev} #{files.join(' ')}") {}
153 return !$?.success?
154 end
155
156 # Returns whether or not the given Emacs mode file (haml or sass)
157 # has changed since the given version.
158 #
159 # @param mode [String, Symbol] The name of the mode
160 # @param version [String] The version number
93f99f0 Natalie Weizenbaum Raise an error when releasing to ELPA if the Sass requirement of Haml is...
nex3 authored
161 # @return [String, nil] The version number if the version has changed
3bcee42 Natalie Weizenbaum Add a Rake task for releasing haml- and sass-mode to ELPA.
nex3 authored
162 def mode_unchanged?(mode, version)
163 mode_version = File.read("extra/#{mode}-mode.el").scan(/^;; Version: (.*)$/).first.first
164 return false if mode_version == version
93f99f0 Natalie Weizenbaum Raise an error when releasing to ELPA if the Sass requirement of Haml is...
nex3 authored
165 return mode_version unless changed_since?(mode_version, "extra/#{mode}-mode.el")
f858cce Natalie Weizenbaum Fix the ELPA-release code in the Rakefile.
nex3 authored
166 raise "#{mode}-mode.el version is #{version.inspect}, but it has changed as of #{version.inspect}"
3bcee42 Natalie Weizenbaum Add a Rake task for releasing haml- and sass-mode to ELPA.
nex3 authored
167 return false
168 end
169
6248ca3 Natalie Weizenbaum Try to make sure submodules get checked out before packaging.
nex3 authored
170 task :submodules do
171 if File.exist?(File.dirname(__FILE__) + "/.git")
172 sh %{git submodule sync}
173 sh %{git submodule update --init}
174 elsif !File.exist?(File.dirname(__FILE__) + "/vendor/fssm/lib")
175 warn <<WARN
176 WARNING: vendor/fssm doesn't exist, and this isn't a git repository so
177 I can't get it automatically!
178 WARN
179 end
180 end
181
1a0b452 Natalie Weizenbaum Add a Rake task for packaging a special edge gem.
nex3 authored
182 task :release_edge do
2432d0c Natalie Weizenbaum Make sure we clean up the git repo after every relevant rake task.
nex3 authored
183 ensure_git_cleanup do
184 puts "#{'=' * 50} Running rake release_edge"
8b1ae1f Natalie Weizenbaum Trace all invoked rake tasks.
nex3 authored
185
2432d0c Natalie Weizenbaum Make sure we clean up the git repo after every relevant rake task.
nex3 authored
186 sh %{git checkout edge-gem}
187 sh %{git reset --hard origin/edge-gem}
188 sh %{git merge origin/master}
1a0b452 Natalie Weizenbaum Add a Rake task for packaging a special edge gem.
nex3 authored
189
2432d0c Natalie Weizenbaum Make sure we clean up the git repo after every relevant rake task.
nex3 authored
190 # Get the current master branch version
191 version = File.read('VERSION').strip.split('.').map {|n| n.to_i}
192 unless version[1] % 2 == 1 && version[2] == 0
193 raise "#{version.join('.')} is not a development version"
194 end
1a0b452 Natalie Weizenbaum Add a Rake task for packaging a special edge gem.
nex3 authored
195
2432d0c Natalie Weizenbaum Make sure we clean up the git repo after every relevant rake task.
nex3 authored
196 # Bump the edge gem version
197 edge_version = File.read('EDGE_GEM_VERSION').strip.split('.').map {|n| n.to_i}
198 if edge_version[0..1] != version[0..1]
199 # A new master branch version was released, reset the edge gem version
200 edge_version[0..1] = version[0..1]
201 edge_version[2] = 0
202 else
203 # Just bump the teeny version
204 edge_version[2] += 1
205 end
206 edge_version = edge_version.join('.')
207 File.open('EDGE_GEM_VERSION', 'w') {|f| f.puts(edge_version)}
208 sh %{git commit -m "Bump edge gem version to #{edge_version}." EDGE_GEM_VERSION}
209 sh %{git push origin edge-gem}
210
211 # Package the edge gem with the proper version
212 File.open('VERSION', 'w') {|f| f.puts(edge_version)}
213 sh %{rake package}
214 sh %{git checkout VERSION}
215
216 sh %{rubyforge add_release haml haml-edge "Bleeding Edge (v#{edge_version})" pkg/haml-edge-#{edge_version}.gem}
b60e905 Natalie Weizenbaum Push the haml-edge gem to Gemcutter.
nex3 authored
217 sh %{gem push pkg/haml-edge-#{edge_version}.gem}
1a0b452 Natalie Weizenbaum Add a Rake task for packaging a special edge gem.
nex3 authored
218 end
219 end
220
00c3f79 Natalie Weizenbaum Make the watcher update the Haml and Sass pages when the respective bran...
nex3 authored
221 task :watch_for_update do
222 sh %{ruby extra/update_watch.rb}
398bbe0 Natalie Weizenbaum Add a Rake task and Sinatra script for a GitHub post-receive hook.
nex3 authored
223 end
224
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
225 # ----- Documentation -----
89a10b9 Creating the next set of branches.
hcatlin authored
226
4261c22 Natalie Weizenbaum Add a YARD Rake task.
nex3 authored
227 task :rdoc do
228 puts '=' * 100, <<END, '=' * 100
229 Haml uses the YARD documentation system (http://github.com/lsegal/yard).
230 Install the yard gem and then run "rake doc".
231 END
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
232 end
addce2f Natalie Weizenbaum A saner way of separating the benchmark task.
nex3 authored
233
4261c22 Natalie Weizenbaum Add a YARD Rake task.
nex3 authored
234 begin
8da2c37 Natalie Weizenbaum Require the YARD gem now that it supports what we need.
nex3 authored
235 require 'yard'
4261c22 Natalie Weizenbaum Add a YARD Rake task.
nex3 authored
236
6d887f7 Natalie Weizenbaum Update the custom YARD CSS to use the proper YARD methodology.
nex3 authored
237 namespace :yard do
238 task :sass do
239 require File.dirname(__FILE__) + '/lib/sass'
240 Dir[File.dirname(__FILE__) + "/yard/default/**/*.sass"].each do |sass|
241 File.open(sass.gsub(/sass$/, 'css'), 'w') do |f|
242 f.write(Sass::Engine.new(File.read(sass)).render)
243 end
244 end
245 end
246 end
247
4261c22 Natalie Weizenbaum Add a YARD Rake task.
nex3 authored
248 YARD::Rake::YardocTask.new do |t|
6f96aeb Natalie Weizenbaum Don't include non-Ruby files in the standard YARD docs.
nex3 authored
249 t.files = FileList.new('lib/**/*.rb') do |list|
250 list.exclude('lib/haml/template/*.rb')
251 list.exclude('lib/haml/helpers/action_view_mods.rb')
252 end.to_a
14c4a88 Natalie Weizenbaum Upgrade to YARD 0.5.3.
nex3 authored
253 t.options << '--incremental' if Rake.application.top_level_tasks.include?('redoc')
50ca366 Natalie Weizenbaum [Sass] Convert Sass::Environment docs to YARD.
nex3 authored
254 t.options += FileList.new('yard/*.rb').to_a.map {|f| ['-e', f]}.flatten
dc84334 Natalie Weizenbaum Order docfiles by filename size.
nex3 authored
255 files = FileList.new('doc-src/*').to_a.sort_by {|s| s.size} + %w[MIT-LICENSE VERSION]
691272b Natalie Weizenbaum Add a doc-src directory for documentation files.
nex3 authored
256 t.options << '--files' << files.join(',')
6d887f7 Natalie Weizenbaum Update the custom YARD CSS to use the proper YARD methodology.
nex3 authored
257 t.options << '--template-path' << File.dirname(__FILE__) + '/yard'
4261c22 Natalie Weizenbaum Add a YARD Rake task.
nex3 authored
258 end
6d887f7 Natalie Weizenbaum Update the custom YARD CSS to use the proper YARD methodology.
nex3 authored
259 Rake::Task['yard'].prerequisites.insert(0, 'yard:sass')
cb04561 Natalie Weizenbaum Update to the latest YARD.
nex3 authored
260 Rake::Task['yard'].instance_variable_set('@comment', nil)
4261c22 Natalie Weizenbaum Add a YARD Rake task.
nex3 authored
261
b4d9aff Natalie Weizenbaum Show the doc task with rake -T.
nex3 authored
262 desc "Generate Documentation"
cb04561 Natalie Weizenbaum Update to the latest YARD.
nex3 authored
263 task :doc => :yard
264 task :redoc => :yard
4261c22 Natalie Weizenbaum Add a YARD Rake task.
nex3 authored
265 rescue LoadError
b4d9aff Natalie Weizenbaum Show the doc task with rake -T.
nex3 authored
266 desc "Generate Documentation"
4261c22 Natalie Weizenbaum Add a YARD Rake task.
nex3 authored
267 task :doc => :rdoc
d600d96 Natalie Weizenbaum Rename yardoc -> yard in an obscure bit of Rakefile.
nex3 authored
268 task :yard => :rdoc
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
269 end
89a10b9 Creating the next set of branches.
hcatlin authored
270
00c3f79 Natalie Weizenbaum Make the watcher update the Haml and Sass pages when the respective bran...
nex3 authored
271 task :pages do
2432d0c Natalie Weizenbaum Make sure we clean up the git repo after every relevant rake task.
nex3 authored
272 ensure_git_cleanup do
273 puts "#{'=' * 50} Running rake pages PROJ=#{ENV["PROJ"].inspect}"
274 raise 'No ENV["PROJ"]!' unless proj = ENV["PROJ"]
275 sh %{git checkout #{proj}-pages}
276 sh %{git reset --hard origin/#{proj}-pages}
277
0123551 Natalie Weizenbaum Make sure we get out of the pages directory after updating.
nex3 authored
278 Dir.chdir("/var/www/#{proj}-pages") do
279 sh %{git fetch origin}
b18a9ac Natalie Weizenbaum Make sure the stable branch of the pages repo is up-to-date.
nex3 authored
280
0123551 Natalie Weizenbaum Make sure we get out of the pages directory after updating.
nex3 authored
281 sh %{git checkout stable}
282 sh %{git reset --hard origin/stable}
b18a9ac Natalie Weizenbaum Make sure the stable branch of the pages repo is up-to-date.
nex3 authored
283
0123551 Natalie Weizenbaum Make sure we get out of the pages directory after updating.
nex3 authored
284 sh %{git checkout #{proj}-pages}
285 sh %{git reset --hard origin/#{proj}-pages}
286 sh %{rake build --trace}
287 sh %{mkdir -p tmp}
288 sh %{touch tmp/restart.txt}
289 end
2432d0c Natalie Weizenbaum Make sure we clean up the git repo after every relevant rake task.
nex3 authored
290 end
00c3f79 Natalie Weizenbaum Make the watcher update the Haml and Sass pages when the respective bran...
nex3 authored
291 end
292
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
293 # ----- Coverage -----
294
c8f6765 Natalie Weizenbaum Clean up the Rakefile.
nex3 authored
295 begin
296 require 'rcov/rcovtask'
297
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
298 Rcov::RcovTask.new do |t|
299 t.test_files = FileList['test/**/*_test.rb']
300 t.rcov_opts << '-x' << '"^\/"'
301 if ENV['NON_NATIVE']
302 t.rcov_opts << "--no-rcovrt"
47616c9 Natalie Weizenbaum Adding support for alternate doctypes (see REFERENCE). Also added a NON_...
nex3 authored
303 end
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
304 t.verbose = true
89a10b9 Creating the next set of branches.
hcatlin authored
305 end
c8f6765 Natalie Weizenbaum Clean up the Rakefile.
nex3 authored
306 rescue LoadError; end
89a10b9 Creating the next set of branches.
hcatlin authored
307
500be8e Natalie Weizenbaum Make benchmark.rb more standalone.
nex3 authored
308 # ----- Profiling -----
89a10b9 Creating the next set of branches.
hcatlin authored
309
b9d4015 Natalie Weizenbaum Cleaning up the profile Rake task.
nex3 authored
310 begin
311 require 'ruby-prof'
312
313 desc <<END
c8f6765 Natalie Weizenbaum Clean up the Rakefile.
nex3 authored
314 Run a profile of haml.
b9d4015 Natalie Weizenbaum Cleaning up the profile Rake task.
nex3 authored
315 ENGINE=str sets the engine to be profiled. Defaults to Haml.
316 TIMES=n sets the number of runs. Defaults to 1000.
317 FILE=str sets the file to profile.
318 Defaults to 'standard' for Haml and 'complex' for Sass.
319 OUTPUT=str sets the ruby-prof output format.
320 Can be Flat, CallInfo, or Graph. Defaults to Flat. Defaults to Flat.
c8f6765 Natalie Weizenbaum Clean up the Rakefile.
nex3 authored
321 END
b9d4015 Natalie Weizenbaum Cleaning up the profile Rake task.
nex3 authored
322 task :profile do
323 engine = (ENV['ENGINE'] || 'haml').downcase
324 times = (ENV['TIMES'] || '1000').to_i
325 file = ENV['FILE']
326
327 if engine == 'sass'
328 require 'lib/sass'
329
330 file = File.read("#{File.dirname(__FILE__)}/test/sass/templates/#{file || 'complex'}.sass")
331 result = RubyProf.profile { times.times { Sass::Engine.new(file).render } }
332 else
333 require 'lib/haml'
334
335 file = File.read("#{File.dirname(__FILE__)}/test/haml/templates/#{file || 'standard'}.haml")
336 obj = Object.new
337 Haml::Engine.new(file).def_method(obj, :render)
338 result = RubyProf.profile { times.times { obj.render } }
339 end
addce2f Natalie Weizenbaum A saner way of separating the benchmark task.
nex3 authored
340
b9d4015 Natalie Weizenbaum Cleaning up the profile Rake task.
nex3 authored
341 RubyProf.const_get("#{(ENV['OUTPUT'] || 'Flat').capitalize}Printer").new(result).print
342 end
343 rescue LoadError; end
74d8a56 Chris Eppstein Test haml & sass against multiple versions of rails.
chriseppstein authored
344
345 # ----- Testing Multiple Rails Versions -----
346
347 rails_versions = [
5bd2d43 Natalie Weizenbaum Update tested Rails versions.
nex3 authored
348 "v2.3.4",
74d8a56 Chris Eppstein Test haml & sass against multiple versions of rails.
chriseppstein authored
349 "v2.2.2",
350 "v2.1.2",
351 ]
239252a Natalie Weizenbaum Don't test against Rails 2.0.5 under Ruby 1.9.
nex3 authored
352 rails_versions << "v2.0.5" if RUBY_VERSION =~ /^1\.8/
74d8a56 Chris Eppstein Test haml & sass against multiple versions of rails.
chriseppstein authored
353
354 namespace :test do
355 desc "Test all supported versions of rails. This takes a while."
356 task :rails_compatibility do
357 `rm -rf test/rails`
358 puts "Checking out rails. Please wait."
359 `git clone git://github.com/rails/rails.git test/rails` rescue nil
360 begin
361 rails_versions.each do |version|
362 Dir.chdir "test/rails" do
363 `git checkout #{version}`
364 end
365 puts "Testing Rails #{version}"
366 Rake::Task['test'].reenable
367 Rake::Task['test'].execute
368 end
369 ensure
370 `rm -rf test/rails`
371 end
372 end
5e09c48 Stefan Penner Modify the Rakefile to support a jgem install.
stefanpenner authored
373 end
458306f Natalie Weizenbaum Delegate update-handling to the Rakefile.
nex3 authored
374
375 # ----- Handling Updates -----
376
2432d0c Natalie Weizenbaum Make sure we clean up the git repo after every relevant rake task.
nex3 authored
377 def ensure_git_cleanup
378 yield
379 ensure
380 sh %{git reset --hard HEAD}
381 sh %{git clean -xdf}
382 sh %{git checkout master}
383 end
384
458306f Natalie Weizenbaum Delegate update-handling to the Rakefile.
nex3 authored
385 task :handle_update do
d758a0d Natalie Weizenbaum Have pages track stable (for now).
nex3 authored
386 unless ENV["REF"] =~ %r{^refs/heads/(master|stable|(?:haml|sass)-pages)$}
5709b70 Natalie Weizenbaum Fix up some update-watcher stuff.
nex3 authored
387 puts "#{'=' * 20} Ignoring rake handle_update REF=#{ENV["REF"].inspect}"
388 next
389 end
390 branch = $1
391
8b1ae1f Natalie Weizenbaum Trace all invoked rake tasks.
nex3 authored
392 puts
393 puts
394 puts '=' * 150
a4d9804 Natalie Weizenbaum Oops, forgot a name in there...
nex3 authored
395 puts "Running rake handle_update REF=#{ENV["REF"].inspect}"
8b1ae1f Natalie Weizenbaum Trace all invoked rake tasks.
nex3 authored
396
87d9e79 Natalie Weizenbaum During updates, don't merge where we can reset.
nex3 authored
397 sh %{git fetch origin}
252a048 Natalie Weizenbaum Make sure the stable branch is up-to-date when generating pages.
nex3 authored
398 sh %{git checkout stable}
399 sh %{git reset --hard origin/stable}
400 sh %{git checkout master}
87d9e79 Natalie Weizenbaum During updates, don't merge where we can reset.
nex3 authored
401 sh %{git reset --hard origin/master}
12aece3 Natalie Weizenbaum Ensure that update handling is done on the master branch.
nex3 authored
402
2432d0c Natalie Weizenbaum Make sure we clean up the git repo after every relevant rake task.
nex3 authored
403 if branch == "master"
404 sh %{rake release_edge --trace}
d758a0d Natalie Weizenbaum Have pages track stable (for now).
nex3 authored
405 elsif branch == "stable"
2432d0c Natalie Weizenbaum Make sure we clean up the git repo after every relevant rake task.
nex3 authored
406 sh %{rake pages --trace PROJ=haml}
407 sh %{rake pages --trace PROJ=sass}
408 elsif branch =~ /^(haml|sass)-pages$/
409 sh %{rake pages --trace PROJ=#{$1}}
458306f Natalie Weizenbaum Delegate update-handling to the Rakefile.
nex3 authored
410 end
5709b70 Natalie Weizenbaum Fix up some update-watcher stuff.
nex3 authored
411
412 puts 'Done running handle_update'
413 puts '=' * 150
458306f Natalie Weizenbaum Delegate update-handling to the Rakefile.
nex3 authored
414 end
Something went wrong with that request. Please try again.