Skip to content

@bitzesty /_README.md forked from kneath/_README.md
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
RAILS_ROOT ||= ENV["RAILS_ROOT"]
namespace :bundle do
js_bundle = Rails.root + "/public/javascripts/bundle.js"
js_files = Dir[Rails.root + "/public/javascripts/{github,jquery}.*.js"].sort
task :all => [ js_bundle, :gist_js, :css ]
file js_bundle => js_files do |task|
require 'lib/js_minimizer'
File.open(task.name, 'w+') do |f|
f.puts JSMinimizer.minimize_files(task.prerequisites)
end
puts "=> bundled js at #{task.name}"
end
task :gist_js do
require 'lib/js_minimizer'
paths = []
paths += Dir[RAILS_ROOT + '/public/javascripts/gist/*.js'].sort
paths = paths.flatten
target = RAILS_ROOT + '/public/javascripts/gist.js'
File.open(target, 'w+') do |f|
f.puts JSMinimizer.minimize_files(*paths)
end
puts "=> bundled gist js at #{target}"
end
task :css do
paths = []
paths += Dir[RAILS_ROOT + '/public/stylesheets/*.css'].reject { |path| path =~ /bundle|admin|staff|scaffold|iui/ }.sort
bundle = ''
paths.flatten.each do |path|
bundle << File.read(path) << "\n"
end
rawpath = "/tmp/bundle_raw.css"
minpath = "/tmp/bundle_min.css"
bundlepath = RAILS_ROOT + "/public/stylesheets/bundle.css"
yuipath = RAILS_ROOT + '/lib/yuicompressor-2.4.1.jar'
File.open(rawpath, 'w') { |f| f.write(bundle) }
`java -jar #{yuipath} --line-break 0 #{rawpath} -o #{bundlepath}`
puts "=> bundled css at #{bundlepath}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.