Module OpenLaszlo
In: lib/openlaszlo/applet.rb
lib/openlaszlo/compiler.rb
lib/openlaszlo/utils.rb

module OpenLaszlo

This module contains utility methods for compiling OpenLaszlo programs.

Example:

  # Set up the environment to use the compile server.  The OpenLaszlo server
  # must be running in order at this location in order for this to work.
  ENV['OPENLASZLO_HOME'] = '/Applications/OpenLaszlo Server 3.1'
  ENV['OPENLASZLO_URL'] = 'http://localhost:8080/lps-3.1'

  require 'openlaszlo'
  # Create a file 'hello.swf' in the current directory:
  OpenLaszlo::compile 'hello.lzx'

See OpenLaszlo.compile for additional documentation.

Methods

Classes and Modules

Class OpenLaszlo::Applet
Class OpenLaszlo::CommandLineCompiler
Class OpenLaszlo::CompilationError
Class OpenLaszlo::CompileServer
Class OpenLaszlo::InvalidSourceLocation

Public Class methods

Compile an OpenLaszlo source file.

Examples:

  require 'openlaszlo'
  OpenLaszlo::compile 'hello.lzx'
  OpenLaszlo::compile 'hello.lzx', :debug => true
  OpenLaszlo::compile 'hello.lzx', :runtime => 'swf8'
  OpenLaszlo::compile 'hello.lzx', :runtime => 'swf8', :debug => true
  OpenLaszlo::compile 'hello.lzx', :output => 'hello-world.swf'

Options are:

  • :debug - debug mode (default false)
  • :output - specify the name and location for the output file (default = input_file.sub(/\.lzx$/, ’.swf’))
  • :proxied - is application proxied (default true)
  • :runtime - runtime (default swf8)

See CompileServer.compile and CommandLineCompiler.compile for additional options that are specific to the compilation methods in those classes.

[Source]

# File lib/openlaszlo/compiler.rb, line 272
  def self.compile(source_file, options={})
    options = options.clone
    options[:runtime] ||= 'swf8'
    compiler.compile(source_file, options)
  rescue InvalidSourceLocation
    CommandLineCompiler.new.compile(source_file, options)
  end

Returns the default compiler. Use the server-based compiler if it‘s available, since it‘s so much faster.

[Source]

# File lib/openlaszlo/compiler.rb, line 234
  def self.compiler
    return @compiler if @compiler
    return @compiler = CompileServer.new if ENV['OPENLASZLO_URL'] and ENV['OPENLASZLO_HOME']
    return @compiler = CommandLineCompiler.new if ENV['OPENLASZLO_HOME']
    raise "Couldn\\'t find an OpenLaszlo compiler.\n\nTo use the compile server (recommended), set ENV['OPENLASZLO_URL'] and ENV['OPENLASZLO_HOME'].\n\nTo use the command-line compiler, set ENV['OPENLASZLO_HOME'].\n"
  end

Sets the default compiler for future invocations of OpenLaszlo.compile.

[Source]

# File lib/openlaszlo/compiler.rb, line 249
  def self.compiler=(compiler)
    @compiler = compiler
  end

Create a symbolic link to source from the OpenLaszlo directory, so that (if allowLinks is enabled) the server compiler can be used on files in this directory. The link will have the same name as the source directory, if name is nil.

[Source]

# File lib/openlaszlo/utils.rb, line 6
  def self.symlink_to(source, name=nil)
    home = ENV['OPENLASZLO_HOME']
    raise "OPENLASZLO_HOME isn't set" unless home
    source = File.expand_path(source)
    name ||= File.basename(source)
    target_dir = Dir[File.join(home, 'Server', 'lps-*')][0]
    raise "Can't find LPS subdirectory in #{home}" unless File.directory?(target_dir)
    target = File.join(target_dir, name)
    if File.exists?(target)
      return if File.ftype(target) == 'link' and File.readlink(target) == source
      raise "#{target} already exists"
    end
    File.symlink source, target
    return target
  end

[Validate]