ropenlaszlo 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/doc/CHANGES +10 -4
- data/doc/README +26 -10
- data/doc/TODO +11 -7
- data/lib/compiler.rb +62 -79
- data/test/compiler_test.rb +37 -65
- data/test/{utils.rb → test_utils.rb} +4 -1
- metadata +6 -6
data/doc/CHANGES
CHANGED
@@ -1,17 +1,23 @@
|
|
1
1
|
= Change Log
|
2
2
|
|
3
|
+
== Version 0.4.0 (2006/01/19)
|
4
|
+
* new feature: command-line compiler detects compilation warnings
|
5
|
+
* bug fix: command-line compilation in qualified directory places object in same directory
|
6
|
+
* improve rdoc
|
7
|
+
* refactored unit tests
|
8
|
+
|
3
9
|
== Version 0.3.0 (2006/01/16)
|
4
|
-
* compilation errors and warnings
|
10
|
+
* New feature: compilation errors and warnings
|
11
|
+
* Bug fix: --output doesn't exist; --dir does
|
5
12
|
* refactored test case setup
|
6
13
|
* fixed test case directory
|
7
|
-
* added rdoc task
|
8
|
-
* --output doesn't exist; --dir does
|
14
|
+
* Rakefile: added rdoc task
|
9
15
|
* Updated installation instructions
|
10
16
|
* Fixed rdoc formatting errors
|
11
17
|
|
12
18
|
== Version 0.2.0 (2006/01/11)
|
13
19
|
* Released as gem
|
14
|
-
*
|
20
|
+
* Moved to rubyforge
|
15
21
|
* Added doc directory
|
16
22
|
* Added test directory
|
17
23
|
* Added examples directory
|
data/doc/README
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
= ROpenLaszlo Interface to the OpenLaszlo
|
1
|
+
= ROpenLaszlo: Interface to the OpenLaszlo compiler
|
2
2
|
|
3
|
-
ROpenLaszo is a Ruby interface to the OpenLaszlo[
|
3
|
+
ROpenLaszo is a Ruby interface to the OpenLaszlo[openlaszlo.org] compiler. It allows you to compile Open<tt></tt>Laszlo programs from within Ruby, in order to integrate Open<tt></tt>Laszlo development into Rake or Rails applications.
|
4
4
|
|
5
|
-
|
5
|
+
If you are using Open<tt></tt>Laszlo with Ruby on Rails, you probably want the {OpenLaszlo Rails plugin}[laszlo-plugin.rubyforge.org] instead.
|
6
|
+
|
7
|
+
OpenLaszlo[openlaszlo.org] programs are written in XML with embedded JavaScript, and compiled into Flash (swf) binary files, or DHTML. (As of this writing, the DHTML target is in pre-beta form.) The APIs in this library make it easy for Ruby code to invoke the Open<tt></tt>Laszlo compiler. For example, if hello.lzx contains the following text:
|
6
8
|
<canvas>
|
7
9
|
<window>
|
8
10
|
<button>Hello, World!</button>
|
@@ -13,28 +15,42 @@ then the following Ruby code can be used to create a file 'hello.swf' which can
|
|
13
15
|
require 'ropenlaszlo'
|
14
16
|
OpenLaszlo::compile 'hello.lzx'
|
15
17
|
|
18
|
+
You can turn this into a Rake task that will compile any Open<tt></tt>Laszlo source file:
|
19
|
+
rule '.swf' => '.lzx' do |t|
|
20
|
+
puts "Compiling #{t.source} => #{t.name}" if verbose
|
21
|
+
OpenLaszlo::compile t.source, :output => t.name
|
22
|
+
end
|
23
|
+
|
16
24
|
== Requirements
|
17
25
|
|
18
|
-
* {OpenLaszlo 3.1 or later}[
|
26
|
+
* {OpenLaszlo 3.1 or later}[openlaszlo.org]
|
19
27
|
* Ruby -v 1.8.2 or later (untested in earlier versions)
|
20
|
-
* RubyGems[
|
28
|
+
* RubyGems[rubygems.rubyforge.org]
|
21
29
|
|
22
30
|
== Installation
|
23
31
|
|
24
|
-
0:: Download and install {OpenLaszlo}[
|
32
|
+
0:: Download and install the {OpenLaszlo SDK}[openlaszlo.org]
|
25
33
|
|
26
34
|
1: Install this gem
|
27
35
|
> gem install ropenlaszlo
|
28
36
|
|
29
|
-
2:: Set your +OPENLASZLO_HOME+ environment variable to the directory that contains the {OpenLaszlo SDK}[
|
37
|
+
2:: Set your +OPENLASZLO_HOME+ environment variable to the directory that contains the {OpenLaszlo SDK}[openlaszlo.org]. If the following prints something, you've got it right:
|
30
38
|
> grep Laszlo "$OPENLASZLO_HOME/README.txt"
|
31
39
|
|
32
|
-
|
40
|
+
3:: (Optional) Set your +OPENLASZLO_URL+ environment variable to the web location of the Open<tt></tt>Laszlo server; for example, <tt>http</tt><tt>://localhost:8080/lps-3.1</tt>. 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+.
|
41
|
+
|
42
|
+
== Additional Resources
|
43
|
+
|
44
|
+
* The {OpenLaszlo web site}[openlaszlo.org] is a rich source of information about the Open<tt></tt>Laszlo platform. It includes links to the wiki, mailing lists, and forums.
|
45
|
+
|
46
|
+
* The {Laszlo on Rails}[groups.google.com/group/laszlo-on-rails] news group discusses the integration of Open<tt></tt>Laszlo with Ruby on Rails.
|
47
|
+
|
48
|
+
* The {OpenLaszlo Rails plugin}[laszlo-plugin.rubyforge.org] provides generators and scaffolding for using Open<tt></tt>Laszlo with Ruby on Rails.
|
33
49
|
|
34
|
-
{This OpenLaszlo Blog entry}[
|
50
|
+
* {This OpenLaszlo Blog entry}[weblog.openlaszlo.org/archives/2006/01/deploying-openlaszlo-applications-with-rake/] has additional information and some examples of using ROpenLaszlo in a Rakefile.
|
35
51
|
|
36
52
|
== License
|
37
53
|
|
38
54
|
ROpenLaszlo is copyright (c) 2006 Oliver Steele. It is open-source software, and may be redistributed
|
39
|
-
under the terms of the MIT license. The text of this
|
55
|
+
under the terms of the MIT license. The text of this licence is included in the
|
40
56
|
ROpenLaszlo distribution, under the +doc+ subdirectory.
|
data/doc/TODO
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
= ROpenLaszlo Project -- To Do List
|
2
2
|
|
3
|
-
==
|
4
|
-
*
|
5
|
-
* Compile server: allow use of proxy
|
3
|
+
== Features
|
4
|
+
* Add rake task file
|
5
|
+
* Compile server: allow use of proxy?
|
6
6
|
* Compile server: temporarily copy files into webapp directory
|
7
|
-
*
|
7
|
+
* compile_string
|
8
|
+
* Dependency tracking
|
9
|
+
* query compiler version
|
8
10
|
|
9
11
|
== Unit Tests
|
10
12
|
* Compiler parameters
|
@@ -12,6 +14,8 @@
|
|
12
14
|
* Unreachable server
|
13
15
|
* Invalid OPENLASZLO_HOME
|
14
16
|
|
15
|
-
==
|
16
|
-
*
|
17
|
-
*
|
17
|
+
== Corners
|
18
|
+
* invalid parameters
|
19
|
+
* server isn't running
|
20
|
+
* thinks lps-dev/foo is in lps/ directory
|
21
|
+
|
data/lib/compiler.rb
CHANGED
@@ -1,33 +1,11 @@
|
|
1
1
|
# Author:: Oliver Steele
|
2
2
|
# Copyright:: Copyright (c) 2005-2006 Oliver Steele. All rights reserved.
|
3
3
|
# License:: Ruby License.
|
4
|
-
#
|
5
|
-
# This module contains utility methods for compiling OpenLaszlo[http://openlaszlo.org] programs. See the OpenLaszlo module documentation for usage information.
|
6
|
-
#
|
7
|
-
#--
|
8
|
-
# Bugs:
|
9
|
-
# - syntax error compiles swf anyway
|
10
|
-
#
|
11
|
-
# Todo:
|
12
|
-
# - unit tests
|
13
|
-
# - doc :profile
|
14
|
-
#
|
15
|
-
# Wishlist:
|
16
|
-
# - compile_string
|
17
|
-
# - detect compiler version
|
18
|
-
# - select compiler based on file location; or, copy files
|
19
|
-
# - retrieve dependencies
|
20
|
-
# - retrieve compiler warnings
|
21
|
-
#
|
22
|
-
# Corners:
|
23
|
-
# - detect invalid parameters
|
24
|
-
# - server isn't running
|
25
|
-
# - lps-dev/foo isn't inside lps
|
26
|
-
|
27
4
|
|
28
5
|
# == module OpenLaszlo
|
29
6
|
#
|
30
|
-
# This module contains utility methods for compiling
|
7
|
+
# This module contains utility methods for compiling
|
8
|
+
# OpenLaszlo[openlaszlo.org] programs.
|
31
9
|
#
|
32
10
|
# Example:
|
33
11
|
# # Set up the environment to use the compile server. The OpenLaszlo server
|
@@ -49,28 +27,29 @@ module OpenLaszlo
|
|
49
27
|
# If you don't need multiple compilers, you can use the methods in
|
50
28
|
# the OpenLaszlo module instead.
|
51
29
|
#
|
52
|
-
#
|
53
|
-
# files in the same directory as the
|
30
|
+
# CompileServer is faster than CommandLineCompiler, but can only compile
|
31
|
+
# files in the same directory as the Open<tt></tt>Laszlo SDK.
|
54
32
|
class CompileServer
|
55
33
|
# Options:
|
56
|
-
# * <tt>:openlaszlo_home</tt> - filesystem location of the
|
34
|
+
# * <tt>:openlaszlo_home</tt> - filesystem location of the Open<tt></tt>Laszlo SDK. Defaults to EVN['OPENLASZLO_HOME']
|
57
35
|
# * <tt>:server_uri</tt> - the URI of the server. Defaults to ENV['OPENLASZLO_URL'] if this is specified, otherwise to 'http://localhost:8080/lps-dev'.
|
58
|
-
def initialize
|
59
|
-
@home =
|
60
|
-
@base_url =
|
36
|
+
def initialize options={}
|
37
|
+
@home = options[:home] || ENV['OPENLASZLO_HOME']
|
38
|
+
@base_url = options[:server_uri] || ENV['OPENLASZLO_URL'] || 'http://localhost:8080/lps-dev'
|
61
39
|
end
|
62
40
|
|
63
|
-
# Invokes the
|
64
|
-
# +source_file+ must be inside the home directory
|
65
|
-
#
|
41
|
+
# Invokes the Open<tt></tt>Laszlo server-based compiler on
|
42
|
+
# +source_file+. +source_file+ must be inside the home directory
|
43
|
+
# of the server.
|
66
44
|
#
|
67
|
-
#
|
45
|
+
# Options:
|
68
46
|
# * <tt>:format</tt> - request type (default 'swf')
|
69
|
-
|
47
|
+
# See OpenLaszlo.compile for a description of +options+.
|
48
|
+
def compile source_file, options={}
|
70
49
|
mtime = File.mtime source_file
|
71
|
-
output =
|
72
|
-
compile_object source_file, output,
|
73
|
-
results = request_metadata_for source_file,
|
50
|
+
output = options[:output] || "#{File.expand_path(File.join(File.dirname(source_file), File.basename(source_file, '.lzx')))}.swf"
|
51
|
+
compile_object source_file, output, options
|
52
|
+
results = request_metadata_for source_file, options
|
74
53
|
raise "Race condition: #{source_file} was modified during compilation" if mtime != File.mtime(source_file)
|
75
54
|
results[:output] = output
|
76
55
|
raise CompilationError.new(results[:error]) if results[:error]
|
@@ -78,15 +57,15 @@ module OpenLaszlo
|
|
78
57
|
end
|
79
58
|
|
80
59
|
private
|
81
|
-
def compile_object source_file, object,
|
82
|
-
|
83
|
-
request source_file,
|
60
|
+
def compile_object source_file, object, options={}
|
61
|
+
options = {}.update(options).update(:output => object)
|
62
|
+
request source_file, options
|
84
63
|
end
|
85
64
|
|
86
|
-
def request_metadata_for source_file,
|
65
|
+
def request_metadata_for source_file, options={}
|
87
66
|
results = {}
|
88
|
-
|
89
|
-
text = request source_file,
|
67
|
+
options = {}.update(options).update(:format => 'canvas-xml', :output => nil)
|
68
|
+
text = request source_file, options
|
90
69
|
if text =~ %r{<warnings>(.*?)</warnings>}m
|
91
70
|
results[:warnings] = $1.scan(%r{<error>\s*(.*?)\s*</error>}m).map{|w|w.first}
|
92
71
|
elsif text !~ %r{<canvas>} && text =~ %r{<pre>Error:\s*(.*?)\s*</pre>}m
|
@@ -95,7 +74,8 @@ module OpenLaszlo
|
|
95
74
|
return results
|
96
75
|
end
|
97
76
|
|
98
|
-
def request source_file,
|
77
|
+
def request source_file, options={}
|
78
|
+
output = options[:output]
|
99
79
|
require 'net/http'
|
100
80
|
require 'uri'
|
101
81
|
# assert that pathname is relative to LPS home:
|
@@ -105,12 +85,11 @@ module OpenLaszlo
|
|
105
85
|
# FIXME: this doesn't handle quoting; use recursive File.split instead
|
106
86
|
# FIXME: should encode the url, for filenames that include '/'
|
107
87
|
server_relative_path.gsub(File::Separator, '/')
|
108
|
-
output = params[:output]
|
109
88
|
options = {
|
110
|
-
:lzr =>
|
111
|
-
:debug =>
|
112
|
-
:lzproxied =>
|
113
|
-
:lzt =>
|
89
|
+
:lzr => options[:runtime],
|
90
|
+
:debug => options[:debug],
|
91
|
+
:lzproxied => options.fetch(:proxied, false),
|
92
|
+
:lzt => options[:format] || 'swf'}
|
114
93
|
query = options.map{|k,v|"#{k}=#{v}" unless v.nil?}.compact.join('&')
|
115
94
|
url = "#{@base_url}#{server_relative_path}"
|
116
95
|
url += "?#{query}" unless query.empty?
|
@@ -127,7 +106,7 @@ module OpenLaszlo
|
|
127
106
|
return response.body
|
128
107
|
end
|
129
108
|
else
|
130
|
-
response.value # raises error
|
109
|
+
response.value # for effect: raises error
|
131
110
|
end
|
132
111
|
end
|
133
112
|
end
|
@@ -138,7 +117,7 @@ module OpenLaszlo
|
|
138
117
|
# If you don't need multiple compilers, you can use the methods in
|
139
118
|
# the OpenLaszlo module instead.
|
140
119
|
#
|
141
|
-
#
|
120
|
+
# CommandLineCompiler is slower than CompileServer, but,
|
142
121
|
# unlike the server, it can compile files in any location.
|
143
122
|
class CommandLineCompiler
|
144
123
|
# Creates a new compiler.
|
@@ -147,45 +126,48 @@ module OpenLaszlo
|
|
147
126
|
# * <tt>:compiler_script</tt> - the path to the shell script that
|
148
127
|
# invokes the compiler. This defaults to a standard location inside
|
149
128
|
# the value specified by :home.
|
150
|
-
# * <tt>:openlaszlo_home</tt> - the home directory of the
|
129
|
+
# * <tt>:openlaszlo_home</tt> - the home directory of the Open<tt></tt>Laszlo SDK.
|
151
130
|
# This defaults to ENV['OPENLASZLO_HOME'].
|
152
|
-
def initialize
|
153
|
-
@lzc =
|
131
|
+
def initialize options={}
|
132
|
+
@lzc = options[:compiler_script]
|
154
133
|
unless @lzc
|
155
|
-
home =
|
134
|
+
home = options[:openlaszlo_home] || ENV['OPENLASZLO_HOME']
|
156
135
|
raise ":compiler_script or :openlaszlo_home must be specified" unless home
|
157
136
|
search = lzc_directories.map{|f| File.join(home, f, 'lzc')}
|
158
137
|
found = search.select{|f| File.exists? f}
|
159
138
|
raise "couldn't find bin/lzc in #{search.join(' or ')}" if found.empty?
|
160
139
|
@lzc = found.first
|
161
|
-
# Adjust the name for Windows
|
140
|
+
# Adjust the name for Windows:
|
162
141
|
@lzc += '.bat' if windows?
|
163
142
|
end
|
164
143
|
end
|
165
144
|
|
166
145
|
# Invokes the OpenLaszlo command-line compiler on +source_file+.
|
167
146
|
#
|
168
|
-
# See OpenLaszlo.compile for a description of
|
169
|
-
def compile source_file,
|
170
|
-
default_output = File.
|
171
|
-
|
147
|
+
# See OpenLaszlo.compile for a description of +options+.
|
148
|
+
def compile source_file, options={}
|
149
|
+
default_output = File.join(File.dirname(source_file),
|
150
|
+
File.basename(source_file, '.lzx') + '.swf')
|
151
|
+
output = options[:output] || default_output
|
172
152
|
# TODO: could handle this case by compiling to a temporary directory and
|
173
153
|
# renaming from there
|
174
154
|
raise "#{source_file} and #{output} do not have the same basename." unless File.basename(source_file, '.lzx') == File.basename(output, '.swf')
|
175
155
|
args = []
|
176
|
-
args << '--runtime=#{
|
177
|
-
args << '--debug' if
|
178
|
-
args << '--profile' if
|
156
|
+
args << '--runtime=#{options[:runtime]}' if options[:runtime]
|
157
|
+
args << '--debug' if options[:debug]
|
158
|
+
args << '--profile' if options[:profile]
|
179
159
|
args << "--dir '#{File.dirname output}'" unless File.dirname(source_file) == File.dirname(output)
|
180
160
|
args << source_file
|
181
|
-
|
161
|
+
# The compiler writes errors to stdout, warnings to stderr
|
162
|
+
require "open3"
|
163
|
+
stdin, stdout, stderr = Open3.popen3("#{@lzc} #{args.join(' ')}")
|
164
|
+
text = stdout.read
|
182
165
|
text.gsub!(/^\d+\s+/, '') # work around a bug in OpenLaszlo 3.1
|
183
166
|
results = {:output => output}
|
184
167
|
if text =~ /^Compilation errors occurred:\n/
|
185
168
|
raise CompilationError.new($'.strip)
|
186
169
|
else
|
187
|
-
|
188
|
-
results[:warnings] = text.split("\n")
|
170
|
+
results[:warnings] = stderr.readlines
|
189
171
|
end
|
190
172
|
return results
|
191
173
|
end
|
@@ -226,7 +208,7 @@ EOF
|
|
226
208
|
@compiler = compiler
|
227
209
|
end
|
228
210
|
|
229
|
-
# Compile an OpenLaszlo
|
211
|
+
# Compile an OpenLaszlo source file.
|
230
212
|
#
|
231
213
|
# Examples:
|
232
214
|
# require 'openlaszlo'
|
@@ -234,27 +216,28 @@ EOF
|
|
234
216
|
# OpenLaszlo::compile 'hello.lzx', :debug => true
|
235
217
|
# OpenLaszlo::compile 'hello.lzx', :runtime => 'swf8'
|
236
218
|
# OpenLaszlo::compile 'hello.lzx', {:runtime => 'swf8', :debug => true}
|
237
|
-
# OpenLaszlo::compile 'hello.lzx', :output => 'hello-world.swf'
|
219
|
+
# OpenLaszlo::compile 'hello.lzx', :output => 'hello-world.swf'
|
238
220
|
#
|
239
221
|
# Options are:
|
240
222
|
# * <tt>:debug</tt> - debug mode (default false)
|
241
|
-
# * <tt>:output</tt> - specify the name and location for the output file (default = input_file.sub(/\.lzx$/, '.swf'))
|
223
|
+
# * <tt>:output</tt> - specify the name and location for the output file (default = <tt>input_file.sub(/\.lzx$/, '.swf')</tt>)
|
242
224
|
# * <tt>:proxied</tt> - is application proxied (default true)
|
243
225
|
# * <tt>:runtime</tt> - runtime (default swf7)
|
244
226
|
#
|
245
|
-
# See CompileServer.compile and CommandLineCompiler.compile for
|
246
|
-
# that are specific to
|
247
|
-
|
248
|
-
|
227
|
+
# See CompileServer.compile and CommandLineCompiler.compile for
|
228
|
+
# additional options that are specific to the compilation methods in
|
229
|
+
# those classes.
|
230
|
+
def self.compile source_file, options={}
|
231
|
+
compiler.compile source_file, options
|
249
232
|
end
|
250
233
|
|
251
|
-
def self.make_html source_file,
|
234
|
+
def self.make_html source_file, options={} #:nodoc:
|
252
235
|
raise 'not really supported, for now'
|
253
|
-
|
236
|
+
options = {
|
254
237
|
:format => 'html-object',
|
255
|
-
:output => File.basename(source_file, '.lzx')+'.html'}.update(
|
256
|
-
compiler.compile source_file,
|
257
|
-
source_file =
|
238
|
+
:output => File.basename(source_file, '.lzx')+'.html'}.update(options)
|
239
|
+
compiler.compile source_file, options
|
240
|
+
source_file = options[:output]
|
258
241
|
s = open(source_file).read
|
259
242
|
open(source_file, 'w') {|f| f.write s.gsub!(/\.lzx\?lzt=swf&/, '.lzx.swf?')}
|
260
243
|
end
|
data/test/compiler_test.rb
CHANGED
@@ -1,12 +1,9 @@
|
|
1
|
-
# Author:: Oliver Steele
|
2
|
-
# Copyright:: Copyright (c) 2005-2006 Oliver Steele. All rights reserved.
|
3
|
-
# License:: Ruby License.
|
4
|
-
|
5
1
|
$:.unshift File.dirname(__FILE__) + "/../lib"
|
6
2
|
|
7
3
|
require 'test/unit'
|
8
4
|
require 'ropenlaszlo'
|
9
5
|
require 'fileutils'
|
6
|
+
require File.join(File.dirname(__FILE__), 'test_utils.rb')
|
10
7
|
|
11
8
|
include FileUtils
|
12
9
|
|
@@ -15,33 +12,9 @@ unless REQUIRED_ENV_VALUES.reject {|w| ENV[w]}.empty?
|
|
15
12
|
raise "These environment variables must be set: #{REQUIRED_ENV_VALUES}.join(', ')"
|
16
13
|
end
|
17
14
|
|
18
|
-
class << ENV
|
19
|
-
# Execute a block, restoring the bindings for +keys+ at the end.
|
20
|
-
# NOT thread-safe!
|
21
|
-
def with_saved_bindings keys, &block
|
22
|
-
saved_bindings = Hash[*keys.map {|k| [k, ENV[k]]}.flatten]
|
23
|
-
begin
|
24
|
-
block.call
|
25
|
-
ensure
|
26
|
-
ENV.update saved_bindings
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Execute a block with the temporary bindings in +bindings+.
|
31
|
-
# Doesn't remove keys; simply sets them to nil.
|
32
|
-
def with_bindings bindings, &block
|
33
|
-
with_saved_bindings bindings.keys do
|
34
|
-
ENV.update bindings
|
35
|
-
return block.call
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
# FIXME: should be able to put the test methods in here too
|
41
15
|
module CompilerTestHelper
|
42
|
-
def
|
43
|
-
|
44
|
-
#cd File.expand_path(File.dirname(__FILE__))
|
16
|
+
def self.included(base)
|
17
|
+
base.send(:include, InstanceMethods)
|
45
18
|
end
|
46
19
|
|
47
20
|
private
|
@@ -49,57 +22,66 @@ module CompilerTestHelper
|
|
49
22
|
File.expand_path file, File.dirname(__FILE__)
|
50
23
|
end
|
51
24
|
|
25
|
+
def assert_same_file a, b
|
26
|
+
assert_equal File.expand_path(a), File.expand_path(b)
|
27
|
+
end
|
28
|
+
|
52
29
|
def compile file, output=nil, options={}
|
53
30
|
file = testfile_pathname file
|
54
|
-
output
|
31
|
+
output ||= File.join(File.dirname(file), File.basename(file, '.lzx')+'.swf')
|
55
32
|
rm_f output
|
33
|
+
raise "Unable to remove output file: #{output}" if File.exists?(output)
|
56
34
|
begin
|
57
35
|
result = OpenLaszlo::compile file, *options
|
36
|
+
assert_same_file output, result[:output]
|
58
37
|
assert File.exists?(output), "#{output} does not exist"
|
59
38
|
return result
|
60
39
|
ensure
|
61
40
|
rm_f output
|
62
41
|
end
|
63
42
|
end
|
43
|
+
|
44
|
+
# Tests that are shared between CompilerServerTest and
|
45
|
+
# CommandLineCompilerTest.
|
46
|
+
module InstanceMethods
|
47
|
+
def test_compilation
|
48
|
+
result = compile 'test.lzx'
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_compilation_warning
|
52
|
+
result = compile 'compilation-warning.lzx'
|
53
|
+
assert_instance_of Array, result[:warnings]
|
54
|
+
assert_equal 2, result[:warnings].length
|
55
|
+
assert_match /^compilation-warning.lzx:1:36/, result[:warnings].first
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_compilation_error
|
59
|
+
ex = (compile 'compilation-error.lzx' rescue $!)
|
60
|
+
assert_instance_of OpenLaszlo::CompilationError, ex
|
61
|
+
assert_match /^compilation-error.lzx:3:1: XML document structures must start and end within the same entity./, ex.message
|
62
|
+
end
|
63
|
+
end
|
64
64
|
end
|
65
65
|
|
66
66
|
class CompileServerTest < Test::Unit::TestCase
|
67
67
|
include CompilerTestHelper
|
68
68
|
|
69
69
|
def setup
|
70
|
-
|
70
|
+
OpenLaszlo::compiler = nil
|
71
|
+
@test_dir = File.join(ENV['OPENLASZLO_HOME'], 'tmp/ropenlaszlo-tests')
|
71
72
|
mkdir @test_dir
|
72
|
-
super_setup
|
73
73
|
end
|
74
74
|
|
75
75
|
def teardown
|
76
|
+
OpenLaszlo::compiler = nil
|
76
77
|
rm_rf @test_dir
|
77
78
|
end
|
78
|
-
|
79
|
-
def test_compilation
|
80
|
-
result = compile 'test.lzx'
|
81
|
-
assert_equal 'test.swf', result[:output]
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_compilation_error
|
85
|
-
#assert_raise(OpenLaszlo::CompilationError) {compile 'compilation-error.lzx'}
|
86
|
-
ex = (compile 'compilation-error.lzx' rescue $!)
|
87
|
-
assert_instance_of OpenLaszlo::CompilationError, ex
|
88
|
-
assert_match /^compilation-error.lzx:3:1: XML document structures must start and end within the same entity./, ex.message
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_compilation_warning
|
92
|
-
result = compile 'compilation-warning.lzx'
|
93
|
-
assert_equal 'compilation-warning.swf', result[:output]
|
94
|
-
assert_instance_of Array, result[:warnings]
|
95
|
-
assert_equal 2, result[:warnings].length
|
96
|
-
assert_match /^compilation-warning.lzx:1:36/, result[:warnings].first
|
97
|
-
end
|
98
79
|
|
99
80
|
private
|
100
81
|
alias :saved_compile :compile
|
101
82
|
|
102
83
|
def compile file, output=nil, options={}
|
84
|
+
raise "unimplemented" if output
|
103
85
|
file = testfile_pathname file
|
104
86
|
server_local_file = File.join @test_dir, File.basename(file)
|
105
87
|
cp file, server_local_file
|
@@ -115,7 +97,7 @@ class CommandLineCompilerTest < Test::Unit::TestCase
|
|
115
97
|
include CompilerTestHelper
|
116
98
|
|
117
99
|
def setup
|
118
|
-
|
100
|
+
OpenLaszlo::compiler = nil
|
119
101
|
callcc do |exit|
|
120
102
|
resume = nil
|
121
103
|
ENV.with_bindings 'OPENLASZLO_URL' => nil do
|
@@ -129,19 +111,9 @@ class CommandLineCompilerTest < Test::Unit::TestCase
|
|
129
111
|
end
|
130
112
|
|
131
113
|
def teardown
|
114
|
+
OpenLaszlo::compiler = nil
|
132
115
|
callcc do |continue| @teardown.call(continue) end
|
133
116
|
end
|
134
|
-
|
135
|
-
def test_compilation
|
136
|
-
result = compile 'test.lzx'
|
137
|
-
assert_equal 'test.swf', result[:output]
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_compilation_error
|
141
|
-
ex = (compile 'compilation-error.lzx' rescue $!)
|
142
|
-
assert_instance_of OpenLaszlo::CompilationError, ex
|
143
|
-
assert_match /^compilation-error.lzx:3:1: XML document structures must start and end within the same entity./, ex.message
|
144
|
-
end
|
145
117
|
end
|
146
118
|
|
147
119
|
class CompilerFacadeTest < Test::Unit::TestCase
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# Author:: Oliver Steele
|
2
|
+
# Copyright:: Copyright (c) 2005-2006 Oliver Steele. All rights reserved.
|
3
|
+
# License:: Ruby License.
|
4
|
+
|
1
5
|
class << ENV
|
2
6
|
# Execute a block, restoring the bindings for +keys+ at the end.
|
3
7
|
# NOT thread-safe!
|
@@ -19,4 +23,3 @@ class << ENV
|
|
19
23
|
end
|
20
24
|
end
|
21
25
|
end
|
22
|
-
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: ropenlaszlo
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2006-01-
|
6
|
+
version: 0.4.0
|
7
|
+
date: 2006-01-19 00:00:00 -05:00
|
8
8
|
summary: Ruby interface to OpenLaszlo.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -38,14 +38,14 @@ files:
|
|
38
38
|
- test/compilation-warning.lzx
|
39
39
|
- test/compiler_test.rb
|
40
40
|
- test/test.lzx
|
41
|
-
- test/
|
41
|
+
- test/test_utils.rb
|
42
42
|
test_files: []
|
43
43
|
|
44
44
|
rdoc_options:
|
45
45
|
- --title
|
46
|
-
- "ROpenLaszlo: Ruby interface to OpenLaszlo
|
47
|
-
- --
|
48
|
-
-
|
46
|
+
- "ROpenLaszlo: Ruby interface to OpenLaszlo"
|
47
|
+
- --exclude
|
48
|
+
- test/.*
|
49
49
|
extra_rdoc_files:
|
50
50
|
- doc/CHANGES
|
51
51
|
- doc/MIT-LICENSE
|