Skip to content
This repository has been archived by the owner on Jun 24, 2018. It is now read-only.

ROpenLaszo is a Ruby interface to the OpenLaszlo compiler. It allows you to compile OpenLaszlo programs from within Ruby, in order to integrate OpenLaszlo development into Rake or Rails applications.

License

osteele/ropenlaszlo

Repository files navigation

ROpenLaszlo: Interface to the OpenLaszlo compiler

ROpenLaszo is a Ruby interface to the OpenLaszlo compiler. It allows you to compile OpenLaszlo programs from within Ruby, in order to integrate OpenLaszlo development into Rake files or Rails applications.

If you are using OpenLaszlo with Ruby on Rails, you want the OpenLaszlo Rails plugin too. That page contains instructions for installing both the gem and the plugin; you can read those instructions instead of these.

Overview

OpenLaszlo programs are written in XML with embedded JavaScript, and compiled into either Flash (swf) binary files, or DHTML. The APIs in this library make it easy for Ruby code to invoke the OpenLaszlo compiler. For example, if hello.lzx contains the following text:

<canvas>
  <window>
    <button>Hello, World!</button>
  </window>
</canvas>

then the following Ruby code can be used to create a file ‘hello.swf’ which can be executed in a browser or placed on a web site:

require 'rubygems'
require 'openlaszlo'
OpenLaszlo::compile 'hello.lzx' # creates hello.swf

You can turn this snippet into a Rake task that will compile any OpenLaszlo source file:

rule '.swf' => '.lzx' do |t|
  puts "Compiling #{t.source} => #{t.name}" if verbose
  OpenLaszlo::compile t.source, :output => t.name
end

The following includes such a task:

require 'openlaszlo'
load 'tasks/openlaszlo.rake'
# defines a pattern *.lzx -> *.swf

Requirements

Installation

0

Download and install the OpenLaszlo SDK

1: Install this gem

$ sudo gem install ropenlaszlo
2

Set your OPENLASZLO_HOME environment variable to the directory that contains the OpenLaszlo SDK. If the following prints something, you’ve got it right:

$ grep Laszlo "$OPENLASZLO_HOME/README.txt"
3

(Optional) Set your OPENLASZLO_URL environment variable to the web location of the OpenLaszlo server; for example, http://localhost:8080/lps-3.1. If you omit this step, the module will use the command line compiler, which is slower but is not limited to compiling files inside of OPENLASZLO_HOME.

Note: The command-line compiler is broken in the Windows version of OpenLaszlo 3.1.1. If you are running Windows, step (3) is required. (OpenLaszlo bug 1428)

Tips

The Ruby front end to the compiler uses two compilation methods. If OPENLASZLO_URL is set, and the source file is in a subdirectory of the OpenLaszlo servlet directory, then the compiler will request the URL that corresponds to the source location. Otherwise, the OpenLaszlo command-line compiler is used.

If the compiler is going to be invoked more than once (because several files are being compiled, or because the compiler is being used in an edit/compile/run cycle), the compile server is faster.

You can place a symbolic link to a source directory in the OpenLaszlo servlet directory thus:

require 'openlaszlo/utils'
OpenLaszlo::symlink_to '.'

Additional Resources

Author

Oliver Steele <steele@osteele.com>

License

ROpenLaszlo is copyright © 2006 - 2009 by Oliver Steele. It is open-source software, and may be redistributed under the terms of the MIT license. The text of this license is included in the ROpenLaszlo distribution.

About

ROpenLaszo is a Ruby interface to the OpenLaszlo compiler. It allows you to compile OpenLaszlo programs from within Ruby, in order to integrate OpenLaszlo development into Rake or Rails applications.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published