flashsdk 1.0.23.pre → 1.0.25.pre

Sign up to get free protection for your applications and to get access to all the features.
data/POSTINSTALL.rdoc CHANGED
@@ -52,6 +52,22 @@ before any flashplayer task:
52
52
 
53
53
  (type, 'help' for more info when prompted)
54
54
 
55
+ ++++++++++++++++++++++++++++++++
56
+ You can also launch any SWF file using
57
+ a debug Flash Player with:
58
+
59
+ flashplayer bin/SomeProject.swf
60
+
61
+ Or run a SWF with FDB like:
62
+
63
+ flashplayer --fdb bin/SomeProject.swf
64
+
65
+ ++++++++++++++++++++++++++++++++
66
+ You can also tail your system's flashlog
67
+ while running a SWF or HTML page with:
68
+
69
+ flashlog
70
+
55
71
  ++++++++++++++++++++++++++++++++
56
72
  Issues or Questions?
57
73
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.23.pre
1
+ 1.0.25.pre
data/bin/flashlog ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'flashsdk'
5
+
6
+ reader = FlashPlayer::LogFile.new
7
+ reader.tail
8
+
data/bin/flashplayer ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'flashsdk'
5
+
6
+ player = FlashPlayer::Executable.new
7
+ player.parse! ARGV
8
+ player.execute
9
+
data/flashsdk.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.homepage = "http://www.adobe.com/products/flex"
14
14
  s.summary = "Adobe Flash SDK including mxmlc, compc, asdoc, adl, adt, optimizer and fdb"
15
15
  s.description = "The Flash SDK Rubygem is brought to you by Project Sprouts (http://projectsprouts.org)"
16
- s.executables = ['sprout-as3', 'sprout-flex']
16
+ s.executables = ['sprout-as3', 'sprout-flex', 'flashplayer', 'flashlog']
17
17
  s.post_install_message = File.read 'POSTINSTALL.rdoc'
18
18
  s.files = FileList['**/**/*'].exclude /.git|.svn|.DS_Store/
19
19
  s.add_bundler_dependencies
@@ -0,0 +1,143 @@
1
+
2
+ module FlashPlayer
3
+
4
+ class Executable < Sprout::Executable::Base
5
+
6
+ attr_accessor :stdout
7
+ attr_accessor :stderr
8
+
9
+ ##
10
+ # The file that the Flash Player should launch.
11
+ #
12
+ # flashplayer bin/SomeProject.swf
13
+ #
14
+ add_param :input, String, { :hidden_name => true, :required => true }
15
+
16
+ ##
17
+ # Drop into FDB after launching the Player.
18
+ #
19
+ # flashplayer --fdb bin/SomeProject.swf
20
+ #
21
+ add_param :fdb, Boolean, { :hidden_value => true }
22
+
23
+ ##
24
+ # The Flash Player version to use.
25
+ add_param :version, String, { :default => FlashPlayer::VERSION }
26
+
27
+ def initialize
28
+ super
29
+ @mm_config = MMConfig.new
30
+ @reader = LogFile.new
31
+ @trust_config = Trust.new
32
+ @process = nil
33
+ @stdout = $stdout
34
+ @stderr = $stderr
35
+ @logger = $stdout
36
+ self.pkg_name = FlashPlayer::NAME
37
+ self.pkg_version = FlashPlayer::VERSION
38
+ end
39
+
40
+ def execute *args
41
+ execute_safely do
42
+ update_mm_config
43
+ update_trust_config_with input
44
+ end
45
+
46
+ if use_fdb?
47
+ launch_fdb_and_player_with input
48
+ else
49
+ player_thread = launch_player_with input
50
+ tail_flashlog player_thread
51
+ end
52
+ end
53
+
54
+ def use_fdb?
55
+ # Check as string b/c this is
56
+ # how the boolean value comes
57
+ # accross the command line input.
58
+ fdb || ENV['USE_FDB'].to_s == 'true'
59
+ end
60
+
61
+ def logger=(logger)
62
+ @logger = logger
63
+ @mm_config.logger = logger
64
+ @reader.logger = logger
65
+ @trust_config.logger = logger
66
+ end
67
+
68
+ def logger
69
+ @logger
70
+ end
71
+
72
+ private
73
+
74
+ def launch_fdb_and_player_with input
75
+ # Keep getting a fatal lock error which I believe
76
+ # is being caused by the FlashPlayer and FDB attempting
77
+ # to write to stdout simultaneously.
78
+ # Trying to give fdb a fake stream until after the
79
+ # player is launched...
80
+ fake_out = Sprout::OutputBuffer.new
81
+ fake_err = Sprout::OutputBuffer.new
82
+
83
+ fdb_instance = FlashSDK::FDB.new
84
+ fdb_instance.stdout = fake_out
85
+ fdb_instance.stderr = fake_err
86
+ fdb_instance.execute false
87
+ fdb_instance.run
88
+ player_thread = launch_player_with input
89
+
90
+ # Emit whatever messages have been passed:
91
+ stdout.puts fake_out.read
92
+ stdout.flush
93
+ stderr.puts fake_err.read
94
+ stdout.flush
95
+ # Replace the fdb instance streams with
96
+ # the real ones:
97
+ fdb_instance.stdout = stdout
98
+ fdb_instance.stderr = stderr
99
+
100
+ # Let the user interact with fdb:
101
+ fdb_instance.handle_user_input
102
+
103
+ fdb_instance.wait
104
+ player_thread.join if player_thread.alive?
105
+ end
106
+
107
+ def execute_safely
108
+ begin
109
+ Thread.abort_on_exception = true
110
+ yield if block_given?
111
+ rescue FlashPlayer::PathError => e
112
+ logger.puts ">> [WARNING] It seems this was the first time FlashPlayer was launched on this system and as a result, the expected folders were not found. Please close the Player and run again - this message should only ever be displayed once."
113
+ end
114
+ end
115
+
116
+ def update_mm_config
117
+ @mm_config.create
118
+ end
119
+
120
+ def update_trust_config_with swf
121
+ @trust_config.add File.dirname(swf)
122
+ end
123
+
124
+ def clean_path path
125
+ current_system.clean_path path
126
+ end
127
+
128
+ def current_system
129
+ @current_system ||= Sprout.current_system
130
+ end
131
+
132
+ def launch_player_with swf
133
+ player = Sprout::Executable.load(:flashplayer, pkg_name, pkg_version).path
134
+ current_system.open_flashplayer_with player, clean_path(swf)
135
+ end
136
+
137
+ def tail_flashlog player_thread
138
+ @reader.tail player_thread
139
+ end
140
+
141
+ end
142
+ end
143
+
@@ -7,52 +7,31 @@ module FlashPlayer
7
7
  attr_accessor :pkg_name
