Sha256: 9f80ec9e049eefe4a708de3fa2d0455958b82a4893508567a03fd3b2ff713988

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 KB

Contents

require "crush/engine"

module Crush
  module YUI
    # Engine implementation the YUI JavaScript
    # compressor. See:
    #
    # https://rubygems.org/gems/yui-compressor
    class JavaScriptCompressor < Crush::Engine
      self.default_mime_type = "application/javascript"
      
      def self.engine_initialized?
        !!(defined?(::YUI) && defined?(::YUI::JavaScriptCompressor))
      end
    
      def initialize_engine
        require_template_library "yui/compressor"
      end
    
      def prepare
        @engine = ::YUI::JavaScriptCompressor.new(options)
        @output = nil
      end
    
      def evaluate(scope, locals, &block)
        @output ||= @engine.compress(data)
      end
    end
    
    # Engine implementation the YUI CSS
    # compressor. See:
    #
    # https://rubygems.org/gems/yui-compressor
    class CssCompressor < Crush::Engine
      self.default_mime_type = "text/css"
      
      def self.engine_initialized?
        !!(defined?(::YUI) && defined?(::YUI::CssCompressor))
      end
    
      def initialize_engine
        require_template_library "yui/compressor"
      end
    
      def prepare
        @engine = ::YUI::CssCompressor.new(options)
        @output = nil
      end
    
      def evaluate(scope, locals, &block)
        @output ||= @engine.compress(data)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
crush-0.3.3 lib/crush/yui.rb
crush-0.3.2 lib/crush/yui.rb
crush-0.3.1 lib/crush/yui.rb