Sha256: 4c0f7f578c082b0e34508b7324ab6edc4dfc25c07e5c2b14fbfc321f410ec7fd
Contents?: true
Size: 1.79 KB
Versions: 1
Compression:
Stored size: 1.79 KB
Contents
require 'rubygems' require 'rake' require 'echoe' def version $1 if File.read('lib/jspec.js').match /version *: *'(.*?)'/ end Echoe.new "jspec", version do |p| p.author = "TJ Holowaychuk" p.email = "tj@vision-media.ca" p.summary = "JavaScript BDD Testing Framework" p.url = "http://visionmedia.github.com/jspec" p.runtime_dependencies << "visionmedia-commander >=3.2.9" end desc 'Package' task :package => [:clear] do begin sh 'mkdir pkg' sh 'cp -fr lib/* pkg' minify 'lib/jspec.js', 'pkg/jspec.min.js' minify 'lib/jspec.jquery.js', 'pkg/jspec.jquery.min.js' compress 'lib/jspec.css', 'pkg/jspec.min.css' sh 'git add pkg/.' rescue Exception => e puts "Failed to package: #{e}." else puts "Packaging of JSpec-#{version} completed." end end desc 'Clear packaging' task :clear do if File.directory? 'pkg' sh 'rm -fr pkg/*' sh 'rmdir pkg' end end desc 'Display compression savings of last release' task :savings do totals = Hash.new { |h, k| h[k] = 0 } format = '%-20s : %0.3f kb' totals = %w( pkg/jspec.min.js pkg/jspec.jquery.min.js pkg/jspec.min.css ).inject totals do |total, file| uncompressed = File.size(file.sub('.min', '')).to_f / 1024 compressed = File.size(file).to_f / 1024 saved = uncompressed - compressed puts format % [file.sub('pkg/', ''), saved] totals[:saved] += saved totals[:uncompressed] += uncompressed totals[:compressed] += compressed totals end puts puts format % ['total uncompressed', totals[:uncompressed]] puts format % ['total compressed', totals[:compressed]] puts format % ['total saved', totals[:saved]] end def minify from, to sh "jsmin < #{from} > #{to}" end def compress from, to File.open(to, 'w+') do |file| file.write File.read(from).gsub(/(^[\t ]*)|\n/, '') end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
visionmedia-jspec-1.1.1 | Rakefile |