Module: UnifiedAssets::Minifier
- Defined in:
- lib/unified_assets/minifier.rb
Class Attribute Summary collapse
-
.enabled ⇒ Object
Returns the value of attribute enabled.
-
.extensions ⇒ Object
Returns the value of attribute extensions.
-
.jarfile ⇒ Object
Returns the value of attribute jarfile.
Class Method Summary collapse
- .available? ⇒ Boolean
- .enabled?(name = nil) ⇒ Boolean
- .minified_name(name) ⇒ Object
- .minify(name) ⇒ Object
Class Attribute Details
.enabled ⇒ Object
Returns the value of attribute enabled.
5 6 7 |
# File 'lib/unified_assets/minifier.rb', line 5 def enabled @enabled end |
.extensions ⇒ Object
Returns the value of attribute extensions.
6 7 8 |
# File 'lib/unified_assets/minifier.rb', line 6 def extensions @extensions end |
.jarfile ⇒ Object
Returns the value of attribute jarfile.
7 8 9 |
# File 'lib/unified_assets/minifier.rb', line 7 def jarfile @jarfile end |
Class Method Details
.available? ⇒ Boolean
13 14 15 |
# File 'lib/unified_assets/minifier.rb', line 13 def self.available? @available ||= !`which java`.empty? # warning: linux only way of checking if java is available end |
.enabled?(name = nil) ⇒ Boolean
17 18 19 |
# File 'lib/unified_assets/minifier.rb', line 17 def self.enabled?(name = nil) enabled && available? && (name.nil? || extensions.include?(File.extname(name))) end |
.minified_name(name) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/unified_assets/minifier.rb', line 21 def self.minified_name(name) if enabled?(name) ext = File.extname(name) name.sub(ext, ".min#{ext}") else name end end |
.minify(name) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/unified_assets/minifier.rb', line 30 def self.minify(name) if name && enabled?(name) && File.exists?(name) minified_name = minified_name(name) `java -jar "#{jarfile}" "#{name}" -o "#{minified_name}"` end end |