asproject 0.1.21
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/CHANGELOG.txt +0 -0
- data/History.txt +0 -0
- data/MIT-LICENSE.txt +20 -0
- data/Manifest.txt +16 -0
- data/README.txt +3 -0
- data/TODO.txt +10 -0
- data/bin/asclass +16 -0
- data/bin/asproject +16 -0
- data/lib/asclass.rb +254 -0
- data/lib/asclass_arguments.rb +147 -0
- data/lib/asproject.rb +248 -0
- data/lib/asproject/version.rb +9 -0
- data/lib/asproject_arguments.rb +175 -0
- data/lib/asproject_base.rb +43 -0
- data/lib/asproject_utils.rb +57 -0
- data/lib/eclipse_project.rb +32 -0
- data/lib/path_finder.rb +286 -0
- data/lib/platform.rb +107 -0
- data/lib/project.rb +82 -0
- data/lib/template_resolver.rb +144 -0
- data/lib/test_suite_generator.rb +128 -0
- data/rakefile.rb +85 -0
- data/setup.rb +1585 -0
- data/templates/asclass/as2/Class.as +11 -0
- data/templates/asclass/as2/Component.as +8 -0
- data/templates/asclass/as2/Interface.as +3 -0
- data/templates/asclass/as2/TestCase.as +30 -0
- data/templates/asclass/as2/TestSuite.as +15 -0
- data/templates/asclass/as3/Class.as +9 -0
- data/templates/asclass/as3/Component.as +9 -0
- data/templates/asclass/as3/Component.mxml +1 -0
- data/templates/asclass/as3/Interface.as +6 -0
- data/templates/asclass/as3/TestCase.as +30 -0
- data/templates/asclass/as3/TestSuite.as +18 -0
- data/templates/asproject/as2/project/rakefile.rb +18 -0
- data/templates/asproject/as2/project/src/AsProject.as +13 -0
- data/templates/asproject/as2/project/test/AsProjectRunner.as +12 -0
- data/templates/asproject/as3/project/rakefile.rb +18 -0
- data/templates/asproject/as3/project/src/AsProject.as +9 -0
- data/templates/asproject/as3/project/src/AsProjectRunner.as +11 -0
- data/templates/asproject/asunit2/project/lib/asunit/AsUnitUi.swf +0 -0
- data/templates/asproject/asunit2/project/lib/asunit/Sys.as +70 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanel.as +182 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTest.as +84 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextArea.as +111 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextAreaTest.as +26 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTitleBar.as +81 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ResizeHandle.as +35 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollArrow.as +34 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollHandle.as +43 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollListener.as +10 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/TextScroller.as +169 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Rectangle.as +29 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Triangle.as +27 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/AsUnit.as +19 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assert.as +408 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assertion.as +27 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as +68 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Test.as +3 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCase.as +191 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCaseXml.as +31 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestFailure.as +15 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestResult.as +15 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestRunner.as +41 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSetup.as +19 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSuite.as +22 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/Main.as +325 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/RemoteVersion.as +24 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/SuccessMeter.as +32 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Comparable.as +7 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventListener.as +29 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventSource.as +89 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnClient.as +42 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnGateway.as +47 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnServer.as +61 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalMessageBroker.as +58 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Observable.as +11 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/TextFile.as +30 -0
- data/templates/asproject/asunit25/project/lib/asunit/AsUnitTestRunner.as +13 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionFailedError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionPassedError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/ClassNotFoundError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/IllegalOperationError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InvocationTargetError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Assert.as +376 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertMock.as +15 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertTest.as +59 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/ITestListener.as +13 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Test.as +11 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCase.as +277 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseMock.as +23 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseTest.as +29 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseXml.as +38 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestFailure.as +47 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestResult.as +168 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestSuite.as +102 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/BaseTestRunner.as +101 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/IResultPrinter.as +8 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/ResultPrinter.as +254 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/SuccessBar.as +41 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/TestRunner.as +17 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIterator.as +24 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIteratorTest.as +52 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/Iterator.as +5 -0
- data/templates/asproject/asunit3/project/lib/asunit/AsUnitTestRunner.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AbstractMemberCalledError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AssertionFailedError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/ClassNotFoundError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Assert.as +271 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCase.as +52 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCaseExample.as +71 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Test.as +15 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCase.as +351 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCaseExample.as +73 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestFailure.as +47 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestListener.as +22 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestResult.as +158 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestSuite.as +115 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/BaseTestRunner.as +15 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/TestSuiteLoader.as +9 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/Version.as +11 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexRunner.as +19 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexTestRunner.as +55 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/ResultPrinter.as +245 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/TestRunner.as +121 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/ArrayIterator.as +26 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Iterator.as +9 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Properties.as +30 -0
- data/templates/asproject/asunit3/project/lib/asunit/mx/managers/LayoutManager.as +945 -0
- data/templates/asproject/config/project/config/asclass_config.rb +58 -0
- data/templates/asproject/fb2as/project/.actionScriptProperties +21 -0
- data/templates/asproject/fb2as/project/.project +29 -0
- data/templates/asproject/fdt/project/.as2_classpath +6 -0
- data/templates/asproject/fdt/project/.project +19 -0
- data/templates/ide/mate/Create Class.tmCommand +37 -0
- data/templates/ide/mate/Rebuild Test Suites.tmCommand +33 -0
- data/templates/ide/mate/Run Rake Task.tmCommand +127 -0
- metadata +266 -0
data/CHANGELOG.txt
ADDED
|
File without changes
|
data/History.txt
ADDED
|
File without changes
|
data/MIT-LICENSE.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2007 Luke Bayes
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Rakefile
|
|
2
|
+
README.txt
|
|
3
|
+
CHANGELOG.txt
|
|
4
|
+
MIT-LICENSE.txt
|
|
5
|
+
Manifest.txt
|
|
6
|
+
setup.rb
|
|
7
|
+
test/test_helper.rb
|
|
8
|
+
test/asproject_test.rb
|
|
9
|
+
test/projects
|
|
10
|
+
bin/asproject
|
|
11
|
+
bin/asclass
|
|
12
|
+
lib/tasks/asproject.rake
|
|
13
|
+
lib/asproject/version.rb
|
|
14
|
+
lib/asproject.rb
|
|
15
|
+
lib/asproject_base.rb
|
|
16
|
+
lib/asclass.rb
|
data/README.txt
ADDED
data/TODO.txt
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---------------------
|
|
2
|
+
Tasks Remaining
|
|
3
|
+
|
|
4
|
+
* Get empty directories to bundle in the gem file
|
|
5
|
+
* Get mac to follow and manage the flash player process
|
|
6
|
+
|
|
7
|
+
* Update the pc on the flash player thread process
|
|
8
|
+
* Integrate as2/mxmlc support
|
|
9
|
+
* Create asunit application for test execution/tracking
|
|
10
|
+
|
data/bin/asclass
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
version = "> 0"
|
|
5
|
+
|
|
6
|
+
if ARGV.size > 0 && ARGV[0][0]==95 && ARGV[0][-1]==95
|
|
7
|
+
if Gem::Version.correct?(ARGV[0][1..-2])
|
|
8
|
+
version = ARGV[0][1..-2]
|
|
9
|
+
ARGV.shift
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
require_gem 'asproject', version
|
|
14
|
+
require 'asclass.rb'
|
|
15
|
+
|
|
16
|
+
AsProject::AsClass.new
|
data/bin/asproject
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
version = "> 0"
|
|
5
|
+
|
|
6
|
+
if ARGV.size > 0 && ARGV[0][0]==95 && ARGV[0][-1]==95
|
|
7
|
+
if Gem::Version.correct?(ARGV[0][1..-2])
|
|
8
|
+
version = ARGV[0][1..-2]
|
|
9
|
+
ARGV.shift
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
require_gem 'asproject', version
|
|
14
|
+
require 'asproject.rb'
|
|
15
|
+
|
|
16
|
+
AsProject::AsProject.new
|
data/lib/asclass.rb
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
$:.push(File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
#require 'rake'
|
|
4
|
+
require 'asproject'
|
|
5
|
+
require 'asclass_arguments'
|
|
6
|
+
require 'test_suite_generator'
|
|
7
|
+
|
|
8
|
+
module AsProject
|
|
9
|
+
class AsClass < AsProjectBase
|
|
10
|
+
@@TEMPLATE_TYPE = 'asclass'
|
|
11
|
+
@@CLASS_TEMPLATE = 'Class.as'
|
|
12
|
+
@@TEST_CASE_TEMPLATE = 'TestCase.as'
|
|
13
|
+
@@TEST_SUITE_TEMPLATE = 'TestSuite.as'
|
|
14
|
+
@@INTERFACE_TEMPLATE = 'Interface.as'
|
|
15
|
+
@@COMPONENT_TEMPLATE = 'Component.as'
|
|
16
|
+
@@MXML_TEMPLATE = 'Component.mxml'
|
|
17
|
+
|
|
18
|
+
def initialize(args=nil)
|
|
19
|
+
# begin
|
|
20
|
+
@created_files = []
|
|
21
|
+
@arguments = parse_args(args)
|
|
22
|
+
@project = get_project(@arguments.execution_dir)
|
|
23
|
+
if(!@arguments.name.nil?)
|
|
24
|
+
configure_project(@arguments.name)
|
|
25
|
+
end
|
|
26
|
+
if(@arguments.force)
|
|
27
|
+
@project.replace_all = true
|
|
28
|
+
end
|
|
29
|
+
execute
|
|
30
|
+
finish
|
|
31
|
+
# rescue Exception => e
|
|
32
|
+
# puts e.to_s
|
|
33
|
+
# exit
|
|
34
|
+
# end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def parse_args(args=nil)
|
|
38
|
+
if(args.nil?)
|
|
39
|
+
args = AsClassArguments.new
|
|
40
|
+
args.execution_dir = Dir.pwd
|
|
41
|
+
args.parse!(ARGV)
|
|
42
|
+
end
|
|
43
|
+
return args
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def execute
|
|
47
|
+
name = @arguments.name
|
|
48
|
+
|
|
49
|
+
# Only build class and test case if a name
|
|
50
|
+
# was provided...
|
|
51
|
+
if(!name.nil?)
|
|
52
|
+
is_test_case = false
|
|
53
|
+
is_interface = false
|
|
54
|
+
|
|
55
|
+
template = ''
|
|
56
|
+
if(@arguments.mxml)
|
|
57
|
+
@project['display_object'] = true
|
|
58
|
+
template = mxml_template
|
|
59
|
+
elsif(@arguments.component)
|
|
60
|
+
template = component_template
|
|
61
|
+
elsif(name.match(/Test$/))
|
|
62
|
+
is_test_case = true
|
|
63
|
+
template = test_case_template
|
|
64
|
+
elsif(name.index('I') == 0 || name.index('able') == name.size - 4)
|
|
65
|
+
is_interface = true
|
|
66
|
+
template = interface_template
|
|
67
|
+
else
|
|
68
|
+
template = class_template
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
if(!is_test_case)
|
|
72
|
+
create_class(template)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
if(!is_interface && @arguments.build_test_case || is_test_case)
|
|
76
|
+
template = test_case_template
|
|
77
|
+
create_test_case(template)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
if(@arguments.build_test_suites)
|
|
82
|
+
create_test_suites
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def create_class(template_file)
|
|
87
|
+
suffix = '.' + template_file.split(File::SEPARATOR).pop.split('.').pop
|
|
88
|
+
target_name = capitalize(@project['class_name'] + suffix)
|
|
89
|
+
create_file(template_file, @project.source_dir, target_name)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def create_test_case(template_file)
|
|
93
|
+
suffix = '.' + template_file.split(File::SEPARATOR).pop.split('.').pop
|
|
94
|
+
target_name = capitalize(@project['class_name'] + 'Test' + suffix)
|
|
95
|
+
create_file(template_file, @project.test_dir, target_name)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def create_file(template_file, target_dir, target_name)
|
|
99
|
+
template_base = select_template_base
|
|
100
|
+
@arguments.verify_template(template_base)
|
|
101
|
+
source_location = @project.get_template(template_type, File.join(template_base, template_file))
|
|
102
|
+
package_dirs = @project['package_name'].split('.').join(File::SEPARATOR)
|
|
103
|
+
target_location = File.join(target_dir, package_dirs, target_name)
|
|
104
|
+
@created_files << @project.copy_file(source_location, target_location, true)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def select_template_base
|
|
108
|
+
if(@arguments.template.nil?)
|
|
109
|
+
return @project.default_templates[0]
|
|
110
|
+
else
|
|
111
|
+
return @arguments.template
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def create_test_suites
|
|
116
|
+
template_base = select_template_base
|
|
117
|
+
template = @project.get_template(template_type, File.join(template_base, 'TestSuite.as'))
|
|
118
|
+
content = IO.read(template)
|
|
119
|
+
name = 'AllTests.as'
|
|
120
|
+
suite_generator = TestSuiteGenerator.new(@project.test_dir, name, content)
|
|
121
|
+
suite_generator.created_files.each do |suite|
|
|
122
|
+
@created_files << suite
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# package_name
|
|
127
|
+
# class_name
|
|
128
|
+
# full_class_name
|
|
129
|
+
# test_case_name
|
|
130
|
+
# full_test_case_name
|
|
131
|
+
# instance_name
|
|
132
|
+
# add_child_line
|
|
133
|
+
# remove_child_line
|
|
134
|
+
|
|
135
|
+
def configure_project(name)
|
|
136
|
+
@project['display_object'] = false
|
|
137
|
+
@project['package_name'] = get_package_name(name)
|
|
138
|
+
@project['class_name'] = get_class_name(name)
|
|
139
|
+
@project['full_class_name'] = @project['package_name'] + '.' + @project['class_name']
|
|
140
|
+
@project['test_case_name'] = get_test_case_name(name)
|
|
141
|
+
@project['full_test_case_name'] = @project['package_name'] + '.' + @project['test_case_name']
|
|
142
|
+
@project['instance_name'] = get_instance_name(name)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def get_package_name(name)
|
|
146
|
+
parts = name.split('.')
|
|
147
|
+
parts.pop
|
|
148
|
+
return parts.join('.')
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def get_class_name(name)
|
|
152
|
+
name = name.sub(/Test$/, '')
|
|
153
|
+
parts = name.split('.')
|
|
154
|
+
return parts.pop
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def get_class_location(name)
|
|
158
|
+
pkg = get_package_name(name)
|
|
159
|
+
return pkg.split('.').join(File::SEPARATOR)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def get_test_case_name(name)
|
|
163
|
+
return get_class_name(name) + 'Test'
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def get_instance_name(name)
|
|
167
|
+
name = get_class_name(name)
|
|
168
|
+
chars = name.split('')
|
|
169
|
+
chars[0] = chars[0].downcase
|
|
170
|
+
return chars.join('')
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def template_type
|
|
174
|
+
return @@TEMPLATE_TYPE
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def class_template
|
|
178
|
+
return @@CLASS_TEMPLATE
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def interface_template
|
|
182
|
+
return @@INTERFACE_TEMPLATE
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def test_case_template
|
|
186
|
+
return @@TEST_CASE_TEMPLATE
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def component_template
|
|
190
|
+
return @@COMPONENT_TEMPLATE
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def mxml_template
|
|
194
|
+
return @@MXML_TEMPLATE
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def get_project(dir)
|
|
198
|
+
if(File.exists?(File.join(dir, '.project')))
|
|
199
|
+
return AsClassProject.new(dir)
|
|
200
|
+
end
|
|
201
|
+
raise ProjectError.new('AsClass could not find a .project file in the current directory: ' + dir)
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# TODO: Refactor EclipseProject out so that
|
|
206
|
+
# Project just instantiates a parser as needed
|
|
207
|
+
# and this class extends the more abstract Project
|
|
208
|
+
class AsClassProject < EclipseProject
|
|
209
|
+
|
|
210
|
+
def package_name
|
|
211
|
+
return self['package_name']
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def class_name
|
|
215
|
+
return self['class_name']
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def full_class_name
|
|
219
|
+
return self['full_class_name']
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
def test_case_name
|
|
223
|
+
return self['test_case_name']
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
def full_test_case_name
|
|
227
|
+
self['full_test_case_name']
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
def instance_name
|
|
231
|
+
self['instance_name']
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def display_object?
|
|
235
|
+
self['display_object']
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def add_child_line
|
|
239
|
+
if(display_object?)
|
|
240
|
+
return "\n addChild(#{instance_name});"
|
|
241
|
+
else
|
|
242
|
+
return ""
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
def remove_child_line
|
|
247
|
+
if(display_object?)
|
|
248
|
+
return "removeChild(#{instance_name});\n "
|
|
249
|
+
else
|
|
250
|
+
return ""
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
end
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
|
|
2
|
+
module AsProject
|
|
3
|
+
|
|
4
|
+
#######################################
|
|
5
|
+
# ProjectArguments
|
|
6
|
+
class AsClassArguments < Hash
|
|
7
|
+
attr_accessor :execution_dir,
|
|
8
|
+
:name,
|
|
9
|
+
:mxml,
|
|
10
|
+
:component,
|
|
11
|
+
:force,
|
|
12
|
+
:build_test_case,
|
|
13
|
+
:build_test_suites,
|
|
14
|
+
:display_object,
|
|
15
|
+
:template,
|
|
16
|
+
@@TEMPLATE_TYPE = 'asclass'
|
|
17
|
+
|
|
18
|
+
def initialize(dir=nil)
|
|
19
|
+
if(dir.nil?)
|
|
20
|
+
@execution_dir = Dir.pwd
|
|
21
|
+
else
|
|
22
|
+
@execution_dir = dir
|
|
23
|
+
end
|
|
24
|
+
@path_finder = PathFinder.new(@execution_dir)
|
|
25
|
+
@force = false
|
|
26
|
+
@mxml = false
|
|
27
|
+
@component = false
|
|
28
|
+
@template = nil
|
|
29
|
+
self[:name] = nil
|
|
30
|
+
self[:build_test_suites] = false # -s == --build-test-suites
|
|
31
|
+
self[:build_test_case] = true # -n == --no-test-case ?
|
|
32
|
+
self[:verbose] = true
|
|
33
|
+
|
|
34
|
+
@class_templates = @path_finder.get_available_templates(@@TEMPLATE_TYPE)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def parse!(args)
|
|
38
|
+
opts = OptionParser.new do |opts|
|
|
39
|
+
opts.banner = <<EOF
|
|
40
|
+
|
|
41
|
+
Usage: #$0 [options] packagename.ClassName
|
|
42
|
+
|
|
43
|
+
AsClass will automatically determine which template file to use based on the class name entered.
|
|
44
|
+
1) Names beginning with 'I' or ending with 'able' are assumed to be interfaces and use 'Interface.as'
|
|
45
|
+
2) Names ending with 'Test' are assumed to be test cases and use the 'TestCase.as' template
|
|
46
|
+
3) If the --mxml flag is set, the 'Component.mxml' template is used
|
|
47
|
+
4) If the --component flas is set, the 'Component.as' template is used
|
|
48
|
+
5) If none of the previous criteria are met, the 'Class.as' template is used
|
|
49
|
+
|
|
50
|
+
Classes will be placed in the ProjectPath/src directory.
|
|
51
|
+
Test cases and test suites will be placed in the ProjectPath/test directory.
|
|
52
|
+
|
|
53
|
+
Using -t requires a single template selection. The template is a folder name inside of the asclass folder.
|
|
54
|
+
|
|
55
|
+
Templates will be used when found in the first folder of the following list:
|
|
56
|
+
1) ./{ProjectName}/config/templates/asclass
|
|
57
|
+
2) #{@path_finder.user_asproject_home}/templates/asclass
|
|
58
|
+
3) #{@path_finder.gem_asproject_home}/templates/asclass
|
|
59
|
+
|
|
60
|
+
Options:
|
|
61
|
+
EOF
|
|
62
|
+
# opts.on('-c', '--copy-templates', "Copy templates to {ProjectName}/config/templates") do
|
|
63
|
+
# self[:copy_to_project] = true
|
|
64
|
+
# end
|
|
65
|
+
#
|
|
66
|
+
# opts.on('-C', '--copy-templates-to-home', "Copy templates to this user account") do
|
|
67
|
+
# self[:copy_to_home] = true
|
|
68
|
+
# end
|
|
69
|
+
#
|
|
70
|
+
# opts.on('-d', '--default-templates', "Set default templates for this project eg: 'mxml,fb2mxml,asunit'") do
|
|
71
|
+
# self[:default_templates] = true
|
|
72
|
+
# end
|
|
73
|
+
#
|
|
74
|
+
# opts.on('-D', '--default-templates-to-home', "Set the default templates for this user account") do
|
|
75
|
+
# self[:default_home_templates] = true
|
|
76
|
+
# end
|
|
77
|
+
|
|
78
|
+
opts.on('-f', '--force', "Force creation - overwrite if necessary") do
|
|
79
|
+
self[:force] = true
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
opts.on('-q', '--quiet', "Do not display created file names") do
|
|
83
|
+
self[:verbose] = false
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
opts.on('-s', '--build-test-suites', "Build TestSuites in my test directory") do
|
|
87
|
+
self[:build_test_suites] = true
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
opts.on('-t', '--template [STRING]', "Define which project template folder to use.") do |str|
|
|
91
|
+
self[:template] = str
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
opts.on_tail('-h', '--help', 'display this help and exit') do
|
|
95
|
+
puts opts
|
|
96
|
+
exit
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
opts.parse!(args)
|
|
100
|
+
|
|
101
|
+
if(args.size > 0)
|
|
102
|
+
self[:name] = args.shift.to_s
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def verify_template(template)
|
|
107
|
+
if(!@class_templates.index template)
|
|
108
|
+
msg = <<EOF
|
|
109
|
+
|
|
110
|
+
Template [#{template}] was not found!
|
|
111
|
+
|
|
112
|
+
Please try again with one of the following available templates:
|
|
113
|
+
#{@class_templates.join(', ')}
|
|
114
|
+
EOF
|
|
115
|
+
raise ProjectError.new(msg)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def template=(template)
|
|
120
|
+
self[:template] = template
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def template
|
|
124
|
+
return self[:template]
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def name
|
|
128
|
+
return self[:name]
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def verbose
|
|
132
|
+
return self[:verbose]
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def build_test_case
|
|
136
|
+
return self[:build_test_case]
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def build_test_suites
|
|
140
|
+
return self[:build_test_suites]
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def force?
|
|
144
|
+
return self[:force]
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|