Sha256: 873082c6dd3e8f8dd1bd400ff4e3bc0441228a8fb0348827eff9e2c8ae146b6c

Contents?: true

Size: 1009 Bytes

Versions: 7

Compression:

Stored size: 1009 Bytes

Contents

require 'sass'
require 'uglifier'
require 'htmlcompressor'

module Alula
  class Compressors
    class DummyCompressor
      def compress(content)
        content
      end
    end
    
    class CSSCompressor
      def compress(content)
        if content.count("\n") > 2
          Sass::Engine.new(content,
            :syntax => :scss,
            :cache => false,
            :read_cache => false,
            :style => :compressed).render
        else
          content
        end
      end
    end
  
    class JSCompressor
      def initialize
        @compressor = Uglifier.new
      end
      
      def compress(content)
        @compressor.compress(content)
      end
    end
    
    class HTMLCompressor
      def initialize
        @compressor = HtmlCompressor::Compressor.new({
          remove_surrounding_spaces: HtmlCompressor::Compressor::BLOCK_TAGS_MAX + ",source",
        })
      end
      
      def compress(content)
        @compressor.compress(content)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
alula-0.4.6 lib/alula/compressors.rb
alula-0.4.5 lib/alula/compressors.rb
alula-0.4.4 lib/alula/compressors.rb
alula-0.4.3 lib/alula/compressors.rb
alula-0.4.2 lib/alula/compressors.rb
alula-0.4.1 lib/alula/compressors.rb
alula-0.4.0 lib/alula/compressors.rb