Rakefile in haml-3.0.25 vs Rakefile in haml-3.1.0.alpha.2
- old
+ new
@@ -40,11 +40,11 @@
# ----- Packaging -----
# Don't use Rake::GemPackageTast because we want prerequisites to run
# before we load the gemspec.
desc "Build all the packages."
-task :package => [:revision_file, :submodules, :permissions] do
+task :package => [:revision_file, :submodules] do
load scope('haml.gemspec')
Gem::Builder.new(HAML_GEMSPEC).build
pkg = "#{HAML_GEMSPEC.name}-#{HAML_GEMSPEC.version}"
mkdir_p "pkg"
verbose(true) {mv "#{pkg}.gem", "pkg/#{pkg}.gem"}
@@ -52,20 +52,10 @@
sh %{rm -f pkg/#{pkg}.tar.gz}
verbose(false) {HAML_GEMSPEC.files.each {|f| sh %{tar rf pkg/#{pkg}.tar #{f}}}}
sh %{gzip pkg/#{pkg}.tar}
end
-task :permissions do
- sh %{chmod -R a+rx bin}
- sh %{chmod -R a+r .}
- require 'shellwords'
- Dir.glob('test/**/*_test.rb') do |file|
- next if file =~ %r{^test/haml/spec/}
- sh %{chmod a+rx #{file}}
- end
-end
-
task :revision_file do
require 'lib/haml'
release = Rake.application.top_level_tasks.include?('release') || File.exist?(scope('EDGE_GEM_VERSION'))
if Haml.version[:rev] && !release
@@ -93,11 +83,12 @@
sh %{rubyforge add_release haml haml "#{name} (v#{version})" pkg/haml-#{version}.gem}
sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.gz}
sh %{gem push pkg/haml-#{version}.gem}
end
-# Ensures that the version have been updated for a new release.
+
+# Ensures that the VERSION file has been updated for a new release.
task :check_release do
version = File.read(scope("VERSION")).strip
raise "There have been changes since current version (#{version})" if changed_since?(version)
raise "VERSION_NAME must not be 'Bleeding Edge'" if File.read(scope("VERSION_NAME")) == "Bleeding Edge"
end
@@ -123,33 +114,14 @@
def changed_since?(rev, *files)
IO.popen("git diff --exit-code #{rev} #{files.join(' ')}") {}
return !$?.success?
end
-# Returns whether or not the given Emacs mode file (haml or sass)
-# has changed since the given version.
-#
-# @param mode [String, Symbol] The name of the mode
-# @param version [String] The version number
-# @return [String, nil] The version number if the version has changed
-def mode_unchanged?(mode, version)
- mode_version = File.read(scope("extra/#{mode}-mode.el")).scan(/^;; Version: (.*)$/).first.first
- return false if mode_version == version
- return mode_version unless changed_since?(mode_version, "extra/#{mode}-mode.el")
- raise "#{mode}-mode.el version is #{version.inspect}, but it has changed as of #{version.inspect}"
- return false
-end
-
task :submodules do
if File.exist?(File.dirname(__FILE__) + "/.git")
sh %{git submodule sync}
sh %{git submodule update --init}
- elsif !File.exist?(File.dirname(__FILE__) + "/vendor/fssm/lib")
- warn <<WARN
-WARNING: vendor/fssm doesn't exist, and this isn't a git repository so
-I can't get it automatically!
-WARN
end
end
task :release_edge do
ensure_git_cleanup do
@@ -157,43 +129,59 @@
sh %{git checkout edge-gem}
sh %{git reset --hard origin/edge-gem}
sh %{git merge origin/master}
- # Get the current master branch version
- version = File.read(scope('VERSION')).strip.split('.')
- pr = version[3]
- version = version.map {|n| n.to_i}
- unless pr || (version[1] % 2 == 1 && version[2] == 0)
- raise "#{version.join('.')} is not a development version"
+ unless edge_version = bump_edge_version
+ puts "master is already a prerelease version, no use building an edge gem"
+ next
end
- # Bump the edge gem version
- edge_version = File.read(scope('EDGE_GEM_VERSION')).strip.split('.').map {|n| n.to_i}
- if !pr && (edge_version[0..1] != version[0..1])
- # A new master branch version was released, reset the edge gem version
- edge_version[0..1] = version[0..1]
- edge_version[2] = 0
- else
- # Just bump the teeny version
- edge_version[2] += 1
- end
- edge_version = edge_version.join('.')
File.open(scope('EDGE_GEM_VERSION'), 'w') {|f| f.puts(edge_version)}
sh %{git commit -m "Bump edge gem version to #{edge_version}." EDGE_GEM_VERSION}
sh %{git push origin edge-gem}
# Package the edge gem with the proper version
File.open(scope('VERSION'), 'w') {|f| f.puts(edge_version)}
sh %{rake package}
sh %{git checkout VERSION}
- sh %{rubyforge add_release haml haml-edge "Bleeding Edge (v#{edge_version})" pkg/haml-edge-#{edge_version}.gem}
- sh %{gem push pkg/haml-edge-#{edge_version}.gem}
+ sh %{rubyforge add_release haml haml "Bleeding Edge (v#{edge_version})" pkg/haml-#{edge_version}.gem}
+ sh %{gem push pkg/haml-#{edge_version}.gem}
end
end
+# Reads the master version and the edge gem version,
+# bump the latter, and return it.
+#
+# Returns nil if the current master version is already a non-alpha prerelease.
+def bump_edge_version
+ # Get the current master branch version
+ version = File.read(scope('VERSION')).strip.split('.')
+ version.map! {|n| n =~ /^[0-9]+$/ ? n.to_i : n}
+ unless version.size == 5 # prerelease
+ raise "master version #{version.join('.')} is not a prerelease version"
+ end
+
+ # Bump the edge gem version
+ edge_version = File.read(scope('EDGE_GEM_VERSION')).strip.split('.')
+ edge_version.map! {|n| n =~ /^[0-9]+$/ ? n.to_i : n}
+
+ if version[3] != "alpha"
+ return
+ elsif edge_version[0..2] != version[0..2]
+ # A new master branch version was released, reset the edge gem version
+ edge_version[0..2] = version[0..2]
+ edge_version[4] = 1
+ else
+ # Just bump the teeny version
+ edge_version[4] += 1
+ end
+
+ edge_version.join('.')
+end
+
task :watch_for_update do
sh %{ruby extra/update_watch.rb}
end
# ----- Documentation -----
@@ -208,11 +196,11 @@
begin
require 'yard'
namespace :doc do
task :sass do
- require scope('lib/sass')
+ require 'sass'
Dir[scope("yard/default/**/*.sass")].each do |sass|
File.open(sass.gsub(/sass$/, 'css'), 'w') do |f|
f.write(Sass::Engine.new(File.read(sass)).render)
end
end
@@ -235,13 +223,10 @@
list.exclude('lib/haml/template/patch.rb')
list.exclude('lib/haml/template/plugin.rb')
list.exclude('lib/haml/railtie.rb')
list.exclude('lib/haml/helpers/action_view_mods.rb')
list.exclude('lib/haml/helpers/xss_mods.rb')
- list.exclude('lib/sass/plugin/merb.rb')
- list.exclude('lib/sass/plugin/rails.rb')
- list.exclude('lib/sass/less.rb')
end.to_a
t.options << '--incremental' if Rake.application.top_level_tasks.include?('redoc')
t.options += FileList.new(scope('yard/*.rb')).to_a.map {|f| ['-e', f]}.flatten
files = FileList.new(scope('doc-src/*')).to_a.sort_by {|s| s.size} + %w[MIT-LICENSE VERSION]
t.options << '--files' << files.join(',')
@@ -266,24 +251,23 @@
task :doc => :rdoc
task :yard => :rdoc
end
task :pages do
+ puts "#{'=' * 50} Running rake pages"
ensure_git_cleanup do
- puts "#{'=' * 50} Running rake pages PROJ=#{ENV["PROJ"].inspect}"
- raise 'No ENV["PROJ"]!' unless proj = ENV["PROJ"]
- sh %{git checkout #{proj}-pages}
- sh %{git reset --hard origin/#{proj}-pages}
+ sh %{git checkout haml-pages}
+ sh %{git reset --hard origin/haml-pages}
- Dir.chdir("/var/www/#{proj}-pages") do
+ Dir.chdir("/var/www/haml-pages") do
sh %{git fetch origin}
sh %{git checkout stable}
sh %{git reset --hard origin/stable}
- sh %{git checkout #{proj}-pages}
- sh %{git reset --hard origin/#{proj}-pages}
+ sh %{git checkout haml-pages}
+ sh %{git reset --hard origin/haml-pages}
sh %{rake build --trace}
sh %{mkdir -p tmp}
sh %{touch tmp/restart.txt}
end
end
@@ -309,36 +293,26 @@
begin
require 'ruby-prof'
desc <<END
Run a profile of haml.
- ENGINE=str sets the engine to be profiled. Defaults to Haml.
TIMES=n sets the number of runs. Defaults to 1000.
- FILE=str sets the file to profile.
- Defaults to 'standard' for Haml and 'complex' for Sass.
+ FILE=str sets the file to profile. Defaults to 'standard'
OUTPUT=str sets the ruby-prof output format.
Can be Flat, CallInfo, or Graph. Defaults to Flat. Defaults to Flat.
END
task :profile do
- engine = (ENV['ENGINE'] || 'haml').downcase
times = (ENV['TIMES'] || '1000').to_i
file = ENV['FILE']
- if engine == 'sass'
- require 'lib/sass'
+ require 'lib/haml'
- file = File.read(scope("test/sass/templates/#{file || 'complex'}.sass"))
- result = RubyProf.profile { times.times { Sass::Engine.new(file).render } }
- else
- require 'lib/haml'
+ file = File.read(scope("test/haml/templates/#{file || 'standard'}.haml"))
+ obj = Object.new
+ Haml::Engine.new(file).def_method(obj, :render)
+ result = RubyProf.profile { times.times { obj.render } }
- file = File.read(scope("test/haml/templates/#{file || 'standard'}.haml"))
- obj = Object.new
- Haml::Engine.new(file).def_method(obj, :render)
- result = RubyProf.profile { times.times { obj.render } }
- end
-
RubyProf.const_get("#{(ENV['OUTPUT'] || 'Flat').capitalize}Printer").new(result).print
end
rescue LoadError; end
# ----- Testing Multiple Rails Versions -----
@@ -402,11 +376,11 @@
sh %{git checkout master}
end
task :handle_update do
email_on_error do
- unless ENV["REF"] =~ %r{^refs/heads/(master|stable|(?:haml|sass)-pages)$}
+ unless ENV["REF"] =~ %r{^refs/heads/(master|stable|haml-pages)$}
puts "#{'=' * 20} Ignoring rake handle_update REF=#{ENV["REF"].inspect}"
next
end
branch = $1
@@ -419,16 +393,14 @@
sh %{git checkout stable}
sh %{git reset --hard origin/stable}
sh %{git checkout master}
sh %{git reset --hard origin/master}
- if branch == "master"
+ case branch
+ when "master"
sh %{rake release_edge --trace}
- elsif branch == "stable"
- sh %{rake pages --trace PROJ=haml}
- sh %{rake pages --trace PROJ=sass}
- elsif branch =~ /^(haml|sass)-pages$/
- sh %{rake pages --trace PROJ=#{$1}}
+ when "stable", "haml-pages"
+ sh %{rake pages --trace}
end
puts 'Done running handle_update'
puts '=' * 150
end