Module: Juicer::Minifyer::JavaBase

Includes:
Binary
Included in:
ClosureCompiler, YuiCompressor
Defined in:
lib/juicer/minifyer/java_base.rb

Overview

Provides an interface to Java based compressor libraries using Juicer::Shell::Binary.

The compressor is invoked using the java binary and the compressor jar file.

Providing the Jar file can be done in several ways. The following directories are searched (in preferred order)

1. The directory specified by the option :bin_path
2. The directory specified by the environment variable, if set
3. Current working directory

Name of environment variable is decided by including classes self.env_name constant.

For more information on how the Jar is located, see Juicer::Minify::JavaMinifyer.locate_jar

Author

Christian Johansen ([email protected])

Copyright

Copyright © 2008-2009 Christian Johansen

License

MIT

Instance Method Summary collapse

Methods included from Binary

#execute, #get_opt, #locate, #method_missing, #options, #path, #set_opt

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Juicer::Binary

Instance Method Details

#commandObject

Constructs the command to use


60
61
62
63
64
65
66
67
68
# File 'lib/juicer/minifyer/java_base.rb', line 60

def command
  java_opts = []
  if ENV['JAVA_OPTS'].nil?
    java_opts = []
  else
    java_opts = ENV['JAVA_OPTS'].split(" ")
  end
  @command = ([@binary] + java_opts).flatten
end

#initialize(options = {}) ⇒ Object


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/juicer/minifyer/java_base.rb', line 34

def initialize(options = {})
  bin = options.delete(:java) || "java"
  bin_path = options.delete(:bin_path) || nil
  @jar = nil
  @jar_args = nil

  super(bin, options)

  if !bin_path.nil?
    if Array === bin_path
      bin_path.each { |p| path << p }
    else
      path << bin_path
    end
  end
end

#jar_argsObject


70
71
72
# File 'lib/juicer/minifyer/java_base.rb', line 70

def jar_args
  @jar_args
end

#set_opts(args) ⇒ Object

Overrides set_opts called from binary class This avoids sending illegal options to the java binary


54
55
56
# File 'lib/juicer/minifyer/java_base.rb', line 54

def set_opts(args)
  @jar_args = " #{args}"
end