ropenlaszlo 0.4.1 → 0.5
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 → CHANGES} +20 -5
- data/{doc/MIT-LICENSE → LICENSE} +1 -1
- data/Manifest +20 -0
- data/{doc/README → README} +14 -2
- data/{doc/TODO → TODO} +5 -6
- data/examples/compile_hello.rb +4 -0
- data/examples/hello.lzx +5 -0
- data/install.rb +0 -0
- data/lib/openlaszlo/applet.rb +81 -0
- data/lib/{compiler.rb → openlaszlo/compiler.rb} +79 -51
- data/lib/openlaszlo.rb +1 -0
- data/lib/ropenlaszlo.rb +1 -1
- data/lib/tasks/openlaszlo.rake +6 -0
- data/ropenlaszlo.gemspec +53 -0
- data/test/compiler_test.rb +1 -1
- data/test/tasks/Rakefile +2 -0
- data/test/tasks/test.lzx +1 -0
- metadata +27 -14
data/{doc/CHANGES → CHANGES}
RENAMED
@@ -1,17 +1,30 @@
|
|
1
1
|
= Change Log
|
2
2
|
|
3
|
-
== Version 0.
|
3
|
+
== Version 0.5 (2008-04-01)
|
4
|
+
* compatible with OpenLaszlo 4.0
|
5
|
+
* reorganize directory structure
|
6
|
+
* new rake task file
|
7
|
+
* follow symbolic links
|
8
|
+
* fall back to cmd-line compiler if source file is not in web path
|
9
|
+
* raise error when lzc is not executable
|
10
|
+
* change default runtime to swf8
|
11
|
+
* switch to echoe for packaging
|
12
|
+
|
13
|
+
|
14
|
+
== Version 0.4.1 (2006-01-25)
|
4
15
|
* bug fix: don't use popen on Windows
|
5
16
|
* bug fix: default LPS_HOME from OPENLASZLO_HOME
|
6
17
|
* added note about OpenLaszlo windows bug
|
7
18
|
|
8
|
-
|
19
|
+
|
20
|
+
== Version 0.4.0 (2006-01-19)
|
9
21
|
* new feature: command-line compiler detects compilation warnings
|
10
22
|
* bug fix: command-line compilation in qualified directory places object in same directory
|
11
23
|
* improve rdoc
|
12
24
|
* refactored unit tests
|
13
25
|
|
14
|
-
|
26
|
+
|
27
|
+
== Version 0.3.0 (2006-01-16)
|
15
28
|
* New feature: compilation errors and warnings
|
16
29
|
* Bug fix: --output doesn't exist; --dir does
|
17
30
|
* refactored test case setup
|
@@ -20,14 +33,16 @@
|
|
20
33
|
* Updated installation instructions
|
21
34
|
* Fixed rdoc formatting errors
|
22
35
|
|
23
|
-
|
36
|
+
|
37
|
+
== Version 0.2.0 (2006-01-11)
|
24
38
|
* Released as gem
|
25
39
|
* Moved to rubyforge
|
26
40
|
* Added doc directory
|
27
41
|
* Added test directory
|
28
42
|
* Added examples directory
|
29
43
|
|
30
|
-
|
44
|
+
|
45
|
+
== Version 0.1.0 (2006-01-04)
|
31
46
|
* Initial release
|
32
47
|
* Published to osteele.com
|
33
48
|
* Announced on weblog.openlaszlo.org
|
data/{doc/MIT-LICENSE → LICENSE}
RENAMED
data/Manifest
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
CHANGES
|
2
|
+
examples/compile_hello.rb
|
3
|
+
examples/hello.lzx
|
4
|
+
install.rb
|
5
|
+
lib/openlaszlo/applet.rb
|
6
|
+
lib/openlaszlo/compiler.rb
|
7
|
+
lib/openlaszlo.rb
|
8
|
+
lib/ropenlaszlo.rb
|
9
|
+
lib/tasks/openlaszlo.rake
|
10
|
+
LICENSE
|
11
|
+
Manifest
|
12
|
+
README
|
13
|
+
test/compilation-error.lzx
|
14
|
+
test/compilation-warning.lzx
|
15
|
+
test/compiler_test.rb
|
16
|
+
test/tasks/Rakefile
|
17
|
+
test/tasks/test.lzx
|
18
|
+
test/test.lzx
|
19
|
+
test/test_utils.rb
|
20
|
+
TODO
|
data/{doc/README → README}
RENAMED
@@ -12,8 +12,8 @@ OpenLaszlo[openlaszlo.org] programs are written in XML with embedded JavaScript,
|
|
12
12
|
</canvas>
|
13
13
|
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:
|
14
14
|
require 'rubygems'
|
15
|
-
require '
|
16
|
-
OpenLaszlo::compile 'hello.lzx'
|
15
|
+
require 'openlaszlo'
|
16
|
+
OpenLaszlo::compile 'hello.lzx' # creates hello.swf
|
17
17
|
|
18
18
|
You can turn this into a Rake task that will compile any Open<tt></tt>Laszlo source file:
|
19
19
|
rule '.swf' => '.lzx' do |t|
|
@@ -21,6 +21,11 @@ You can turn this into a Rake task that will compile any Open<tt></tt>Laszlo sou
|
|
21
21
|
OpenLaszlo::compile t.source, :output => t.name
|
22
22
|
end
|
23
23
|
|
24
|
+
The following includes such a task:
|
25
|
+
require 'openlaszlo'
|
26
|
+
load 'tasks/openlaszlo.rake'
|
27
|
+
# defines a pattern *.lzx -> *.swf
|
28
|
+
|
24
29
|
== Requirements
|
25
30
|
|
26
31
|
* {OpenLaszlo 3.1 or later}[openlaszlo.org]
|
@@ -53,6 +58,13 @@ You can turn this into a Rake task that will compile any Open<tt></tt>Laszlo sou
|
|
53
58
|
|
54
59
|
* The RubyForge project page is here[http://rubyforge.org/projects/ropenlaszlo/].
|
55
60
|
|
61
|
+
|
62
|
+
== Author
|
63
|
+
|
64
|
+
Oliver Steele
|
65
|
+
steele@osteele.com
|
66
|
+
|
67
|
+
|
56
68
|
== License
|
57
69
|
|
58
70
|
ROpenLaszlo is copyright (c) 2006 Oliver Steele. It is open-source software, and may be redistributed
|
data/{doc/TODO → TODO}
RENAMED
@@ -1,21 +1,20 @@
|
|
1
1
|
= ROpenLaszlo Project -- To Do List
|
2
2
|
|
3
3
|
== Features
|
4
|
-
*
|
5
|
-
* Compile server:
|
6
|
-
*
|
4
|
+
* Compiler server: test whether allow_links=true
|
5
|
+
* Compile server: add alias to source directory
|
6
|
+
* Dependency tracking: switch to hpricot
|
7
7
|
* compile_string
|
8
|
-
* Dependency tracking
|
9
8
|
* query compiler version
|
10
9
|
|
11
10
|
== Unit Tests
|
11
|
+
* "Runtime" option
|
12
|
+
* Fallback to command-line compiler
|
12
13
|
* Compiler parameters
|
13
14
|
* Missing source file
|
14
15
|
* Unreachable server
|
15
16
|
* Invalid OPENLASZLO_HOME
|
16
17
|
|
17
18
|
== Corners
|
18
|
-
* invalid parameters
|
19
19
|
* server isn't running
|
20
20
|
* thinks lps-dev/foo is in lps/ directory
|
21
|
-
|
data/examples/hello.lzx
ADDED
data/install.rb
ADDED
File without changes
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# Author:: Oliver Steele
|
2
|
+
# Copyright:: Copyright (c) 2005-2008 Oliver Steele. All rights reserved.
|
3
|
+
# License:: MIT License
|
4
|
+
module OpenLaszlo
|
5
|
+
class Applet
|
6
|
+
attr_reader :source
|
7
|
+
|
8
|
+
def initialize(source)
|
9
|
+
source = source + '.lzx' unless source =~ /\.lzx$/
|
10
|
+
@source = source
|
11
|
+
end
|
12
|
+
|
13
|
+
def source_dir
|
14
|
+
File.dirname(source)
|
15
|
+
end
|
16
|
+
|
17
|
+
def compile(target=nil, options={})
|
18
|
+
target ||= source + '.swf'
|
19
|
+
return if up2date?(target) unless options[:force]
|
20
|
+
|
21
|
+
puts "Compiling #{source} -> #{target}" if options[:verbose]
|
22
|
+
OpenLaszlo::compile(source, options)
|
23
|
+
end
|
24
|
+
|
25
|
+
def up2date?(target=nil)
|
26
|
+
target ||= source + '.swf'
|
27
|
+
return false unless File.exists?(target)
|
28
|
+
sources = Dir["#{source_dir}/**/*"].reject { |fname| fname =~ /\.lzx\.swf/ } -
|
29
|
+
Dir["#{source_dir}/build/**/*"]
|
30
|
+
source_mtime = sources.
|
31
|
+
# the 'rescue' ignores symbolic links without targets
|
32
|
+
map { |f| File.mtime(f) rescue nil }.
|
33
|
+
compact.
|
34
|
+
max
|
35
|
+
source_mtime < File.mtime(target)
|
36
|
+
end
|
37
|
+
|
38
|
+
def runtime_assets
|
39
|
+
dir = File.dirname(source)
|
40
|
+
includes = `grep -h http: #{dir}/*.lzx`.scan(/http:(.*?)['"]/).
|
41
|
+
map(&:first)
|
42
|
+
includes += `grep -h http: #{dir}/*/*.lzx`.scan(/http:(.*?)['"]/).
|
43
|
+
map(&:first).
|
44
|
+
map { |s| s.sub(/^\.\.\//, '') }
|
45
|
+
return includes.
|
46
|
+
uniq.
|
47
|
+
map { |f| File.join(dir, f) }.
|
48
|
+
select { |src| File.exists?(src) && File.ftype(src) != 'directory' }
|
49
|
+
end
|
50
|
+
|
51
|
+
def preprocess_to(dir, options={})
|
52
|
+
files = Dir[File.join(source_dir, '**/*.js')] - Dir[File.join(source_dir, '.hg')]
|
53
|
+
files.each do |src|
|
54
|
+
dst = File.join(dir, src.sub(source_dir, ''))
|
55
|
+
next if File.exists?(dst) and (!options[:force] and File.mtime(dst) > File.mtime(src))
|
56
|
+
puts "Copy #{src} #{dst}"
|
57
|
+
content = preprocess_string(open(src).read)
|
58
|
+
open(dst, 'w') do |fo| fo << content end
|
59
|
+
end.length
|
60
|
+
end
|
61
|
+
|
62
|
+
def preprocess_string(content)
|
63
|
+
re = /^\s*([a-zA-Z][a-zA-Z0=9]*)\.each\(function\(([a-zA-Z][a-zA-Z0-9]*)\)\{(.*?)}\);/m
|
64
|
+
content.gsub!(re) do |s|
|
65
|
+
target, var, body = s.match(re).captures
|
66
|
+
"var $0=#{target}, $1=$0.length;for(var $2=0; $1--;){var #{var}=$0[$2++];#{body}}"
|
67
|
+
end
|
68
|
+
return content
|
69
|
+
end
|
70
|
+
|
71
|
+
#
|
72
|
+
# Class methods
|
73
|
+
#
|
74
|
+
|
75
|
+
def self.compile(basename, target, options={})
|
76
|
+
source = "lzx/#{basename}"
|
77
|
+
target = "public/#{target}"
|
78
|
+
self.new(source).compile(target, options)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# Author:: Oliver Steele
|
2
|
-
# Copyright:: Copyright (c) 2005-
|
3
|
-
# License::
|
4
|
-
|
2
|
+
# Copyright:: Copyright (c) 2005-2008 Oliver Steele. All rights reserved.
|
3
|
+
# License:: MIT License
|
4
|
+
|
5
5
|
# == module OpenLaszlo
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# This module contains utility methods for compiling
|
8
8
|
# OpenLaszlo[openlaszlo.org] programs.
|
9
9
|
#
|
@@ -18,10 +18,11 @@
|
|
18
18
|
# OpenLaszlo::compile 'hello.lzx'
|
19
19
|
#
|
20
20
|
# See OpenLaszlo.compile for additional documentation.
|
21
|
-
#
|
21
|
+
#
|
22
22
|
module OpenLaszlo
|
23
23
|
class CompilationError < StandardError; end
|
24
|
-
|
24
|
+
class InvalidSourceLocation < StandardError; end
|
25
|
+
|
25
26
|
# This class implements a bridge to the compile server.
|
26
27
|
#
|
27
28
|
# If you don't need multiple compilers, you can use the methods in
|
@@ -33,11 +34,11 @@ module OpenLaszlo
|
|
33
34
|
# Options:
|
34
35
|
# * <tt>:openlaszlo_home</tt> - filesystem location of the Open<tt></tt>Laszlo SDK. Defaults to EVN['OPENLASZLO_HOME']
|
35
36
|
# * <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'.
|
36
|
-
def initialize
|
37
|
+
def initialize(options={})
|
37
38
|
@home = options[:home] || ENV['OPENLASZLO_HOME']
|
38
39
|
@base_url = options[:server_uri] || ENV['OPENLASZLO_URL'] || 'http://localhost:8080/lps-dev'
|
39
40
|
end
|
40
|
-
|
41
|
+
|
41
42
|
# Invokes the Open<tt></tt>Laszlo server-based compiler on
|
42
43
|
# +source_file+. +source_file+ must be inside the home directory
|
43
44
|
# of the server.
|
@@ -45,7 +46,7 @@ module OpenLaszlo
|
|
45
46
|
# Options:
|
46
47
|
# * <tt>:format</tt> - request type (default 'swf')
|
47
48
|
# See OpenLaszlo.compile for a description of +options+.
|
48
|
-
def compile
|
49
|
+
def compile(source_file, options={})
|
49
50
|
mtime = File.mtime source_file
|
50
51
|
output = options[:output] || "#{File.expand_path(File.join(File.dirname(source_file), File.basename(source_file, '.lzx')))}.swf"
|
51
52
|
compile_object source_file, output, options
|
@@ -55,42 +56,54 @@ module OpenLaszlo
|
|
55
56
|
raise CompilationError.new(results[:error]) if results[:error]
|
56
57
|
return results
|
57
58
|
end
|
58
|
-
|
59
|
+
|
59
60
|
private
|
60
|
-
def compile_object
|
61
|
+
def compile_object(source_file, object, options={})
|
61
62
|
options = {}.update(options).update(:output => object)
|
62
63
|
request source_file, options
|
63
64
|
end
|
64
|
-
|
65
|
-
def request_metadata_for
|
65
|
+
|
66
|
+
def request_metadata_for(source_file, options={})
|
66
67
|
results = {}
|
67
68
|
options = {}.update(options).update(:format => 'canvas-xml', :output => nil)
|
68
69
|
text = request source_file, options
|
69
70
|
if text =~ %r{<warnings>(.*?)</warnings>}m
|
70
|
-
results[:warnings] = $1.scan(%r{<error>\s*(.*?)\s*</error>}m).map{|w|w.first}
|
71
|
+
results[:warnings] = $1.scan(%r{<error>\s*(.*?)\s*</error>}m).map { |w| w.first }
|
71
72
|
elsif text !~ %r{<canvas>} && text =~ %r{<pre>Error:\s*(.*?)\s*</pre>}m
|
72
73
|
results[:error] = $1
|
73
74
|
end
|
74
75
|
return results
|
75
76
|
end
|
76
|
-
|
77
|
-
def request
|
77
|
+
|
78
|
+
def request(source_file, options={})
|
78
79
|
output = options[:output]
|
79
80
|
require 'net/http'
|
80
81
|
require 'uri'
|
81
82
|
# assert that pathname is relative to LPS home:
|
82
83
|
absolute_path = File.expand_path source_file
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
84
|
+
server_relative_path = nil
|
85
|
+
begin
|
86
|
+
# follow links
|
87
|
+
server_relative_path = Dir[File.join(@home, '*')].map do |file|
|
88
|
+
next unless File.ftype(file) == 'link'
|
89
|
+
dir = File.readlink(file)
|
90
|
+
next unless absolute_path.index(dir) == 0
|
91
|
+
File.join('/', File.basename(file), absolute_path[dir.length..-1])
|
92
|
+
end.compact.first
|
93
|
+
end
|
94
|
+
unless server_relative_path
|
95
|
+
raise InvalidSourceLocation.new("#{absolute_path} isn't inside #{@home}") unless absolute_path.index(@home) == 0
|
96
|
+
server_relative_path = absolute_path[@home.length..-1]
|
97
|
+
# FIXME: this doesn't handle quoting; use recursive File.split instead
|
98
|
+
# FIXME: should encode the url, for filenames that include '/'
|
99
|
+
server_relative_path.gsub(File::Separator, '/')
|
100
|
+
end
|
88
101
|
options = {
|
89
102
|
:lzr => options[:runtime],
|
90
103
|
:debug => options[:debug],
|
91
104
|
:lzproxied => options.fetch(:proxied, false),
|
92
105
|
:lzt => options[:format] || 'swf'}
|
93
|
-
query = options.map{|k,v|"#{k}=#{v}" unless v.nil?}.compact.join('&')
|
106
|
+
query = options.map { |k,v| "#{k}=#{v}" unless v.nil? }.compact.join('&')
|
94
107
|
url = "#{@base_url}#{server_relative_path}"
|
95
108
|
url += "?#{query}" unless query.empty?
|
96
109
|
Net::HTTP.get_response URI.parse(url) do |response|
|
@@ -111,7 +124,7 @@ module OpenLaszlo
|
|
111
124
|
end
|
112
125
|
end
|
113
126
|
end
|
114
|
-
|
127
|
+
|
115
128
|
# This class implements a bridge to the command-line compiler.
|
116
129
|
#
|
117
130
|
# If you don't need multiple compilers, you can use the methods in
|
@@ -128,29 +141,32 @@ module OpenLaszlo
|
|
128
141
|
# the value specified by :home.
|
129
142
|
# * <tt>:openlaszlo_home</tt> - the home directory of the Open<tt></tt>Laszlo SDK.
|
130
143
|
# This defaults to ENV['OPENLASZLO_HOME'].
|
131
|
-
def initialize
|
132
|
-
@lzc = options[:compiler_script]
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
144
|
+
def initialize(options={})
|
145
|
+
@lzc = options[:compiler_script] || self.class.executable_path(options)
|
146
|
+
end
|
147
|
+
|
148
|
+
def self.executable_path(options={})
|
149
|
+
home = options[:openlaszlo_home] || ENV['OPENLASZLO_HOME']
|
150
|
+
raise ":compiler_script or OPENLASZLO_HOME must be specified" unless home
|
151
|
+
path = bin_directories.
|
152
|
+
map { |f| File.join(home, f, 'lzc') }.
|
153
|
+
select { |f| File.exists? f }.
|
154
|
+
first
|
155
|
+
raise "couldn't find bin/lzc in #{bin_directories.join(' or ')}" unless path
|
156
|
+
path += '.bat' if windows?
|
157
|
+
return path
|
142
158
|
end
|
143
159
|
|
144
160
|
# Invokes the OpenLaszlo command-line compiler on +source_file+.
|
145
161
|
#
|
146
162
|
# See OpenLaszlo.compile for a description of +options+.
|
147
|
-
def compile
|
163
|
+
def compile(source_file, options={})
|
148
164
|
default_output = File.join(File.dirname(source_file),
|
149
165
|
File.basename(source_file, '.lzx') + '.swf')
|
150
166
|
output = options[:output] || default_output
|
151
167
|
raise "#{source_file} and #{output} do not have the same basename." unless File.basename(source_file, '.lzx') == File.basename(output, '.swf')
|
152
168
|
args = []
|
153
|
-
args <<
|
169
|
+
args << "--runtime=#{options[:runtime]}" if options[:runtime]
|
154
170
|
args << '--debug' if options[:debug]
|
155
171
|
args << '--profile' if options[:profile]
|
156
172
|
args << "--dir '#{File.dirname output}'" unless File.dirname(source_file) == File.dirname(output)
|
@@ -164,6 +180,12 @@ module OpenLaszlo
|
|
164
180
|
stdin, stdout, stderr = Open3.popen3(command)
|
165
181
|
errors = stdout.read
|
166
182
|
warnings = stderr.readlines
|
183
|
+
raise warnings.join("\n") if warnings.first =~ /^sh:/
|
184
|
+
# OpenLaszlo 4.0:
|
185
|
+
if warnings.first =~ /Compiling:.* to (\S+)/
|
186
|
+
warnings.shift
|
187
|
+
File.rename($1, output) if File.exists?($1)
|
188
|
+
end
|
167
189
|
rescue NotImplementedError
|
168
190
|
# Windows doesn't have popen
|
169
191
|
errors = `#{command}`
|
@@ -176,23 +198,23 @@ module OpenLaszlo
|
|
176
198
|
results = {:output => output, :warnings => warnings}
|
177
199
|
return results
|
178
200
|
end
|
179
|
-
|
201
|
+
|
180
202
|
private
|
181
|
-
|
203
|
+
|
182
204
|
# Locations in which to look for the lzc script, relative to OPENLASZLO_HOME
|
183
|
-
def bin_directories
|
205
|
+
def self.bin_directories
|
184
206
|
[# binary distro location
|
185
207
|
'bin',
|
186
208
|
# source distro location
|
187
209
|
'WEB-INF/lps/server/bin'
|
188
210
|
]
|
189
211
|
end
|
190
|
-
|
191
|
-
def windows?
|
212
|
+
|
213
|
+
def self.windows?
|
192
214
|
RUBY_PLATFORM =~ /win/ and not RUBY_PLATFORM =~ /darwin/
|
193
215
|
end
|
194
216
|
end
|
195
|
-
|
217
|
+
|
196
218
|
# Returns the default compiler. Use the server-based compiler if it's
|
197
219
|
# available, since it's so much faster.
|
198
220
|
def self.compiler
|
@@ -207,12 +229,12 @@ To use the compile server (recommended), set ENV['OPENLASZLO_URL'] and ENV['OPEN
|
|
207
229
|
To use the command-line compiler, set ENV['OPENLASZLO_HOME'].
|
208
230
|
EOF
|
209
231
|
end
|
210
|
-
|
232
|
+
|
211
233
|
# Sets the default compiler for future invocations of OpenLaszlo.compile.
|
212
234
|
def self.compiler= compiler
|
213
235
|
@compiler = compiler
|
214
236
|
end
|
215
|
-
|
237
|
+
|
216
238
|
# Compile an OpenLaszlo source file.
|
217
239
|
#
|
218
240
|
# Examples:
|
@@ -220,23 +242,27 @@ EOF
|
|
220
242
|
# OpenLaszlo::compile 'hello.lzx'
|
221
243
|
# OpenLaszlo::compile 'hello.lzx', :debug => true
|
222
244
|
# OpenLaszlo::compile 'hello.lzx', :runtime => 'swf8'
|
223
|
-
# OpenLaszlo::compile 'hello.lzx',
|
245
|
+
# OpenLaszlo::compile 'hello.lzx', :runtime => 'swf8', :debug => true
|
224
246
|
# OpenLaszlo::compile 'hello.lzx', :output => 'hello-world.swf'
|
225
247
|
#
|
226
248
|
# Options are:
|
227
249
|
# * <tt>:debug</tt> - debug mode (default false)
|
228
250
|
# * <tt>:output</tt> - specify the name and location for the output file (default = <tt>input_file.sub(/\.lzx$/, '.swf')</tt>)
|
229
251
|
# * <tt>:proxied</tt> - is application proxied (default true)
|
230
|
-
# * <tt>:runtime</tt> - runtime (default
|
252
|
+
# * <tt>:runtime</tt> - runtime (default swf8)
|
231
253
|
#
|
232
254
|
# See CompileServer.compile and CommandLineCompiler.compile for
|
233
255
|
# additional options that are specific to the compilation methods in
|
234
256
|
# those classes.
|
235
|
-
def self.compile
|
236
|
-
|
257
|
+
def self.compile(source_file, options={})
|
258
|
+
options = options.clone
|
259
|
+
options[:runtime] ||= 'swf8'
|
260
|
+
compiler.compile(source_file, options)
|
261
|
+
rescue InvalidSourceLocation
|
262
|
+
CommandLineCompiler.new.compile(source_file, options)
|
237
263
|
end
|
238
|
-
|
239
|
-
def self.make_html
|
264
|
+
|
265
|
+
def self.make_html(source_file, options={}) #:nodoc:
|
240
266
|
raise 'not really supported, for now'
|
241
267
|
options = {
|
242
268
|
:format => 'html-object',
|
@@ -244,6 +270,8 @@ EOF
|
|
244
270
|
compiler.compile source_file, options
|
245
271
|
source_file = options[:output]
|
246
272
|
s = open(source_file).read
|
247
|
-
open(source_file, 'w')
|
273
|
+
open(source_file, 'w') do |f|
|
274
|
+
f << s.gsub!(/\.lzx\?lzt=swf&/, '.lzx.swf?')
|
275
|
+
end
|
248
276
|
end
|
249
277
|
end
|
data/lib/openlaszlo.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'ropenlaszlo'
|
data/lib/ropenlaszlo.rb
CHANGED
data/ropenlaszlo.gemspec
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
|
2
|
+
# Gem::Specification for Ropenlaszlo-0.5
|
3
|
+
# Originally generated by Echoe
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = %q{ropenlaszlo}
|
7
|
+
s.version = "0.5"
|
8
|
+
s.date = %q{2008-04-01}
|
9
|
+
s.summary = %q{Ruby interface to OpenLaszlo.}
|
10
|
+
s.email = %q{steele@osteele.com}
|
11
|
+
s.homepage = %q{http://ropenlaszlo.rubyforge.org}
|
12
|
+
s.rubyforge_project = %q{ropenlaszlo}
|
13
|
+
s.description = %q{ROpenLaszlo is an interface to the OpenLaszlo compiler.}
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.authors = ["Oliver Steele"]
|
16
|
+
s.files = ["CHANGES", "examples/compile_hello.rb", "examples/hello.lzx", "install.rb", "lib/openlaszlo/applet.rb", "lib/openlaszlo/compiler.rb", "lib/openlaszlo.rb", "lib/ropenlaszlo.rb", "lib/tasks/openlaszlo.rake", "LICENSE", "Manifest", "README", "test/compilation-error.lzx", "test/compilation-warning.lzx", "test/compiler_test.rb", "test/tasks/Rakefile", "test/tasks/test.lzx", "test/test.lzx", "test/test_utils.rb", "TODO", "ropenlaszlo.gemspec"]
|
17
|
+
s.test_files = ["test/compiler_test.rb"]
|
18
|
+
s.rdoc_options = ["--title", "ROpenLaszlo: Ruby interface to OpenLaszlo", "--main", "README", "--exclude", "test/.*"]
|
19
|
+
s.extra_rdoc_files = ["README", "CHANGES", "TODO", "LICENSE"]
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
# # Original Rakefile source (requires the Echoe gem):
|
24
|
+
#
|
25
|
+
# require 'rubygems'
|
26
|
+
# require 'echoe'
|
27
|
+
#
|
28
|
+
# PKG_VERSION = '0.5'
|
29
|
+
#
|
30
|
+
# Echoe.new('ropenlaszlo', PKG_VERSION) do |p|
|
31
|
+
# p.summary = "Ruby interface to OpenLaszlo."
|
32
|
+
# p.url = 'http://ropenlaszlo.rubyforge.org'
|
33
|
+
# p.description = <<-EOF
|
34
|
+
# ROpenLaszlo is an interface to the OpenLaszlo compiler.
|
35
|
+
# EOF
|
36
|
+
# p.author = 'Oliver Steele'
|
37
|
+
# p.email = 'steele@osteele.com'
|
38
|
+
# p.ignore_pattern = /^(.git|.*\.swf|.*#.*#)$/
|
39
|
+
# p.test_pattern = 'test/*_test.rb'
|
40
|
+
# p.rdoc_pattern = /^(lib|bin|tasks|ext)|^README|^CHANGES|^TODO|^LICENSE$/
|
41
|
+
# p.eval = proc do |s|
|
42
|
+
# s.rdoc_options <<
|
43
|
+
# '--title' << "ROpenLaszlo: #{s.summary.sub(/.$/,'')}" <<
|
44
|
+
# '--main' << 'README' <<
|
45
|
+
# '--exclude' << 'test/.*'
|
46
|
+
# s.extra_rdoc_files = ['README', 'CHANGES', 'TODO', 'LICENSE']
|
47
|
+
# end
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# desc "Really a replacement for echoe's 'install', which bombs on my machine"
|
51
|
+
# task :reinstall => [:clean, :package, :uninstall] do
|
52
|
+
# system "sudo gem install pkg/*.gem"
|
53
|
+
# end
|
data/test/compiler_test.rb
CHANGED
@@ -7,7 +7,7 @@ require File.join(File.dirname(__FILE__), 'test_utils.rb')
|
|
7
7
|
|
8
8
|
include FileUtils
|
9
9
|
|
10
|
-
REQUIRED_ENV_VALUES = %w{OPENLASZLO_HOME
|
10
|
+
REQUIRED_ENV_VALUES = %w{OPENLASZLO_HOME OPENLASZLO_URL}
|
11
11
|
unless REQUIRED_ENV_VALUES.reject {|w| ENV[w]}.empty?
|
12
12
|
raise "These environment variables must be set: #{REQUIRED_ENV_VALUES}.join(', ')"
|
13
13
|
end
|
data/test/tasks/Rakefile
ADDED
data/test/tasks/test.lzx
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
<canvas/>
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: ropenlaszlo
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date:
|
6
|
+
version: "0.5"
|
7
|
+
date: 2008-04-01 00:00:00 -04:00
|
8
8
|
summary: Ruby interface to OpenLaszlo.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -25,32 +25,45 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
25
25
|
platform: ruby
|
26
26
|
signing_key:
|
27
27
|
cert_chain:
|
28
|
+
post_install_message:
|
28
29
|
authors:
|
29
30
|
- Oliver Steele
|
30
31
|
files:
|
31
|
-
-
|
32
|
+
- CHANGES
|
33
|
+
- examples/compile_hello.rb
|
34
|
+
- examples/hello.lzx
|
35
|
+
- install.rb
|
36
|
+
- lib/openlaszlo/applet.rb
|
37
|
+
- lib/openlaszlo/compiler.rb
|
38
|
+
- lib/openlaszlo.rb
|
32
39
|
- lib/ropenlaszlo.rb
|
33
|
-
-
|
34
|
-
-
|
35
|
-
-
|
36
|
-
-
|
40
|
+
- lib/tasks/openlaszlo.rake
|
41
|
+
- LICENSE
|
42
|
+
- Manifest
|
43
|
+
- README
|
37
44
|
- test/compilation-error.lzx
|
38
45
|
- test/compilation-warning.lzx
|
39
46
|
- test/compiler_test.rb
|
47
|
+
- test/tasks/Rakefile
|
48
|
+
- test/tasks/test.lzx
|
40
49
|
- test/test.lzx
|
41
50
|
- test/test_utils.rb
|
42
|
-
|
43
|
-
|
51
|
+
- TODO
|
52
|
+
- ropenlaszlo.gemspec
|
53
|
+
test_files:
|
54
|
+
- test/compiler_test.rb
|
44
55
|
rdoc_options:
|
45
56
|
- --title
|
46
57
|
- "ROpenLaszlo: Ruby interface to OpenLaszlo"
|
58
|
+
- --main
|
59
|
+
- README
|
47
60
|
- --exclude
|
48
61
|
- test/.*
|
49
62
|
extra_rdoc_files:
|
50
|
-
-
|
51
|
-
-
|
52
|
-
-
|
53
|
-
-
|
63
|
+
- README
|
64
|
+
- CHANGES
|
65
|
+
- TODO
|
66
|
+
- LICENSE
|
54
67
|
executables: []
|
55
68
|
|
56
69
|
extensions: []
|