Class: HerokuDeployment::Packer
- Inherits:
-
Object
- Object
- HerokuDeployment::Packer
- Defined in:
- lib/heroku_deployment/packer.rb
Instance Attribute Summary collapse
-
#compressor ⇒ Object
readonly
Returns the value of attribute compressor.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Class Method Summary collapse
Instance Method Summary collapse
- #compress ⇒ Object
-
#initialize(f, t) ⇒ Packer
constructor
A new instance of Packer.
Constructor Details
#initialize(f, t) ⇒ Packer
Returns a new instance of Packer.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/heroku_deployment/packer.rb', line 20 def initialize(f, t) @file = f if t == :js @compressor = YUI::JavaScriptCompressor.new(:munge => true) elsif t == :css @compressor = YUI::CssCompressor.new else raise "File type '#{t}' is not supported" end end |
Instance Attribute Details
#compressor ⇒ Object (readonly)
Returns the value of attribute compressor.
18 19 20 |
# File 'lib/heroku_deployment/packer.rb', line 18 def compressor @compressor end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
18 19 20 |
# File 'lib/heroku_deployment/packer.rb', line 18 def file @file end |
Class Method Details
.compress_css(file) ⇒ Object
12 13 14 15 |
# File 'lib/heroku_deployment/packer.rb', line 12 def compress_css(file) return unless File.exists?(file) new(file, :css).compress end |
.compress_js(file) ⇒ Object
7 8 9 10 |
# File 'lib/heroku_deployment/packer.rb', line 7 def compress_js(file) return unless File.exists?(file) new(file, :js).compress end |
Instance Method Details
#compress ⇒ Object
31 32 33 34 |
# File 'lib/heroku_deployment/packer.rb', line 31 def compress compressed_content = compressor.compress(readfile) writefile(compressed_content) end |