8
8
  attr_accessor :pkg_version
9
9
 
10
- attr_accessor :stdout
11
- attr_accessor :stderr
12
-
13
10
  ##
14
11
  # This is the Rake::Task constructor
15
12
  # signature...
16
13
  def initialize task_name, rake_application
17
14
  super
18
- @mm_config = MMConfig.new
19
- @reader = LogFile.new
20
- @trust_config = Trust.new
21
- @process = nil
22
- @input = task_name
23
- @stdout = $stdout
24
- @stderr = $stderr
25
- @logger = $stdout
26
-
27
- @pkg_name = FlashPlayer::NAME
28
- @pkg_version = FlashPlayer::VERSION
15
+ @input = task_name
16
+ @player = FlashPlayer::Executable.new
17
+ @pkg_name = FlashPlayer::NAME
18
+ @pkg_version = FlashPlayer::VERSION
29
19
  end
30
20
 
31
21
  def execute *args
32
22
  super
33
23
  update_input_if_necessary
34
- execute_safely do
35
- update_mm_config
36
- update_trust_config_with input
37
- end
38
-
39
- if use_fdb?
40
- launch_fdb_and_player_with input
41
- else
42
- player_thread = launch_player_with input
43
- tail_flashlog player_thread
44
- end
24
+ @player.input = input
25
+ @player.fdb = use_fdb?
26
+ @player.execute
45
27
  end
46
28
 
47
29
  def logger=(logger)
48
- @logger = logger
49
- @mm_config.logger = logger
50
- @reader.logger = logger
51
- @trust_config.logger = logger
30
+ @player.logger = logger
52
31
  end
53
32
 
54
33
  def logger
55
- @logger
34
+ @player.logger
56
35
  end
57
36
 
58
37
  private
@@ -64,48 +43,6 @@ module FlashPlayer
64
43
  ENV['USE_FDB'].to_s == 'true'
65
44
  end
66
45
 
