flashsdk_sqe 0.0.1

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 +81 -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_sqe.gemspec +25 -0
  13. data/lib/flashplayer.rb +9 -0
  14. data/lib/flashplayer/errors.rb +12 -0
  15. data/lib/flashplayer/executable.rb +142 -0
  16. data/lib/flashplayer/log_file.rb +100 -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/flashsdk.rb +24 -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/flex3.rb +54 -0
  53. data/lib/flex4.rb +115 -0
  54. data/pkg/flashsdk_sqe-0.0.1.gem +0 -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 +200 -0
@@ -0,0 +1,87 @@
1
+
2
+ module FlashSDK
3
+
4
+ ##
5
+ # This Generator will create a new ActionScript class
6
+ # based on the +ActionScript3Class.as+ template.
7
+ #
8
+ # This Generator should only be executed from within
9
+ # a project that has a Gemfile. If your Gemfile
10
+ # loads the "asunit4" gem, a test case and test suite
11
+ # will also be created whenever this generator is run.
12
+ #
13
+ # You can run this generator as follows:
14
+ #
15
+ # $ sprout-class utils.MathUtil
16
+ #
17
+ # You can prevent the creation of a test case and test
18
+ # suite by sending in the +--no-test+ parameter as follows:
19
+ #
20
+ # $ sprout-class utils.MathUtil --no-test
21
+ #
22
+ class ClassGenerator < Sprout::Generator::Base
23
+ include FlashHelper
24
+
25
+ ##
26
+ # @return [String] The default package to use.
27
+ add_param :package, String, { :default => ""}
28
+
29
+ ##
30
+ # @return [String] The path where assets will be created.
31
+ add_param :assets, String, { :default => 'assets' }
32
+
33
+ ##
34
+ # @return [String] The path where skins will be created.
35
+ add_param :skins, String, { :default => 'skins' }
36
+
37
+ ##
38
+ # @return [String] The path where test cases should be created.
39
+ add_param :test, String, { :default => 'test' }
40
+
41
+ ##
42
+ # @return [String] The path where libraries should be added.
43
+ add_param :lib, String, { :default => 'lib' }
44
+
45
+ ##
46
+ # @return [String] The path where binaries should be created.
47
+ add_param :bin, String, { :default => 'bin' }
48
+
49
+ ##
50
+ # @return [String] The path where source files should be created.
51
+ add_param :src, String, { :default => 'src' }
52
+
53
+ ##
54
+ # @return [String] The path where documentation should be created.
55
+ add_param :doc, String, { :default => 'doc' }
56
+
57
+ ##
58
+ # @return [Boolean] Call the TestClassGenerator after creating class.
59
+ add_param :test_class, Boolean, { :default => true }
60
+
61
+ def manifest
62
+ if(!input.match(/Test$/))
63
+ directory class_directory do
64
+ template "#{class_name}.as", 'ActionScript3Class.as'
65
+ end
66
+ end
67
+
68
+ if test_class
69
+ generator :test_class, :input => "#{fully_qualified_class_name}Test"
70
+ end
71
+ end
72
+
73
+ end
74
+ end
75
+
76
+ module FlashSDK
77
+ ##
78
+ # This is a null Generator, if you add a test library
79
+ # to your Gemfile, it should have it's own TestClassGenerator
80
+ # that supercedes this one.
81
+ class TestClassGenerator < Sprout::Generator::Base
82
+
83
+ def manifest
84
+ end
85
+ end
86
+ end
87
+
@@ -0,0 +1,234 @@
1
+
2
+ module FlashSDK
3
+
4
+ ##
5
+ # The FlashHelper is a module that can be included into any {Sprout::Generator}
6
+ # in order to provide support for many common features.
7
+ #
8
+ # @example An example of how to use this helper:
9
+ #
10
+ # require 'flashsdk'
11
+ #
12
+ # class BigFatGenerator < Sprout::Generator::Base
13
+ # include FlashSDK::FlashHelper
14
+ #
15
+ # ...
16
+ # end
17
+ #
18
+ module FlashHelper
19
+
20
+ protected
21
+
22
+ ##
23
+ # @return [String] The directory of the package based on the +input+ string.
24
+ def package_directory
25
+ if package.include?('/')
26
+ remove_slashes package
27
+ end
28
+ split_package package
29
+ end
30
+
31
+ ##
32
+ # @param [String] A directory or path on disk with slashes like ('/')
33
+ # @return [String] The provided value with slashes replaced by dots.
34
+ def remove_slashes(value)
35
+ if value.include?('/')
36
+ value = value.split('/').join('.')
37
+ end
38
+ return value
39
+ end
40
+
41
+ ##
42
+ # @param value [String] A fully-qualified package or class name (com.example.project.SomeClass)
43
+ # @return [Array<String>] The provided package or class name split on the period.
44
+ # split on dots.
45
+ def split_package(value)
46
+ value.split('.')
47
+ end
48
+
49
+ ##
50
+ # @return [String] The directory for test cases that are related to the class provided by +input+
51
+ def test_class_directory
52
+ parts = input_in_parts
53
+ if parts.size > 1
54
+ parts.pop
55
+ return File.join test, *parts
56
+ end
57
+ return test
58
+ end
59
+
60
+ ##
61
+ # @return [String] Glob that is used to search for test cases and build
62
+ # up the test suites.
63
+ def test_glob
64
+ return @test_glob ||= File.join(path, test, '**', '?*Test.as')
65
+ end
66
+
67
+ # @return [String] The provided or default glob.
68
+ def test_glob= glob
69
+ @test_glob = glob
70
+ end
71
+
72
+ ##
73
+ # @return [Array<File>] Collection of all test case files either assigned or found
74
+ # using the test_glob as provided.
75
+ def test_cases
76
+ @test_cases ||= Dir.glob(test_glob)
77
+ end
78
+
79
+ ##
80
+ # @param [Array<String>] Set the collection of test cases as Files on disk.
81
+ # @return [Array<String>] Collection of all test case files that were assigned or found.
82
+ def test_cases= collection
83
+ @test_cases = collection
84
+ end
85
+
86
+ ##
87
+ # @return [Array<String>] Get the list of test_cases (which are files) as a
88
+ # list of fully qualified class names.
89
+ def test_case_classes
90
+ classes = self.test_cases.dup
91
+ classes.collect do |file|
92
+ actionscript_file_to_class_name(file)
93
+ end
94
+ end
95
+
96
+ ##
97
+ # Transform a file name in the source or test path
98
+ # into a fully-qualified class name.
99
+ #
100
+ # @param file [File] The path to a file on disk that is in the +src+ or +test+ folder.
101
+ # @return [String] The fully-qualified class name.
102
+ def actionscript_file_to_class_name file
103
+ name = file.dup
104
+ name.gsub!(/^#{path}\//, '') if respond_to? :path
105
+ name.gsub!(/^#{test}\//, '') if respond_to? :test
106
+ name.gsub!(/^#{src}\//, '') if respond_to? :src
107
+ name.gsub!(/.as$/, '')
108
+ name.gsub!(/#{File::SEPARATOR}/, '.')
109
+ return name
110
+ end
111
+
112
+ ##
113
+ # @return [String] The directory that contains the +input+ class.
114
+ def class_directory
115
+ parts = input_in_parts
116
+ if parts.size > 1
117
+ parts.pop
118
+ return File.join src, *parts
119
+ end
120
+ return src
121
+ end
122
+
123
+ ##
124
+ # @return [String] The package that provided on the command line at +--package+
125
+ def default_package_name
126
+ remove_slashes package
127
+ end
128
+
129
+ ##
130
+ # @return [String] The package that was provided on the command line at +--input+
131
+ def package_name
132
+ parts = input_in_parts
133
+ if parts.size > 1
134
+ parts.pop
135
+ return "#{parts.join('.')} "
136
+ end
137
+ return ""
138
+ end
139
+
140
+ ##
141
+ # @return [String] The fully-qualified class name provided on the command line at +--input+.
142
+ def class_name
143
+ parts = input_in_parts
144
+ name = parts.pop.camel_case
145
+ if(name.match(/Test$/))
146
+ return name.gsub(/Test$/, '')
147
+ end
148
+ name
149
+ end
150
+
151
+ ##
152
+ # @return [String] The fully-qualified test class name based on the +--input+
153
+ # argument provided on the command line.
154
+ def test_class_name
155
+ source = class_name
156
+ if(!source.match(/Test$/))
157
+ return "#{source}Test"
158
+ end
159
+ source
160
+ end
161
+
162
+ ##
163
+ # @return [String] The project name provided as +--input+ on the command line.
164
+ # This is probably only helpful for project generators.
165
+ def project_name
166
+ input.camel_case
167
+ end
168
+
169
+ ##
170
+ # @return [String] Currently returns hard-coded 'instance'.
171
+ def instance_name
172
+ # TODO: should uncapitalize class_name
173
+ # (not the same as lowercase)
174
+ # If the name is > 12 character, just
175
+ # use 'instance' instead.
176
+ 'instance'
177
+ end
178
+
179
+ ##
180
+ # @param value [String] If no value is provided, will use +--input+ instead.
181
+ # @return [Array<String>] An Array of the provided string split on slahes
182
+ # or dots with the file extension removed.
183
+ def input_in_parts(value=nil)
184
+ provided_input = value || input.dup
185
+ provided_input.gsub! /^#{src}\//, '' if respond_to? :src
186
+ provided_input = provided_input.split('/').join('.')
187
+
188
+ remove_file_extensions(provided_input).split('.')
189
+ end
190
+
191
+ ##
192
+ # @return [String] The fully qualified class name version of whatever was +input+.
193
+ def fully_qualified_class_name
194
+ remove_slashes remove_file_extensions(input)
195
+ end
196
+
197
+ ##
198
+ # @param value [String] A string that may have a file extension.
199
+ # @return [String] A new String with common file extensions
200
+ # (.as, .mxml, .xml) removed from the provided value.
201
+ def remove_file_extensions value
202
+ value = value.dup
203
+ value.gsub!(/\.as$/, '')
204
+ value.gsub!(/\.mxml$/, '')
205
+ value.gsub!(/\.xml$/, '')
206
+ return value
207
+ end
208
+
209
+ ##
210
+ # @return [String] The +class_name+ with '.swf' appended.
211
+ def deploy_swf_name
212
+ "#{class_name}.swf"
213
+ end
214
+
215
+ ##
216
+ # @return [String] The +class_name+ with '-debug.swf' appended.
217
+ def debug_swf_name
218
+ "#{class_name}-debug.swf"
219
+ end
220
+
221
+ ##
222
+ # @return [String] The +class_name+ with '-test.swf' appendend.
223
+ def test_swf_name
224
+ "#{class_name}-test.swf"
225
+ end
226
+
227
+ ##
228
+ # @return [String] The +class_name+ with 'Runner.swf' appended.
229
+ def test_runner_name
230
+ "#{class_name}Runner"
231
+ end
232
+
233
+ end
234
+ end
@@ -0,0 +1,30 @@
1
+ module FlashSDK
2
+ class FlexProjectGenerator < ProjectGenerator
3
+
4
+ def manifest
5
+ directory input do
6
+ template 'Rakefile', 'Flex4Rakefile.rb'
7
+ template 'Gemfile'
8
+
9
+ directory src do
10
+ template "#{input.camel_case}.mxml", 'Flex4Application.mxml'
11
+ template "#{test_runner_name}.mxml", 'Flex4RunnerClass.mxml'
12
+
13
+ directory assets do
14
+ directory css do
15
+ file 'Main.css', 'Flex4Main.css'
16
+ end
17
+ directory images
18
+ directory fonts
19
+ end
20
+
21
+ end
22
+
23
+ # Create empty directories:
24
+ directory lib
25
+ directory bin
26
+ end
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,31 @@
1
+ module FlashSDK
2
+ class ProjectGenerator < ClassGenerator
3
+
4
+ add_param :css, Path, { :default => 'css' }
5
+ add_param :images, Path, { :default => 'images' }
6
+ add_param :fonts, Path, { :default => 'fonts' }
7
+
8
+ def manifest
9
+ directory input do
10
+ template 'rakefile.rb'
11
+ template 'Gemfile'
12
+
13
+ directory src do
14
+ template "#{input.camel_case}.as", 'ActionScript3MainClass.as'
15
+ template "#{test_runner_name}.as", 'ActionScript3RunnerClass.as'
16
+ end
17
+
18
+ directory assets do
19
+ directory skins do
20
+ file 'DefaultProjectImage.png'
21
+ end
22
+ end
23
+
24
+ # Create empty directories:
25
+ directory lib
26
+ directory bin
27
+ end
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,9 @@
1
+ package <%= package_name %>{
2
+
3
+ public class <%= class_name %> {
4
+
5
+ public function <%= class_name %>() {
6
+ }
7
+ }
8
+ }
9
+
@@ -0,0 +1,11 @@
1
+ package <%= package_name %>{
2
+ import flash.display.Sprite;
3
+
4
+ public class <%= class_name %> extends Sprite {
5
+
6
+ public function <%= class_name %>() {
7
+ trace(">> <%= class_name %> Instantiated!");
8
+ }
9
+ }
10
+ }
11
+
@@ -0,0 +1,19 @@
1
+ package {
2
+ import asunit.core.TextCore;
3
+ import flash.display.MovieClip;
4
+
5
+ public class <%= test_runner_name %> extends MovieClip {
6
+
7
+ private var core:TextCore;
8
+
9
+ public function <%= test_runner_name %>() {
10
+ core = new TextCore();
11
+ // You can run a single Test Case with:
12
+ // core.start(SomeTest, null, this);
13
+ // Or a single test method with:
14
+ // core.start(SomeTest, 'testMethod', this);
15
+ core.start(AllTests, null, this);
16
+ }
17
+ }
18
+ }
19
+
@@ -0,0 +1,45 @@
1
+ <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
2
+ xmlns:s="library://ns.adobe.com/flex/spark"
3
+ xmlns:mx="library://ns.adobe.com/flex/mx"
4
+ minWidth="800"
5
+ minHeight="600"
6
+ width="1024"
7
+ height="768"
8
+ pageTitle="<%= project_name %>"
9
+ applicationComplete="<%= project_name %>CompleteHandler()">
10
+
11
+ <fx:Declarations>
12
+
13
+ <!-- You have to put all non-visual object declarations here -->
14
+
15
+ </fx:Declarations>
16
+
17
+ <s:Label id="myLabel"
18
+ text="<%= project_name %>"
19
+ width="100%"
20
+ height="100%"
21
+ fontSize="200" />
22
+
23
+ <fx:Style source="./assets/css/Main.css" />
24
+
25
+ <fx:Script>
26
+
27
+ <![CDATA[
28
+
29
+ //---------------------------------------
30
+ // PRIVATE METHODS
31
+ //---------------------------------------
32
+
33
+ /**
34
+ * @private
35
+ */
36
+ private function <%= project_name %>CompleteHandler():void
37
+ {
38
+ trace("<%= project_name %>.mxml::<%= project_name %>CompleteHandler()");
39
+ }
40
+ ]]>
41
+
42
+ </fx:Script>
43
+
44
+ </s:Application>
45
+