Class: Assets::Minify::Compressor
- Inherits:
-
Object
- Object
- Assets::Minify::Compressor
- Defined in:
- lib/assets/minify/compressor.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#file_path ⇒ Object
Returns the value of attribute file_path.
Instance Method Summary collapse
- #css_compress ⇒ Object
- #css_compressor ⇒ Object
-
#initialize(file_path) ⇒ Compressor
constructor
A new instance of Compressor.
- #js_compress ⇒ Object
- #js_compressor ⇒ Object
Constructor Details
#initialize(file_path) ⇒ Compressor
Returns a new instance of Compressor.
8 9 10 11 |
# File 'lib/assets/minify/compressor.rb', line 8 def initialize(file_path) @config = ::Rails.application.config @file_path = file_path end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
6 7 8 |
# File 'lib/assets/minify/compressor.rb', line 6 def config @config end |
#file_path ⇒ Object
Returns the value of attribute file_path.
6 7 8 |
# File 'lib/assets/minify/compressor.rb', line 6 def file_path @file_path end |
Instance Method Details
#css_compress ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/assets/minify/compressor.rb', line 22 def css_compress case css_compressor when :yui, :yui_compressor ::YUI::CssCompressor.new.compress(File.read(@file_path)) when :postcss `npx postcss #{@file_path}` end end |
#css_compressor ⇒ Object
35 36 37 |
# File 'lib/assets/minify/compressor.rb', line 35 def css_compressor @config.css_compressor end |
#js_compress ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/assets/minify/compressor.rb', line 13 def js_compress case js_compressor when :yui, :yui_compressor ::YUI::JavaScriptCompressor.new.compress(File.read(@file_path)) when :terser ::Terser.compile(File.read(@file_path)) end end |
#js_compressor ⇒ Object
31 32 33 |
# File 'lib/assets/minify/compressor.rb', line 31 def js_compressor @config.js_compressor end |