Permalink
Browse files

Prepare jquery.turbolinks for v1.0.0 release

  • Loading branch information...
1 parent 69d08ec commit c85e3b0b386bef9f5df0f7c9a30145b711a08d44 @kossnocorp committed Apr 5, 2013
View
@@ -1,6 +1,7 @@
source 'https://rubygems.org'
group :development do
+ gem 'uglifier'
gem 'guard'
gem 'guard-rake'
gem 'talks', '0.4.0'
View
@@ -22,15 +22,42 @@ namespace :release do
end
namespace :js do
+
+ desc 'Build JavaScript from CoffeeScript source code'
task :build do
command = [
'./node_modules/coffee-script/bin/coffee',
'--compile',
'--output ./vendor/assets/javascripts/',
- './src/jquery.turbolinks.coffee'
+ './src/*.coffee'
]
system command.join(' ')
end
+
+ desc 'Use UglifyJS to compress JavaScript'
+ task :uglify do
+ require 'uglifier'
+ Dir['./vendor/assets/javascripts/*.js']
+ .select { |f| not f.match(/min\.js$/) }
+ .each do |file_name|
+ source = File.read(file_name)
+ compressed = Uglifier.compile(source, copyright: false)
+ min_file_name = file_name.gsub(/\.js$/, '.min.js')
+
+ File.open(min_file_name, 'w') do |f|
+ f.write(compressed)
+ end
+
+ uglify_rate = compressed.length.to_f / source.length
+ gzipped_size = `cat #{min_file_name} | gzip -9f | wc -c`.to_i
+ gzip_rate = gzipped_size.to_f / source.length
+
+ puts "# #{file_name}.js"
+ puts "Original size: #{source.length}b or #{(source.length.to_f / 1024).round(2)}kb"
+ puts "Uglified size: #{compressed.length}b (#{(uglify_rate * 100).round}% from original size)"
+ puts "GZipped size: #{gzipped_size}b or #{(gzipped_size.to_f / 1025).round(2)}kb (#{(gzip_rate * 100).round}% from original size)"
+ end
+ end
end
task :test do
@@ -1,3 +1,3 @@
module JqueryTurbolinks
- VERSION = '1.0.0.rc2'
+ VERSION = '1.0.0'
end
View
@@ -1,7 +1,7 @@
{
"name": "jquery.turbolinks",
- "version": "1.0.0-rc2",
- "author": "Sasha Koss <koss@nocorp.me>",
+ "version": "1.0.0",
+ "author": "Sasha Koss <kossnocorp@gmail.com>",
"description": "jQuery plugin for drop-in fix binded events problem caused by Turbolinks",
"devDependencies": {
@@ -10,7 +10,6 @@
"chai": "*",
"sinon": "*",
"sinon-chai": "*",
- "uglify-js": "*",
"jquery": "*",
"jsdom": "*"
},
@@ -1,5 +1,5 @@
###
- jquery.turbolinks.js ~ v1.0.0-rc2 ~ https://github.com/kossnocorp/jquery.turbolinks
+ jquery.turbolinks.js ~ v1.0.0 ~ https://github.com/kossnocorp/jquery.turbolinks
jQuery plugin for drop-in fix binded events problem caused by Turbolinks
@@ -1,7 +1,7 @@
// Generated by CoffeeScript 1.4.0
/*
- jquery.turbolinks.js ~ v1.0.0-rc2 ~ https://github.com/kossnocorp/jquery.turbolinks
+ jquery.turbolinks.js ~ v1.0.0 ~ https://github.com/kossnocorp/jquery.turbolinks
jQuery plugin for drop-in fix binded events problem caused by Turbolinks
@@ -0,0 +1 @@
+(function(){var e,t,n,r,i;e=window.jQuery||(typeof require=="function"?require("jquery"):void 0),t=[],r=function(){var n,r,i,s;s=[];for(r=0,i=t.length;r<i;r++)n=t[r],s.push(n(e));return s},i=function(){return e.isReady=!0,r()},n=function(){return e.isReady=!1},e(r),e.fn.ready=function(n){t.push(n);if(e.isReady)return n(e)},e.setReadyEvent=function(t){return e(document).off(".turbolinks-ready").on(t+".turbolinks-ready",i)},e.setFetchEvent=function(t){return e(document).off(".turbolinks-fetch").on(t+".turbolinks-fetch",n)},e.setReadyEvent("page:load"),e.setFetchEvent("page:fetch")}).call(this);

0 comments on commit c85e3b0

Please sign in to comment.