67
- def launch_fdb_and_player_with input
68
- # Keep getting a fatal lock error which I believe
69
- # is being caused by the FlashPlayer and FDB attempting
70
- # to write to stdout simultaneously.
71
- # Trying to give fdb a fake stream until after the
72
- # player is launched...
73
- fake_out = Sprout::OutputBuffer.new
74
- fake_err = Sprout::OutputBuffer.new
75
-
76
- fdb_instance = FlashSDK::FDB.new
77
- fdb_instance.stdout = fake_out
78
- fdb_instance.stderr = fake_err
79
- fdb_instance.execute false
80
- fdb_instance.run
81
- player_thread = launch_player_with input
82
-
83
- # Emit whatever messages have been passed:
84
- stdout.puts fake_out.read
85
- stdout.flush
86
- stderr.puts fake_err.read
87
- stdout.flush
88
- # Replace the fdb instance streams with
89
- # the real ones:
90
- fdb_instance.stdout = stdout
91
- fdb_instance.stderr = stderr
92
-
93
- # Let the user interact with fdb:
94
- fdb_instance.handle_user_input
95
-
96
- fdb_instance.wait
97
- player_thread.join if player_thread.alive?
98
- end
99
-
100
- def execute_safely
101
- begin
102
- Thread.abort_on_exception = true
103
- yield if block_given?
104
- rescue FlashPlayer::PathError => e
105
- logger.puts ">> [WARNING] It seems this was the first time FlashPlayer was launched on this system and as a result, the expected folders were not found. Please close the Player and run again - this message should only ever be displayed once."
106
- end
107
- end
108
-
109
46
  def update_input_if_necessary
110
47
  return if input.match(/\.swf$/)
111
48
  prerequisites.each do |prereq|
@@ -116,30 +53,6 @@ module FlashPlayer
116
53
  end
117
54
  end
118
55
 
119
- def update_mm_config
120
- @mm_config.create
121
- end
122
-
123
- def update_trust_config_with swf
124
- @trust_config.add File.dirname(swf)
125
- end
126
-
127
- def clean_path path
128
- current_system.clean_path path
129
- end
130
-
131
- def current_system
132
- @current_system ||= Sprout.current_system
133
- end
134
-
135
- def launch_player_with swf
136
- player = Sprout::Executable.load(:flashplayer, pkg_name, pkg_version).path
137
- current_system.open_flashplayer_with player, clean_path(swf)
138
- end
139
-
140
- def tail_flashlog player_thread
141
- @reader.tail player_thread
142
- end
143
56
  end
144
57
  end
145
58
 
data/lib/flashplayer.rb CHANGED
@@ -4,6 +4,7 @@ require 'flashplayer/module'
4
4
  require 'flashplayer/mm_config'
5
5
  require 'flashplayer/trust'
6
6
  require 'flashplayer/log_file'
7
+ require 'flashplayer/executable'
7
8
  require 'flashplayer/task'
8
9
  require 'flashplayer/specification'
9
10
 
@@ -0,0 +1,11 @@
1
+
2
+ class FakeFlashPlayerSystem
3
+
4
+ def clean_path path
5
+ path
6
+ end
7
+
8
+ def open_flashplayer_with player, swf
9
+ end
10
+ end
11
+
@@ -0,0 +1,69 @@
1
+ require 'test_helper'
2
+ require 'fake_flashplayer_system'
3
+
4
+ class FlashPlayerExecutableTest < Test::Unit::TestCase
5
+ include Sprout::TestHelper
6
+
7
+ context "A FlashPlayer Executable" do
8
+
9
+ setup do
10
+ # Force reload of the Specification on each
11
+ # test method b/c Sprout::TestHelper calls
12
+ # Executable.clear_entities! but 'require'
13
+ # only runs once per VM run...
14
+ load 'flashplayer/specification.rb'
15
+ @swf = File.join(fixtures, 'flashplayer', 'AsUnit Runner.swf')
16
+ @missing_home = File.join(fixtures, 'missing_folder')
17
+ @config_path = File.join(@missing_home, 'fp_config', 'mm.cfg')
18
+
19
+ Sprout.stdout = $stdout
20
+ Sprout.stderr = $stderr
21
+ end
22
+
23
+ teardown do
24
+ remove_file @missing_home
25
+ ENV['USE_FDB'] = 'false'
26
+ end
27
+
28
+ ## THIS METHOD SHOULD BE COMMENTED OUT....
29
+ =begin
30
+ should "launch SWF on os x" do
31
+ # No creation of expected FlashPlayer folders...
32
+
33
+ #FlashPlayer.stubs(:home).returns @missing_home
34
+ #FlashPlayer::MMConfig.any_instance.stubs(:system_home).returns @missing_home
35
+ #FlashPlayer::MMConfig.any_instance.stubs(:config_path).returns @config_path
36
+ #FlashPlayer::MMConfig.any_instance.stubs(:user_confirmation?).returns false
37
+
38
+ #ENV['USE_FDB'] = 'true'
39
+
40
+ as_a_mac_system do
41
+ player = FlashPlayer::Executable.new
42
+ player.input = @swf
43
+ player.fdb = true
44
+ player.execute
45
+ end
46
+ end
47
+ =end
48
+
49
+ should "work with input" do
50
+ player = FlashPlayer::Executable.new
51
+ player.input = @swf
52
+ configure player
53
+ player.execute
54
+ end
55
+
56
+ end
57
+
58
+ private
59
+
60
+ def configure player
61
+ player.logger = StringIO.new
62
+
63
+ # Comment following lines to really launch the player:
64
+ sys = FakeFlashPlayerSystem.new
65
+ player.stubs(:current_system).returns sys
66
+ sys.expects(:open_flashplayer_with).returns Thread.new{}
67
+ end
68
+ end
69
+
@@ -1,4 +1,5 @@
1
1
  require 'test_helper'
