Class: OpenLaszlo::CompileServer

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

Overview

This class implements a bridge to the compile server.

If you don’t need multiple compilers, you can use the methods in the OpenLaszlo module instead.

CompileServer is faster than CommandLineCompiler, but can only compile files in the same directory as the OpenLaszlo SDK.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CompileServer

Options:

  • :openlaszlo_home - filesystem location of the OpenLaszlo SDK. Defaults to ENV

  • :server_uri - the URI of the server. Defaults to ENV if this is specified, otherwise to ‘localhost:8080/lps-dev’.



36
37
38
39
40
41
# File 'lib/openlaszlo/compiler.rb', line 36

def initialize(options={})
  @home = options[:home] || ENV['OPENLASZLO_HOME']
  dirs = Dir[File.join(@home, 'Server', 'lps-*', 'WEB-INF')]
  @home = File.dirname(dirs.first) if dirs.any?
  @base_url = options[:server_uri] || ENV['OPENLASZLO_URL'] || 'http://localhost:8080/lps-dev'
end

Instance Method Details

#compile(source_file, options = {}) ⇒ Object

Invokes the OpenLaszlo server-based compiler on source_file. source_file must be inside the home directory of the server.

Options:

  • :format - request type (default ‘swf’)

See OpenLaszlo.compile for a description of options.

Raises:



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/openlaszlo/compiler.rb', line 50

def compile(source_file, options={})
  mtime = File.mtime(source_file)
  runtime = options[:runtime] || 'swf8'
  default_output = source_file.sub(/\.lzx/, '') + '.swf'
  output = options[:output] || default_output
  compile_object(source_file, output, options)
  results = (source_file, options)
  raise "Race condition: #{source_file} was modified during compilation" if mtime != File.mtime(source_file)
  raise CompilationError.new(results[:error]) if results[:error]
  results[:output] = output
  return results
end