module Assets::Base if Assets.production? def bundle include_links + tag_for_file('application_compressed') end else def bundle include_links + include_files end end def compress raise 'You need java to compress assets' if `which java`.empty? compressor = "#{File.dirname(__FILE__)}/compressor.jar" file = system_path('application_compressed') File.open file, 'w+' do |it| it.puts files.map {|it| File.read system_path(it) }.join("\n") end `java -jar #{compressor} --charset utf-8 -o #{file} #{file}` end protected def sources raise 'Abstract method' end def tag(url) raise 'Abstract method' end def url_path(asset_name) raise 'Abstract method' end def links sources.select {|it| it[/^http/] } end def include_links links.map {|it| tag it }.join end def files sources - links end def tag_for_file(asset_name) tag url_path(asset_name) end def include_files files.map {|it| tag_for_file it }.join end def system_path(asset_name) 'public' + url_path(asset_name) end end