sprout-flashplayer-bundle 9.115.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sprout/flashplayer.rb +3 -0
- data/lib/sprout/flashplayer/version.rb +12 -0
- data/lib/sprout/tasks/flashplayer_task.rb +365 -0
- data/rakefile.rb +54 -0
- metadata +71 -0
@@ -0,0 +1,365 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (c) 2007 Pattern Park
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
=end
|
23
|
+
|
24
|
+
module Sprout
|
25
|
+
|
26
|
+
class FlashPlayerError < StandardError #:nodoc:
|
27
|
+
end
|
28
|
+
|
29
|
+
# The FlashPlayerTask will download, unpack, configure and launch the debug
|
30
|
+
# Flash Player for OS X, Windows and Linux.
|
31
|
+
#
|
32
|
+
# Simply send the rake task the +swf+ you'd like to launch either indirectly as a
|
33
|
+
# rake dependency or directly as the +swf+ property of this task.
|
34
|
+
#
|
35
|
+
# flashplayer :run => 'bin/SomeProject.swf'
|
36
|
+
#
|
37
|
+
# Or you could:
|
38
|
+
#
|
39
|
+
# flashplayer :run do |t|
|
40
|
+
# t.swf = 'bin/SomeProject.swf'
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# You can also send the FlashPlayerTask a variety of additional parameters including which
|
44
|
+
# version of the FlashPlayer to download (only 9.115.x is supported at the time of this writing).
|
45
|
+
#
|
46
|
+
class FlashPlayerTask < Rake::Task
|
47
|
+
DEFAULT_VERSION = nil
|
48
|
+
EXECUTABLE_NAME = 'sprout-flashplayer-tool'
|
49
|
+
|
50
|
+
@@test_result_pre_delimiter = '<XMLResultPrinter>'
|
51
|
+
@@test_result_post_delimiter = '</XMLResultPrinter>'
|
52
|
+
@@home = nil
|
53
|
+
@@trust = nil
|
54
|
+
|
55
|
+
attr_accessor :version,
|
56
|
+
:name
|
57
|
+
|
58
|
+
attr_writer :swf,
|
59
|
+
:test_result_file
|
60
|
+
|
61
|
+
def self.define_task(args, &block)
|
62
|
+
t = super
|
63
|
+
yield t if block_given?
|
64
|
+
t.define
|
65
|
+
end
|
66
|
+
|
67
|
+
def initialize_task
|
68
|
+
end
|
69
|
+
|
70
|
+
def swf
|
71
|
+
@swf ||= nil
|
72
|
+
if(@swf.nil?)
|
73
|
+
prerequisites.each do |req|
|
74
|
+
if(req.index('.swf'))
|
75
|
+
@swf = req.to_s
|
76
|
+
break
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
return @swf
|
81
|
+
end
|
82
|
+
|
83
|
+
def define
|
84
|
+
CLEAN.add(test_result_file)
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_result_file
|
88
|
+
@test_result_file ||= 'AsUnitResults.xml'
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_result
|
92
|
+
@test_result ||= ''
|
93
|
+
end
|
94
|
+
|
95
|
+
def FlashPlayerTask.trust
|
96
|
+
if(@@trust)
|
97
|
+
return @@trust
|
98
|
+
end
|
99
|
+
@@trust = File.join(FlashPlayerTask.home, '#Security', 'FlashPlayerTrust', 'sprout.cfg')
|
100
|
+
return @@trust
|
101
|
+
end
|
102
|
+
|
103
|
+
def FlashPlayerTask.home
|
104
|
+
if(@@home)
|
105
|
+
return @@home
|
106
|
+
end
|
107
|
+
|
108
|
+
FlashPlayerTask.home_paths.each do |path|
|
109
|
+
if(File.exists?(path))
|
110
|
+
return @@home = path
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
if(@@home.nil?)
|
115
|
+
raise FlashPlayerError.new('FlashPlayer unable to find home folder for your platform')
|
116
|
+
end
|
117
|
+
return @@home
|
118
|
+
end
|
119
|
+
|
120
|
+
# Enumerate the potential locations of the Flash Player Home
|
121
|
+
# For each supported Platform, the first existing location
|
122
|
+
# will be used.
|
123
|
+
def FlashPlayerTask.home_paths
|
124
|
+
return [File.join(User.library, 'Preferences', 'Macromedia', 'Flash Player'),
|
125
|
+
File.join(User.library, 'Application Support', 'Macromedia'),
|
126
|
+
File.join(User.home, 'Application Data', 'Macromedia', 'Flash Player'),
|
127
|
+
File.join(User.home, '.macromedia', 'Flash_Player')]
|
128
|
+
end
|
129
|
+
|
130
|
+
def initialize(task_name, app)
|
131
|
+
super(task_name, app)
|
132
|
+
@version = DEFAULT_VERSION
|
133
|
+
@inside_test_result = false
|
134
|
+
end
|
135
|
+
|
136
|
+
def execute(*args)
|
137
|
+
super
|
138
|
+
raise FlashPlayerError.new("FlashPlayer task #{name} required field swf is nil") unless swf
|
139
|
+
|
140
|
+
log_file = nil
|
141
|
+
|
142
|
+
# Don't let trust or log file failures break other features...
|
143
|
+
begin
|
144
|
+
log_file = FlashPlayerConfig.new().log
|
145
|
+
FlashPlayerTrust.new(File.dirname(swf))
|
146
|
+
|
147
|
+
if(File.exists?(log_file))
|
148
|
+
File.open(log_file, 'w') do |f|
|
149
|
+
f.write('')
|
150
|
+
end
|
151
|
+
else
|
152
|
+
FileUtils.mkdir_p(File.dirname(log_file))
|
153
|
+
FileUtils.touch(log_file)
|
154
|
+
end
|
155
|
+
rescue
|
156
|
+
puts '[WARNING] FlashPlayer encountered an error working with the mm.cfg log and/or editing the Trust file'
|
157
|
+
end
|
158
|
+
|
159
|
+
@running_process = nil
|
160
|
+
@thread = run(EXECUTABLE_NAME, version, swf)
|
161
|
+
read_log(@thread, log_file)
|
162
|
+
@thread.join
|
163
|
+
end
|
164
|
+
|
165
|
+
def close
|
166
|
+
if(User.new().is_a?(WinUser))
|
167
|
+
Thread.kill(@thread)
|
168
|
+
else
|
169
|
+
Process.kill("SIGALRM", @player_pid)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def run(tool, version, swf)
|
174
|
+
target = User.clean_path(Sprout.get_executable(tool, nil, version))
|
175
|
+
@player_pid = nil
|
176
|
+
|
177
|
+
thread_out = $stdout
|
178
|
+
command = "#{target} #{User.clean_path(swf)}"
|
179
|
+
|
180
|
+
return Thread.new {
|
181
|
+
usr = User.new()
|
182
|
+
if(usr.is_a?(WinUser) && !usr.is_a?(CygwinUser))
|
183
|
+
system command
|
184
|
+
else
|
185
|
+
require 'open4'
|
186
|
+
@player_pid, stdin, stdout, stderr = Open4.popen4(command)
|
187
|
+
focus_player_on_mac(thread_out)
|
188
|
+
stdout.read
|
189
|
+
end
|
190
|
+
}
|
191
|
+
end
|
192
|
+
|
193
|
+
def focus_player_on_mac(out)
|
194
|
+
if(User.new.is_a?(OSXUser))
|
195
|
+
require 'rbosa'
|
196
|
+
system_events = OSA.app("System Events")
|
197
|
+
system_events.application_processes.each do |process|
|
198
|
+
if(process.name == "Flash Player")
|
199
|
+
#out.puts "Focusing Flash Player now"
|
200
|
+
process.frontmost = true
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def read_log(thread, log_file)
|
207
|
+
lines_put = 0
|
208
|
+
|
209
|
+
if(!File.exists?(log_file))
|
210
|
+
raise FlashPlayerError.new('[ERROR] Unable to find the trace output log file in the expected location: ' + log_file)
|
211
|
+
end
|
212
|
+
|
213
|
+
while(thread.alive?)
|
214
|
+
sleep(0.2)
|
215
|
+
lines_read = 0
|
216
|
+
|
217
|
+
File.open(log_file, 'r') do |file|
|
218
|
+
file.readlines.each do |line|
|
219
|
+
lines_read = lines_read + 1
|
220
|
+
if(lines_read > lines_put)
|
221
|
+
if(!parse_test_result(line, thread))
|
222
|
+
puts "[trace] #{line}"
|
223
|
+
end
|
224
|
+
$stdout.flush
|
225
|
+
lines_put = lines_put + 1
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
# Returns true if inside of a test result
|
233
|
+
def parse_test_result(line, thread)
|
234
|
+
if(@inside_test_result)
|
235
|
+
if(line.index(@@test_result_post_delimiter))
|
236
|
+
@inside_test_result = false
|
237
|
+
write_test_result(test_result)
|
238
|
+
close
|
239
|
+
return true
|
240
|
+
else
|
241
|
+
test_result << line
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
if(line.index(@@test_result_pre_delimiter))
|
246
|
+
@inside_test_result = true
|
247
|
+
end
|
248
|
+
|
249
|
+
return @inside_test_result
|
250
|
+
end
|
251
|
+
|
252
|
+
def write_test_result(result)
|
253
|
+
FileUtils.makedirs(File.dirname(test_result_file))
|
254
|
+
File.open(test_result_file, File::CREAT|File::TRUNC|File::RDWR) do |f|
|
255
|
+
f.puts(result)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
##########################################
|
261
|
+
# FlashPlayerConfig Class
|
262
|
+
|
263
|
+
class FlashPlayerConfig # :nodoc:
|
264
|
+
|
265
|
+
@@file_name = 'mm.cfg'
|
266
|
+
|
267
|
+
def initialize
|
268
|
+
osx_fp9 = File.join(User.library, 'Application Support', 'Macromedia')
|
269
|
+
if(FlashPlayerTask.home == osx_fp9)
|
270
|
+
@config = File.join(osx_fp9, @@file_name)
|
271
|
+
else
|
272
|
+
@config = File.join(User.home, @@file_name)
|
273
|
+
end
|
274
|
+
|
275
|
+
if(!File.exists?(@config))
|
276
|
+
write_config(@config, content)
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
def log
|
281
|
+
path = File.join(FlashPlayerTask.home, 'Logs', 'flashlog.txt')
|
282
|
+
if(User.new().is_a?(CygwinUser))
|
283
|
+
parts = path.split("/")
|
284
|
+
parts.shift()
|
285
|
+
part = parts.shift() # shift cygdrive
|
286
|
+
if(part != 'cygdrive')
|
287
|
+
Log.puts "[WARNING] There may have been a problem writing mm.cfg, please check the path in #{@config} and make sure it's a windows path..."
|
288
|
+
return path
|
289
|
+
end
|
290
|
+
drive = parts.shift()
|
291
|
+
parts.unshift(drive.upcase + ":")
|
292
|
+
path = parts.join("/")
|
293
|
+
end
|
294
|
+
return path
|
295
|
+
end
|
296
|
+
|
297
|
+
def content
|
298
|
+
return <<EOF
|
299
|
+
ErrorReportingEnable=1
|
300
|
+
MaxWarnings=0
|
301
|
+
TraceOutputEnable=1
|
302
|
+
TraceOutputFileName=#{log}
|
303
|
+
EOF
|
304
|
+
end
|
305
|
+
|
306
|
+
private
|
307
|
+
def write_config(location, content)
|
308
|
+
puts <<EOF
|
309
|
+
|
310
|
+
Correctly configured mm.cfg file not found at: #{location}
|
311
|
+
|
312
|
+
This file is required in order to capture trace output.
|
313
|
+
|
314
|
+
Would you like this file created automatically? [Yn]
|
315
|
+
|
316
|
+
EOF
|
317
|
+
answer = $stdin.gets.chomp.downcase
|
318
|
+
if(answer == 'y' || answer == '')
|
319
|
+
File.open(location, 'w') do |f|
|
320
|
+
f.write(content)
|
321
|
+
end
|
322
|
+
Log.puts ">> Created file: " + File.expand_path(location)
|
323
|
+
else
|
324
|
+
raise FlashPlayerError.new("[ERROR] Unable to create mm.cfg file at: #{location}")
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
##########################################
|
330
|
+
# FlashPlayerTrust Class
|
331
|
+
|
332
|
+
class FlashPlayerTrust # :nodoc:
|
333
|
+
|
334
|
+
def initialize(path)
|
335
|
+
trust_file = FlashPlayerTask.trust
|
336
|
+
if(!File.exists?(trust_file))
|
337
|
+
FileUtils.mkdir_p(File.dirname(trust_file))
|
338
|
+
FileUtils.touch(trust_file)
|
339
|
+
end
|
340
|
+
|
341
|
+
parts = path.split(File::SEPARATOR)
|
342
|
+
if(parts.size == 1)
|
343
|
+
path = File::SEPARATOR + path
|
344
|
+
end
|
345
|
+
|
346
|
+
if(!has_path?(trust_file, path))
|
347
|
+
File.open(trust_file, 'a') do |f|
|
348
|
+
f.puts path
|
349
|
+
end
|
350
|
+
Log.puts ">> Added #{path} to Flash Player Trust file at: #{trust_file}"
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
def has_path?(file, path)
|
355
|
+
File.open(file, 'r') do |f|
|
356
|
+
return (f.read.index(path))
|
357
|
+
end
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
end
|
362
|
+
|
363
|
+
def flashplayer(args, &block)
|
364
|
+
Sprout::FlashPlayerTask.define_task(args, &block)
|
365
|
+
end
|
data/rakefile.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'lib/sprout/flashplayer/version'
|
6
|
+
|
7
|
+
SPROUT_HOME = ENV['SPROUT_HOME']
|
8
|
+
|
9
|
+
PROJECT = 'sprout'
|
10
|
+
NAME = 'sprout-flashplayer-bundle'
|
11
|
+
SUMMARY = 'Supporting tasks for Flash Player Rake integration'
|
12
|
+
GEM_VERSION = Sprout::FlashPlayer::VERSION::STRING
|
13
|
+
AUTHOR = 'Pattern Park'
|
14
|
+
EMAIL = 'projectsprouts@googlegroups.com'
|
15
|
+
HOMEPAGE = 'http://www.projectsprouts.org'
|
16
|
+
DESCRIPTION = "Shared Project to support the Flash Player task"
|
17
|
+
HOMEPATH = "http://#{PROJECT}.rubyforge.org"
|
18
|
+
RELEASE_TYPES = ["gem"]
|
19
|
+
PKG_LIST = FileList['[a-zA-Z]*',
|
20
|
+
'lib/**/*'
|
21
|
+
]
|
22
|
+
|
23
|
+
PKG_LIST.exclude('.svn')
|
24
|
+
PKG_LIST.exclude('artifacts')
|
25
|
+
PKG_LIST.each do |file|
|
26
|
+
task :package => file
|
27
|
+
end
|
28
|
+
|
29
|
+
spec = Gem::Specification.new do |s|
|
30
|
+
s.platform = Gem::Platform::RUBY
|
31
|
+
s.summary = SUMMARY
|
32
|
+
s.description = DESCRIPTION
|
33
|
+
s.name = NAME
|
34
|
+
s.version = GEM_VERSION
|
35
|
+
s.author = AUTHOR
|
36
|
+
s.email = EMAIL
|
37
|
+
s.homepage = HOMEPAGE
|
38
|
+
s.rubyforge_project = PROJECT
|
39
|
+
s.require_path = 'lib'
|
40
|
+
s.autorequire = 'sprout/flashplayer'
|
41
|
+
s.has_rdoc = false
|
42
|
+
s.files = PKG_LIST.to_a
|
43
|
+
|
44
|
+
s.add_dependency('sprout', '>= 0.7.1')
|
45
|
+
end
|
46
|
+
|
47
|
+
Rake::GemPackageTask.new(spec) do |p|
|
48
|
+
end
|
49
|
+
|
50
|
+
require File.join(SPROUT_HOME, 'sprout/script/build_helpers')
|
51
|
+
|
52
|
+
# Each task that wants this feature, needs to set this up
|
53
|
+
# because the flexsdks shouldn't get it...
|
54
|
+
#task :release => :increment_revision
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sprout-flashplayer-bundle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 9.115.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pattern Park
|
8
|
+
autorequire: sprout/flashplayer
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-02-09 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: sprout
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.7.1
|
23
|
+
version:
|
24
|
+
description: Shared Project to support the Flash Player task
|
25
|
+
email: projectsprouts@googlegroups.com
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files: []
|
31
|
+
|
32
|
+
files:
|
33
|
+
- lib
|
34
|
+
- pkg
|
35
|
+
- rakefile.rb
|
36
|
+
- samples
|
37
|
+
- test
|
38
|
+
- lib/sprout
|
39
|
+
- lib/sprout/flashplayer
|
40
|
+
- lib/sprout/flashplayer/version.rb
|
41
|
+
- lib/sprout/flashplayer.rb
|
42
|
+
- lib/sprout/tasks
|
43
|
+
- lib/sprout/tasks/flashplayer_task.rb
|
44
|
+
has_rdoc: false
|
45
|
+
homepage: http://www.projectsprouts.org
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
version:
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project: sprout
|
66
|
+
rubygems_version: 1.0.1
|
67
|
+
signing_key:
|
68
|
+
specification_version: 2
|
69
|
+
summary: Supporting tasks for Flash Player Rake integration
|
70
|
+
test_files: []
|
71
|
+
|