Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 395 lines (332 sloc) 10.99 kb
e167efa @nex3 Scope all file accesses in the Rakefile so it'll work regardless of cwd.
nex3 authored
1 # ----- Utility Functions -----
2
3 def scope(path)
4 File.join(File.dirname(__FILE__), path)
5 end
6
addce2f @nex3 A saner way of separating the benchmark task.
nex3 authored
7 # ----- Benchmarking -----
8
c8f6765 @nex3 Clean up the Rakefile.
nex3 authored
9 desc <<END
3f0c221 @nex3 Replacing HAML with Haml.
nex3 authored
10 Benchmark haml against ERb.
c8f6765 @nex3 Clean up the Rakefile.
nex3 authored
11 TIMES=n sets the number of runs. Defaults to 1000.
addce2f @nex3 A saner way of separating the benchmark task.
nex3 authored
12 END
13 task :benchmark do
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
14 sh "ruby test/benchmark.rb #{ENV['TIMES']}"
485197a @nex3 Rake tasks no longer collide with each other.
nex3 authored
15 end
16
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
17 # ----- Default: Testing ------
ad712a6 Proudly presenting excellent test coverage for HAML.
hcatlin authored
18
74d8a56 @chriseppstein Test haml & sass against multiple versions of rails.
chriseppstein authored
19 if ENV["RUN_CODE_RUN"] == "true"
20 task :default => :"test:rails_compatibility"
21 else
22 task :default => :test
23 end
addce2f @nex3 A saner way of separating the benchmark task.
nex3 authored
24
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
25 require 'rake/testtask'
35f7e17 Initial upload.
hcatlin authored
26
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
27 Rake::TestTask.new do |t|
28 t.libs << 'lib'
e167efa @nex3 Scope all file accesses in the Rakefile so it'll work regardless of cwd.
nex3 authored
29 test_files = FileList[scope('test/**/*_test.rb')]
30 test_files.exclude(scope('test/rails/*'))
31 test_files.exclude(scope('test/plugins/*'))
32 test_files.exclude(scope('test/haml/spec/*'))
0f49933 @nex3 Make sure we don't run linked Rails tests.
nex3 authored
33 t.test_files = test_files
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
34 t.verbose = true
35 end
36 Rake::Task[:test].send(:add_comment, <<END)
243f46d @nex3 Add a comment about using alternate Rails versions to the test task d…
nex3 authored
37 To run with an alternate version of Rails, make test/rails a symlink to that version.
38 END
35f7e17 Initial upload.
hcatlin authored
39
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
40 # ----- Packaging -----
b88841e @nex3 Gemification for 1.5dev.
nex3 authored
41
fe39992 @nex3 Make sure we always build the package after the sync the submodules a…
nex3 authored
42 # Don't use Rake::GemPackageTast because we want prerequisites to run
43 # before we load the gemspec.
44 desc "Build all the packages."
f69b99e @nex3 Set permissions on the revision file and submodules as well.
nex3 authored
45 task :package => [:revision_file, :submodules, :permissions] do
5681001 @nex3 Change the edge-gem versioning scheme.
nex3 authored
46 version = get_version
47 File.open(scope('VERSION'), 'w') {|f| f.puts(version)}
fe39992 @nex3 Make sure we always build the package after the sync the submodules a…
nex3 authored
48 load scope('haml.gemspec')
49 Gem::Builder.new(HAML_GEMSPEC).build
5681001 @nex3 Change the edge-gem versioning scheme.
nex3 authored
50 sh %{git checkout VERSION}
51
a983cd0 @nex3 Make the new package command work with haml-edge.
nex3 authored
52 pkg = "#{HAML_GEMSPEC.name}-#{HAML_GEMSPEC.version}"
fe39992 @nex3 Make sure we always build the package after the sync the submodules a…
nex3 authored
53 mkdir_p "pkg"
54 verbose(true) {mv "#{pkg}.gem", "pkg/#{pkg}.gem"}
55
56 sh %{rm -f pkg/#{pkg}.tar.gz}
57 verbose(false) {HAML_GEMSPEC.files.each {|f| sh %{tar rf pkg/#{pkg}.tar #{f}}}}
58 sh %{gzip pkg/#{pkg}.tar}
39da4e4 @nex3 Build tarballs etc. when packaging for a release.
nex3 authored
59 end
1a2040b Added a Rake task for benchmarking. Use with rake benchmark (TIMES=n)
packagethief authored
60
551fd06 @nex3 As part of packaging, fix up some permissions that can apparently go …
nex3 authored
61 task :permissions do
62 sh %{chmod -R a+rx bin}
63 sh %{chmod -R a+r .}
64 require 'shellwords'
65 Dir.glob('test/**/*_test.rb') do |file|
66 next if file =~ %r{^test/haml/spec/}
6509162 @nex3 Don't use Shellwords.shellescape.
nex3 authored
67 sh %{chmod a+rx #{file}}
551fd06 @nex3 As part of packaging, fix up some permissions that can apparently go …
nex3 authored
68 end
69 end
70
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
71 task :revision_file do
6fc675e @nex3 Don't load Haml in the Rakefile unless it's necessary.
nex3 authored
72 require 'lib/haml'
73
e167efa @nex3 Scope all file accesses in the Rakefile so it'll work regardless of cwd.
nex3 authored
74 release = Rake.application.top_level_tasks.include?('release') || File.exist?(scope('EDGE_GEM_VERSION'))
1a0b452 @nex3 Add a Rake task for packaging a special edge gem.
nex3 authored
75 if Haml.version[:rev] && !release
e167efa @nex3 Scope all file accesses in the Rakefile so it'll work regardless of cwd.
nex3 authored
76 File.open(scope('REVISION'), 'w') { |f| f.puts Haml.version[:rev] }
1a0b452 @nex3 Add a Rake task for packaging a special edge gem.
nex3 authored
77 elsif release
e167efa @nex3 Scope all file accesses in the Rakefile so it'll work regardless of cwd.
nex3 authored
78 File.open(scope('REVISION'), 'w') { |f| f.puts "(release)" }
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
79 else
e167efa @nex3 Scope all file accesses in the Rakefile so it'll work regardless of cwd.
nex3 authored
80 File.open(scope('REVISION'), 'w') { |f| f.puts "(unknown)" }
c0a88ed @nex3 Make sure revision version information is preserved when installing H…
nex3 authored
81 end
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
82 end
c0a88ed @nex3 Make sure revision version information is preserved when installing H…
nex3 authored
83
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
84 # We also need to get rid of this file after packaging.
e167efa @nex3 Scope all file accesses in the Rakefile so it'll work regardless of cwd.
nex3 authored
85 at_exit { File.delete(scope('REVISION')) rescue nil }
c0a88ed @nex3 Make sure revision version information is preserved when installing H…
nex3 authored
86
32161b1 @nex3 Don't use sudo by default w/rake install.
nex3 authored
87 desc "Install Haml as a gem. Use SUDO=1 to install with sudo."
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
88 task :install => [:package] do
5e09c48 @stefanpenner Modify the Rakefile to support a jgem install.
stefanpenner authored
89 gem = RUBY_PLATFORM =~ /java/ ? 'jgem' : 'gem'
5681001 @nex3 Change the edge-gem versioning scheme.
nex3 authored
90 sh %{#{'sudo ' if ENV["SUDO"]}#{gem} install --no-ri pkg/haml-#{get_version}}
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
91 end
5c09bf1 @nex3 Added an install task to the Rakefiles in trunk and stable.
nex3 authored
92
3bcee42 @nex3 Add a Rake task for releasing haml- and sass-mode to ELPA.
nex3 authored
93 desc "Release a new Haml package to Rubyforge."
fd9a367 @nex3 Excise Sass from within files.
nex3 authored
94 task :release => [:check_release, :package] do
e167efa @nex3 Scope all file accesses in the Rakefile so it'll work regardless of cwd.
nex3 authored
95 name = File.read(scope("VERSION_NAME")).strip
96 version = File.read(scope("VERSION")).strip
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
97 sh %{rubyforge add_release haml haml "#{name} (v#{version})" pkg/haml-#{version}.gem}
98 sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.gz}
d8a7bd4 @nex3 Add a Gemcutter push to the release process.
nex3 authored
99 sh %{gem push pkg/haml-#{version}.gem}
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
100 end
7a1ebe0 @nex3 Added a "release" rake task.
nex3 authored
101
3bcee42 @nex3 Add a Rake task for releasing haml- and sass-mode to ELPA.
nex3 authored
102
d9382b1 @nex3 Update VERSION-handling to cope with prerelease versions for edge.
nex3 authored
103 # Ensures that the VERSION file has been updated for a new release.
3bcee42 @nex3 Add a Rake task for releasing haml- and sass-mode to ELPA.
nex3 authored
104 task :check_release do
e167efa @nex3 Scope all file accesses in the Rakefile so it'll work regardless of cwd.
nex3 authored
105 version = File.read(scope("VERSION")).strip
3bcee42 @nex3 Add a Rake task for releasing haml- and sass-mode to ELPA.
nex3 authored
106 raise "There have been changes since current version (#{version})" if changed_since?(version)
e167efa @nex3 Scope all file accesses in the Rakefile so it'll work regardless of cwd.
nex3 authored
107 raise "VERSION_NAME must not be 'Bleeding Edge'" if File.read(scope("VERSION_NAME")) == "Bleeding Edge"
3bcee42 @nex3 Add a Rake task for releasing haml- and sass-mode to ELPA.
nex3 authored
108 end
109
110 # Reads a password from the command line.
111 #
112 # @param name [String] The prompt to use to read the password
113 def read_password(prompt)
114 require 'readline'
115 system "stty -echo"
116 Readline.readline("#{prompt}: ").strip
117 ensure
118 system "stty echo"
119 puts
120 end
121
122 # Returns whether or not the repository, or specific files,
123 # has/have changed since a given revision.
124 #
125 # @param rev [String] The revision to check against
126 # @param files [Array<String>] The files to check.
127 # If this is empty, checks the entire repository
128 def changed_since?(rev, *files)
129 IO.popen("git diff --exit-code #{rev} #{files.join(' ')}") {}
130 return !$?.success?
131 end
132
6248ca3 @nex3 Try to make sure submodules get checked out before packaging.
nex3 authored
133 task :submodules do
134 if File.exist?(File.dirname(__FILE__) + "/.git")
135 sh %{git submodule sync}
c6c7b96 @nex3 Recursively initialize submodules.
nex3 authored
136 sh %{git submodule update --init --recursive}
6248ca3 @nex3 Try to make sure submodules get checked out before packaging.
nex3 authored
137 end
138 end
139
1a0b452 @nex3 Add a Rake task for packaging a special edge gem.
nex3 authored
140 task :release_edge do
2432d0c @nex3 Make sure we clean up the git repo after every relevant rake task.
nex3 authored
141 ensure_git_cleanup do
142 puts "#{'=' * 50} Running rake release_edge"
8b1ae1f @nex3 Trace all invoked rake tasks.
nex3 authored
143
5681001 @nex3 Change the edge-gem versioning scheme.
nex3 authored
144 sh %{git checkout master}
145 sh %{git reset --hard origin/master}
2432d0c @nex3 Make sure we clean up the git repo after every relevant rake task.
nex3 authored
146 sh %{rake package}
2ddf279 @nex3 Fix a stupid mistake.
nex3 authored
147 version = get_version
5681001 @nex3 Change the edge-gem versioning scheme.
nex3 authored
148 sh %{rubyforge add_release haml haml "Bleeding Edge (v#{version})" pkg/haml-#{version}.gem}
149 sh %{gem push pkg/haml-#{version}.gem}
d9382b1 @nex3 Update VERSION-handling to cope with prerelease versions for edge.
nex3 authored
150 end
151 end
152
5681001 @nex3 Change the edge-gem versioning scheme.
nex3 authored
153 # Get the version string. If this is being installed from Git,
154 # this includes the proper prerelease version.
155 def get_version
156 written_version = File.read(scope('VERSION').strip)
157 return written_version unless File.exist?(scope('.git'))
158
d9382b1 @nex3 Update VERSION-handling to cope with prerelease versions for edge.
nex3 authored
159 # Get the current master branch version
5681001 @nex3 Change the edge-gem versioning scheme.
nex3 authored
160 version = written_version.split('.')
d9382b1 @nex3 Update VERSION-handling to cope with prerelease versions for edge.
nex3 authored
161 version.map! {|n| n =~ /^[0-9]+$/ ? n.to_i : n}
5681001 @nex3 Change the edge-gem versioning scheme.
nex3 authored
162 return written_version unless version.size == 5 && version[3] == "alpha" # prerelease
d9382b1 @nex3 Update VERSION-handling to cope with prerelease versions for edge.
nex3 authored
163
5681001 @nex3 Change the edge-gem versioning scheme.
nex3 authored
164 return written_version if (commit_count = `git log --pretty=oneline --first-parent stable.. | wc -l`).empty?
165 version[4] = commit_count.strip
166 version.join('.')
1a0b452 @nex3 Add a Rake task for packaging a special edge gem.
nex3 authored
167 end
168
00c3f79 @nex3 Make the watcher update the Haml and Sass pages when the respective b…
nex3 authored
169 task :watch_for_update do
170 sh %{ruby extra/update_watch.rb}
398bbe0 @nex3 Add a Rake task and Sinatra script for a GitHub post-receive hook.
nex3 authored
171 end
172
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
173 # ----- Documentation -----
89a10b9 Creating the next set of branches.
hcatlin authored
174
4261c22 @nex3 Add a YARD Rake task.
nex3 authored
175 task :rdoc do
176 puts '=' * 100, <<END, '=' * 100
177 Haml uses the YARD documentation system (http://github.com/lsegal/yard).
178 Install the yard gem and then run "rake doc".
179 END
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
180 end
addce2f @nex3 A saner way of separating the benchmark task.
nex3 authored
181
4261c22 @nex3 Add a YARD Rake task.
nex3 authored
182 begin
8da2c37 @nex3 Require the YARD gem now that it supports what we need.
nex3 authored
183 require 'yard'
4261c22 @nex3 Add a YARD Rake task.
nex3 authored
184
0066976 @nex3 Add support for listing undocumented stuff.
nex3 authored
185 namespace :doc do
6d887f7 @nex3 Update the custom YARD CSS to use the proper YARD methodology.
nex3 authored
186 task :sass do
fd9a367 @nex3 Excise Sass from within files.
nex3 authored
187 require 'sass'
e167efa @nex3 Scope all file accesses in the Rakefile so it'll work regardless of cwd.
nex3 authored
188 Dir[scope("yard/default/**/*.sass")].each do |sass|
6d887f7 @nex3 Update the custom YARD CSS to use the proper YARD methodology.
nex3 authored
189 File.open(sass.gsub(/sass$/, 'css'), 'w') do |f|
190 f.write(Sass::Engine.new(File.read(sass)).render)
191 end
192 end
193 end
0066976 @nex3 Add support for listing undocumented stuff.
nex3 authored
194
195 desc "List all undocumented methods and classes."
196 task :undocumented do
197 opts = ENV["YARD_OPTS"] || ""
198 ENV["YARD_OPTS"] = opts.dup + <<OPTS
199 --list --query "
200 object.docstring.blank? &&
201 !(object.type == :method && object.is_alias?)"
202 OPTS
203 Rake::Task['yard'].execute
204 end
6d887f7 @nex3 Update the custom YARD CSS to use the proper YARD methodology.
nex3 authored
205 end
206
4261c22 @nex3 Add a YARD Rake task.
nex3 authored
207 YARD::Rake::YardocTask.new do |t|
e167efa @nex3 Scope all file accesses in the Rakefile so it'll work regardless of cwd.
nex3 authored
208 t.files = FileList.new(scope('lib/**/*.rb')) do |list|
f93746f @nex3 [Haml] Make sure Haml::Template.options is documented.
nex3 authored
209 list.exclude('lib/haml/template/patch.rb')
210 list.exclude('lib/haml/template/plugin.rb')
6ec791e @nex3 Clean up some undocumented stuff.
nex3 authored
211 list.exclude('lib/haml/railtie.rb')
6f96aeb @nex3 Don't include non-Ruby files in the standard YARD docs.
nex3 authored
212 list.exclude('lib/haml/helpers/action_view_mods.rb')
0066976 @nex3 Add support for listing undocumented stuff.
nex3 authored
213 list.exclude('lib/haml/helpers/xss_mods.rb')
6f96aeb @nex3 Don't include non-Ruby files in the standard YARD docs.
nex3 authored
214 end.to_a
14c4a88 @nex3 Upgrade to YARD 0.5.3.
nex3 authored
215 t.options << '--incremental' if Rake.application.top_level_tasks.include?('redoc')
e167efa @nex3 Scope all file accesses in the Rakefile so it'll work regardless of cwd.
nex3 authored
216 t.options += FileList.new(scope('yard/*.rb')).to_a.map {|f| ['-e', f]}.flatten
217 files = FileList.new(scope('doc-src/*')).to_a.sort_by {|s| s.size} + %w[MIT-LICENSE VERSION]
691272b @nex3 Add a doc-src directory for documentation files.
nex3 authored
218 t.options << '--files' << files.join(',')
e167efa @nex3 Scope all file accesses in the Rakefile so it'll work regardless of cwd.
nex3 authored
219 t.options << '--template-path' << scope('yard')
aa1beff @nex3 Add support for custom YARD doc titles (for websites).
nex3 authored
220 t.options << '--title' << ENV["YARD_TITLE"] if ENV["YARD_TITLE"]
0066976 @nex3 Add support for listing undocumented stuff.
nex3 authored
221
222 t.before = lambda do
223 if ENV["YARD_OPTS"]
224 require 'shellwords'
225 t.options.concat(Shellwords.shellwords(ENV["YARD_OPTS"]))
226 end
c974e28 @nex3 Add the ability to pass custom YARD options in to rake doc.
nex3 authored
227 end
4261c22 @nex3 Add a YARD Rake task.
nex3 authored
228 end
0066976 @nex3 Add support for listing undocumented stuff.
nex3 authored
229 Rake::Task['yard'].prerequisites.insert(0, 'doc:sass')
cb04561 @nex3 Update to the latest YARD.
nex3 authored
230 Rake::Task['yard'].instance_variable_set('@comment', nil)
4261c22 @nex3 Add a YARD Rake task.
nex3 authored
231
b4d9aff @nex3 Show the doc task with rake -T.
nex3 authored
232 desc "Generate Documentation"
cb04561 @nex3 Update to the latest YARD.
nex3 authored
233 task :doc => :yard
234 task :redoc => :yard
4261c22 @nex3 Add a YARD Rake task.
nex3 authored
235 rescue LoadError
b4d9aff @nex3 Show the doc task with rake -T.
nex3 authored
236 desc "Generate Documentation"
4261c22 @nex3 Add a YARD Rake task.
nex3 authored
237 task :doc => :rdoc
d600d96 @nex3 Rename yardoc -> yard in an obscure bit of Rakefile.
nex3 authored
238 task :yard => :rdoc
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
239 end
89a10b9 Creating the next set of branches.
hcatlin authored
240
00c3f79 @nex3 Make the watcher update the Haml and Sass pages when the respective b…
nex3 authored
241 task :pages do
fd9a367 @nex3 Excise Sass from within files.
nex3 authored
242 puts "#{'=' * 50} Running rake pages"
2432d0c @nex3 Make sure we clean up the git repo after every relevant rake task.
nex3 authored
243 ensure_git_cleanup do
fd9a367 @nex3 Excise Sass from within files.
nex3 authored
244 sh %{git checkout haml-pages}
245 sh %{git reset --hard origin/haml-pages}
2432d0c @nex3 Make sure we clean up the git repo after every relevant rake task.
nex3 authored
246
fd9a367 @nex3 Excise Sass from within files.
nex3 authored
247 Dir.chdir("/var/www/haml-pages") do
0123551 @nex3 Make sure we get out of the pages directory after updating.
nex3 authored
248 sh %{git fetch origin}
b18a9ac @nex3 Make sure the stable branch of the pages repo is up-to-date.
nex3 authored
249
0123551 @nex3 Make sure we get out of the pages directory after updating.
nex3 authored
250 sh %{git checkout stable}
251 sh %{git reset --hard origin/stable}
b18a9ac @nex3 Make sure the stable branch of the pages repo is up-to-date.
nex3 authored
252
fd9a367 @nex3 Excise Sass from within files.
nex3 authored
253 sh %{git checkout haml-pages}
254 sh %{git reset --hard origin/haml-pages}
0123551 @nex3 Make sure we get out of the pages directory after updating.
nex3 authored
255 sh %{rake build --trace}
256 sh %{mkdir -p tmp}
257 sh %{touch tmp/restart.txt}
258 end
2432d0c @nex3 Make sure we clean up the git repo after every relevant rake task.
nex3 authored
259 end
00c3f79 @nex3 Make the watcher update the Haml and Sass pages when the respective b…
nex3 authored
260 end
261
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
262 # ----- Coverage -----
263
c8f6765 @nex3 Clean up the Rakefile.
nex3 authored
264 begin
265 require 'rcov/rcovtask'
266
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
267 Rcov::RcovTask.new do |t|
e167efa @nex3 Scope all file accesses in the Rakefile so it'll work regardless of cwd.
nex3 authored
268 t.test_files = FileList[scope('test/**/*_test.rb')]
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
269 t.rcov_opts << '-x' << '"^\/"'
270 if ENV['NON_NATIVE']
271 t.rcov_opts << "--no-rcovrt"
47616c9 @nex3 Adding support for alternate doctypes (see REFERENCE). Also added a N…
nex3 authored
272 end
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
273 t.verbose = true
89a10b9 Creating the next set of branches.
hcatlin authored
274 end
c8f6765 @nex3 Clean up the Rakefile.
nex3 authored
275 rescue LoadError; end
89a10b9 Creating the next set of branches.
hcatlin authored
276
500be8e @nex3 Make benchmark.rb more standalone.
nex3 authored
277 # ----- Profiling -----
89a10b9 Creating the next set of branches.
hcatlin authored
278
b9d4015 @nex3 Cleaning up the profile Rake task.
nex3 authored
279 begin
280 require 'ruby-prof'
281
282 desc <<END
c8f6765 @nex3 Clean up the Rakefile.
nex3 authored
283 Run a profile of haml.
b9d4015 @nex3 Cleaning up the profile Rake task.
nex3 authored
284 TIMES=n sets the number of runs. Defaults to 1000.
fd9a367 @nex3 Excise Sass from within files.
nex3 authored
285 FILE=str sets the file to profile. Defaults to 'standard'
b9d4015 @nex3 Cleaning up the profile Rake task.
nex3 authored
286 OUTPUT=str sets the ruby-prof output format.
287 Can be Flat, CallInfo, or Graph. Defaults to Flat. Defaults to Flat.
c8f6765 @nex3 Clean up the Rakefile.
nex3 authored
288 END
b9d4015 @nex3 Cleaning up the profile Rake task.
nex3 authored
289 task :profile do
290 times = (ENV['TIMES'] || '1000').to_i
291 file = ENV['FILE']
292
fd9a367 @nex3 Excise Sass from within files.
nex3 authored
293 require 'lib/haml'
b9d4015 @nex3 Cleaning up the profile Rake task.
nex3 authored
294
fd9a367 @nex3 Excise Sass from within files.
nex3 authored
295 file = File.read(scope("test/haml/templates/#{file || 'standard'}.haml"))
296 obj = Object.new
297 Haml::Engine.new(file).def_method(obj, :render)
298 result = RubyProf.profile { times.times { obj.render } }
addce2f @nex3 A saner way of separating the benchmark task.
nex3 authored
299
b9d4015 @nex3 Cleaning up the profile Rake task.
nex3 authored
300 RubyProf.const_get("#{(ENV['OUTPUT'] || 'Flat').capitalize}Printer").new(result).print
301 end
302 rescue LoadError; end
74d8a56 @chriseppstein Test haml & sass against multiple versions of rails.
chriseppstein authored
303
304 # ----- Testing Multiple Rails Versions -----
305
306 rails_versions = [
134431b @nex3 Update tested Rails versions.
nex3 authored
307 "v2.3.5",
308 "v2.2.3",
74d8a56 @chriseppstein Test haml & sass against multiple versions of rails.
chriseppstein authored
309 "v2.1.2",
310 ]
239252a @nex3 Don't test against Rails 2.0.5 under Ruby 1.9.
nex3 authored
311 rails_versions << "v2.0.5" if RUBY_VERSION =~ /^1\.8/
74d8a56 @chriseppstein Test haml & sass against multiple versions of rails.
chriseppstein authored
312
e02e77a @nex3 Have RunCodeRun test against Rails v2.3.5 with rails_xss enabled.
nex3 authored
313 def test_rails_version(version)
314 Dir.chdir "test/rails" do
64f2d8f @nex3 Use 'sh' for running git commands so we see the output.
nex3 authored
315 sh %{git checkout #{version}}
e02e77a @nex3 Have RunCodeRun test against Rails v2.3.5 with rails_xss enabled.
nex3 authored
316 end
317 puts "Testing Rails #{version}"
318 Rake::Task['test'].reenable
319 Rake::Task['test'].execute
320 end
321
74d8a56 @chriseppstein Test haml & sass against multiple versions of rails.
chriseppstein authored
322 namespace :test do
323 desc "Test all supported versions of rails. This takes a while."
324 task :rails_compatibility do
64f2d8f @nex3 Use 'sh' for running git commands so we see the output.
nex3 authored
325 sh %{rm -rf test/rails}
74d8a56 @chriseppstein Test haml & sass against multiple versions of rails.
chriseppstein authored
326 puts "Checking out rails. Please wait."
64f2d8f @nex3 Use 'sh' for running git commands so we see the output.
nex3 authored
327 sh %{git clone git://github.com/rails/rails.git test/rails}
74d8a56 @chriseppstein Test haml & sass against multiple versions of rails.
chriseppstein authored
328 begin
e02e77a @nex3 Have RunCodeRun test against Rails v2.3.5 with rails_xss enabled.
nex3 authored
329 rails_versions.each {|version| test_rails_version version}
330
331 puts "Checking out rails_xss. Please wait."
64f2d8f @nex3 Use 'sh' for running git commands so we see the output.
nex3 authored
332 sh %{git clone git://github.com/NZKoz/rails_xss.git test/plugins/rails_xss}
e02e77a @nex3 Have RunCodeRun test against Rails v2.3.5 with rails_xss enabled.
nex3 authored
333 test_rails_version(rails_versions.find {|s| s =~ /^v2\.3/})
74d8a56 @chriseppstein Test haml & sass against multiple versions of rails.
chriseppstein authored
334 ensure
335 `rm -rf test/rails`
e02e77a @nex3 Have RunCodeRun test against Rails v2.3.5 with rails_xss enabled.
nex3 authored
336 `rm -rf test/plugins`
74d8a56 @chriseppstein Test haml & sass against multiple versions of rails.
chriseppstein authored
337 end
338 end
5e09c48 @stefanpenner Modify the Rakefile to support a jgem install.
stefanpenner authored
339 end
458306f @nex3 Delegate update-handling to the Rakefile.
nex3 authored
340
341 # ----- Handling Updates -----
342
1d983dd @nex3 Modify the Rakefile so that remote processing tasks email me when som…
nex3 authored
343 def email_on_error
2432d0c @nex3 Make sure we clean up the git repo after every relevant rake task.
nex3 authored
344 yield
1d983dd @nex3 Modify the Rakefile so that remote processing tasks email me when som…
nex3 authored
345 rescue Exception => e
346 IO.popen("sendmail nex342@gmail.com", "w") do |sm|
347 sm << "From: nex3@nex-3.com\n" <<
348 "To: nex342@gmail.com\n" <<
349 "Subject: Exception when running rake #{Rake.application.top_level_tasks.join(', ')}\n" <<
350 e.message << "\n\n" <<
351 e.backtrace.join("\n")
352 end
353 ensure
354 raise e if e
355 end
356
357 def ensure_git_cleanup
358 email_on_error {yield}
2432d0c @nex3 Make sure we clean up the git repo after every relevant rake task.
nex3 authored
359 ensure
360 sh %{git reset --hard HEAD}
361 sh %{git clean -xdf}
362 sh %{git checkout master}
363 end
364
458306f @nex3 Delegate update-handling to the Rakefile.
nex3 authored
365 task :handle_update do
1d983dd @nex3 Modify the Rakefile so that remote processing tasks email me when som…
nex3 authored
366 email_on_error do
fd9a367 @nex3 Excise Sass from within files.
nex3 authored
367 unless ENV["REF"] =~ %r{^refs/heads/(master|stable|haml-pages)$}
1d983dd @nex3 Modify the Rakefile so that remote processing tasks email me when som…
nex3 authored
368 puts "#{'=' * 20} Ignoring rake handle_update REF=#{ENV["REF"].inspect}"
369 next
370 end
371 branch = $1
372
373 puts
374 puts
375 puts '=' * 150
376 puts "Running rake handle_update REF=#{ENV["REF"].inspect}"
377
378 sh %{git fetch origin}
379 sh %{git checkout stable}
380 sh %{git reset --hard origin/stable}
381 sh %{git checkout master}
382 sh %{git reset --hard origin/master}
383
fd9a367 @nex3 Excise Sass from within files.
nex3 authored
384 case branch
385 when "master"
1d983dd @nex3 Modify the Rakefile so that remote processing tasks email me when som…
nex3 authored
386 sh %{rake release_edge --trace}
fd9a367 @nex3 Excise Sass from within files.
nex3 authored
387 when "stable", "haml-pages"
388 sh %{rake pages --trace}
1d983dd @nex3 Modify the Rakefile so that remote processing tasks email me when som…
nex3 authored
389 end
8b1ae1f @nex3 Trace all invoked rake tasks.
nex3 authored
390
1d983dd @nex3 Modify the Rakefile so that remote processing tasks email me when som…
nex3 authored
391 puts 'Done running handle_update'
392 puts '=' * 150
458306f @nex3 Delegate update-handling to the Rakefile.
nex3 authored
393 end
394 end
Something went wrong with that request. Please try again.