Class: Hanami::Assets::Bundler::Compressor Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/assets/bundler/compressor.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Compresses a JS or CSS file

Since:

  • 0.3.0

Constant Summary collapse

JAVASCRIPT_EXT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.0

'.js'.freeze
STYLESHEET_EXT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.0

'.css'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(path, configuration) ⇒ Compressor

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return a new instance

Since:

  • 0.3.0



21
22
23
24
# File 'lib/hanami/assets/bundler/compressor.rb', line 21

def initialize(path, configuration)
  @path = path
  @configuration = configuration
end

Instance Method Details

#compressString?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the compressed contents of the file OR nil if it’s not compressable.

Returns:

  • (String, nil)

    the compressed contents of the file OR nil if it’s not compressable

Since:

  • 0.3.0



30
31
32
33
34
35
# File 'lib/hanami/assets/bundler/compressor.rb', line 30

def compress
  case File.extname(@path)
  when JAVASCRIPT_EXT then _compress(compressor(:js))
  when STYLESHEET_EXT then _compress(compressor(:css))
  end
end