Rakefile 831 B

123456789101112131415161718192021222324
  1. # encoding: utf-8
  2. task default: :test
  3. desc 'Use UglifyJS to compress Underscore.string'
  4. task :build do
  5. require 'uglifier'
  6. source = File.read('lib/underscore.string.js', :encoding => 'utf-8')
  7. compressed = Uglifier.compile(source, copyright: false)
  8. File.open('dist/underscore.string.min.js', 'w'){ |f| f.write compressed }
  9. compression_rate = compressed.length.to_f/source.length
  10. puts "compressed dist/underscore.string.min.js: #{compressed.length}/#{source.length} #{(compression_rate * 100).round}%"
  11. end
  12. desc 'Run tests'
  13. task :test do
  14. puts "Running underscore.string test suite."
  15. result1 = system %{phantomjs ./test/run-qunit.js "test/test.html"}
  16. puts "Running Underscore test suite."
  17. result2 = system %{phantomjs ./test/run-qunit.js "test/test_underscore/index.html"}
  18. exit(result1 && result2 ? 0 : 1)
  19. end