Sha256: 3f0066d2045903dc3d7aeadb34e359718fe379fb19c189349b050a495cbc2029

Contents?: true

Size: 841 Bytes

Versions: 1

Compression:

Stored size: 841 Bytes

Contents

class MiniAsset::Js < MiniAsset::Base

  def content_type
    'text/javascript'
  end

  def asset_join_string
    ";\n"
  end

  def cache_file
    super.sub('.coffee', '.js')
  end

  def compiled_data
    return content if ext == :js

    if ext == :coffee && do_compile?
      coffee_path = './node_modules/coffee-script/bin/coffee'
      coffee_opts = production? ? '-cp' : '-Mcp --no-header'

      run! "#{coffee_path} #{coffee_opts} '#{local_file}' > '#{cache_file}'"

      data = File.read cache_file
      data.gsub!(%r{//#\ssourceURL=[\w\-\.\/]+/app/assets/}, '//# sourceURL=/raw_asset/')
      File.write cache_file, data
    end

    File.read cache_file
  end

  def minify!
    if [:coffee, :js].include?(ext)
      run! `./node_modules/minifier/index.js --output '#{production_file}' '#{production_file}'`
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lux-fw-0.1.17 ./lib/vendor/mini_assets/mini_asset/js.rb