flashsdk 1.0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +9 -0
- data/README.textile +0 -0
- data/VERSION +1 -0
- data/bin/sprout-as3 +9 -0
- data/flashsdk.gemspec +23 -0
- data/lib/flashplayer/clix_flash_player.rb +91 -0
- data/lib/flashplayer/clix_wrapper.rb +22 -0
- data/lib/flashplayer/errors.rb +12 -0
- data/lib/flashplayer/log_file.rb +95 -0
- data/lib/flashplayer/mm_config.rb +96 -0
- data/lib/flashplayer/module.rb +50 -0
- data/lib/flashplayer/specification.rb +32 -0
- data/lib/flashplayer/task.legacy.rb +293 -0
- data/lib/flashplayer/task.rb +137 -0
- data/lib/flashplayer/trust.rb +45 -0
- data/lib/flashplayer.rb +8 -0
- data/lib/flashsdk/generators/class_generator.rb +43 -0
- data/lib/flashsdk/generators/flash_helper.rb +48 -0
- data/lib/flashsdk/generators/project_generator.rb +53 -0
- data/lib/flashsdk/generators/templates/ActionScript3Class.as +9 -0
- data/lib/flashsdk/generators/templates/ActionScript3MainClass.as +11 -0
- data/lib/flashsdk/generators/templates/DefaultProjectImage.png +0 -0
- data/lib/flashsdk/generators/templates/Gemfile +6 -0
- data/lib/flashsdk/generators/templates/rakefile.rb +17 -0
- data/lib/flashsdk/module.rb +9 -0
- data/lib/flashsdk/tasks/mxmlc.rb +687 -0
- data/lib/flashsdk/tasks/mxmlc_legacy.rb +135 -0
- data/lib/flashsdk.rb +12 -0
- data/lib/flex3.rb +53 -0
- data/lib/flex4.rb +58 -0
- data/rakefile.rb +20 -0
- data/test/fixtures/mxmlc/simple/SomeFile.as +11 -0
- data/test/unit/class_generator_test.rb +50 -0
- data/test/unit/flash_helper_test.rb +27 -0
- data/test/unit/flashplayer_test.rb +56 -0
- data/test/unit/log_file_test.rb +47 -0
- data/test/unit/mm_config_test.rb +74 -0
- data/test/unit/mxmlc_test.rb +45 -0
- data/test/unit/project_generator_test.rb +53 -0
- data/test/unit/task_test.rb +93 -0
- data/test/unit/test_helper.rb +16 -0
- data/test/unit/trust_test.rb +30 -0
- metadata +145 -0
data/Gemfile
ADDED
data/README.textile
ADDED
File without changes
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.1.pre
|
data/bin/sprout-as3
ADDED
data/flashsdk.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path File.dirname(__FILE__), 'lib'
|
3
|
+
$:.unshift lib unless $:.include?(lib)
|
4
|
+
|
5
|
+
require 'bundler'
|
6
|
+
Bundler.setup
|
7
|
+
|
8
|
+
require 'flashsdk'
|
9
|
+
|
10
|
+
Gem::Specification.new do |s|
|
11
|
+
s.name = 'flashsdk'
|
12
|
+
s.version = FlashSDK::VERSION
|
13
|
+
s.author = "Luke Bayes"
|
14
|
+
s.email = "projectsprouts@googlegroups.com"
|
15
|
+
s.homepage = "http://www.adobe.com/products/flex"
|
16
|
+
s.summary = "Adobe Flash SDK including mxmlc, compc, asdoc, adl, adt, optimizer and fdb"
|
17
|
+
s.description = "The Flash SDK Rubygem is brought to you by Project Sprouts (http://projectsprouts.org)"
|
18
|
+
s.executable = 'sprout-as3'
|
19
|
+
s.files = FileList['**/**/*'].exclude /.git|.svn|.DS_Store/
|
20
|
+
s.add_bundler_dependencies
|
21
|
+
s.require_paths << 'lib'
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'open4'
|
3
|
+
|
4
|
+
$CLIX_WRAPPER_TARGET = File.join(File.expand_path(File.dirname(__FILE__)), 'clix_wrapper.rb')
|
5
|
+
|
6
|
+
class CLIXFlashPlayerError < StandardError; end
|
7
|
+
|
8
|
+
class CLIXFlashPlayer
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@activate_pid = nil
|
12
|
+
@player_pid = nil
|
13
|
+
@thread = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute(player, swf)
|
17
|
+
cleanup
|
18
|
+
player = clean_path(player)
|
19
|
+
swf = clean_path(swf)
|
20
|
+
validate(player, swf)
|
21
|
+
|
22
|
+
if(!player.match('Contents/MacOS'))
|
23
|
+
player = File.join(player, 'Contents', 'MacOS', 'Flash Player')
|
24
|
+
end
|
25
|
+
|
26
|
+
setup_trap
|
27
|
+
|
28
|
+
@thread = Thread.new {
|
29
|
+
@player_pid = open4.popen4("#{player.split(' ').join('\ ')}")[0]
|
30
|
+
begin
|
31
|
+
raise "clix_wrapper.rb could not be found at: #{wrapper}" if !File.exists?($CLIX_WRAPPER_TARGET)
|
32
|
+
command = "ruby #{$CLIX_WRAPPER_TARGET} '#{player}' '#{swf}'"
|
33
|
+
@activate_pid, stdin, stdout, stderr = open4.popen4(command)
|
34
|
+
$stdout.puts stdout.read
|
35
|
+
error = stderr.read
|
36
|
+
raise error if !error.nil? && error != ''
|
37
|
+
Process.wait(@player_pid)
|
38
|
+
rescue StandardError => e
|
39
|
+
$stdout.puts e.to_s
|
40
|
+
kill
|
41
|
+
raise e
|
42
|
+
end
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def kill
|
47
|
+
system("kill -9 #{@player_pid}")
|
48
|
+
end
|
49
|
+
|
50
|
+
def join
|
51
|
+
if(@thread.alive?)
|
52
|
+
@thread.join
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def alive?
|
57
|
+
return @thread.alive?
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def clean_path(path)
|
63
|
+
File.expand_path(path.gsub("'", '').gsub("\\", ''))
|
64
|
+
end
|
65
|
+
|
66
|
+
def cleanup
|
67
|
+
if(@thread && @thread.alive?)
|
68
|
+
kill
|
69
|
+
@thread.join
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def validate(player, swf)
|
74
|
+
raise CLIXFlashPlayerError.new("Player must not be nil") if(player.nil? || player == '')
|
75
|
+
raise CLIXFlashPlayerError.new("Player cannot be found: '#{player}'") if(!File.exists?(player))
|
76
|
+
raise CLIXFlashPlayerError.new("SWF must not be nil") if(swf.nil? || swf == '')
|
77
|
+
raise CLIXFlashPlayerError.new("SWF cannot be found: '#{swf}'") if(!File.exists?(swf))
|
78
|
+
end
|
79
|
+
|
80
|
+
def setup_trap
|
81
|
+
# Trap the CTRL+C Interrupt signal
|
82
|
+
# Which prevents nasty exception messages
|
83
|
+
Kernel.trap('INT') do
|
84
|
+
if(@thread.alive?)
|
85
|
+
@thread.kill
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
player = ARGV[0]
|
5
|
+
swf = ARGV[1]
|
6
|
+
|
7
|
+
raise "CLIXWrapper requires 'player' argument like:\nruby clix_wrapper [player] [swf]" if(player.nil?)
|
8
|
+
raise "CLIXWrapper could not find player at '#{player}'" if !File.exists?(player)
|
9
|
+
|
10
|
+
raise "CLIXWrapper requires 'swf' argument like:\nruby clix_wrapper [player] [swf]" if(swf.nil?)
|
11
|
+
raise "CLIXWrapper could not find swf at '#{swf}'" if !File.exists?(swf)
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'appscript'
|
15
|
+
# Give the player focus:
|
16
|
+
Appscript.app(player).activate
|
17
|
+
# Open the SWF:
|
18
|
+
Appscript.app(player).open(MacTypes::Alias.path(swf))
|
19
|
+
rescue LoadError => e
|
20
|
+
raise "\n\n[ERROR] You must install the rb-appscript gem to use the desktop debug Flash Player, you do this by running:\n\ngem install rb-appscript"
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
|
2
|
+
module FlashPlayer
|
3
|
+
|
4
|
+
class LogFile
|
5
|
+
|
6
|
+
attr_accessor :logger
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@logger = $stdout
|
10
|
+
end
|
11
|
+
|
12
|
+
def tail thread=nil
|
13
|
+
tail_path flashlog_path, thread
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def tail_path path, thread=nil
|
19
|
+
logger.puts ">> Tailing '#{path}', press CTRL+C to quit"
|
20
|
+
create_flashlog_at path
|
21
|
+
clear_flashlog_at path
|
22
|
+
read_flashlog_at path, thread
|
23
|
+
end
|
24
|
+
|
25
|
+
def read_flashlog_at path, thread=nil
|
26
|
+
thread ||= fake_thread
|
27
|
+
lines_put = 0
|
28
|
+
|
29
|
+
trap("INT") { thread.kill }
|
30
|
+
|
31
|
+
while thread.alive? do
|
32
|
+
lines_put = read_from_file path, lines_put
|
33
|
+
logger.flush
|
34
|
+
sleep(0.2)
|
35
|
+
end
|
36
|
+
|
37
|
+
logger.puts ""
|
38
|
+
logger.puts ">> Exiting from tailing '#{path}' at user request"
|
39
|
+
end
|
40
|
+
|
41
|
+
def read_from_file path, lines_put
|
42
|
+
File.open(path, 'r') do |file|
|
43
|
+
lines_read = 0
|
44
|
+
file.readlines.each do |line|
|
45
|
+
if(lines_read >= lines_put)
|
46
|
+
logger.puts "[trace] #{line}"
|
47
|
+
logger.flush
|
48
|
+
lines_put += 1
|
49
|
+
end
|
50
|
+
lines_read += 1
|
51
|
+
end
|
52
|
+
end unless !File.exists?(path)
|
53
|
+
lines_put
|
54
|
+
end
|
55
|
+
|
56
|
+
def flashlog_path
|
57
|
+
begin
|
58
|
+
FlashPlayer.flashlog
|
59
|
+
rescue FlashPlayer::PathError
|
60
|
+
"/dev/null"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def clear_flashlog_at path
|
65
|
+
File.open(path, 'w') do |f|
|
66
|
+
f.write('')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def create_flashlog_at path
|
71
|
+
if(!File.exists?(path))
|
72
|
+
FileUtils.makedirs(File.dirname(path))
|
73
|
+
FileUtils.touch(path)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def fake_thread
|
78
|
+
Thread.new do
|
79
|
+
while true
|
80
|
+
sleep(0.2)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
desc "Tail the flashlog.txt and block"
|
89
|
+
task :flashlog do
|
90
|
+
mm_config = FlashPlayer::MMConfig.new
|
91
|
+
mm_config.create
|
92
|
+
reader = FlashPlayer::LogFile.new
|
93
|
+
reader.tail
|
94
|
+
end
|
95
|
+
|
@@ -0,0 +1,96 @@
|
|
1
|
+
|
2
|
+
module FlashPlayer
|
3
|
+
|
4
|
+
class MMConfig
|
5
|
+
FILE_NAME = 'mm.cfg'
|
6
|
+
|
7
|
+
attr_accessor :logger
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@file_name = FILE_NAME
|
11
|
+
@logger = $stdout
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
create_if_necessary_at config_path
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def create_if_necessary_at path
|
21
|
+
if(File.exists?(File.dirname(path)))
|
22
|
+
write_config(path, content(flashlog_path)) if(file_blank?(path))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def config_path
|
27
|
+
if(flashplayer_home == osx_fp9_dir)
|
28
|
+
path = File.join(osx_fp9_dir, @file_name)
|
29
|
+
else
|
30
|
+
path = File.join(system_home, @file_name)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def flashplayer_home
|
35
|
+
FlashPlayer.home
|
36
|
+
end
|
37
|
+
|
38
|
+
def flashlog_path
|
39
|
+
FlashPlayer.flashlog
|
40
|
+
end
|
41
|
+
|
42
|
+
def file_blank?(file)
|
43
|
+
!File.exists?(file) || File.read(file).empty?
|
44
|
+
end
|
45
|
+
|
46
|
+
def write_config(location, content)
|
47
|
+
if(user_confirmation?(location))
|
48
|
+
FileUtils.makedirs File.dirname(location)
|
49
|
+
|
50
|
+
File.open(location, 'w') do |f|
|
51
|
+
f.write(content)
|
52
|
+
end
|
53
|
+
logger.puts ">> Created file: " + File.expand_path(location)
|
54
|
+
location
|
55
|
+
else
|
56
|
+
raise FlashPlayer::PathError.new("Unable to create #{location}")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def content(flashlog)
|
61
|
+
return <<EOF
|
62
|
+
ErrorReportingEnable=1
|
63
|
+
MaxWarnings=0
|
64
|
+
TraceOutputEnable=1
|
65
|
+
TraceOutputFileName=#{flashlog}
|
66
|
+
EOF
|
67
|
+
end
|
68
|
+
|
69
|
+
def user_confirmation?(location)
|
70
|
+
puts <<EOF
|
71
|
+
|
72
|
+
Correctly configured mm.cfg file not found at: #{location}
|
73
|
+
|
74
|
+
This file is required in order to capture trace output.
|
75
|
+
|
76
|
+
Would you like this file created automatically? [Yn]
|
77
|
+
|
78
|
+
EOF
|
79
|
+
answer = $stdin.gets.chomp.downcase
|
80
|
+
return (answer == 'y' || answer == '')
|
81
|
+
end
|
82
|
+
|
83
|
+
def osx_fp9_dir
|
84
|
+
File.join(system_library, 'Application Support', 'Macromedia')
|
85
|
+
end
|
86
|
+
|
87
|
+
def system_library
|
88
|
+
Sprout.current_system.library
|
89
|
+
end
|
90
|
+
|
91
|
+
def system_home
|
92
|
+
Sprout.current_system.home
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
module FlashPlayer
|
3
|
+
NAME = 'flashplayer'
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def home
|
8
|
+
# NOTE: Look up the value every time,
|
9
|
+
# this way we're not storing state globally
|
10
|
+
# and the performance penalty is minimal...
|
11
|
+
home_paths.each do |path|
|
12
|
+
return path if File.exists?(path)
|
13
|
+
end
|
14
|
+
raise FlashPlayer::PathError.new('FlashPlayer unable to find home folder for your System')
|
15
|
+
end
|
16
|
+
|
17
|
+
def trust
|
18
|
+
File.join home, '#Security', 'FlashPlayerTrust', 'sprout.cfg'
|
19
|
+
end
|
20
|
+
|
21
|
+
def flashlog
|
22
|
+
File.join home, 'Logs', 'flashlog.txt'
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def system_home
|
28
|
+
Sprout.current_system.home
|
29
|
+
end
|
30
|
+
|
31
|
+
def system_library
|
32
|
+
Sprout.current_system.library
|
33
|
+
end
|
34
|
+
|
35
|
+
# Collection of the potential locations of the Flash Player Home
|
36
|
+
# For each supported Platform, the first existing location
|
37
|
+
# will be used.
|
38
|
+
def home_paths
|
39
|
+
[
|
40
|
+
File.join(system_library, 'Preferences', 'Macromedia', 'Flash Player'),
|
41
|
+
File.join(system_library, 'Application Support', 'Macromedia'),
|
42
|
+
File.join(system_home, 'Application Data', 'Macromedia', 'Flash Player'),
|
43
|
+
File.join(system_home, 'AppData', 'Roaming', 'Macromedia', 'Flash Player'),
|
44
|
+
File.join(system_home, '.macromedia', 'Flash_Player')
|
45
|
+
]
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'flashsdk'
|
2
|
+
|
3
|
+
Sprout::Specification.new do |s|
|
4
|
+
s.name = FlashPlayer::NAME
|
5
|
+
s.version = FlashSDK::VERSION
|
6
|
+
|
7
|
+
s.add_remote_file_target do |t|
|
8
|
+
t.platform = :osx
|
9
|
+
t.archive_type = :zip
|
10
|
+
t.url = "http://download.macromedia.com/pub/flashplayer/updaters/10/flashplayer_10_sa_debug.app.zip"
|
11
|
+
t.md5 = "ff6824b7fd676dd1b613204221f5b5b9"
|
12
|
+
t.add_executable :flashplayer, "Flash Player Debugger.app/Contents/MacOS/Flash Player Debugger"
|
13
|
+
end
|
14
|
+
|
15
|
+
s.add_remote_file_target do |t|
|
16
|
+
t.platform = :win32
|
17
|
+
t.archive_type = :exe
|
18
|
+
t.url = "http://download.macromedia.com/pub/flashplayer/updaters/10/flashplayer_10_sa_debug.exe"
|
19
|
+
t.md5 = "4d8d58d72709f44421b2ea4e89cc30be"
|
20
|
+
t.add_executable :flashplayer, "flashplayer_10_sa_debug.exe"
|
21
|
+
end
|
22
|
+
|
23
|
+
s.add_remote_file_target do |t|
|
24
|
+
t.platform = :linux
|
25
|
+
t.archive_type = :tgz
|
26
|
+
t.url = "http://download.macromedia.com/pub/flashplayer/updaters/10/flashplayer_10_sa_debug.tar.gz"
|
27
|
+
t.md5 = "6cabe6038343374b547043d29de14417"
|
28
|
+
t.add_executable :flashplayer, "flashplayerdebugger"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|