Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions asset_hat.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,15 @@ Gem::Specification.new do |s|
s.add_development_dependency(%q<shoulda>, ["~> 2.10.2"])
s.add_runtime_dependency(%q<cssmin>, ["~> 1.0.2"])
s.add_runtime_dependency(%q<jsmin>, ["~> 1.0.1"])
s.add_runtime_dependency(%q<yui-compressor>, ["~> 0.9.6"])
else
s.add_dependency(%q<flexmock>, ["~> 0.8.6"])
s.add_dependency(%q<hanna>, ["~> 0.1.12"])
s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
s.add_dependency(%q<shoulda>, ["~> 2.10.2"])
s.add_dependency(%q<cssmin>, ["~> 1.0.2"])
s.add_dependency(%q<jsmin>, ["~> 1.0.1"])
s.add_dependency(%q<yui-compressor>, ["~> 0.9.6"])
end
else
s.add_dependency(%q<flexmock>, ["~> 0.8.6"])
Expand All @@ -128,6 +130,7 @@ Gem::Specification.new do |s|
s.add_dependency(%q<shoulda>, ["~> 2.10.2"])
s.add_dependency(%q<cssmin>, ["~> 1.0.2"])
s.add_dependency(%q<jsmin>, ["~> 1.0.1"])
s.add_dependency(%q<yui-compressor>, ["~> 0.9.6"])
end
end

14 changes: 13 additions & 1 deletion lib/asset_hat/css.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
require 'cssmin'
require 'yui/compressor'

module AssetHat
# Methods for minifying and optimizing CSS.
module CSS
# A list of supported minification
# <a href=CSS/Engines.html>engine</a> names.
ENGINES = [:weak, :cssmin]
ENGINES = [:weak, :cssmin, :yui]

# Returns the expected path for the minified version of a CSS asset:
#
Expand Down Expand Up @@ -121,6 +122,17 @@ def self.cssmin(input_string)

output
end

# Ruby-YUI Compressor provides a Ruby interface to the YUI Compressor
# Java library for minifying JavaScript and CSS assets.
#
# Sources:
# - http://github.com/sstephenson/ruby-yui-compressor/
# - http://rubygems.org/gems/yui-compressor
def self.yui(input_string)
compressor = YUI::CssCompressor.new
compressor.compress(input_string)
end
end


Expand Down
15 changes: 14 additions & 1 deletion lib/asset_hat/js.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
require 'jsmin'
require 'yui/compressor'
require File.join(File.dirname(__FILE__), 'js', 'vendors')

module AssetHat
# Methods for minifying JavaScript.
module JS
# A list of supported minification
# <a href=JS/Engines.html>engine</a> names.
ENGINES = [:weak, :jsmin]
ENGINES = [:weak, :jsmin, :yui]

# A list of supported
# <a href=JS/Vendors.html>3rd-party JavaScript plugin/vendor</a> names.
Expand Down Expand Up @@ -79,6 +80,18 @@ def self.weak(input_string)
def self.jsmin(input_string)
JSMin.minify(input_string + "\n")
end

# Ruby-YUI Compressor provides a Ruby interface to the YUI Compressor
# Java library for minifying JavaScript and CSS assets.
#
# Sources:
# - http://github.com/sstephenson/ruby-yui-compressor/
# - http://rubygems.org/gems/yui-compressor
def self.yui(input_string)
compressor = YUI::JavaScriptCompressor.new(:munge => true)
compressor.compress(input_string)
end

end # module Engines

end
Expand Down