Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby 1.9.x compatibility fix and support for Yahoo's YUI Javascript/CSS compressors #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
13 changes: 12 additions & 1 deletion lib/bundle_fu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def bundle_js_files(filenames=[], options={})
if options[:compress]
if Object.const_defined?("Packr")
content
elsif Object.const_defined?("YUI")
content
else
JSMinimizer.minimize_content(content)
end
Expand All @@ -40,6 +42,9 @@ def bundle_js_files(filenames=[], options={})
if Object.const_defined?("Packr")
# use Packr plugin (http://blog.jcoglan.com/packr/)
Packr.new.pack(output, options[:packr_options] || {:shrink_vars => false, :base62 => false})
elsif Object.const_defined?("YUI")
compressor = YUI::JavaScriptCompressor.new(options[:yui_js_options] || {:munge => true})
compressor.compress(output)
else
output
end
Expand All @@ -48,7 +53,13 @@ def bundle_js_files(filenames=[], options={})

def bundle_css_files(filenames=[], options = {})
bundle_files(filenames) { |filename, content|
BundleFu::CSSUrlRewriter.rewrite_urls(filename, content)
content = BundleFu::CSSUrlRewriter.rewrite_urls(filename, content)
# use YUI compressor
if Object.const_defined?("YUI")
compressor = YUI::CssCompressor.new(options[:yui_css_options] || {})
content = compressor.compress(content)
end
content
}
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/bundle_fu/js_minimizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def isAlphanum(c)
return false if !c || c == EOF
return ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') ||
(c >= 'A' && c <= 'Z') || c == '_' || c == '$' ||
c == '\\' || c[0] > 126)
c == '\\' || c[0..0] > '~')
end

# get -- return the next character from input. Watch out for lookahead. If
Expand Down Expand Up @@ -214,4 +214,4 @@ def self.minimize_content(content)
js_minimizer.output.string
end

end
end