h4oflashsdk 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/Gemfile +3 -0
  2. data/Gemfile.lock +41 -0
  3. data/POSTINSTALL.rdoc +79 -0
  4. data/README.textile +79 -0
  5. data/VERSION +1 -0
  6. data/bin/flashlog +8 -0
  7. data/bin/flashplayer +9 -0
  8. data/bin/sprout-as3 +9 -0
  9. data/bin/sprout-flex +8 -0
  10. data/ext/CloseFlashPlayerForDumbassOSX.scpt +6 -0
  11. data/ext/OpenFlashPlayerForDumbassOSX.scpt +12 -0
  12. data/flashsdk.gemspec +25 -0
  13. data/flashsdk.komodoproject +4 -0
  14. data/lib/flashplayer/errors.rb +12 -0
  15. data/lib/flashplayer/executable.rb +143 -0
  16. data/lib/flashplayer/log_file.rb +94 -0
  17. data/lib/flashplayer/mm_config.rb +96 -0
  18. data/lib/flashplayer/module.rb +51 -0
  19. data/lib/flashplayer/specification.rb +45 -0
  20. data/lib/flashplayer/system_mixins.rb +98 -0
  21. data/lib/flashplayer/task.legacy.rb +293 -0
  22. data/lib/flashplayer/task.rb +62 -0
  23. data/lib/flashplayer/trust.rb +45 -0
  24. data/lib/flashplayer.rb +9 -0
  25. data/lib/flashsdk/acompc.rb +29 -0
  26. data/lib/flashsdk/adl.rb +83 -0
  27. data/lib/flashsdk/adt.rb +276 -0
  28. data/lib/flashsdk/amxmlc.rb +28 -0
  29. data/lib/flashsdk/asdoc.rb +164 -0
  30. data/lib/flashsdk/compc.rb +124 -0
  31. data/lib/flashsdk/compiler_base.rb +1131 -0
  32. data/lib/flashsdk/fcsh.rb +173 -0
  33. data/lib/flashsdk/fcsh_socket.rb +167 -0
  34. data/lib/flashsdk/fdb.rb +833 -0
  35. data/lib/flashsdk/generators/class_generator.rb +87 -0
  36. data/lib/flashsdk/generators/flash_helper.rb +234 -0
  37. data/lib/flashsdk/generators/flex_project_generator.rb +30 -0
  38. data/lib/flashsdk/generators/project_generator.rb +31 -0
  39. data/lib/flashsdk/generators/templates/ActionScript3Class.as +9 -0
  40. data/lib/flashsdk/generators/templates/ActionScript3MainClass.as +11 -0
  41. data/lib/flashsdk/generators/templates/ActionScript3RunnerClass.as +19 -0
  42. data/lib/flashsdk/generators/templates/DefaultProjectImage.png +0 -0
  43. data/lib/flashsdk/generators/templates/Flex4Application.mxml +45 -0
  44. data/lib/flashsdk/generators/templates/Flex4Main.css +7 -0
  45. data/lib/flashsdk/generators/templates/Flex4Rakefile.rb +34 -0
  46. data/lib/flashsdk/generators/templates/Flex4RunnerClass.mxml +29 -0
  47. data/lib/flashsdk/generators/templates/FlexTestRunner.mxml +0 -0
  48. data/lib/flashsdk/generators/templates/Gemfile +5 -0
  49. data/lib/flashsdk/generators/templates/rakefile.rb +79 -0
  50. data/lib/flashsdk/module.rb +107 -0
  51. data/lib/flashsdk/mxmlc.rb +160 -0
  52. data/lib/flashsdk.rb +24 -0
  53. data/lib/flex3.rb +54 -0
  54. data/lib/flex4.rb +115 -0
  55. data/rakefile.rb +42 -0
  56. data/test/fixtures/acompc/simple/SomeAirFile.as +11 -0
  57. data/test/fixtures/air/simple/SomeProject.apk +1 -0
  58. data/test/fixtures/air/simple/SomeProject.as +11 -0
  59. data/test/fixtures/air/simple/SomeProject.mxml +9 -0
  60. data/test/fixtures/air/simple/SomeProject.pfx +0 -0
  61. data/test/fixtures/air/simple/SomeProject.swf +0 -0
  62. data/test/fixtures/air/simple/SomeProject.xml +13 -0
  63. data/test/fixtures/asdoc/lib/OtherFile.as +17 -0
  64. data/test/fixtures/asdoc/src/SomeFile.as +11 -0
  65. data/test/fixtures/compc/simple/SomeFile.as +11 -0
  66. data/test/fixtures/flashplayer/AsUnit Runner.swf +0 -0
  67. data/test/fixtures/mxmlc/broken/SomeFile.as +10 -0
  68. data/test/fixtures/mxmlc/simple/SomeFile.as +11 -0
  69. data/test/fixtures/sdk/fdb +90 -0
  70. data/test/fixtures/sdk/mxmlc +56 -0
  71. data/test/unit/acompc_test.rb +37 -0
  72. data/test/unit/adl_test.rb +32 -0
  73. data/test/unit/adt_test.rb +185 -0
  74. data/test/unit/amxmlc_test.rb +55 -0
  75. data/test/unit/asdoc_test.rb +45 -0
  76. data/test/unit/class_generator_test.rb +56 -0
  77. data/test/unit/compc_test.rb +37 -0
  78. data/test/unit/fake_flashplayer_system.rb +11 -0
  79. data/test/unit/fcsh_socket_test.rb +53 -0
  80. data/test/unit/fcsh_test.rb +55 -0
  81. data/test/unit/fdb_test.rb +54 -0
  82. data/test/unit/flash_helper_test.rb +43 -0
  83. data/test/unit/flashplayer_executable_test.rb +69 -0
  84. data/test/unit/flashplayer_log_file_test.rb +47 -0
  85. data/test/unit/flashplayer_mm_config_test.rb +74 -0
  86. data/test/unit/flashplayer_module_test.rb +56 -0
  87. data/test/unit/flashplayer_task_test.rb +91 -0
  88. data/test/unit/flashplayer_trust_test.rb +30 -0
  89. data/test/unit/flex_compiler_options_test.rb +213 -0
  90. data/test/unit/flex_generator_test.rb +37 -0
  91. data/test/unit/mxmlc_test.rb +65 -0
  92. data/test/unit/project_generator_test.rb +57 -0
  93. data/test/unit/test_helper.rb +18 -0
  94. metadata +284 -0
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,41 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ h4oflashsdk (1.0.0)
5
+ sprout (>= 1.1.18.pre)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ activesupport (3.2.8)
11
+ i18n (~> 0.6)
12
+ multi_json (~> 1.0)
13
+ archive-tar-minitar (0.5.2)
14
+ i18n (0.6.1)
15
+ metaclass (0.0.1)
16
+ mocha (0.12.4)
17
+ metaclass (~> 0.0.1)
18
+ multi_json (1.3.6)
19
+ open4 (1.3.0)
20
+ rake (0.9.2.2)
21
+ rubyzip (0.9.4)
22
+ shoulda (3.1.1)
23
+ shoulda-context (~> 1.0)
24
+ shoulda-matchers (~> 1.2)
25
+ shoulda-context (1.0.0)
26
+ shoulda-matchers (1.3.0)
27
+ activesupport (>= 3.0.0)
28
+ sprout (1.1.18.pre)
29
+ archive-tar-minitar (= 0.5.2)
30
+ bundler (>= 0.9.19)
31
+ open4 (>= 0.9.6)
32
+ rake (>= 0.9.2)
33
+ rubyzip (= 0.9.4)
34
+
35
+ PLATFORMS
36
+ ruby
37
+
38
+ DEPENDENCIES
39
+ h4oflashsdk!
40
+ mocha
41
+ shoulda
data/POSTINSTALL.rdoc ADDED
@@ -0,0 +1,79 @@
1
+ ++++++++++++++++++++++++++++++++
2
+ You have successfully installed the Project Sprouts Flash SDK!
3
+
4
+ To get started with a new ActionScript 3 project:
5
+
6
+ # Generate a project named 'SomeProject'
7
+ sprout-as3 SomeProject
8
+
9
+ # Change directory to the newly-created directory:
10
+ cd SomeProject
11
+
12
+ # Install whatever additional gems are required
13
+ # by this project Gemfile:
14
+ bundle install
15
+
16
+ # Use Rake to run the default task:
17
+ rake
18
+
19
+ ++++++++++++++++++++++++++++++++
20
+ Next Steps:
21
+
22
+ # Generate a new class, test case and test suite:
23
+ sprout-class utils.MathUtil
24
+
25
+ # Compile and run the test harness:
26
+ rake test
27
+
28
+ # List available rake tasks:
29
+ rake -T
30
+
31
+ # List available generators:
32
+ sprout-
33
+ (followed by the TAB key)
34
+
35
+ ++++++++++++++++++++++++++++++++
36
+ To use FCSH, simply start the service,
37
+ and call the fcsh task before any other
38
+ mxmlc or compc task:
39
+
40
+ # Open a new terminal and from your project:
41
+ rake fcsh:start
42
+
43
+ # Open a new terminal and from your project:
44
+ rake fcsh test
45
+
46
+ ++++++++++++++++++++++++++++++++
47
+ To use FDB, simply call the fdb task
48
+ before any flashplayer task:
49
+
50
+ # Run the default task with FDB:
51
+ rake fdb test
52
+
53
+ (type, 'help' for more info when prompted)
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
+
71
+ ++++++++++++++++++++++++++++++++
72
+ Issues or Questions?
73
+
74
+ Troubleshooting at:
75
+ http://projectsprouts.org/troubleshooting.html
76
+
77
+ Email us at:
78
+ projectsprouts@googlegroups.com
79
+
data/README.textile ADDED
@@ -0,0 +1,79 @@
1
+
2
+ h1. The Flash SDK Sprout Gem
3
+
4
+ h3. Installation
5
+
6
+ # "Install Ruby":http://www.ruby-lang.org/en/downloads/ _(>= v 1.8.7)_
7
+ # "Install RubyGems":http://rubyforge.org/frs/?group_id=126 _(>= v 1.3.6)_
8
+ # Install the Flash SDK prerelease gem:
9
+
10
+ <pre><code>gem install flashsdk --pre</code></pre>
11
+
12
+ h3. Getting Started
13
+
14
+ Open a terminal and enter the following commands:
15
+
16
+ Create a new ActionScript 3 project and move into it:
17
+
18
+ <pre><code>sprout-as3 SomeProject
19
+ cd SomeProject</code></pre>
20
+
21
+
22
+ Resolve all dependencies, compile and launch the SWF:
23
+
24
+ <pre><code>rake</code></pre>
25
+
26
+ Generate a new class, test case and test suite:
27
+
28
+ <pre><code>sprout-class utils.MathUtil</code></pre>
29
+
30
+ Compile and launch the test harness:
31
+
32
+ <pre><code>rake test</code></pre>
33
+
34
+ Compile a SWC file:
35
+
36
+ <pre><code>rake swc</code></pre>
37
+
38
+ Generate documentation using "AsDoc":http://labs.adobe.com/wiki/index.php/ASDoc:
39
+
40
+ <pre><code>rake asdoc</code></pre>
41
+
42
+ Execute the test harness, emit a JUnit-compatible test results document, and close the Flash Player when complete or after encountering an uncaught exception:
43
+
44
+ <pre><code>rake ci</code></pre>
45
+
46
+ Display all available Rake tasks:
47
+
48
+ <pre><code>rake -T</code></pre>
49
+
50
+ h3. Some Links
51
+
52
+ * "Web Site":http://projectsprouts.org
53
+ * "See the Documentation":http://projectsprouts.org/rdoc
54
+ * "Meet the Community":http://groups.google.com/group/projectsprouts
55
+
56
+ h3. MIT License
57
+
58
+ <pre>
59
+ Copyright (c) 2007-2010 Pattern Park
60
+
61
+ Permission is hereby granted, free of charge, to any person obtaining
62
+ a copy of this software and associated documentation files (the
63
+ "Software"), to deal in the Software without restriction, including
64
+ without limitation the rights to use, copy, modify, merge, publish,
65
+ distribute, sublicense, and/or sell copies of the Software, and to
66
+ permit persons to whom the Software is furnished to do so, subject to
67
+ the following conditions:
68
+
69
+ The above copyright notice and this permission notice shall be
70
+ included in all copies or substantial portions of the Software.
71
+
72
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
73
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
74
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
75
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
76
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
77
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
78
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
79
+ </pre>
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
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/bin/sprout-as3 ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'flashsdk'
5
+
6
+ generator = FlashSDK::ProjectGenerator.new
7
+ generator.parse! ARGV
8
+ generator.execute
9
+
data/bin/sprout-flex ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'flashsdk'
5
+
6
+ generator = FlashSDK::FlexProjectGenerator.new
7
+ generator.parse! ARGV
8
+ generator.execute
@@ -0,0 +1,6 @@
1
+
2
+ on run argv
3
+ set flash_player to item 1 of argv as text
4
+ tell application flash_player to quit
5
+ end run
6
+
@@ -0,0 +1,12 @@
1
+
2
+ on run argv
3
+ set flash_player to item 1 of argv as text
4
+ set swf_file to item 2 of argv as text
5
+ tell application flash_player to activate
6
+ tell application flash_player to open swf_file
7
+ repeat
8
+ if application flash_player is not running then exit repeat
9
+ delay 0.1
10
+ end repeat
11
+ end run
12
+
data/flashsdk.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib/', __FILE__)
3
+ $:.unshift lib unless $:.include?(lib)
4
+
5
+ require 'bundler'
6
+ require 'flashsdk/module.rb'
7
+
8
+ Gem::Specification.new do |s|
9
+ s.name = 'h4oflashsdk'
10
+ s.version = FlashSDK::VERSION
11
+ s.author = "Guenael LABOIS - H4o Studio"
12
+ s.email = "glabois@h4o-studio.com"
13
+ s.homepage = "http://www.adobe.com/products/flex"
14
+ s.summary = "Adobe Flash SDK including mxmlc, compc, asdoc, adl, adt, optimizer and fdb"
15
+ s.description = "The Flash SDK Rubygem is brought to you by Project Sprouts (http://projectsprouts.org)"
16
+ s.executables = ['sprout-as3', 'sprout-flex', 'flashplayer', 'flashlog']
17
+ s.post_install_message = File.read 'POSTINSTALL.rdoc'
18
+ s.files = Dir['**/*']
19
+ s.files.reject! { |fn| fn.match /.git|.svn|.DS_Store/ }
20
+ s.add_dependency('sprout', '>= 1.1.18.pre')
21
+ s.add_development_dependency('shoulda')
22
+ s.add_development_dependency('mocha')
23
+ s.require_paths << 'lib'
24
+ end
25
+
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- Komodo Project File - DO NOT EDIT -->
3
+ <project id="5f758bda-07d1-4717-8925-9c89041b60d9" kpf_version="5" name="flashsdk.komodoproject">
4
+ </project>
@@ -0,0 +1,12 @@
1
+
2
+ module FlashPlayer
3
+
4
+ ##
5
+ # Had trouble finding or resolving a path.
6
+ class PathError < StandardError; end
7
+
8
+ ##
9
+ # There was a problem with an input.
10
+ class UsageError < StandardError; end
11
+ end
12
+
@@ -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
+
@@ -0,0 +1,94 @@
1
+
2
+ module FlashPlayer
3
+
4
+ class LogFile
5
+
6
+ attr_accessor :logger
7
+
8
+ def initialize
9
+ @logger = $stdout
10
+ super
11
+ end
12
+
13
+ def tail thread=nil
14
+ tail_path flashlog_path, thread
15
+ end
16
+
17
+ private
18
+
19
+ def tail_path path, thread=nil
20
+ logger.puts ">> Tailing '#{path}', press CTRL+C to quit"
21
+ create_flashlog_at path
22
+ clear_flashlog_at path
23
+ read_flashlog_at path, thread
24
+ end
25
+
26
+ def read_flashlog_at path, thread=nil
27
+ thread ||= fake_thread
28
+ lines_put = 0
29
+
30
+ while thread.alive? do
31
+ lines_put = read_from_file path, lines_put
32
+ logger.flush
33
+ sleep(0.1)
34
+ end
35
+
36
+ logger.puts ""
37
+ logger.puts ">> Exiting from tailing '#{path}' at user request"
38
+ end
39
+
40
+ def read_from_file path, lines_put
41
+ File.open(path, 'r') do |file|
42
+ lines_read = 0
43
+ file.readlines.each do |line|
44
+ if(lines_read >= lines_put)
45
+ logger.puts "[trace] #{line}"
46
+ logger.flush
47
+ lines_put += 1
48
+ end
49
+ lines_read += 1
50
+ end
51
+ end unless !File.exists?(path)
52
+ lines_put
53
+ end
54
+
55
+ def flashlog_path
56
+ begin
57
+ FlashPlayer.flashlog
58
+ rescue FlashPlayer::PathError
59
+ "/dev/null"
60
+ end
61
+ end
62
+
63
+ def clear_flashlog_at path
64
+ File.open(path, 'w') do |f|
65
+ f.write('')
66
+ end
67
+ end
68
+
69
+ def create_flashlog_at path
70
+ if(!File.exists?(path))
71
+ FileUtils.makedirs(File.dirname(path))
72
+ FileUtils.touch(path)
73
+ end
74
+ end
75
+
76
+ def fake_thread
77
+ Thread.new do
78
+ while true
79
+ sleep(0.2)
80
+ end
81
+ end
82
+ end
83
+
84
+ end
85
+ end
86
+
87
+ desc "Tail the flashlog.txt and block (until CTRL+C)"
88
+ task :flashlog do
89
+ mm_config = FlashPlayer::MMConfig.new
90
+ mm_config.create
91
+ reader = FlashPlayer::LogFile.new
92
+ reader.tail
93
+ end
94
+
@@ -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,51 @@
1
+
2
+ module FlashPlayer
3
+ NAME = 'flashplayer'
4
+ VERSION = '11.1.102'
5
+
6
+ class << self
7
+
8
+ def home
9
+ # NOTE: Look up the value every time,
10
+ # this way we're not storing state globally
11
+ # and the performance penalty is minimal...
12
+ home_paths.each do |path|
13
+ return path if File.exists?(path)
14
+ end
15
+ raise FlashPlayer::PathError.new('FlashPlayer unable to find home folder for your System')
16
+ end
17
+
18
+ def trust
19
+ File.join home, '#Security', 'FlashPlayerTrust', 'sprout.cfg'
20
+ end
21
+
22
+ def flashlog
23
+ File.join home, 'Logs', 'flashlog.txt'
24
+ end
25
+
26
+ private
27
+
28
+ def system_home
29
+ Sprout.current_system.home
30
+ end
31
+
32
+ def system_library
33
+ Sprout.current_system.library
34
+ end
35
+
36
+ # Collection of the potential locations of the Flash Player Home
37
+ # For each supported Platform, the first existing location
38
+ # will be used.
39
+ def home_paths
40
+ [
41
+ File.join(system_library, 'Preferences', 'Macromedia', 'Flash Player'),
42
+ File.join(system_library, 'Application Support', 'Macromedia'),
43
+ File.join(system_home, 'Application Data', 'Macromedia', 'Flash Player'),
44
+ File.join(system_home, 'AppData', 'Roaming', 'Macromedia', 'Flash Player'),
45
+ File.join(system_home, '.macromedia', 'Flash_Player')
46
+ ]
47
+ end
48
+
49
+ end
50
+ end
51
+