Sha256: 17181b376c84cb5d6e00671d59627bf2fc05f89db13b4f3302cb1f097852529a

Contents?: true

Size: 884 Bytes

Versions: 2

Compression:

Stored size: 884 Bytes

Contents

require 'tilt'

module Minjs
  class MinjsCompressor < Tilt::Template
    DEBUG = false

    def self.engine_initialized?
      defined?(::Minjs)
    end

    def initialize_engine
    end

    def prepare
    end

    def evaluate(context, locals, &block)
      case context.content_type
      when 'application/javascript'
        if DEBUG
          @@c = 0 unless defined?(@@c)
          puts "start: compressing"
          file = "tmp#{@@c}.js"
          output = "tmp#{@@c}.js.min"
          @@c += 1
          puts "source: #{file}"
          puts "output: #{output}"
          tmp = open(file, "w")
          tmp.write(data)
          tmp.close
        end
        t = Minjs::Compressor.new.compress(data)
        if DEBUG
          tmp = open(output, "w")
          tmp.write(t)
          tmp.close
        end
        t
      else
        data
      end
    end
  end

end


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
minjs-0.1.3 lib/minjs/minjs_compressor.rb
minjs-0.1.2 lib/minjs/minjs_compressor.rb