Class: Join::Compressor
- Inherits:
-
Object
show all
- Defined in:
- lib/join/compressor.rb
Overview
Files get sent through the asset compressor to be minified before deployment
Defined Under Namespace
Classes: UnknownTypeError
Instance Method Summary
collapse
Instance Method Details
#compress(type, data) ⇒ Object
12
13
14
15
16
17
18
19
20
|
# File 'lib/join/compressor.rb', line 12
def compress(type, data)
if type == :javascript
compress_javascript(data)
elsif type == :css
compress_css(data)
else
throw UnknownTypeError
end
end
|
#compress_css(data) ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'lib/join/compressor.rb', line 26
def compress_css(data)
data.gsub!(/\s+/, " ")
data.gsub(/\s/, '')
data.gsub!(/\/\*(.*?)\*\//, "")
data.gsub!(/\n$/, "")
data.gsub!(/ \{ /, " {")
data.gsub!(/; \}/, "}")
data
end
|
#compress_javascript(data) ⇒ Object
22
23
24
|
# File 'lib/join/compressor.rb', line 22
def compress_javascript(data)
Closure::Compiler.new.compile(data)
end
|