Module: YUICompressor
- Defined in:
- lib/yuicompressor.rb,
lib/yuicompressor/jruby.rb,
lib/yuicompressor/shell.rb
Defined Under Namespace
Constant Summary collapse
- JAR_FILE =
The path to the YUI Compressor jar file.
File.('../yuicompressor-2.4.2.jar', __FILE__)
Class Method Summary collapse
-
.compress_css(stream_or_string, options = {}, &block) ⇒ Object
Compress the given CSS
stream_or_string
using the givenoptions
. -
.compress_js(stream_or_string, options = {}, &block) ⇒ Object
Compress the given JavaScript
stream_or_string
using the givenoptions
. -
.default_css_options ⇒ Object
:nodoc:.
-
.default_js_options ⇒ Object
:nodoc:.
-
.jruby? ⇒ Boolean
Returns
true
if the Ruby platform is JRuby. -
.streamify(stream_or_string) ⇒ Object
:nodoc:.
Class Method Details
.compress_css(stream_or_string, options = {}, &block) ⇒ Object
Compress the given CSS stream_or_string
using the given options
. Options should be a Hash with any of the following keys:
:line_break
-
The maximum number of characters that may appear in a single line of compressed code. Defaults to no maximum length. If set to 0 each line will be the minimum length possible.
25 26 27 |
# File 'lib/yuicompressor.rb', line 25 def compress_css(stream_or_string, ={}, &block) compress(stream_or_string, .merge(:type => 'css'), &block) end |
.compress_js(stream_or_string, options = {}, &block) ⇒ Object
Compress the given JavaScript stream_or_string
using the given options
. Options should be a Hash with any of the following keys:
:line_break
-
The maximum number of characters that may appear in a single line of compressed code. Defaults to no maximum length. If set to 0 each line will be the minimum length possible.
:munge
-
Should be
true
if the compressor should shorten local variable names when possible. Defaults tofalse
. :preserve_semicolons
-
Should be
true
if the compressor should preserve all semicolons in the code. Defaults tofalse
. :optimize
-
Should be
true
if the compressor should enable all micro optimizations. Defaults totrue
.
42 43 44 |
# File 'lib/yuicompressor.rb', line 42 def compress_js(stream_or_string, ={}, &block) compress(stream_or_string, .merge(:type => 'js'), &block) end |
.default_css_options ⇒ Object
:nodoc:
46 47 48 |
# File 'lib/yuicompressor.rb', line 46 def #:nodoc: { :line_break => nil } end |
.default_js_options ⇒ Object
:nodoc:
50 51 52 53 54 55 56 |
# File 'lib/yuicompressor.rb', line 50 def #:nodoc: .merge( :munge => false, :preserve_semicolons => false, :optimize => true ) end |
.jruby? ⇒ Boolean
Returns true
if the Ruby platform is JRuby.
14 15 16 |
# File 'lib/yuicompressor.rb', line 14 def jruby? !! (RUBY_PLATFORM =~ /java/) end |
.streamify(stream_or_string) ⇒ Object
:nodoc:
58 59 60 61 62 63 64 65 66 |
# File 'lib/yuicompressor.rb', line 58 def streamify(stream_or_string) #:nodoc: if IO === stream_or_string || StringIO === stream_or_string stream_or_string elsif String === stream_or_string StringIO.new(stream_or_string.to_s) else raise ArgumentError, 'Stream or string required' end end |