2
+ require 'fake_flashplayer_system'
2
3
 
3
4
  class TaskTest < Test::Unit::TestCase
4
5
  include Sprout::TestHelper
@@ -15,8 +16,8 @@ class TaskTest < Test::Unit::TestCase
15
16
  @missing_home = File.join(fixtures, 'missing_folder')
16
17
  @config_path = File.join(@missing_home, 'fp_config', 'mm.cfg')
17
18
 
18
- Sprout.stdout = $stdout
19
- Sprout.stderr = $stderr
19
+ #Sprout.stdout = $stdout
20
+ #Sprout.stderr = $stderr
20
21
  end
21
22
 
22
23
  teardown do
@@ -83,18 +84,8 @@ class TaskTest < Test::Unit::TestCase
83
84
 
84
85
  # Comment following lines to really launch the player:
85
86
  sys = FakeFlashPlayerSystem.new
86
- t.stubs(:current_system).returns sys
87
+ FlashPlayer::Executable.any_instance.stubs(:current_system).returns sys
87
88
  sys.expects(:open_flashplayer_with).returns Thread.new{}
88
89
  end
89
90
  end
90
91
 
91
- class FakeFlashPlayerSystem
92
-
93
- def clean_path path
94
- path
95
- end
96
-
97
- def open_flashplayer_with player, swf
98
- end
99
- end
100
-
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 23
8
+ - 25
9
9
  - pre
10
- version: 1.0.23.pre
10
+ version: 1.0.25.pre
11
11
  platform: ruby
12
12
  authors:
13
13
  - Luke Bayes
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-01 00:00:00 -08:00
18
+ date: 2011-03-03 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -65,11 +65,15 @@ email: projectsprouts@googlegroups.com
65
65
  executables:
66
66
  - sprout-as3
67
67
  - sprout-flex
68
+ - flashplayer
69
+ - flashlog
68
70
  extensions: []
69
71
 
70
72
  extra_rdoc_files: []
71
73
 
72
74
  files:
75
+ - bin/flashlog
76
+ - bin/flashplayer
73
77
  - bin/sprout-as3
74
78
  - bin/sprout-flex
75
79
  - ext/CloseFlashPlayerForDumbassOSX.scpt
@@ -78,6 +82,7 @@ files:
78
82
  - Gemfile
79
83
  - Gemfile.lock
80
84
  - lib/flashplayer/errors.rb
85
+ - lib/flashplayer/executable.rb
81
86
  - lib/flashplayer/log_file.rb
82
87
  - lib/flashplayer/mm_config.rb
83
88
  - lib/flashplayer/module.rb
@@ -138,10 +143,12 @@ files:
138
143
  - test/unit/asdoc_test.rb
139
144
  - test/unit/class_generator_test.rb
140
145
  - test/unit/compc_test.rb
146
+ - test/unit/fake_flashplayer_system.rb
141
147
  - test/unit/fcsh_socket_test.rb
142
148
  - test/unit/fcsh_test.rb
143
149
  - test/unit/fdb_test.rb
144
150
  - test/unit/flash_helper_test.rb
151
+ - test/unit/flashplayer_executable_test.rb
145
152
  - test/unit/flashplayer_log_file_test.rb
146
153
  - test/unit/flashplayer_mm_config_test.rb
147
154
  - test/unit/flashplayer_module_test.rb
@@ -211,6 +218,22 @@ post_install_message: |+
211
218
 
212
219
  (type, 'help' for more info when prompted)
213
220
 
221
+ ++++++++++++++++++++++++++++++++
222
+ You can also launch any SWF file using
223
+ a debug Flash Player with:
224
+
225
+ flashplayer bin/SomeProject.swf
226
+
227
+ Or run a SWF with FDB like:
228
+
229
+ flashplayer --fdb bin/SomeProject.swf
230
+
231
+ ++++++++++++++++++++++++++++++++
232
+ You can also tail your system's flashlog
233
+ while running a SWF or HTML page with:
234
+
235
+ flashlog
236
+
214
237
  ++++++++++++++++++++++++++++++++
215
238
  Issues or Questions?
216
239