sprout-as2-bundle 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +47 -0
- data/lib/sprout/as2/version.rb +12 -0
- data/lib/sprout/as2.rb +5 -0
- data/lib/sprout/as2_tasks.rb +5 -0
- data/lib/sprout/generators/class/USAGE +42 -0
- data/lib/sprout/generators/class/class_generator.rb +35 -0
- data/lib/sprout/generators/class/templates/Class.as +10 -0
- data/lib/sprout/generators/class/templates/Component.mxml +8 -0
- data/lib/sprout/generators/class/templates/TestCase.as +30 -0
- data/lib/sprout/generators/class/templates/TestSuite.as +15 -0
- data/lib/sprout/generators/project/project_generator.rb +30 -0
- data/lib/sprout/generators/project/templates/DefaultSkin.as +7 -0
- data/lib/sprout/generators/project/templates/MainClass.as +20 -0
- data/lib/sprout/generators/project/templates/ProjectSprouts.jpg +0 -0
- data/lib/sprout/generators/project/templates/README.txt +56 -0
- data/lib/sprout/generators/project/templates/SWFMillTemplate.erb +13 -0
- data/lib/sprout/generators/project/templates/TestRunner.as +17 -0
- data/lib/sprout/generators/project/templates/generate +21 -0
- data/lib/sprout/generators/project/templates/rakefile.rb +88 -0
- data/lib/sprout/generators/suite/USAGE +0 -0
- data/lib/sprout/generators/suite/suite_generator.rb +17 -0
- data/lib/sprout/generators/suite/templates/TestSuite.as +18 -0
- data/lib/sprout/generators/test/USAGE +37 -0
- data/lib/sprout/generators/test/templates/TestCase.as +30 -0
- data/lib/sprout/generators/test/templates/TestSuite.as +18 -0
- data/lib/sprout/generators/test/test_generator.rb +20 -0
- data/lib/sprout/tasks/mtasc_doc.rb +112 -0
- data/lib/sprout/tasks/mtasc_task.rb +262 -0
- data/lib/sprout/tasks/swfmill_doc.rb +31 -0
- data/lib/sprout/tasks/swfmill_input_task.rb +135 -0
- data/lib/sprout/tasks/swfmill_task.rb +100 -0
- data/rakefile.rb +66 -0
- metadata +126 -0
data/README
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
= ActionScript 2.0 Bundle
|
3
|
+
|
4
|
+
The ActionScript 2 Bundle provides support for ActionScript 2.0 project and class generators as well as Rake build tasks.
|
5
|
+
|
6
|
+
You can install this bundle and run it's project generator as follows:
|
7
|
+
|
8
|
+
sprout -n as2 SomeProject
|
9
|
+
|
10
|
+
Once you have generated a new project, using a terminal, you can change to the newly created directory
|
11
|
+
and use script/generate to create a variety of other features.
|
12
|
+
|
13
|
+
To generate a new ActionScript class, test case and test suite, simply run the following from the
|
14
|
+
same directory as your rakefile.
|
15
|
+
|
16
|
+
script/generate class [fully-qualified-class-name]
|
17
|
+
|
18
|
+
For example:
|
19
|
+
|
20
|
+
script/generate class utils.MathUtil
|
21
|
+
|
22
|
+
While you can change where classes are created by modifying your ProjectModel,
|
23
|
+
if the default values are used, the following statements should be correct:
|
24
|
+
|
25
|
+
The class will be created in:
|
26
|
+
src/utils/MathUtil.as
|
27
|
+
The test case will will be created in:
|
28
|
+
test/utils/MathUtilTest.as
|
29
|
+
The test suite will be created or updated at:
|
30
|
+
test/AllTests.as
|
31
|
+
|
32
|
+
If the class name passed into this generator ends with 'Test', only a test case
|
33
|
+
and test suite will be generated in the test package and no class will be generated.
|
34
|
+
|
35
|
+
You can also only create the test case and test suite by calling it's generator directly as follows:
|
36
|
+
|
37
|
+
script/generate test utils.MathUtilTest
|
38
|
+
|
39
|
+
You can update only your test suite by simply initiating the suite generator as follows:
|
40
|
+
|
41
|
+
script/generate suite
|
42
|
+
|
43
|
+
= Available Rake Tasks
|
44
|
+
|
45
|
+
* Sprout::MTASCTask
|
46
|
+
* Sprout::SWFMillInputTask
|
47
|
+
* Sprout::SWFMillTask
|
data/lib/sprout/as2.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
Description:
|
2
|
+
Stubs out a new ActionScript class and test case and then rebuilds all test
|
3
|
+
suites. Pass the fully-qualified class name, either as a shell file target
|
4
|
+
or a dot-delimited string.
|
5
|
+
|
6
|
+
This command uses the Sprout::Generator::NamedBase class which will search
|
7
|
+
for configuration parameters as follows:
|
8
|
+
|
9
|
+
1) Command line parameters will supercede any of the following.
|
10
|
+
2) Search the current working directory and all parent directories
|
11
|
+
for a valid Rakefile.
|
12
|
+
3) If a Rakefile is not found, classes will be created directly from the
|
13
|
+
current working directory.
|
14
|
+
4) If a Rakefile is found, it will be loaded. If the rakefile instantiates
|
15
|
+
a Sprout::ProjectModel, that configuration will be used for source and test
|
16
|
+
paths, language preferences, and other values.
|
17
|
+
5) If no ProjectModel is instantiated in your Rakefile, the Rakefile itself
|
18
|
+
will be treated as the project root, and classes will be created from that
|
19
|
+
directory.
|
20
|
+
|
21
|
+
You can edit the erb templates that this command uses in a variety of ways.
|
22
|
+
If you would like to edit the templates for all projects on your system,
|
23
|
+
simply copy the directory at: File.dirname(__FILE__) into:
|
24
|
+
|
25
|
+
#{SPROUT_HOME}/sprout/generators/
|
26
|
+
|
27
|
+
To edit templates for a single project, copy the directory to:
|
28
|
+
|
29
|
+
#{PROJECT_HOME}/script/generators/
|
30
|
+
|
31
|
+
Once you have the contents of this package copied, simply edit the files found
|
32
|
+
in the templates/ folder to your satisfaction.
|
33
|
+
|
34
|
+
Example:
|
35
|
+
`./script/generate class utils.MathUtil`
|
36
|
+
|
37
|
+
Will create the follow files:
|
38
|
+
|
39
|
+
Class: src/utils/MathUtil.as
|
40
|
+
Test Case: test/utils/MathUtilTest.as
|
41
|
+
Test Suites: test/AllTests.as
|
42
|
+
test/utils/AllTests.as
|
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
# Generate a new ActionScript 3.0 class,
|
3
|
+
# test case and test suite.
|
4
|
+
#
|
5
|
+
# This generator can be executed as follows:
|
6
|
+
#
|
7
|
+
# sprout -n as3 SomeProject
|
8
|
+
# cd SomeProject
|
9
|
+
# script/generator class utils.MathUtil
|
10
|
+
#
|
11
|
+
# Be sure to check out NamedBase to learn more about what kinds of class names
|
12
|
+
# can be accepted.
|
13
|
+
#
|
14
|
+
# If the class name passed into this generator ends with 'Test', only a test case
|
15
|
+
# and test suite will be generated.
|
16
|
+
#
|
17
|
+
class ClassGenerator < Sprout::Generator::NamedBase # :nodoc:
|
18
|
+
|
19
|
+
def manifest
|
20
|
+
record do |m|
|
21
|
+
# m.class_collisions class_dir, "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper"
|
22
|
+
|
23
|
+
if(!user_requested_test)
|
24
|
+
m.directory full_class_dir
|
25
|
+
m.template 'Class.as', full_class_path
|
26
|
+
end
|
27
|
+
|
28
|
+
m.directory full_test_dir
|
29
|
+
m.template 'TestCase.as', full_test_case_path
|
30
|
+
|
31
|
+
m.template 'TestSuite.as', File.join(test_dir, 'AllTests.as')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
|
2
|
+
class <%= full_class_name %> {
|
3
|
+
public static var linkageId:String = "__Packages.<%= full_class_name %>";
|
4
|
+
public static var classRef:Function = <%= class_name %>;
|
5
|
+
|
6
|
+
public function <%= class_name %>() {
|
7
|
+
}
|
8
|
+
|
9
|
+
public static var serializable:Boolean = Object.registerClass(linkageId, classRef);
|
10
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
import asunit.framework.TestCase;
|
3
|
+
import <%= full_class_name %>;
|
4
|
+
|
5
|
+
class <%= full_test_case_name %> extends TestCase {
|
6
|
+
private var className:String = "<%= package_name %>.<%= test_case_name %>";
|
7
|
+
private var <%= instance_name %>:<%= class_name %>;
|
8
|
+
|
9
|
+
public function <%= test_case_name %>(testMethod:String) {
|
10
|
+
super(testMethod);
|
11
|
+
}
|
12
|
+
|
13
|
+
public function setUp():Void {
|
14
|
+
super.setUp();
|
15
|
+
<%= instance_name %> = new <%= class_name %>();
|
16
|
+
}
|
17
|
+
|
18
|
+
public function tearDown():Void {
|
19
|
+
super.tearDown();
|
20
|
+
delete <%= instance_name %>;
|
21
|
+
}
|
22
|
+
|
23
|
+
public function testInstantiated():Void {
|
24
|
+
assertTrue("<%= instance_name %> instanceof <%= class_name %>", <%= instance_name %> instanceof <%= class_name %>);
|
25
|
+
}
|
26
|
+
|
27
|
+
public function testFailure():Void {
|
28
|
+
assertTrue("Failing test", false);
|
29
|
+
}
|
30
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/**
|
2
|
+
* This file has been automatically created using
|
3
|
+
* #!/usr/bin/ruby asclass -s
|
4
|
+
* If you modify it and run this script, your
|
5
|
+
* modifications will be lost!
|
6
|
+
*/
|
7
|
+
|
8
|
+
import asunit.framework.TestSuite;
|
9
|
+
|
10
|
+
class AllTests extends TestSuite {
|
11
|
+
|
12
|
+
public function AllTests() {<% test_case_classes.each do |test_case| %>
|
13
|
+
addTest(new <%=test_case%>());<% end %>
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
# Generate a new ActionScript 2.0 Project
|
3
|
+
# This generator can be executed as follows:
|
4
|
+
#
|
5
|
+
# sprout -n as2 SomeProject
|
6
|
+
#
|
7
|
+
class ProjectGenerator < Sprout::Generator::NamedBase # :nodoc:
|
8
|
+
|
9
|
+
def manifest
|
10
|
+
record do |m|
|
11
|
+
base = class_name
|
12
|
+
m.directory base
|
13
|
+
m.directory File.join(base, 'assets/skins', project_name + 'Skin')
|
14
|
+
m.directory File.join(base, 'bin')
|
15
|
+
m.directory File.join(base, 'lib')
|
16
|
+
m.directory File.join(base, 'script')
|
17
|
+
m.directory File.join(base, 'src')
|
18
|
+
m.directory File.join(base, 'test')
|
19
|
+
|
20
|
+
m.file 'ProjectSprouts.jpg', File.join(base, 'assets/skins', project_name + 'Skin', 'ProjectSprouts.jpg')
|
21
|
+
m.template 'rakefile.rb', File.join(base, "rakefile.rb")
|
22
|
+
m.template 'README.txt', File.join(base, "README.txt")
|
23
|
+
|
24
|
+
m.template 'generate', File.join(base, 'script', "generate"), :chmod => 0755
|
25
|
+
|
26
|
+
m.template 'MainClass.as', File.join(base, 'src', "#{class_name}.as")
|
27
|
+
m.template 'TestRunner.as', File.join(base, 'test', "#{class_name}Runner.as")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
class <%= project_name %> extends MovieClip {
|
3
|
+
public static var linkageId:String = "__Packages.<%= project_name %>";
|
4
|
+
public static var classRef:Function = <%= project_name %>;
|
5
|
+
private static var instance:<%= project_name %>;
|
6
|
+
|
7
|
+
private var image:MovieClip;
|
8
|
+
|
9
|
+
public function <%= project_name %>() {
|
10
|
+
trace("<%= project_name %> Instantiated");
|
11
|
+
image = attachMovie("ProjectSprouts", "image", 1);
|
12
|
+
}
|
13
|
+
|
14
|
+
public static function main():Void {
|
15
|
+
instance = <%= project_name %>(_root.attachMovie(<%= project_name %>.linkageId, '<%=instance_name%>', 1));
|
16
|
+
}
|
17
|
+
|
18
|
+
public static var serializable:Boolean = Object.registerClass(linkageId, classRef);
|
19
|
+
}
|
20
|
+
|
Binary file
|
@@ -0,0 +1,56 @@
|
|
1
|
+
|
2
|
+
########################################
|
3
|
+
This project was generated using Sprouts
|
4
|
+
http://code.google.com/p/projectsprouts/
|
5
|
+
|
6
|
+
Please report any bugs to:
|
7
|
+
http://code.google.com/p/projectsprouts/issues/list
|
8
|
+
|
9
|
+
Please feel free to ask questions at:
|
10
|
+
http://groups.google.com/group/projectsprouts
|
11
|
+
|
12
|
+
########################################
|
13
|
+
Using your favorite terminal, cd to this directory have fun!
|
14
|
+
|
15
|
+
########################################
|
16
|
+
To create a new ActionScript class, TestCase and rebuild all project TestSuites:
|
17
|
+
|
18
|
+
script/generate class -s utils.MathUtil
|
19
|
+
|
20
|
+
########################################
|
21
|
+
To create a new Interface begin the name with I + Capital letter (eg: ISomeName)
|
22
|
+
or end the name with 'able'
|
23
|
+
|
24
|
+
Name begins with Capital 'I' followed by another capital letter
|
25
|
+
script/generate class utils.ISomeName
|
26
|
+
|
27
|
+
or
|
28
|
+
|
29
|
+
Name ends with 'able'
|
30
|
+
script/generate class utils.Observable
|
31
|
+
|
32
|
+
or
|
33
|
+
|
34
|
+
Explicitly identify interface creation
|
35
|
+
script/generate interface utils.SomeInterface
|
36
|
+
|
37
|
+
########################################
|
38
|
+
To create a new TestCase only, enter the following:
|
39
|
+
|
40
|
+
script/generate test utils.SomeTest
|
41
|
+
|
42
|
+
########################################
|
43
|
+
To compile and launch your application:
|
44
|
+
|
45
|
+
rake
|
46
|
+
|
47
|
+
########################################
|
48
|
+
To compile and launch your test suites:
|
49
|
+
|
50
|
+
rake test
|
51
|
+
|
52
|
+
########################################
|
53
|
+
To see all available rake tasks:
|
54
|
+
|
55
|
+
rake -T
|
56
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1" ?>
|
2
|
+
<%= xml_edit_warning %>
|
3
|
+
<movie width="600" height="450" framerate="24" version="8">
|
4
|
+
<background color="#FFFFFF"/>
|
5
|
+
<frame>
|
6
|
+
<library><% files.each do |file| if(!ignore_file?(file) && !File.directory?(file)) %>
|
7
|
+
<clip id="<%= get_symbol_id(file) %>" import="<%=file%>" /><% end end %>
|
8
|
+
</library>
|
9
|
+
</frame>
|
10
|
+
<frame>
|
11
|
+
<stop />
|
12
|
+
</frame>
|
13
|
+
</movie>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import asunit.textui.TestRunner;
|
2
|
+
|
3
|
+
class <%= project_name %>Runner extends TestRunner {
|
4
|
+
|
5
|
+
public function <%= project_name %>Runner() {
|
6
|
+
// start(clazz:Class, methodName:String, showTrace:Boolean)
|
7
|
+
// NOTE: sending a particular class and method name will
|
8
|
+
// execute setUp(), the method and NOT tearDown.
|
9
|
+
// This allows you to get visual confirmation while developing
|
10
|
+
// visual entities
|
11
|
+
start(AllTests, null, TestRunner.SHOW_TRACE);
|
12
|
+
}
|
13
|
+
|
14
|
+
public static function main():Void {
|
15
|
+
var runner:<%= project_name %>Runner = new <%= project_name %>Runner();
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'sprout'
|
4
|
+
sprout 'sprout-as2-bundle'
|
5
|
+
|
6
|
+
# Add a class name if TestSuites were generated
|
7
|
+
if(ARGV.size == 1 && ARGV[0] == 'suite')
|
8
|
+
ARGV << 'AllTests'
|
9
|
+
end
|
10
|
+
|
11
|
+
# Insert class type by default
|
12
|
+
if(ARGV.size == 1)
|
13
|
+
ARGV.unshift('class')
|
14
|
+
end
|
15
|
+
|
16
|
+
# Execute generators like this:
|
17
|
+
# script/generate class utils.MathUtil
|
18
|
+
# script/generate suite
|
19
|
+
# script/generate test utils.MathUtilTest
|
20
|
+
|
21
|
+
Sprout::Sprout.generate('as2', ARGV.shift, ARGV, File.dirname(File.dirname(__FILE__)))
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'sprout'
|
2
|
+
sprout 'as2'
|
3
|
+
|
4
|
+
############################################
|
5
|
+
# Uncomment and modify any of the following:
|
6
|
+
model = Sprout::ProjectModel.instance
|
7
|
+
model.project_name = '<%= project_name %>'
|
8
|
+
|
9
|
+
# Default Values:
|
10
|
+
# model.src_dir = 'src'
|
11
|
+
# model.lib_dir = 'lib'
|
12
|
+
# model.swc_dir = 'lib'
|
13
|
+
# model.bin_dir = 'bin'
|
14
|
+
# model.test_dir = 'test'
|
15
|
+
# model.asset_dir = 'assets'
|
16
|
+
model.language = 'as2'
|
17
|
+
|
18
|
+
output = "#{model.bin_dir}/<%= project_name %>.swf"
|
19
|
+
test_output = "#{model.bin_dir}/<%= project_name %>Runner.swf"
|
20
|
+
skin_output = "#{model.skin_dir}/<%= project_name %>Skin.swf"
|
21
|
+
|
22
|
+
############################################
|
23
|
+
# Set up remote library tasks
|
24
|
+
# the task name will be converted to a string
|
25
|
+
# and modified as follows sprout-#{name}-library
|
26
|
+
# unless you pass t.gem_name = 'full-sprout-name'
|
27
|
+
# For libraries that contain source code, the
|
28
|
+
# task name will also be the folder name that
|
29
|
+
# will be added to ProjectModel.lib_dir
|
30
|
+
# For a complete list of available sprout gems:
|
31
|
+
# http://gems.projectsprouts.org/quick/index
|
32
|
+
# You can also search that list directly from a
|
33
|
+
# terminal as follows:
|
34
|
+
# gem search -r library
|
35
|
+
# Any gems with 'sprout-' prefix and '-library'
|
36
|
+
# suffix can be be used as a library task.
|
37
|
+
|
38
|
+
library :asunit25
|
39
|
+
|
40
|
+
############################################
|
41
|
+
# Launch the application using the Flash Player
|
42
|
+
# NOTE: double-quoted strings in ruby enable
|
43
|
+
# runtime expression evaluation using the
|
44
|
+
# following syntax:
|
45
|
+
# "Some String with: #{variable}"
|
46
|
+
|
47
|
+
desc "Compile and run main application"
|
48
|
+
flashplayer :run => output
|
49
|
+
|
50
|
+
# Make 'run' the default task
|
51
|
+
task :default => :run
|
52
|
+
|
53
|
+
############################################
|
54
|
+
# Launch the test suites using the Flash Player
|
55
|
+
|
56
|
+
desc "Compile and run test suites"
|
57
|
+
flashplayer :test => test_output
|
58
|
+
|
59
|
+
############################################
|
60
|
+
# Compile the skin using SWFMill
|
61
|
+
|
62
|
+
swfmill skin_output do |t|
|
63
|
+
t.input = "#{model.skin_dir}/<%= project_name %>Skin"
|
64
|
+
end
|
65
|
+
|
66
|
+
############################################
|
67
|
+
# Compile your application using mtasc
|
68
|
+
# Any library tasks that are set as
|
69
|
+
# dependencies will automatically be added
|
70
|
+
# to the compiler source or swc paths
|
71
|
+
|
72
|
+
desc "Compile application"
|
73
|
+
mtasc output => [skin_output] do |t|
|
74
|
+
t.main = true
|
75
|
+
t.frame = 2
|
76
|
+
t.input = "#{model.src_dir}/<%= project_name %>.as"
|
77
|
+
# t.class_path << "#{model.lib_dir}/non-sprout-src-library"
|
78
|
+
end
|
79
|
+
|
80
|
+
############################################
|
81
|
+
# Compile test harness using mtasc
|
82
|
+
mtasc test_output => [:asunit25, skin_output] do |t|
|
83
|
+
t.main = true
|
84
|
+
t.input = "#{model.test_dir}/<%= project_name %>Runner.as"
|
85
|
+
t.class_path << model.src_dir
|
86
|
+
t.class_path << model.test_dir
|
87
|
+
# t.class_path << "#{model.lib_dir}/non-sprout-src-library"
|
88
|
+
end
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
# Generate a new ActionScript 3.0 test suite
|
3
|
+
# This generator can be executed as follows:
|
4
|
+
#
|
5
|
+
# sprout -n as3 SomeProject
|
6
|
+
# cd SomeProject
|
7
|
+
# script/generator suite
|
8
|
+
#
|
9
|
+
class SuiteGenerator < Sprout::Generator::NamedBase # :nodoc:
|
10
|
+
|
11
|
+
def manifest
|
12
|
+
record do |m|
|
13
|
+
m.template 'TestSuite.as', File.join(test_dir, 'AllTests.as')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
package {
|
2
|
+
/**
|
3
|
+
* This file has been automatically created using
|
4
|
+
* #!/usr/bin/ruby script/generate suite
|
5
|
+
* If you modify it and run this script, your
|
6
|
+
* modifications will be lost!
|
7
|
+
*/
|
8
|
+
|
9
|
+
import asunit.framework.TestSuite;<% test_case_classes.each do |test_case| %>
|
10
|
+
import <%= test_case %>;<% end %>
|
11
|
+
|
12
|
+
public class AllTests extends TestSuite {
|
13
|
+
|
14
|
+
public function AllTests() {<% test_case_classes.each do |test_case| %>
|
15
|
+
addTest(new <%= test_case %>());<% end %>
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Description:
|
2
|
+
Stubs out a new ActionScript test case that depends on the AsUnit framework.
|
3
|
+
|
4
|
+
This command uses the Sprout::Generator::NamedBase class which will search
|
5
|
+
for configuration parameters as follows:
|
6
|
+
|
7
|
+
1) Command line parameters will supercede any of the following.
|
8
|
+
2) Search the current working directory and all parent directories
|
9
|
+
for a valid Rakefile.
|
10
|
+
3) If a Rakefile is not found, classes will be created directly from the
|
11
|
+
current working directory.
|
12
|
+
4) If a Rakefile is found, it will be loaded. If the rakefile instantiates
|
13
|
+
a Sprout::ProjectModel, that configuration will be used for source and test
|
14
|
+
paths, language preferences, and other values.
|
15
|
+
5) If no ProjectModel is instantiated in your Rakefile, the Rakefile itself
|
16
|
+
will be treated as the project root, and classes will be created from that
|
17
|
+
directory.
|
18
|
+
|
19
|
+
You can edit the erb templates that this command uses in a variety of ways.
|
20
|
+
If you would like to edit the templates for all projects on your system,
|
21
|
+
simply copy the directory at: File.dirname(__FILE__) into:
|
22
|
+
|
23
|
+
#{SPROUT_HOME}/sprout/generators/
|
24
|
+
|
25
|
+
To edit templates for a single project, copy the directory to:
|
26
|
+
|
27
|
+
#{PROJECT_HOME}/script/generators/
|
28
|
+
|
29
|
+
Once you have the contents of this package copied, simply edit the files found
|
30
|
+
in the templates/ folder to your satisfaction.
|
31
|
+
|
32
|
+
Example:
|
33
|
+
`./script/generate class utils.MathUtil`
|
34
|
+
|
35
|
+
Will create the follow files:
|
36
|
+
|
37
|
+
Test Case: test/utils/MathUtilTest.as
|
@@ -0,0 +1,30 @@
|
|
1
|
+
package <%= package_name %> {
|
2
|
+
|
3
|
+
import asunit.framework.TestCase;
|
4
|
+
|
5
|
+
public class <%= test_case_name %> extends TestCase {
|
6
|
+
private var <%= instance_name %>:<%= class_name %>;
|
7
|
+
|
8
|
+
public function <%= test_case_name %>(methodName:String=null) {
|
9
|
+
super(methodName)
|
10
|
+
}
|
11
|
+
|
12
|
+
override protected function setUp():void {
|
13
|
+
super.setUp();
|
14
|
+
<%= instance_name %> = new <%= class_name %>();
|
15
|
+
}
|
16
|
+
|
17
|
+
override protected function tearDown():void {
|
18
|
+
super.tearDown();
|
19
|
+
<%= instance_name %> = null;
|
20
|
+
}
|
21
|
+
|
22
|
+
public function testInstantiated():void {
|
23
|
+
assertTrue("<%= instance_name %> is <%= class_name %>", <%= instance_name %> is <%= class_name %>);
|
24
|
+
}
|
25
|
+
|
26
|
+
public function testFailure():void {
|
27
|
+
assertTrue("Failing test", false);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
package {
|
2
|
+
/**
|
3
|
+
* This file has been automatically created using
|
4
|
+
* #!/usr/bin/ruby script/generate suite
|
5
|
+
* If you modify it and run this script, your
|
6
|
+
* modifications will be lost!
|
7
|
+
*/
|
8
|
+
|
9
|
+
import asunit.framework.TestSuite;<% test_case_classes.each do |test_case| %>
|
10
|
+
import <%= test_case %>;<% end %>
|
11
|
+
|
12
|
+
public class AllTests extends TestSuite {
|
13
|
+
|
14
|
+
public function AllTests() {<% test_case_classes.each do |test_case| %>
|
15
|
+
addTest(new <%= test_case %>());<% end %>
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
# Generate a new ActionScript 3.0 TestCase and rebuild the test suites.
|
3
|
+
# This generator can be executed as follows:
|
4
|
+
#
|
5
|
+
# sprout -n as3 SomeProject
|
6
|
+
# cd SomeProject
|
7
|
+
# script/generator test utils.MathUtilTest
|
8
|
+
#
|
9
|
+
class TestGenerator < Sprout::Generator::NamedBase # :nodoc:
|
10
|
+
|
11
|
+
def manifest
|
12
|
+
record do |m|
|
13
|
+
m.directory full_test_dir
|
14
|
+
m.template "TestCase.as", full_test_case_path
|
15
|
+
|
16
|
+
m.template 'TestSuite.as', File.join(test_dir, 'AllTests.as')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|