Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: e2287cee35
Fetching contributors…

Cannot retrieve contributors at this time

45 lines (36 sloc) 1.009 kb
require 'rake'
require 'yui/compressor'
desc 'Aggregate all javascript files'
task :aggregate, :compress do |t, args|
args.with_defaults(:compress => false)
output_file = ENV['output'] || 'ajax-solr.min.js'
core = [
'Core',
'AbstractManager',
'ParameterStore',
'Parameter',
'AbstractWidget',
'AbstractFacetWidget'
]
dirs = [
'core',
'helpers',
'managers',
'widgets'
]
compressor = YUI::JavaScriptCompressor.new(:munge => true) if args[:compress]
files = core.map{ |name| "core/#{name}.js" } + dirs.map{ |dir| Dir["#{dir}/**/*.js"] }.flatten
files.uniq!
action = args[:compress] ? "Compressing" : "Aggregating"
File.open(output_file, 'w') do |output|
files.each do |file_name|
puts "#{action} #{file_name}"
input = File.read(file_name)
output.write(args[:compress] ? compressor.compress(input) : input)
end
end
end
desc 'Compress all javascript files'
task :compress do
Rake::Task[:aggregate].invoke(true)
end
Jump to Line
Something went wrong with that request. Please try again.