Class: Hanami::Assets::Compressors::SassStylesheet Private

Inherits:
Stylesheet show all
Defined in:
lib/hanami/assets/compressors/sass_stylesheet.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.

Sass compressor for stylesheet

It depends on sass gem.

Constant Summary collapse

SASS_CACHE_LOCATION =

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.

FIXME This is the same logic that we have for Hanami::Assets::Compiler

Since:

  • 0.1.0

Pathname(Hanami.respond_to?(:root) ? # rubocop:disable Style/MultilineTernaryOperator
Hanami.root : Dir.pwd).join('tmp', 'sass-cache')

Instance Method Summary collapse

Methods inherited from Stylesheet

for

Constructor Details

#initializeSassStylesheet

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 a new instance of SassStylesheet.

Since:

  • 0.1.0



25
26
27
# File 'lib/hanami/assets/compressors/sass_stylesheet.rb', line 25

def initialize
  @compressor = Sass::Engine
end

Instance Method Details

#compress(filename) ⇒ Object

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.

Since:

  • 0.1.0



31
32
33
34
# File 'lib/hanami/assets/compressors/sass_stylesheet.rb', line 31

def compress(filename)
  compressor.new(read(filename), filename: filename, syntax: :scss,
                                 style: :compressed, cache_location: SASS_CACHE_LOCATION).render
end