osteele-ropenlaszlo 0.6.0 → 0.6.2
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/{CHANGES → CHANGES.rdoc} +8 -0
- data/{TODO → TODO.rdoc} +0 -0
- data/lib/openlaszlo/compiler.rb +18 -29
- data/test/compiler_test.rb +1 -1
- metadata +5 -6
data/{CHANGES → CHANGES.rdoc}
RENAMED
@@ -1,5 +1,13 @@
|
|
1
1
|
= Change Log
|
2
2
|
|
3
|
+
== Version 0.6.2 (2009-03-23)
|
4
|
+
* return which compiler was used
|
5
|
+
|
6
|
+
|
7
|
+
== Version 0.6.1 (2009-03-23)
|
8
|
+
* rename command-line compiler output file
|
9
|
+
|
10
|
+
|
3
11
|
== Version 0.6 (2009-03-23)
|
4
12
|
* follow symbolic links
|
5
13
|
* reorganize directory structure
|
data/{TODO → TODO.rdoc}
RENAMED
File without changes
|
data/lib/openlaszlo/compiler.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# License:: MIT License
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
4
3
|
|
5
4
|
# == module OpenLaszlo
|
6
5
|
#
|
@@ -49,14 +48,15 @@ module OpenLaszlo
|
|
49
48
|
# * <tt>:format</tt> - request type (default 'swf')
|
50
49
|
# See OpenLaszlo.compile for a description of +options+.
|
51
50
|
def compile(source_file, options={})
|
52
|
-
mtime = File.mtime
|
51
|
+
mtime = File.mtime(source_file)
|
53
52
|
runtime = options[:runtime] || 'swf8'
|
54
|
-
|
53
|
+
default_output = source_file.sub(/\.lzx/, '') + '.swf'
|
54
|
+
output = options[:output] || default_output
|
55
55
|
compile_object(source_file, output, options)
|
56
56
|
results = request_metadata_for(source_file, options)
|
57
57
|
raise "Race condition: #{source_file} was modified during compilation" if mtime != File.mtime(source_file)
|
58
|
-
results[:output] = output
|
59
58
|
raise CompilationError.new(results[:error]) if results[:error]
|
59
|
+
results[:output] = output
|
60
60
|
return results
|
61
61
|
end
|
62
62
|
|
@@ -67,8 +67,8 @@ module OpenLaszlo
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def request_metadata_for(source_file, options={})
|
70
|
-
results = {}
|
71
70
|
options = {}.update(options).update(:format => 'canvas-xml', :output => nil)
|
71
|
+
results = {:compiler => self}
|
72
72
|
text = request(source_file, options)
|
73
73
|
if text =~ %r{<warnings>(.*?)</warnings>}m
|
74
74
|
results[:warnings] = $1.scan(%r{<error>\s*(.*?)\s*</error>}m).map { |w| w.first }
|
@@ -80,8 +80,6 @@ module OpenLaszlo
|
|
80
80
|
|
81
81
|
def request(source_file, options={})
|
82
82
|
output = options[:output]
|
83
|
-
require 'net/http'
|
84
|
-
require 'uri'
|
85
83
|
# assert that pathname is relative to LPS home:
|
86
84
|
absolute_path = File.expand_path(source_file)
|
87
85
|
server_relative_path = nil
|
@@ -98,8 +96,8 @@ module OpenLaszlo
|
|
98
96
|
raise InvalidSourceLocation.new("#{absolute_path} isn't inside #{@home}") unless absolute_path.index(@home) == 0
|
99
97
|
server_relative_path = absolute_path[@home.length..-1]
|
100
98
|
# FIXME: this doesn't handle quoting; use recursive File.split instead
|
101
|
-
# FIXME:
|
102
|
-
server_relative_path.gsub(File::Separator, '/')
|
99
|
+
# FIXME: encode the url
|
100
|
+
server_relative_path.gsub!(File::Separator, '/')
|
103
101
|
end
|
104
102
|
options = {
|
105
103
|
:lzr => options[:runtime],
|
@@ -174,11 +172,9 @@ module OpenLaszlo
|
|
174
172
|
# See OpenLaszlo.compile for a description of +options+.
|
175
173
|
def compile(source_file, options={})
|
176
174
|
runtime = options[:runtime] || 'swf8'
|
177
|
-
output_suffix = ".lzr=#{runtime}.swf"
|
178
175
|
default_output = File.join(File.dirname(source_file),
|
179
|
-
File.basename(source_file, '.lzx') +
|
176
|
+
File.basename(source_file, '.lzx') + '.swf')
|
180
177
|
output = options[:output] || default_output
|
181
|
-
raise "#{source_file} and #{output} do not have the same basename." unless File.basename(source_file, '.lzx') == File.basename(output, output_suffix)
|
182
178
|
args = []
|
183
179
|
args << "--runtime=#{options[:runtime]}" if options[:runtime]
|
184
180
|
args << '--debug' if options[:debug]
|
@@ -195,7 +191,13 @@ module OpenLaszlo
|
|
195
191
|
stdin, stdout, stderr = Open3.popen3(command)
|
196
192
|
errors = stdout.read
|
197
193
|
warnings = stderr.readlines
|
198
|
-
|
194
|
+
# OpenLaszlo >= 4.0
|
195
|
+
if warnings.first and warnings.first =~ /^Compiling:.* to (.+)/
|
196
|
+
real_output = $1
|
197
|
+
warnings.shift
|
198
|
+
FileUtils.mv(real_output, output) if
|
199
|
+
File.exists?(real_output) and real_output != output
|
200
|
+
end
|
199
201
|
rescue NotImplementedError
|
200
202
|
# Windows doesn't have popen
|
201
203
|
errors = `#{command}`
|
@@ -205,7 +207,7 @@ module OpenLaszlo
|
|
205
207
|
if errors =~ /^Compilation errors occurred:\n/
|
206
208
|
raise CompilationError.new($'.strip)
|
207
209
|
end
|
208
|
-
results = {:output => output, :warnings => warnings}
|
210
|
+
results = {:output => output, :warnings => warnings, :compiler => compiler}
|
209
211
|
return results
|
210
212
|
end
|
211
213
|
|
@@ -271,17 +273,4 @@ EOF
|
|
271
273
|
rescue InvalidSourceLocation
|
272
274
|
CommandLineCompiler.new.compile(source_file, options)
|
273
275
|
end
|
274
|
-
|
275
|
-
def self.make_html(source_file, options={}) #:nodoc:
|
276
|
-
raise 'not really supported, for now'
|
277
|
-
options = {
|
278
|
-
:format => 'html-object',
|
279
|
-
:output => File.basename(source_file, '.lzx')+'.html'}.update(options)
|
280
|
-
compiler.compile(source_file, options)
|
281
|
-
source_file = options[:output]
|
282
|
-
s = open(source_file).read
|
283
|
-
open(source_file, 'w') do |f|
|
284
|
-
f << s.gsub!(/\.lzx\?lzt=swf&/, '.lzx.swf?')
|
285
|
-
end
|
286
|
-
end
|
287
276
|
end
|
data/test/compiler_test.rb
CHANGED
@@ -28,7 +28,7 @@ module CompilerTestHelper
|
|
28
28
|
|
29
29
|
def compile(file, output=nil, options={})
|
30
30
|
file = testfile_pathname(file)
|
31
|
-
output ||= File.join(File.dirname(file), File.basename(file, '.lzx')+'.
|
31
|
+
output ||= File.join(File.dirname(file), File.basename(file, '.lzx')+'.swf')
|
32
32
|
rm_f output
|
33
33
|
raise "Unable to remove output file: #{output}" if File.exists?(output)
|
34
34
|
begin
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osteele-ropenlaszlo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oliver Steele
|
@@ -22,13 +22,12 @@ extensions: []
|
|
22
22
|
extra_rdoc_files:
|
23
23
|
- README.rdoc
|
24
24
|
- MIT-LICENSE
|
25
|
-
- CHANGES
|
26
|
-
- TODO
|
25
|
+
- CHANGES.rdoc
|
26
|
+
- TODO.rdoc
|
27
27
|
files:
|
28
28
|
- lib/openlaszlo
|
29
29
|
- lib/openlaszlo/applet.rb
|
30
30
|
- lib/openlaszlo/compiler.rb
|
31
|
-
- lib/openlaszlo/compiler.rb.orig
|
32
31
|
- lib/openlaszlo.rb
|
33
32
|
- lib/ropenlaszlo.rb
|
34
33
|
- lib/tasks
|
@@ -44,8 +43,8 @@ files:
|
|
44
43
|
- test/test_utils.rb
|
45
44
|
- README.rdoc
|
46
45
|
- MIT-LICENSE
|
47
|
-
- CHANGES
|
48
|
-
- TODO
|
46
|
+
- CHANGES.rdoc
|
47
|
+
- TODO.rdoc
|
49
48
|
has_rdoc: true
|
50
49
|
homepage: http://github.com/osteele/ropenlaszlo
|
51
50
|
post_install_message:
|