Class: AssetsBooster::Compiler::Uglify

Inherits:
Object
  • Object
show all
Defined in:
lib/assets_booster/compiler/uglify.rb

Instance Method Summary collapse

Instance Method Details

#compile(code) ⇒ Object

Raises:

  • (LoadError)


8
9
10
11
12
13
14
15
16
17
# File 'lib/assets_booster/compiler/uglify.rb', line 8

def compile(code)
  nodejs = %x[which node].strip
  raise LoadError, "You need to install node.js in order to compile using UglifyJS." unless nodejs.length > 1
  np_path = Pathname.new(File.join(File.dirname(__FILE__), 'node-js')).realpath
  IO.popen("#{nodejs} #{np_path}/uglify.js", "r+") do |io|
    io.write(code)
    io.close_write
    io.read
  end
end

#nameObject



4
5
6
# File 'lib/assets_booster/compiler/uglify.rb', line 4

def name
  'UglifyJS running on Node.js'
end