Skip to content

Commit

Permalink
Updated rake build to use google js compiler and removed unneeded yui…
Browse files Browse the repository at this point in the history
…compressor.
  • Loading branch information
jaykz52 committed Mar 10, 2012
1 parent a6cb4ed commit 71df0aa
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 178 deletions.
41 changes: 3 additions & 38 deletions Rakefile
Expand Up @@ -11,7 +11,7 @@ MECHANIC_COMPONENTS = [
'mechanic-core',
'logging',
'data',
'events'
'events'
]

task :default => [:clean, :concat, :dist]
Expand Down Expand Up @@ -71,27 +71,6 @@ def google_compiler(src, target)
`java -jar vendor/google-compiler/compiler.jar --js #{src} --summary_detail_level 3 --js_output_file #{target}`
end

def yui_compressor(src, target)
puts "Minifying #{src} with YUI Compressor..."
`java -jar vendor/yuicompressor/yuicompressor-2.4.2.jar #{src} -o #{target}`
end

def uglifyjs(src, target)
begin
require 'uglifier'
rescue LoadError => e
if verbose
puts "\nYou'll need the 'uglifier' gem for minification. Just run:\n\n"
puts " $ gem install uglifier"
puts "\nand you should be all set.\n\n"
exit
end
return false
end
puts "Minifying #{src} with UglifyJS..."
File.open(target, "w"){|f| f.puts Uglifier.new.compile(File.read(src))}
end

def process_minified(src, target)
cp target, File.join(MECHANIC_DIST_DIR,'temp.js')
msize = File.size(File.join(MECHANIC_DIST_DIR,'temp.js'))
Expand All @@ -106,34 +85,20 @@ def process_minified(src, target)
puts "Minified and gzipped: %.3fk, compression factor %.3f" % [dsize/1024.0, osize/dsize.to_f]
end

desc "Generates a minified version for distribution, using UglifyJS."
task :dist do
src, target = File.join(MECHANIC_DIST_DIR,'mechanic.js'), File.join(MECHANIC_DIST_DIR,'mechanic.min.js')
uglifyjs src, target
process_minified src, target
end

desc "Generates a minified version for distribution using the Google Closure compiler."
task :googledist do
task :dist do
src, target = File.join(MECHANIC_DIST_DIR,'mechanic.js'), File.join(MECHANIC_DIST_DIR,'mechanic.min.js')
google_compiler src, target
process_minified src, target
end

desc "Generates a minified version for distribution using the YUI compressor."
task :yuidist do
src, target = File.join(MECHANIC_DIST_DIR,'mechanic.js'), File.join(MECHANIC_DIST_DIR,'mechanic.min.js')
yui_compressor src, target
process_minified src, target
end

Rake::PackageTask.new('mechanic', MECHANIC_VERSION) do |package|
package.need_tar_gz = true
package.need_zip = true
package.package_dir = MECHANIC_PKG_DIR
package.package_files.include(
'README.md',
'MIT-LICENSE',
'LICENSE',
'dist/**/*',
'src/**/*',
'test/**/*',
Expand Down
4 changes: 4 additions & 0 deletions src/data.js
@@ -1,3 +1,7 @@
// mechanic.js
// Copyright (c) 2012 Jason Kozemczak
// mechanic.js may be freely distributed under the MIT license.

(function($) {
$.extend($.fn, {
name: function() { return (this.length > 0) ? this[0].name() : null; },
Expand Down
4 changes: 4 additions & 0 deletions src/events.js
@@ -1,3 +1,7 @@
// mechanic.js
// Copyright (c) 2012 Jason Kozemczak
// mechanic.js may be freely distributed under the MIT license.

(function($) {
$.extend($, {
timeout: function(duration) { target.setTimeout(duration); },
Expand Down
4 changes: 4 additions & 0 deletions src/logging.js
@@ -1,3 +1,7 @@
// mechanic.js
// Copyright (c) 2012 Jason Kozemczak
// mechanic.js may be freely distributed under the MIT license.

(function($) {
$.extend($, {
log: function(s, level) {
Expand Down
140 changes: 0 additions & 140 deletions vendor/yuicompressor/README

This file was deleted.

Binary file removed vendor/yuicompressor/yuicompressor-2.4.2.jar
Binary file not shown.

0 comments on commit 71df0aa

Please sign in to comment.