lib/asset_hat/tasks.rb in asset_hat-0.2.1 vs lib/asset_hat/tasks.rb in asset_hat-0.3.0
- old
+ new
@@ -2,20 +2,39 @@
require 'asset_hat/tasks/js'
namespace :asset_hat do
desc 'Minifies all CSS and JS bundles'
- task :minify => ['asset_hat:css:minify', 'asset_hat:js:minify']
+ task :minify, :needs => :environment do
+ format = ENV['FORMAT']
+ print 'Minifying CSS/JS...'
+ puts unless format == 'dot'
+ %w[css js].each do |type|
+ task = Rake::Task["asset_hat:#{type}:minify"]
+ task.reenable
+ task.invoke(:show_intro => false, :show_outro => false)
+ end
+ puts unless format == 'short'
+ puts 'Done.'
+ end
+
+ namespace :minify do
+ %w[css js].each do |type|
+ desc "Alias for asset_hat:#{type}:minify"
+ task type.to_sym => "asset_hat:#{type}:minify"
+ end
+ end
+
desc 'Prepare configuration file'
- task :config do
+ task :config, :needs => :environment do
template_filepath = File.join(File.dirname(__FILE__), '..', '..',
AssetHat::RELATIVE_CONFIG_FILEPATH)
target_filepath = AssetHat::CONFIG_FILEPATH
if File.exists?(target_filepath)
print "Replace #{target_filepath}? (y/n) "
- response = STDIN.gets.chomp
+ response = $stdin.gets.chomp
unless response.downcase == 'y'
puts 'Aborted.' ; exit
end
end