├── README.md
├── assets
└── skins
│ ├── RLUtilsCompoundCommandMap
│ └── ProjectSprouts.png
│ └── RLUtilsCompoundCommandMapSkin.as
├── bin
└── RelaxedEventMapRunner.swf
├── lib
├── FLoxy.swc
├── asunit3
│ ├── AsUnit.as
│ └── asunit
│ │ ├── errors
│ │ ├── AbstractError.as
│ │ ├── AssertionFailedError.as
│ │ ├── ClassNotFoundError.as
│ │ ├── InstanceNotFoundError.as
│ │ └── UnimplementedFeatureError.as
│ │ ├── framework
│ │ ├── Assert.as
│ │ ├── AsyncOperation.as
│ │ ├── AsynchronousHTTPServiceTestCase.as
│ │ ├── AsynchronousTestCase.as
│ │ ├── AsynchronousTestCaseExample.as
│ │ ├── RemotingTestCase.as
│ │ ├── Test.as
│ │ ├── TestCase.as
│ │ ├── TestCaseExample.as
│ │ ├── TestFailure.as
│ │ ├── TestListener.as
│ │ ├── TestMethod.as
│ │ ├── TestResult.as
│ │ └── TestSuite.as
│ │ ├── runner
│ │ ├── BaseTestRunner.as
│ │ ├── TestSuiteLoader.as
│ │ └── Version.as
│ │ ├── textui
│ │ ├── AirRunner.as
│ │ ├── FlexRunner.as
│ │ ├── FlexTestRunner.as
│ │ ├── ResultPrinter.as
│ │ ├── TestRunner.as
│ │ ├── TestTime.as
│ │ └── XMLResultPrinter.as
│ │ └── util
│ │ ├── ArrayIterator.as
│ │ ├── Iterator.as
│ │ └── Properties.as
├── asx.swc
├── hamcrest.swc
├── mockolate
│ └── mockolate
│ │ ├── errors
│ │ ├── ExpectationError.as
│ │ ├── InvocationError.as
│ │ ├── MockolateError.as
│ │ └── VerificationError.as
│ │ ├── ingredients
│ │ ├── Couverture.as
│ │ ├── Expectation.as
│ │ ├── Invocation.as
│ │ ├── InvocationType.as
│ │ ├── MockingCouverture.as
│ │ ├── Mockolate.as
│ │ ├── MockolateFactory.as
│ │ ├── Mockolatier.as
│ │ ├── MockolatierMaster.as
│ │ ├── RecordingCouverture.as
│ │ ├── Verification.as
│ │ ├── VerifyingCouverture.as
│ │ ├── answers
│ │ │ ├── Answer.as
│ │ │ ├── CallsAnswer.as
│ │ │ ├── DispatchesEventAnswer.as
│ │ │ ├── PassThroughAnswer.as
│ │ │ ├── ReturnsAnswer.as
│ │ │ ├── ReturnsCallAnswer.as
│ │ │ ├── ReturnsValueAnswer.as
│ │ │ └── ThrowsAnswer.as
│ │ ├── faux
│ │ │ ├── FauxFloxyInterceptor.as
│ │ │ ├── FauxFloxyInvocation.as
│ │ │ ├── FauxInvocation.as
│ │ │ └── FauxMockolate.as
│ │ ├── floxy
│ │ │ ├── FloxyInvocation.as
│ │ │ ├── FloxyMockolate.as
│ │ │ ├── FloxyMockolateFactory.as
│ │ │ └── InterceptingCouverture.as
│ │ └── mockolate_ingredient.as
│ │ ├── make.as
│ │ ├── mock.as
│ │ ├── nice.as
│ │ ├── prepare.as
│ │ ├── strict.as
│ │ ├── stub.as
│ │ └── verify.as
├── robotlegs_v1_0
│ └── org
│ │ ├── robotlegs
│ │ ├── adapters
│ │ │ ├── SwiftSuspendersInjector.as
│ │ │ └── SwiftSuspendersReflector.as
│ │ ├── base
│ │ │ ├── CommandMap.as
│ │ │ ├── ContextBase.as
│ │ │ ├── ContextError.as
│ │ │ ├── ContextEvent.as
│ │ │ ├── EventMap.as
│ │ │ ├── MediatorBase.as
│ │ │ ├── MediatorMap.as
│ │ │ ├── ViewMap.as
│ │ │ └── ViewMapBase.as
│ │ ├── core
│ │ │ ├── ICommandMap.as
│ │ │ ├── IContext.as
│ │ │ ├── IContextProvider.as
│ │ │ ├── IEventMap.as
│ │ │ ├── IInjector.as
│ │ │ ├── IMediator.as
│ │ │ ├── IMediatorMap.as
│ │ │ ├── IReflector.as
│ │ │ └── IViewMap.as
│ │ └── mvcs
│ │ │ ├── Actor.as
│ │ │ ├── Command.as
│ │ │ ├── Context.as
│ │ │ └── Mediator.as
│ │ └── swiftsuspenders
│ │ ├── InjectionConfig.as
│ │ ├── InjectionType.as
│ │ ├── Injector.as
│ │ ├── InjectorError.as
│ │ ├── Reflector.as
│ │ ├── injectionpoints
│ │ ├── ConstructorInjectionPoint.as
│ │ ├── InjectionPoint.as
│ │ ├── MethodInjectionPoint.as
│ │ ├── NoParamsConstructorInjectionPoint.as
│ │ ├── PostConstructInjectionPoint.as
│ │ └── PropertyInjectionPoint.as
│ │ └── injectionresults
│ │ ├── IInjectionResult.as
│ │ ├── InjectClassResult.as
│ │ ├── InjectNullResult.as
│ │ ├── InjectSingletonResult.as
│ │ └── InjectValueResult.as
└── robotlegs_v1_4
│ └── org
│ ├── robotlegs
│ ├── adapters
│ │ ├── SwiftSuspendersInjector.as
│ │ └── SwiftSuspendersReflector.as
│ ├── base
│ │ ├── CommandMap.as
│ │ ├── ContextBase.as
│ │ ├── ContextError.as
│ │ ├── ContextEvent.as
│ │ ├── EventMap.as
│ │ ├── MediatorBase.as
│ │ ├── MediatorMap.as
│ │ ├── ViewMap.as
│ │ └── ViewMapBase.as
│ ├── core
│ │ ├── ICommandMap.as
│ │ ├── IContext.as
│ │ ├── IContextProvider.as
│ │ ├── IEventMap.as
│ │ ├── IInjector.as
│ │ ├── IMediator.as
│ │ ├── IMediatorMap.as
│ │ ├── IReflector.as
│ │ └── IViewMap.as
│ └── mvcs
│ │ ├── Actor.as
│ │ ├── Command.as
│ │ ├── Context.as
│ │ └── Mediator.as
│ └── swiftsuspenders
│ ├── InjectionConfig.as
│ ├── InjectionType.as
│ ├── Injector.as
│ ├── InjectorError.as
│ ├── Reflector.as
│ ├── getConstructor.as
│ ├── injectionpoints
│ ├── ConstructorInjectionPoint.as
│ ├── InjectionPoint.as
│ ├── MethodInjectionPoint.as
│ ├── NoParamsConstructorInjectionPoint.as
│ ├── PostConstructInjectionPoint.as
│ └── PropertyInjectionPoint.as
│ └── injectionresults
│ ├── InjectClassResult.as
│ ├── InjectOtherRuleResult.as
│ ├── InjectSingletonResult.as
│ ├── InjectValueResult.as
│ └── InjectionResult.as
├── rakefile.rb
├── rakefiles
└── sprouts_test_extensions.rb
├── script
├── generate
└── generators
│ ├── event
│ ├── USAGE
│ ├── event_generator.rb
│ └── templates
│ │ ├── Component.mxml
│ │ ├── Event.as
│ │ ├── TestCase.as
│ │ └── TestSuite.as
│ ├── interface
│ ├── USAGE
│ ├── interface_generator.rb
│ └── templates
│ │ ├── Component.mxml
│ │ └── Interface.as
│ ├── rlcommand
│ ├── USAGE
│ ├── rlcommand_generator.rb
│ └── templates
│ │ ├── Component.mxml
│ │ ├── RLCommand.as
│ │ ├── TestCase.as
│ │ └── TestSuite.as
│ └── support
│ ├── USAGE
│ ├── support_generator.rb
│ └── templates
│ ├── Component.mxml
│ └── Support.as
├── src
├── RelaxedEventMapRunner.as
├── RelaxedEventMapXMLRunner.as
└── org
│ └── robotlegs
│ ├── base
│ └── RelaxedEventMap.as
│ └── core
│ ├── IRelaxedEventContext.as
│ └── IRelaxedEventMap.as
├── support
└── org
│ └── robotlegs
│ └── mvcs
│ └── events
│ ├── SampleEventA.as
│ └── SampleEventB.as
└── test
├── AllTests.as
└── org
└── robotlegs
└── base
└── RelaxedEventMapTest.as
/assets/skins/RLUtilsCompoundCommandMap/ProjectSprouts.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Stray/robotlegs-utilities-RelaxedEventMap/9d0fa632e9bca43237db6ca5df0cad4253cbd581/assets/skins/RLUtilsCompoundCommandMap/ProjectSprouts.png
--------------------------------------------------------------------------------
/assets/skins/RLUtilsCompoundCommandMapSkin.as:
--------------------------------------------------------------------------------
1 |
2 | package skins {
3 | public class RLUtilsCompoundCommandMapSkin {
4 | [Embed(source="RLUtilsCompoundCommandMap/ProjectSprouts.png")]
5 | public static var ProjectSprouts:Class;
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/bin/RelaxedEventMapRunner.swf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Stray/robotlegs-utilities-RelaxedEventMap/9d0fa632e9bca43237db6ca5df0cad4253cbd581/bin/RelaxedEventMapRunner.swf
--------------------------------------------------------------------------------
/lib/FLoxy.swc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Stray/robotlegs-utilities-RelaxedEventMap/9d0fa632e9bca43237db6ca5df0cad4253cbd581/lib/FLoxy.swc
--------------------------------------------------------------------------------
/lib/asunit3/AsUnit.as:
--------------------------------------------------------------------------------
1 | package {
2 | import asunit.errors.AssertionFailedError;
3 | import asunit.errors.ClassNotFoundError;
4 | import asunit.errors.InstanceNotFoundError;
5 | import asunit.errors.UnimplementedFeatureError;
6 | import asunit.framework.Assert;
7 | import asunit.framework.AsynchronousTestCase;
8 | import asunit.framework.AsynchronousTestCaseExample;
9 | import asunit.framework.AsyncOperation;
10 | import asunit.framework.RemotingTestCase;
11 | import asunit.framework.Test;
12 | import asunit.framework.TestCase;
13 | import asunit.framework.TestCaseExample;
14 | import asunit.framework.TestFailure;
15 | import asunit.framework.TestListener;
16 | import asunit.framework.TestMethod;
17 | import asunit.framework.TestResult;
18 | import asunit.framework.TestSuite;
19 | import asunit.runner.BaseTestRunner;
20 | import asunit.runner.TestSuiteLoader;
21 | import asunit.runner.Version;
22 | import asunit.textui.AirRunner;
23 | import asunit.textui.FlexRunner;
24 | import asunit.textui.FlexTestRunner;
25 | import asunit.textui.ResultPrinter;
26 | import asunit.textui.TestRunner;
27 | import asunit.textui.XMLResultPrinter;
28 | import asunit.util.ArrayIterator;
29 | import asunit.util.Iterator;
30 | import asunit.util.Properties;
31 |
32 | public class AsUnit {
33 | private var assertionFailedError:AssertionFailedError;
34 | private var classNotFoundError:ClassNotFoundError;
35 | private var instanceNotFoundError:InstanceNotFoundError;
36 | private var unimplementedFeatureError:UnimplementedFeatureError;
37 | private var assert:Assert;
38 | private var asynchronousTestCase:AsynchronousTestCase;
39 | private var asynchronousTestCaseExample:AsynchronousTestCaseExample;
40 | private var asyncOperation:AsyncOperation;
41 | private var remotingTestCase:RemotingTestCase;
42 | private var test:Test;
43 | private var testCase:TestCase;
44 | private var testCaseExample:TestCaseExample;
45 | private var testFailure:TestFailure;
46 | private var testListener:TestListener;
47 | private var testMethod:TestMethod;
48 | private var testResult:TestResult;
49 | private var testSuite:TestSuite;
50 | private var baseTestRunner:BaseTestRunner;
51 | private var testSuiteLoader:TestSuiteLoader;
52 | private var version:Version;
53 | private var airRunner:AirRunner;
54 | private var flexRunner:FlexRunner;
55 | private var flexTestRunner:FlexTestRunner;
56 | private var resultPrinter:ResultPrinter;
57 | private var testRunner:TestRunner;
58 | private var xMLResultPrinter:XMLResultPrinter;
59 | private var arrayIterator:ArrayIterator;
60 | private var iterator:Iterator;
61 | private var properties:Properties;
62 | private var asUnit:AsUnit;
63 | }
64 | }
--------------------------------------------------------------------------------
/lib/asunit3/asunit/errors/AbstractError.as:
--------------------------------------------------------------------------------
1 | package asunit.errors {
2 |
3 | public class AbstractError extends Error {
4 |
5 | public function AbstractError(message:String) {
6 | super(message);
7 | name = "AbstractError";
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/lib/asunit3/asunit/errors/AssertionFailedError.as:
--------------------------------------------------------------------------------
1 | package asunit.errors {
2 |
3 | public class AssertionFailedError extends Error {
4 |
5 | public function AssertionFailedError(message:String) {
6 | super(message);
7 | name = "AssertionFailedError";
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/lib/asunit3/asunit/errors/ClassNotFoundError.as:
--------------------------------------------------------------------------------
1 | package asunit.errors {
2 |
3 | public class ClassNotFoundError extends Error {
4 |
5 | public function ClassNotFoundError(message:String) {
6 | super(message);
7 | name = "ClassNotFoundError";
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/lib/asunit3/asunit/errors/InstanceNotFoundError.as:
--------------------------------------------------------------------------------
1 | package asunit.errors {
2 |
3 | public class InstanceNotFoundError extends Error {
4 |
5 | public function InstanceNotFoundError(message:String) {
6 | super(message);
7 | name = "InstanceNotFoundError";
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/lib/asunit3/asunit/errors/UnimplementedFeatureError.as:
--------------------------------------------------------------------------------
1 | package asunit.errors {
2 |
3 | public class UnimplementedFeatureError extends Error {
4 |
5 | public function UnimplementedFeatureError(message:String) {
6 | super(message);
7 | name = "UnimplementedFeatureError";
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/lib/asunit3/asunit/framework/AsyncOperation.as:
--------------------------------------------------------------------------------
1 | package asunit.framework {
2 | import asunit.errors.AssertionFailedError;
3 | import flash.errors.IllegalOperationError;
4 | import flash.events.Event;
5 | import flash.events.TimerEvent;
6 | import flash.utils.Timer;
7 |
8 | public class AsyncOperation{
9 |
10 | private var timeout:Timer;
11 | private var testCase:TestCase;
12 | private var callback:Function;
13 | private var duration:Number;
14 | private var failureHandler:Function;
15 |
16 | public function AsyncOperation(testCase:TestCase, handler:Function, duration:Number, failureHandler:Function=null){
17 | this.testCase = testCase;
18 | this.duration = duration;
19 | timeout = new Timer(duration, 1);
20 | timeout.addEventListener(TimerEvent.TIMER_COMPLETE, onTimeoutComplete);
21 | timeout.start();
22 | if(handler == null) {
23 | handler = function(args:*):* {return;};
24 | }
25 | this.failureHandler = failureHandler;
26 | var context:AsyncOperation = this;
27 | callback = function(args:*):* {
28 | timeout.stop();
29 | try {
30 | handler.apply(testCase, arguments);
31 | }
32 | catch(e:AssertionFailedError) {
33 | testCase.getResult().addFailure(testCase, e);
34 | }
35 | catch(ioe:IllegalOperationError) {
36 | testCase.getResult().addError(testCase, ioe);
37 | }
38 | catch(unknownError:Error) {
39 | testCase.getResult().addError(testCase, unknownError);
40 | }
41 | finally {
42 | testCase.asyncOperationComplete(context);
43 | }
44 | return;
45 | };
46 | }
47 |
48 | public function getCallback():Function{
49 | return callback;
50 | }
51 |
52 | private function onTimeoutComplete(event:TimerEvent):void {
53 | if(null != failureHandler) {
54 | failureHandler(new Event('async timeout'));
55 | }
56 | testCase.asyncOperationTimeout(this, duration, null==failureHandler);
57 | }
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/lib/asunit3/asunit/framework/AsynchronousHTTPServiceTestCase.as:
--------------------------------------------------------------------------------
1 | package asunit.framework {
2 | import asunit.errors.AbstractError;
3 |
4 | import flash.errors.IllegalOperationError;
5 | import flash.events.*;
6 | import flash.net.URLLoader;
7 | import flash.utils.getTimer;
8 |
9 | import mx.rpc.AsyncToken;
10 | import mx.rpc.Responder;
11 | import mx.rpc.events.FaultEvent;
12 |
13 | /**
14 | * Extend this class if you have a TestCase that requires the
15 | * asynchronous load of external data.
16 | */
17 | public class AsynchronousHTTPServiceTestCase extends TestCase implements Test {
18 |
19 | public function AsynchronousHTTPServiceTestCase(testMethod:String = null) {
20 | super(testMethod);
21 | }
22 |
23 | // use this method in overriding run() if you are using an HTTPService:
24 | protected function configureResponder(token:AsyncToken):void {
25 | token.addResponder(new Responder(resultFunc, faultFunc));
26 | }
27 |
28 | protected function resultFunc(event:Object):void {
29 | completeHandler(event as Event);
30 | }
31 |
32 | protected function faultFunc(event:Object):void {
33 | var faultEvent:FaultEvent = event as FaultEvent;
34 | if (faultEvent == null) {
35 | return;
36 | }
37 | var cause:Object = faultEvent.fault.rootCause;
38 | var ioErrorEvent:IOErrorEvent = cause as IOErrorEvent;
39 | if (ioErrorEvent) {
40 | ioErrorHandler(ioErrorEvent);
41 | return;
42 | }
43 | var securityErrorEvent:SecurityErrorEvent = cause as SecurityErrorEvent;
44 | if (securityErrorEvent) {
45 | securityErrorHandler(securityErrorEvent);
46 | }
47 | }
48 |
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/lib/asunit3/asunit/framework/Test.as:
--------------------------------------------------------------------------------
1 | package asunit.framework {
2 | import flash.display.DisplayObjectContainer;
3 | import flash.events.IEventDispatcher;
4 |
5 | public interface Test extends IEventDispatcher {
6 | function countTestCases():int;
7 | function getName():String;
8 | function getTestMethods():Array;
9 | function toString():String;
10 | function setResult(result:TestListener):void;
11 | function run():void;
12 | function runBare():void;
13 | function getCurrentMethod():String;
14 | function getIsComplete():Boolean;
15 | function setContext(context:DisplayObjectContainer):void;
16 | function getContext():DisplayObjectContainer;
17 | }
18 | }
--------------------------------------------------------------------------------
/lib/asunit3/asunit/framework/TestCaseExample.as:
--------------------------------------------------------------------------------
1 | package asunit.framework {
2 | import asunit.framework.TestCase;
3 | import flash.display.Sprite;
4 | import flash.events.Event;
5 | import flash.events.IEventDispatcher;
6 | import flash.events.EventDispatcher;
7 | import flash.utils.setTimeout;
8 |
9 | // TestCase subclasses should always end with 'Test', the example
10 | // doesn't because we don't want TestSuites in this directory.
11 | public class TestCaseExample extends TestCase {
12 | private var date:Date;
13 | private var sprite:Sprite;
14 |
15 | // TestCase constructors must be implemented as follows
16 | // so that we can execute a single method on them from
17 | // the TestRunner
18 | public function TestCaseExample(testMethod:String = null) {
19 | super(testMethod);
20 | }
21 |
22 | // This method will be called before every test method
23 | override protected function setUp():void {
24 | date = new Date();
25 | // sprite = new Sprite();
26 | // addChild(sprite);
27 | }
28 |
29 | // This method will be called after every test method
30 | // but only if we're executing the entire TestCase,
31 | // the tearDown method won't be called if we're
32 | // calling start(MyTestCase, "someMethod");
33 | override protected function tearDown():void {
34 | // removeChild(sprite);
35 | // sprite = null;
36 | date = null;
37 | }
38 |
39 | // This is auto-created by the XULUI and ensures that
40 | // our objects are actually created as we expect.
41 | public function testInstantiated():void {
42 | assertTrue("Date instantiated", date is Date);
43 | // assertTrue("Sprite instantiated", sprite is Sprite);
44 | }
45 |
46 | // This is an example of a typical test method
47 | public function testMonthGetterSetter():void {
48 | date.month = 1;
49 | assertEquals(1, date.month);
50 | }
51 |
52 | // This is an asynchronous test method
53 | public function testAsyncFeature():void {
54 | // create a new object that dispatches events...
55 | var dispatcher:IEventDispatcher = new EventDispatcher();
56 | // get a TestCase async event handler reference
57 | // the 2nd arg is an optional timeout in ms. (default=1000ms )
58 | var handler:Function = addAsync(changeHandler, 2000);
59 | // subscribe to your event dispatcher using the returned handler
60 | dispatcher.addEventListener(Event.CHANGE, handler);
61 | // cause the event to be dispatched.
62 | // either immediately:
63 | //dispatcher.dispatchEvent(new Event(Event.CHANGE));
64 | // or in the future < your assigned timeout
65 | setTimeout( dispatcher.dispatchEvent, 200, new Event(Event.CHANGE));
66 | }
67 |
68 | protected function changeHandler(event:Event):void {
69 | // perform assertions in your handler
70 | assertEquals(Event.CHANGE, event.type);
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/lib/asunit3/asunit/framework/TestFailure.as:
--------------------------------------------------------------------------------
1 | package asunit.framework {
2 | import asunit.errors.AssertionFailedError;
3 |
4 | /**
5 | * A TestFailure
collects a failed test together with
6 | * the caught exception.
7 | * @see TestResult
8 | */
9 | public class TestFailure {
10 | protected var fFailedTest:Test;
11 | protected var fFailedTestMethod:String;
12 | protected var fThrownException:Error;
13 |
14 | /**
15 | * Constructs a TestFailure with the given test and exception.
16 | */
17 | public function TestFailure(failedTest:Test, thrownException:Error) {
18 | fFailedTest = failedTest;
19 | fFailedTestMethod = failedTest.getCurrentMethod();
20 | fThrownException = thrownException;
21 | }
22 |
23 | public function failedFeature():String {
24 | return failedTest().getName() + '.' + fFailedTestMethod;
25 | }
26 |
27 | public function failedMethod():String {
28 | return fFailedTestMethod;
29 | }
30 |
31 | /**
32 | * Gets the failed test case.
33 | */
34 | public function failedTest():Test {
35 | return fFailedTest;
36 | }
37 | /**
38 | * Gets the thrown exception.
39 | */
40 | public function thrownException():Error {
41 | return fThrownException;
42 | }
43 | /**
44 | * Returns a short description of the failure.
45 | */
46 | public function toString():String {
47 | return "";
48 | }
49 |
50 | public function exceptionMessage():String {
51 | return thrownException().message;
52 | }
53 |
54 | public function isFailure():Boolean {
55 | return thrownException() is AssertionFailedError;
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/lib/asunit3/asunit/framework/TestListener.as:
--------------------------------------------------------------------------------
1 | package asunit.framework {
2 | import asunit.errors.AssertionFailedError;
3 |
4 | public interface TestListener {
5 |
6 | /**
7 | * Run the provided Test.
8 | */
9 | function run(test:Test):void;
10 | /**
11 | * A test started.
12 | */
13 | function startTest(test:Test):void;
14 | /**
15 | * A failure occurred.
16 | */
17 | function addFailure(test:Test, t:AssertionFailedError):void;
18 | /**
19 | * An error occurred.
20 | */
21 | function addError(test:Test, t:Error):void;
22 | /**
23 | * A test method has begun execution.
24 | */
25 | function startTestMethod(test:Test, methodName:String):void;
26 | /**
27 | * A test method has completed.
28 | */
29 | function endTestMethod(test:Test, methodName:String):void;
30 | /**
31 | * A test ended.
32 | */
33 | function endTest(test:Test):void;
34 | }
35 | }
--------------------------------------------------------------------------------
/lib/asunit3/asunit/framework/TestMethod.as:
--------------------------------------------------------------------------------
1 | package asunit.framework {
2 |
3 | import flash.utils.getTimer;
4 |
5 | /**
6 | * A TestFailure
collects a failed test together with
7 | * the caught exception.
8 | * @see TestResult
9 | */
10 | public class TestMethod {
11 | protected var test:Test;
12 | protected var method:String;
13 |
14 | private var _duration:Number;
15 | private var start:Number;
16 |
17 | /**
18 | * Constructs a TestMethod with a given Test and method name.
19 | */
20 | public function TestMethod(test:Test, method:String) {
21 | this.test = test;
22 | this.method = method;
23 | start = getTimer();
24 | }
25 |
26 | public function getName():String {
27 | return method;
28 | }
29 |
30 | public function endTest(test:Test):void {
31 | _duration = (getTimer() - start) * .001;
32 | }
33 |
34 | public function duration():Number {
35 | return _duration;
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/lib/asunit3/asunit/runner/BaseTestRunner.as:
--------------------------------------------------------------------------------
1 | package asunit.runner {
2 | import flash.display.Sprite;
3 |
4 | /**
5 | * Base class for all test runners.
6 | * This class was born live on stage in Sardinia during XP2000.
7 | */
8 | public class BaseTestRunner extends Sprite {
9 |
10 | // Filters stack frames from internal JUnit classes
11 | public static function getFilteredTrace(stack:String):String {
12 | return stack;
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/lib/asunit3/asunit/runner/TestSuiteLoader.as:
--------------------------------------------------------------------------------
1 | package asunit.runner {
2 |
3 | public interface TestSuiteLoader {
4 | // throws ClassNotFoundException
5 | function load(suiteClassName:String):Class;
6 | // throws ClassNotFoundException
7 | function reload(aClass:Class):Class;
8 | }
9 | }
--------------------------------------------------------------------------------
/lib/asunit3/asunit/runner/Version.as:
--------------------------------------------------------------------------------
1 | package asunit.runner {
2 |
3 | public class Version {
4 | private static var version:String = "3.0";
5 |
6 | public static function id():String {
7 | return version.toString();
8 | }
9 |
10 | }
11 | }
--------------------------------------------------------------------------------
/lib/asunit3/asunit/textui/AirRunner.as:
--------------------------------------------------------------------------------
1 | package asunit.textui {
2 | import asunit.framework.TestResult;
3 |
4 | import mx.core.WindowedApplication;
5 |
6 | /**
7 | * The base class for Air application runners that use the Flex framework.
8 | *
9 | * @includeExample AirRunnerExample.mxml
10 | *
11 | * @author Ian
12 | * @playerversion AIR 1.1
13 | **/
14 | public class AirRunner extends WindowedApplication {
15 |
16 | protected var runner:TestRunner;
17 |
18 | override protected function createChildren():void {
19 | super.createChildren();
20 | runner = new FlexTestRunner();
21 | rawChildren.addChild(runner);
22 | }
23 |
24 | public function start(testCase:Class, testMethod:String = null, showTrace:Boolean = false) : TestResult {
25 | return runner.start(testCase, testMethod, showTrace);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/lib/asunit3/asunit/textui/FlexRunner.as:
--------------------------------------------------------------------------------
1 | package asunit.textui {
2 | import asunit.framework.TestResult;
3 |
4 | import mx.core.Application;
5 |
6 | /**
7 | * The FlexTestRunner
should be the base class for your
8 | * test harness if you're testing a project that uses Flex components.
9 | *
10 | * @includeExample FlexRunnerExample.mxml
11 | **/
12 | public class FlexRunner extends Application {
13 | protected var runner:TestRunner;
14 |
15 | override protected function createChildren():void {
16 | super.createChildren();
17 | runner = new FlexTestRunner();
18 | rawChildren.addChild(runner);
19 | }
20 |
21 | public function start(testCase:Class, testMethod:String = null, showTrace:Boolean = false):TestResult {
22 | return runner.start(testCase, testMethod, showTrace);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/lib/asunit3/asunit/textui/FlexTestRunner.as:
--------------------------------------------------------------------------------
1 | package asunit.textui {
2 | import flash.display.DisplayObject;
3 | import flash.events.Event;
4 | import mx.core.IUIComponent;
5 | import asunit.textui.TestRunner;
6 |
7 | /**
8 | * @private
9 | **/
10 | public class FlexTestRunner extends TestRunner {
11 |
12 | public function FlexTestRunner() {
13 | setPrinter(new ResultPrinter());
14 | }
15 |
16 | protected override function addedHandler(event:Event):void {
17 | if(event.target === this) {
18 | parent.addEventListener(Event.RESIZE, resizeHandler);
19 | resizeHandler(new Event(Event.RESIZE));
20 | }
21 | else {
22 | event.stopPropagation();
23 | }
24 | }
25 |
26 | public override function set width(w:Number):void {
27 | fPrinter.width = w;
28 | }
29 |
30 | public override function set height(h:Number):void {
31 | fPrinter.height = h;
32 | }
33 |
34 | public function resizeHandler(event:Event):void {
35 | width = parent.width;
36 | height = parent.height;
37 | }
38 |
39 | public override function addChild(child:DisplayObject):DisplayObject {
40 | if(parent && child is IUIComponent) {
41 | // AND check for 'is' UIUComponent...
42 | return parent.addChild(child);
43 | }
44 | else {
45 | return super.addChild(child);
46 | }
47 | }
48 |
49 | public override function removeChild(child:DisplayObject):DisplayObject {
50 | if(child is IUIComponent) {
51 | return parent.removeChild(child);
52 | }
53 | else {
54 | return super.removeChild(child);
55 | }
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/lib/asunit3/asunit/textui/TestTime.as:
--------------------------------------------------------------------------------
1 | package asunit.textui
2 | {
3 | import asunit.framework.AsynchronousTestCase;
4 | import asunit.framework.Test;
5 |
6 | public class TestTime extends Object
7 | {
8 | public static function create(test:Test, duration:int):TestTime
9 | {
10 | var asyncTest:AsynchronousTestCase = test as AsynchronousTestCase;
11 | if (asyncTest && asyncTest.remoteDurationIsValid())
12 | {
13 | return new AsyncTestTime(asyncTest, duration, PrivateConstructorEnforcer);
14 | }
15 | else
16 | {
17 | return new TestTime(test, duration, PrivateConstructorEnforcer);
18 | }
19 | }
20 |
21 | private var _name:String;
22 | private var _duration:int;
23 | public function get duration():int
24 | {
25 | return _duration;
26 | }
27 |
28 | public function TestTime(test:Test, duration:int, lock:Class)
29 | {
30 | super();
31 | if (lock != PrivateConstructorEnforcer)
32 | {
33 | throw new Error("TestTime: private constructor");
34 | }
35 |
36 | _name = test.getName();
37 | _duration = duration;
38 | }
39 |
40 | public function toString():String
41 | {
42 | return "" + _duration + 'ms : ' + _name;
43 | }
44 |
45 | }
46 | }
47 | import asunit.framework.Test;
48 | import asunit.framework.AsynchronousTestCase;
49 | import asunit.textui.TestTime;
50 |
51 |
52 | class AsyncTestTime extends TestTime
53 | {
54 | private var _remoteDuration:int;
55 |
56 | public function AsyncTestTime(test:AsynchronousTestCase, duration:int, lock:Class)
57 | {
58 | super(test, duration, lock);
59 | _remoteDuration = test.remoteDuration;
60 | }
61 |
62 | override public function toString():String
63 | {
64 | return super.toString() + ' (remote: ' + _remoteDuration + 'ms)';
65 | }
66 | }
67 |
68 | class PrivateConstructorEnforcer {}
--------------------------------------------------------------------------------
/lib/asunit3/asunit/util/ArrayIterator.as:
--------------------------------------------------------------------------------
1 | package asunit.util {
2 |
3 | import asunit.util.Iterator;
4 |
5 | [ExcludeClass]
6 | public class ArrayIterator implements Iterator {
7 | private var list:Array;
8 | private var index:Number = 0;
9 |
10 | public function ArrayIterator(list:Array) {
11 | this.list = list;
12 | }
13 |
14 | public function hasNext():Boolean {
15 | return list[index] != null;
16 | }
17 |
18 | public function next():Object {
19 | return list[index++];
20 | }
21 |
22 | public function reset():void {
23 | index = 0;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/lib/asunit3/asunit/util/Iterator.as:
--------------------------------------------------------------------------------
1 | package asunit.util {
2 |
3 | [ExcludeClass]
4 | public interface Iterator {
5 | function next():Object;
6 | function hasNext():Boolean;
7 | function reset():void;
8 | }
9 | }
--------------------------------------------------------------------------------
/lib/asunit3/asunit/util/Properties.as:
--------------------------------------------------------------------------------
1 | package asunit.util {
2 | import asunit.errors.UnimplementedFeatureError;
3 | import flash.errors.IllegalOperationError;
4 |
5 | [ExcludeClass]
6 | public dynamic class Properties {
7 |
8 | public function store(sharedObjectId:String):void {
9 | throw new UnimplementedFeatureError("Properties.store");
10 | }
11 |
12 | public function put(key:String, value:Object):void {
13 | this[key] = value;
14 | }
15 |
16 | public function setProperty(key:String, value:Object):void {
17 | put(key, value);
18 | }
19 |
20 | public function getProperty(key:String):Object {
21 | try {
22 | return this[key];
23 | }
24 | catch(e:Error) {
25 | throw IllegalOperationError("Properties.getProperty");
26 | }
27 | return null;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/lib/asx.swc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Stray/robotlegs-utilities-RelaxedEventMap/9d0fa632e9bca43237db6ca5df0cad4253cbd581/lib/asx.swc
--------------------------------------------------------------------------------
/lib/hamcrest.swc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Stray/robotlegs-utilities-RelaxedEventMap/9d0fa632e9bca43237db6ca5df0cad4253cbd581/lib/hamcrest.swc
--------------------------------------------------------------------------------
/lib/mockolate/mockolate/errors/ExpectationError.as:
--------------------------------------------------------------------------------
1 | package mockolate.errors
2 | {
3 | import mockolate.ingredients.Expectation;
4 | import mockolate.ingredients.Mockolate;
5 |
6 | /**
7 | * Expectation-related Error
8 | */
9 | public class ExpectationError extends MockolateError
10 | {
11 | private var _expectation:Expectation;
12 |
13 | /**
14 | * Constructor
15 | */
16 | public function ExpectationError(message:Object, expectation:Expectation, mockolate:Mockolate, target:Object)
17 | {
18 | super(message, mockolate, target);
19 |
20 | _expectation = expectation;
21 | }
22 |
23 | /**
24 | * Expectation instance related to this Error
25 | */
26 | public function get expectation():Expectation
27 | {
28 | return _expectation;
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/lib/mockolate/mockolate/errors/InvocationError.as:
--------------------------------------------------------------------------------
1 | package mockolate.errors
2 | {
3 | import mockolate.ingredients.Invocation;
4 | import mockolate.ingredients.Mockolate;
5 |
6 | /**
7 | * Invocation-related Error
8 | */
9 | public class InvocationError extends MockolateError
10 | {
11 | private var _invocation:Invocation;
12 |
13 | /**
14 | * Constructor.
15 | */
16 | public function InvocationError(message:Object, invocation:Invocation, mockolate:Mockolate, target:Object)
17 | {
18 | super(message, mockolate, target);
19 |
20 | _invocation = invocation;
21 | }
22 |
23 | public function get invocation():Invocation
24 | {
25 | return _invocation;
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/lib/mockolate/mockolate/errors/MockolateError.as:
--------------------------------------------------------------------------------
1 | package mockolate.errors
2 | {
3 | import asx.string.substitute;
4 |
5 | import mockolate.ingredients.Mockolate;
6 |
7 | /**
8 | * Mockolate-related Error
9 | */
10 | public class MockolateError extends Error
11 | {
12 | private var _mockolate:Mockolate;
13 | private var _target:Object;
14 |
15 | /**
16 | * Constructor.
17 | */
18 | public function MockolateError(message:Object, mockolate:Mockolate, target:Object) {
19 |
20 | if (message is Array)
21 | message = substitute(message[0], message[1] || []);
22 |
23 | super(message);
24 |
25 | _mockolate = mockolate;
26 | _target = target;
27 | }
28 |
29 | public function get mockolate():Mockolate {
30 | return _mockolate;
31 | }
32 |
33 | public function get target():Object {
34 | return _target;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/lib/mockolate/mockolate/errors/VerificationError.as:
--------------------------------------------------------------------------------
1 | package mockolate.errors
2 | {
3 | import mockolate.ingredients.Expectation;
4 | import mockolate.ingredients.Mockolate;
5 | import mockolate.ingredients.Verification;
6 |
7 | /**
8 | * Verification-related Error
9 | */
10 | public class VerificationError extends MockolateError
11 | {
12 | private var _verification:Verification;
13 |
14 | /**
15 | * Constructor.
16 | */
17 | public function VerificationError(
18 | message:Object,
19 | verification:Verification,
20 | mockolate:Mockolate,
21 | target:Object)
22 | {
23 | super(message, mockolate, target);
24 |
25 | _verification = verification;
26 | }
27 |
28 | /**
29 | * Verification instance related to this Error
30 | */
31 | public function get verification():Verification
32 | {
33 | return _verification;
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/lib/mockolate/mockolate/ingredients/Couverture.as:
--------------------------------------------------------------------------------
1 | package mockolate.ingredients
2 | {
3 | use namespace mockolate_ingredient;
4 |
5 | /**
6 | * Couverture.
7 | *
8 | * @see RecordingCouverture
9 | * @see MockingCouverture
10 | *
11 | * @author drewbourne
12 | */
13 | public class Couverture
14 | {
15 | /**
16 | * Constructor.
17 | */
18 | public function Couverture(mockolate:Mockolate)
19 | {
20 | super();
21 |
22 | if (!mockolate)
23 | throw new ArgumentError("Couverture requires a Mockolate instance.");
24 |
25 | _mockolate = mockolate;
26 | }
27 |
28 | /**
29 | * Mockolate instance this Couverture belongs to.
30 | */
31 | public function get mockolate():Mockolate
32 | {
33 | return _mockolate;
34 | }
35 |
36 | private var _mockolate:Mockolate;
37 |
38 | /**
39 | * Called by the Mockolate when an Invocation is received.
40 | *
41 | * Subclasses should override invoked and perform whatever logic they require.
42 | */
43 | mockolate_ingredient function invoked(invocation:Invocation):void
44 | {
45 | // abstract
46 | }
47 |
48 | /**
49 | * Called by Mockolate when verify.
50 | *
51 | * Subclasses should override verify and perform whatever logic they require.
52 | */
53 | mockolate_ingredient function verify():void
54 | {
55 | // abstract
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/lib/mockolate/mockolate/ingredients/Invocation.as:
--------------------------------------------------------------------------------
1 | package mockolate.ingredients
2 | {
3 | /**
4 | * Interface implemented by facades to the invocation objects provided by ASMock and Loom.
5 | *
6 | * @author drewbourne
7 | */
8 | public interface Invocation
9 | {
10 | /**
11 | * Object this Invocation was triggered by.
12 | */
13 | function get target():Object;
14 |
15 | /**
16 | * Name of the Method, Getter or Setter.
17 | */
18 | function get name():String;
19 |
20 | /**
21 | * InvocationType indicates if this invocation is a Method, Getter or Setter.
22 | */
23 | function get invocationType():InvocationType;
24 |
25 | /**
26 | * Indicates this Invocation is a Method
27 | */
28 | function get isMethod():Boolean;
29 |
30 | /**
31 | * Indicates this Invocation is a Getter
32 | */
33 | function get isGetter():Boolean;
34 |
35 | /**
36 | * Indicates this Invocation is a Setter
37 | */
38 | function get isSetter():Boolean;
39 |
40 | /**
41 | * Array of arguments received by this Invocation
42 | */
43 | function get arguments():Array;
44 |
45 | /**
46 | * Value to return.
47 | */
48 | function get returnValue():*;
49 |
50 | function set returnValue(value:*):void;
51 |
52 | /**
53 | * Proceed with the original implementation.
54 | */
55 | function proceed():void;
56 | }
57 | }
--------------------------------------------------------------------------------
/lib/mockolate/mockolate/ingredients/InvocationType.as:
--------------------------------------------------------------------------------
1 | package mockolate.ingredients
2 | {
3 | /**
4 | * Type of an Invocation.
5 | *
6 | *
METHOD
indicates the Invocation is a Method.
8 | * GETTER
indicates the Invocation is for the getter of a Property.
9 | * SETTER
indicates the Invocation is for the setter of a Property.
10 | * Event.COMPLETE
17 | */
18 | function prepare(... rest):IEventDispatcher;
19 |
20 | /**
21 | * Create an instance of Mockolate for the given Class reference.
22 | *
23 | * Attempting to call create()
before prepare()
24 | * has completed for that class will throw an Error.
25 | *
26 | * @param klass Class reference that has been given to prepare()
.
27 | * @param constructorArgs Array of args to pass to the target instances constructor.
28 | * @param asStrict Indicates if the Mockolate should be create in strict mode.
29 | * @param name Name of the Mockolate instance to aid with debugging.
30 | * @returns Mockolate instance.
31 | *
32 | * @see Mockolate#isStrict
33 | */
34 | function create(klass:Class, constructorArgs:Array=null, asStrict:Boolean=true, name:String=null):Mockolate;
35 | }
36 | }
--------------------------------------------------------------------------------
/lib/mockolate/mockolate/ingredients/MockolatierMaster.as:
--------------------------------------------------------------------------------
1 | package mockolate.ingredients
2 | {
3 | import flash.events.IEventDispatcher;
4 |
5 | [ExcludeClass]
6 |
7 | /**
8 | * Oversees and delegates work to a Mockolatier.
9 | *
10 | * Provides a static wrapper around a Mockolatier instance for use with the
11 | * mockolate.*
package functions.
12 | *
13 | * Do not reference directly.
14 | */
15 | public class MockolatierMaster
16 | {
17 | // create a default Mockolatier
18 | private static var _mockolatier:Mockolatier = new Mockolatier();
19 |
20 | /**
21 | * Mockolatier instance to use with the mockolate.*
22 | * package-level functions.
23 | */
24 | public static function get mockolatier():Mockolatier
25 | {
26 | return _mockolatier;
27 | }
28 |
29 | /** @private */
30 | public static function set mockolatier(value:Mockolatier):void
31 | {
32 | if (value)
33 | {
34 | _mockolatier = value;
35 | }
36 | }
37 |
38 | /**
39 | * @see mockolate#prepare()
40 | */
41 | public static function prepare(... rest):IEventDispatcher
42 | {
43 | return mockolatier.prepare(rest);
44 | }
45 |
46 | /**
47 | * @see mockolate#prepare()
48 | */
49 | public static function nice(klass:Class, name:String=null, constructorArgs:Array=null):*
50 | {
51 | return mockolatier.nice(klass, name, constructorArgs);
52 | }
53 |
54 | /**
55 | * @see mockolate#strict()
56 | */
57 | public static function strict(klass:Class, name:String=null, constructorArgs:Array=null):*
58 | {
59 | return mockolatier.strict(klass, name, constructorArgs);
60 | }
61 |
62 | /**
63 | * @see mockolate#mock()
64 | */
65 | public static function mock(target:*):MockingCouverture
66 | {
67 | return mockolatier.mock(target);
68 | }
69 |
70 | /**
71 | * @see mockolate#stub()
72 | */
73 | public static function stub(target:*):MockingCouverture
74 | {
75 | return mockolatier.stub(target);
76 | }
77 |
78 | /**
79 | * @see mockolate#verify()
80 | */
81 | public static function verify(target:*):VerifyingCouverture
82 | {
83 | return mockolatier.verify(target);
84 | }
85 | }
86 | }
--------------------------------------------------------------------------------
/lib/mockolate/mockolate/ingredients/RecordingCouverture.as:
--------------------------------------------------------------------------------
1 | package mockolate.ingredients
2 | {
3 | use namespace mockolate_ingredient;
4 |
5 | /**
6 | * Couverture that records every Invocation passed to invoked(Invocation)
.
7 | *
8 | * @author drewbourne
9 | */
10 | public class RecordingCouverture extends Couverture
11 | {
12 | [ArrayElementType("mockolate.ingredients.Invocation")]
13 | private var _invocations:Array;
14 |
15 | /**
16 | * Constructor.
17 | */
18 | public function RecordingCouverture(mockolate:Mockolate)
19 | {
20 | super(mockolate);
21 |
22 | _invocations = [];
23 | }
24 |
25 | [ArrayElementType("mockolate.ingredients.Invocation")]
26 | /**
27 | * Returns the recorded Invocations up to the time this property is accessed.
28 | */
29 | mockolate_ingredient function get invocations():Array
30 | {
31 | return _invocations.slice(0);
32 | }
33 |
34 | /**
35 | * Records the given Invocation.
36 | */
37 | override mockolate_ingredient function invoked(invocation:Invocation):void
38 | {
39 | addInvocation(invocation);
40 | }
41 |
42 | /**
43 | * Adds an Invocation to the invocations
Array.
44 | */
45 | protected function addInvocation(invocation:Invocation):void
46 | {
47 | _invocations.push(invocation);
48 | }
49 |
50 | /**
51 | * @private
52 | */
53 | override mockolate_ingredient function verify():void
54 | {
55 |
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/lib/mockolate/mockolate/ingredients/Verification.as:
--------------------------------------------------------------------------------
1 | package mockolate.ingredients
2 | {
3 | import org.hamcrest.Matcher;
4 | import org.hamcrest.core.allOf;
5 | import mockolate.ingredients.InvocationType;
6 |
7 | // FIXME Verification is not the most appropriate name for this class.
8 | /**
9 | * Verification.
10 | *
11 | * @see mockolate#verify()
12 | * @see mockolate.ingredients.VerifyingCouverture
13 | *
14 | * @author drewbourne
15 | */
16 | public class Verification
17 | {
18 | /**
19 | * Constructor.
20 | */
21 | public function Verification()
22 | {
23 | }
24 |
25 | /**
26 | * When set verifies Invocations with this InvocationType.
27 | */
28 | public function get invocationType():InvocationType
29 | {
30 | return _invocationType;
31 | }
32 |
33 | /** @private */
34 | public function set invocationType(value:InvocationType):void
35 | {
36 | _invocationType = value;
37 | }
38 |
39 | private var _invocationType:InvocationType;
40 |
41 | /** @private */
42 | public function get invocationTypeMatcher():Matcher
43 | {
44 | return _invocationTypeMatcher;
45 | }
46 |
47 | /** @private */
48 | public function set invocationTypeMatcher(value:Matcher):void
49 | {
50 | _invocationTypeMatcher = value;
51 | }
52 |
53 | private var _invocationTypeMatcher:Matcher;
54 |
55 | /**
56 | * When set verifies Invocations with this name.
57 | */
58 | public function get name():String
59 | {
60 | return _name;
61 | }
62 |
63 | /** @private */
64 | public function set name(value:String):void
65 | {
66 | _name = value;
67 | }
68 |
69 | private var _name:String;
70 |
71 | /** @private */
72 | public function get nameMatcher():Matcher
73 | {
74 | return _nameMatcher;
75 | }
76 |
77 | /** @private */
78 | public function set nameMatcher(value:Matcher):void
79 | {
80 | _nameMatcher = value;
81 | }
82 |
83 | private var _nameMatcher:Matcher;
84 |
85 | /**
86 | * When set verifies the arguments of Invocations.
87 | */
88 | public function get arguments():Array
89 | {
90 | return _arguments;
91 | }
92 |
93 | /** @private */
94 | public function set arguments(value:Array):void
95 | {
96 | _arguments = value;
97 | }
98 |
99 | private var _arguments:Array;
100 |
101 | /** @private */
102 | public function get argumentsMatcher():Matcher
103 | {
104 | return _argumentsMatcher;
105 | }
106 |
107 | /** @private */
108 | public function set argumentsMatcher(value:Matcher):void
109 | {
110 | _argumentsMatcher = value;
111 | }
112 |
113 | private var _argumentsMatcher:Matcher;
114 |
115 | /**
116 | * When set verifies Invocations as having been invoked this number of times.
117 | */
118 | public function get invokedCount():String
119 | {
120 | return _invokedCount;
121 | }
122 |
123 | /** @private */
124 | public function set invokedCount(value:String):void
125 | {
126 | _invokedCount = value;
127 | }
128 |
129 | private var _invokedCount:String;
130 |
131 | /** @private */
132 | public function get invokedCountMatcher():Matcher
133 | {
134 | return _invokedCountMatcher;
135 | }
136 |
137 | /** @private */
138 | public function set invokedCountMatcher(value:Matcher):void
139 | {
140 | _invokedCountMatcher = value;
141 | }
142 |
143 | private var _invokedCountMatcher:Matcher;
144 | }
145 | }
--------------------------------------------------------------------------------
/lib/mockolate/mockolate/ingredients/answers/Answer.as:
--------------------------------------------------------------------------------
1 | package mockolate.ingredients.answers
2 | {
3 | import mockolate.ingredients.Invocation;
4 |
5 | /**
6 | * Answer instances are used by mock()
and stub()
7 | * to define the behaviour of a method or property invocation.
8 | *
9 | * @author drewbourne
10 | */
11 | public interface Answer
12 | {
13 | /**
14 | * Perform Answer action.
15 | *
16 | * @param invocation
17 | * @returns possible Invocation.returnValue
18 | */
19 | function invoke(invocation:Invocation):*;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/lib/mockolate/mockolate/ingredients/answers/CallsAnswer.as:
--------------------------------------------------------------------------------
1 | package mockolate.ingredients.answers
2 | {
3 | import mockolate.ingredients.Invocation;
4 |
5 | /**
6 | * Calls a Function.
7 | *
8 | * @see mockolate.ingredients.MockingCouverture
9 | *
10 | * @example
11 | * strict()
7 | *
8 | * @see mockolate#strict()
9 | *
10 | * @author drewbourne
11 | */
12 | public function make(klass:Class, name:String=null, constructorArgs:Array=null):*
13 | {
14 | return strict(klass, name, constructorArgs);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/lib/mockolate/mockolate/mock.as:
--------------------------------------------------------------------------------
1 | package mockolate
2 | {
3 | import mockolate.ingredients.MockingCouverture;
4 | import mockolate.ingredients.MockolatierMaster;
5 |
6 | /**
7 | * Create an expectation of required behaviour on a target instance.
8 | *
9 | * When the target instance was created using nice()
10 | * and a method or property on the target instance is called
11 | * and no expectations have been set using mock()
or stub()
12 | * then a false-y value will be returned (false
, null
, 0
, NaN
)
13 | *
14 | * When the target instance was created using strict()
15 | * and a method or property on the target instance is called
16 | * and no expectations have been set using mock()
or stub()
17 | * then an UnspecifiedBehaiourError
will be thrown.
18 | *
19 | * When verify()
is called for the target instance
20 | * and the expectation has not been met
21 | * then an UnmetExpectationError
will be thrown.
22 | *
23 | * @see mockolate#stub()
24 | *
25 | * @see mockolate#nice()
26 | * @see mockolate#strict()
27 | *
28 | * @example
29 | * mock()
or
10 | * stub()
Expectation defined.
11 | *
12 | * @param klass Class to create a nice mock for.
13 | * @param name Name for the mock instance.
14 | *
15 | * @see mockolate#strict()
16 | * @see mockolate#mock()
17 | * @see mockolate#stub()
18 | *
19 | * @example
20 | * prepare()
returns an IEventDispatcher
13 | * that will fire an Event.COMPLETE
event when finished preparing.
14 | *
15 | * @param ...rest One or more Class references.
16 | * @return IEventDispatcher
17 | *
18 | * @see mockolate#nice()
19 | * @see mockolate#strict()
20 | *
21 | * @example
22 | * mock()
or
10 | * stub()
Expectation defined.
11 | *
12 | * @param klass Class to create a strict mock for.
13 | * @param name Name for the mock instance.
14 | *
15 | * @see mockolate#strict()
16 | * @see mockolate#mock()
17 | * @see mockolate#stub()
18 | *
19 | * @example
20 | * nice()
10 | * and a method or property on the target instance is called
11 | * and no expectations have been set using mock()
or stub()
12 | * then a false-y value will be returned (false
, null
, 0
, NaN
)
13 | *
14 | * When the target instance was created using strict()
15 | * and a method or property on the target instance is called
16 | * and no expectations have been set using mock()
or stub()
17 | * then an UnspecifiedBehaiourError
will be thrown.
18 | *
19 | * @see mockolate#mock()
20 | *
21 | * @see mockolate#nice()
22 | * @see mockolate#strict()
23 | *
24 | * @example
25 | * verify()
will verify that any Expectations defined
10 | * by mock()
have been invoked their expected number of times.
11 | *
12 | * Using the VerifyingCouverture additional verification can be performed
13 | * on the Invocations recorded by the Mockolate instance.
14 | *
15 | * @see mockolate.ingredients.VerifyingCouverture
16 | *
17 | * @example
18 | * IInjector
adpater - See: SwiftSuspenders
15 | *
16 | * @author tschneidereit
17 | */
18 | public class SwiftSuspendersInjector extends Injector implements IInjector
19 | {
20 | protected static const XML_CONFIG:XML =
21 | IReflector
adpater - See: SwiftSuspenders
15 | *
16 | * @author tschneidereit
17 | */
18 | public class SwiftSuspendersReflector extends Reflector implements IReflector
19 | {
20 | }
21 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/robotlegs/base/ContextError.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.base
9 | {
10 |
11 | /**
12 | * A framework Error implementation
13 | */
14 | public class ContextError extends Error
15 | {
16 | public static const E_COMMANDMAP_NOIMPL:String = 'Command Class does not implement an execute() method';
17 | public static const E_COMMANDMAP_OVR:String = 'Cannot overwrite map';
18 |
19 | public static const E_MEDIATORMAP_NOIMPL:String = 'Mediator Class does not implement IMediator';
20 | public static const E_MEDIATORMAP_OVR:String = 'Mediator Class has already been mapped to a View Class in this context';
21 |
22 | public static const E_EVENTMAP_NOSNOOPING:String = 'Listening to the context eventDispatcher is not enabled for this EventMap';
23 |
24 | public function ContextError(message:String = "", id:int = 0)
25 | {
26 | super(message, id);
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/robotlegs/base/ContextEvent.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.base
9 | {
10 | import flash.events.Event;
11 |
12 | /**
13 | * A framework Event implementation
14 | */
15 | public class ContextEvent extends Event
16 | {
17 | public static const STARTUP:String = 'startup';
18 | public static const STARTUP_COMPLETE:String = 'startupComplete';
19 |
20 | public static const SHUTDOWN:String = 'shutdown';
21 | public static const SHUTDOWN_COMPLETE:String = 'shutdownComplete';
22 |
23 | protected var _body:*;
24 |
25 | /**
26 | * A generic context Event
implementation
27 | *
28 | * This class is handy for prototype work, but it's usage is not considered Best Practice
29 | * 30 | * @param type TheEvent
type
31 | * @param body A loosely typed payload
32 | */
33 | public function ContextEvent(type:String, body:* = null)
34 | {
35 | super(type);
36 | _body = body;
37 | }
38 |
39 | /**
40 | * Loosely typed Event
payload
41 | * @return Payload
42 | */
43 | public function get body():*
44 | {
45 | return _body;
46 | }
47 |
48 | override public function clone():Event
49 | {
50 | return new ContextEvent(type, body);
51 | }
52 |
53 | }
54 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/robotlegs/core/ICommandMap.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.core
9 | {
10 |
11 | /**
12 | * The Robotlegs CommandMap contract
13 | */
14 | public interface ICommandMap
15 | {
16 | /**
17 | * Map a Class to an Event type
18 | *
19 | * The commandClass
must implement an execute() method
flash.events.Event
. Your commandClass can optionally [Inject] a variable of this type to access the event that triggered the command.
24 | * @param oneshot Unmap the Class after execution?
25 | */
26 | function mapEvent(eventType:String, commandClass:Class, eventClass:Class = null, oneshot:Boolean = false):void;
27 |
28 | /**
29 | * Unmap a Class to Event type mapping
30 | *
31 | * @param eventType The Event type
32 | * @param commandClass The Class to unmap
33 | * @param eventClass Optional Event class for a stronger mapping. Defaults to flash.events.Event
.
34 | */
35 | function unmapEvent(eventType:String, commandClass:Class, eventClass:Class = null):void;
36 |
37 | /**
38 | * Check if a Class has been mapped to an Event type
39 | *
40 | * @param eventType The Event type
41 | * @param commandClass The Class
42 | * @param eventClass Optional Event class for a stronger mapping. Defaults to flash.events.Event
.
43 | * @return Whether the Class is mapped to this Event type
44 | */
45 | function hasEventCommand(eventType:String, commandClass:Class, eventClass:Class = null):Boolean;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/robotlegs/core/IContext.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.core
9 | {
10 | import flash.events.IEventDispatcher;
11 |
12 | /**
13 | * The Robotlegs Context contract
14 | */
15 | public interface IContext
16 | {
17 | /**
18 | * The IContext
's IEventDispatcher
19 | */
20 | function get eventDispatcher():IEventDispatcher;
21 |
22 | }
23 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/robotlegs/core/IContextProvider.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.core
9 | {
10 |
11 | /**
12 | * The Robotlegs Context Provider contract
13 | */
14 | public interface IContextProvider
15 | {
16 | /**
17 | * Retrieve the IContext
18 | * @return The IContext
19 | */
20 | function getContext():IContext;
21 | }
22 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/robotlegs/core/IEventMap.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.core
9 | {
10 | import flash.events.IEventDispatcher;
11 |
12 | /**
13 | * The Robotlegs EventMap contract
14 | */
15 | public interface IEventMap
16 | {
17 | /**
18 | * The same as calling addEventListener
directly on the IEventDispatcher
,
19 | * but keeps a list of listeners for easy (usually automatic) removal.
20 | *
21 | * @param dispatcher The IEventDispatcher
to listen to
22 | * @param type The Event
type to listen for
23 | * @param listener The Event
handler
24 | * @param eventClass Optional Event class for a stronger mapping. Defaults to flash.events.Event
.
25 | * @param useCapture
26 | * @param priority
27 | * @param useWeakReference
28 | */
29 | function mapListener(dispatcher:IEventDispatcher, type:String, listener:Function, eventClass:Class = null, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = true):void;
30 |
31 | /**
32 | * The same as calling removeEventListener
directly on the IEventDispatcher
,
33 | * but updates our local list of listeners.
34 | *
35 | * @param dispatcher The IEventDispatcher
36 | * @param type The Event
type
37 | * @param listener The Event
handler
38 | * @param eventClass Optional Event class for a stronger mapping. Defaults to flash.events.Event
.
39 | * @param useCapture
40 | */
41 | function unmapListener(dispatcher:IEventDispatcher, type:String, listener:Function, eventClass:Class = null, useCapture:Boolean = false):void;
42 |
43 | /**
44 | * Removes all listeners registered through mapListener
45 | */
46 | function unmapListeners():void;
47 | }
48 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/robotlegs/core/IMediator.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.core
9 | {
10 |
11 | /**
12 | * The Robotlegs Mediator contract
13 | */
14 | public interface IMediator
15 | {
16 | /**
17 | * Should be invoked by the IMediatorMap
during IMediator
registration
18 | */
19 | function preRegister():void;
20 |
21 | /**
22 | * Should be invoked by the IMediator
itself when it is ready to be interacted with
23 | *
24 | * Override and place your initialization code here
25 | */ 26 | function onRegister():void; 27 | 28 | /** 29 | * Invoked when theIMediator
has been removed by the IMediatorMap
30 | */
31 | function preRemove():void;
32 |
33 | /**
34 | * Should be invoked by the IMediator
itself when it is ready to for cleanup
35 | *
36 | * Override and place your cleanup code here
37 | */ 38 | function onRemove():void; 39 | 40 | /** 41 | * TheIMediator
's view component
42 | *
43 | * @return The view component
44 | */
45 | function getViewComponent():Object;
46 |
47 | /**
48 | * The IMediator
's view component
49 | *
50 | * @param The view component
51 | */
52 | function setViewComponent(viewComponent:Object):void;
53 |
54 | }
55 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/robotlegs/core/IReflector.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.core
9 | {
10 | import flash.system.ApplicationDomain;
11 |
12 | /**
13 | * The Robotlegs Reflector contract
14 | */
15 | public interface IReflector
16 | {
17 |
18 | /**
19 | * Does this class or class name implement this superclass or interface?
20 | *
21 | * @param classOrClassName
22 | * @param superclass
23 | * @param applicationDomain
24 | * @return Boolean
25 | */
26 | function classExtendsOrImplements(classOrClassName:Object, superclass:Class, applicationDomain:ApplicationDomain = null):Boolean;
27 |
28 | /**
29 | * Get the class of this instance
30 | *
31 | * @param value The instance
32 | * @param applicationDomain
33 | * @return Class
34 | */
35 | function getClass(value:*, applicationDomain:ApplicationDomain = null):Class
36 |
37 | /**
38 | * Get the Fully Qualified Class Name of this instance, class name, or class
39 | *
40 | * @param value The instance, class name, or class
41 | * @param replaceColons
42 | * @return The Fully Qualified Class Name
43 | */
44 | function getFQCN(value:*, replaceColons:Boolean = false):String;
45 |
46 | }
47 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/robotlegs/core/IViewMap.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.core
9 | {
10 | import flash.display.DisplayObjectContainer;
11 |
12 | /**
13 | * The Robotlegs ViewMap contract. All IViewMap automatic injections occur AFTER the view components are added to the stage.
14 | */
15 | public interface IViewMap
16 | {
17 | /**
18 | * Map an entire package (including sub-packages) for automatic injection
19 | *
20 | * @param packageName The substring to compare
21 | */
22 | function mapPackage(packageName:String):void;
23 |
24 | /**
25 | * Unmap a package
26 | *
27 | * @param packageName The substring to compare
28 | */
29 | function unmapPackage(packageName:String):void;
30 |
31 | /**
32 | * Check if a package has been registered for automatic injection
33 | *
34 | * @param packageName The substring to compare
35 | * @return Whether a package has been registered for automatic injection
36 | */
37 | function hasPackage(packageName:String):Boolean;
38 |
39 | /**
40 | * Map a view component class or interface for automatic injection
41 | *
42 | * @param type The concrete view Interface
43 | */
44 | function mapType(type:Class):void;
45 |
46 | /**
47 | * Unmap a view component class or interface
48 | *
49 | * @param type The concrete view Interface
50 | */
51 | function unmapType(type:Class):void;
52 |
53 | /**
54 | * Check if a class or interface has been registered for automatic injection
55 | *
56 | * @param type The concrete view interface
57 | * @return Whether an interface has been registered for automatic injection
58 | */
59 | function hasType(type:Class):Boolean;
60 |
61 | /**
62 | * The IViewMap
's DisplayObjectContainer
63 | *
64 | * @return view The DisplayObjectContainer
to use as scope for this IViewMap
65 | */
66 | function get contextView():DisplayObjectContainer;
67 |
68 | /**
69 | * The IViewMap
's DisplayObjectContainer
70 | *
71 | * @param value The DisplayObjectContainer
to use as scope for this IViewMap
72 | */
73 | function set contextView(value:DisplayObjectContainer):void;
74 |
75 | /**
76 | * The IViewMap
's enabled status
77 | *
78 | * @return Whether the IViewMap
is enabled
79 | */
80 | function get enabled():Boolean;
81 |
82 | /**
83 | * The IViewMap
's enabled status
84 | *
85 | * @param value Whether the IViewMap
should be enabled
86 | */
87 | function set enabled(value:Boolean):void;
88 |
89 | }
90 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/robotlegs/mvcs/Actor.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.mvcs
9 | {
10 | import flash.events.Event;
11 | import flash.events.IEventDispatcher;
12 |
13 | import org.robotlegs.base.EventMap;
14 | import org.robotlegs.core.IEventMap;
15 |
16 | /**
17 | * Abstract MVCS IActor
implementation
18 | *
19 | * As part of the MVCS implementation the Actor
provides core functionality to an applications
20 | * various working parts.
Some possible uses for the Actor
include, but are no means limited to:
Essentially any class where it might be advantagous to have basic dependency injection supplied is a candidate
32 | * for extending Actor
.
Event
to dispatch on the IContext
's IEventDispatcher
94 | */
95 | protected function dispatch(event:Event):Boolean
96 | {
97 | if(eventDispatcher.hasEventListener(event.type))
98 | return eventDispatcher.dispatchEvent(event);
99 | return false;
100 | }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/robotlegs/mvcs/Command.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.mvcs
9 | {
10 | import flash.display.DisplayObjectContainer;
11 | import flash.events.Event;
12 | import flash.events.IEventDispatcher;
13 |
14 | import org.robotlegs.core.ICommandMap;
15 | import org.robotlegs.core.IInjector;
16 | import org.robotlegs.core.IMediatorMap;
17 |
18 | /**
19 | * Abstract MVCS command implementation
20 | */
21 | public class Command
22 | {
23 | [Inject]
24 | public var contextView:DisplayObjectContainer;
25 |
26 | [Inject]
27 | public var commandMap:ICommandMap;
28 |
29 | [Inject]
30 | public var eventDispatcher:IEventDispatcher;
31 |
32 | [Inject]
33 | public var injector:IInjector;
34 |
35 | [Inject]
36 | public var mediatorMap:IMediatorMap;
37 |
38 | public function Command()
39 | {
40 | }
41 |
42 | /**
43 | * @inheritDoc
44 | */
45 | public function execute():void
46 | {
47 | }
48 |
49 | /**
50 | * Dispatch helper method
51 | *
52 | * @param event The Event
to dispatch on the IContext
's IEventDispatcher
53 | */
54 | protected function dispatch(event:Event):Boolean
55 | {
56 | if(eventDispatcher.hasEventListener(event.type))
57 | return eventDispatcher.dispatchEvent(event);
58 | return false;
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/robotlegs/mvcs/Mediator.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.mvcs
9 | {
10 | import flash.display.DisplayObjectContainer;
11 | import flash.events.Event;
12 | import flash.events.IEventDispatcher;
13 |
14 | import org.robotlegs.base.EventMap;
15 | import org.robotlegs.base.MediatorBase;
16 | import org.robotlegs.core.IEventMap;
17 | import org.robotlegs.core.IMediatorMap;
18 |
19 | /**
20 | * Abstract MVCS IMediator
implementation
21 | */
22 | public class Mediator extends MediatorBase
23 | {
24 | [Inject]
25 | public var contextView:DisplayObjectContainer;
26 |
27 | [Inject]
28 | public var mediatorMap:IMediatorMap;
29 |
30 | /**
31 | * @private
32 | */
33 | protected var _eventDispatcher:IEventDispatcher;
34 |
35 | /**
36 | * @private
37 | */
38 | protected var _eventMap:IEventMap;
39 |
40 | public function Mediator()
41 | {
42 | }
43 |
44 | /**
45 | * @inheritDoc
46 | */
47 | override public function preRemove():void
48 | {
49 | eventMap.unmapListeners();
50 | super.preRemove();
51 | }
52 |
53 | /**
54 | * @inheritDoc
55 | */
56 | public function get eventDispatcher():IEventDispatcher
57 | {
58 | return _eventDispatcher;
59 | }
60 |
61 | [Inject]
62 | /**
63 | * @private
64 | */
65 | public function set eventDispatcher(value:IEventDispatcher):void
66 | {
67 | _eventDispatcher = value;
68 | }
69 |
70 | /**
71 | * Local EventMap
72 | *
73 | * @return The EventMap for this Actor
74 | */
75 | protected function get eventMap():IEventMap
76 | {
77 | return _eventMap || (_eventMap = new EventMap(eventDispatcher));
78 | }
79 |
80 | /**
81 | * Dispatch helper method
82 | *
83 | * @param event The Event to dispatch on the IContext
's IEventDispatcher
84 | */
85 | protected function dispatch(event:Event):Boolean
86 | {
87 | if(eventDispatcher.hasEventListener(event.type))
88 | return eventDispatcher.dispatchEvent(event);
89 | return false;
90 | }
91 |
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/swiftsuspenders/InjectionConfig.as:
--------------------------------------------------------------------------------
1 | /*
* Copyright (c) 2009 the original author or authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.swiftsuspenders
{
import flash.utils.Dictionary;
import org.swiftsuspenders.injectionresults.IInjectionResult;
import org.swiftsuspenders.injectionresults.InjectClassResult;
import org.swiftsuspenders.injectionresults.InjectNullResult;
import org.swiftsuspenders.injectionresults.InjectSingletonResult;
import org.swiftsuspenders.injectionresults.InjectValueResult;
2 |
public class InjectionConfig
{
/*******************************************************************************************
* public properties *
*******************************************************************************************/
public var request : Class;
public var response : Object;
public var injectionType : int;
public var injectionName : String;
/*******************************************************************************************
* public methods *
*******************************************************************************************/
public function InjectionConfig(request : Class, response : Object,
injectionType : int, injectionName : String)
{
this.request = request;
this.response = response;
this.injectionType = injectionType;
this.injectionName = injectionName;
}
public function getResponse(injector : Injector, singletons : Dictionary) : Object
{
return createResultByInjectionType().getResponse(injector, singletons);
}
/*******************************************************************************************
* private methods *
*******************************************************************************************/
private function createResultByInjectionType() : IInjectionResult
{
switch (injectionType)
{
case InjectionType.CLASS:
{
return new InjectClassResult(this);
}
case InjectionType.VALUE:
{
return new InjectValueResult(this);
}
case InjectionType.SINGLETON:
{
return new InjectSingletonResult(this);
}
default:
{
break;
}
}
return new InjectNullResult();
}
}
}
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/swiftsuspenders/InjectionType.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | * THE SOFTWARE.
21 | */
22 |
23 | package org.swiftsuspenders
24 | {
25 | public class InjectionType
26 | {
27 | public static const VALUE : int = 0;
28 | public static const CLASS : int = 1;
29 | public static const SINGLETON : int = 2;
30 | }
31 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/swiftsuspenders/InjectorError.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | * THE SOFTWARE.
21 | */
22 |
23 | package org.swiftsuspenders
24 | {
25 | public class InjectorError extends Error
26 | {
27 | public function InjectorError(message:*="", id:*=0)
28 | {
29 | trace("InjectorError: " + message );
30 | super(message, id);
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/swiftsuspenders/Reflector.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.swiftsuspenders
9 | {
10 | import flash.system.ApplicationDomain;
11 | import flash.utils.describeType;
12 | import flash.utils.getDefinitionByName;
13 | import flash.utils.getQualifiedClassName;
14 |
15 | /**
16 | * @author tschneidereit
17 | */
18 | public class Reflector
19 | {
20 | /*******************************************************************************************
21 | * public methods *
22 | *******************************************************************************************/
23 | public function Reflector()
24 | {
25 | }
26 |
27 | public function classExtendsOrImplements(classOrClassName : Object,
28 | superclass : Class, application : ApplicationDomain = null) : Boolean
29 | {
30 | var actualClass : Class;
31 |
32 | if (classOrClassName is Class)
33 | {
34 | actualClass = Class(classOrClassName);
35 | }
36 | else if (classOrClassName is String)
37 | {
38 | try
39 | {
40 | actualClass = Class(getDefinitionByName(classOrClassName as String));
41 | }
42 | catch (e : Error)
43 | {
44 | throw new Error("The class name " + classOrClassName +
45 | " is not valid because of " + e + "\n" + e.getStackTrace());
46 | }
47 | }
48 |
49 | if (!actualClass)
50 | {
51 | throw new Error("The parameter classOrClassName must be a valid Class " +
52 | "instance or fully qualified class name.");
53 | }
54 |
55 | if (actualClass == superclass)
56 | return true;
57 |
58 | var factoryDescription : XML = describeType(actualClass).factory[0];
59 |
60 | return (factoryDescription.children().(
61 | name() == "implementsInterface" || name() == "extendsClass").(
62 | attribute("type") == getQualifiedClassName(superclass)).length() > 0);
63 | }
64 |
65 | public function getClass(
66 | value : *, applicationDomain : ApplicationDomain = null) : Class
67 | {
68 | if (value is Class)
69 | {
70 | return value;
71 | }
72 | return value.constructor;
73 | }
74 |
75 | public function getFQCN(value : *, replaceColons : Boolean = false) : String
76 | {
77 | var fqcn:String;
78 | if (value is String)
79 | {
80 | fqcn = value;
81 | // Add colons if missing and desired.
82 | if (!replaceColons && fqcn.indexOf('::') == -1)
83 | {
84 | var lastDotIndex:int = fqcn.lastIndexOf('.');
85 | if (lastDotIndex == -1) return fqcn;
86 | return fqcn.substring(0, lastDotIndex) + '::' + fqcn.substring(lastDotIndex + 1);
87 | }
88 | }
89 | else
90 | {
91 | fqcn = getQualifiedClassName(value);
92 | }
93 | return replaceColons ? fqcn.replace('::', '.') : fqcn;
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/swiftsuspenders/injectionpoints/InjectionPoint.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.swiftsuspenders.injectionpoints
9 | {
10 | import flash.utils.Dictionary;
11 | import org.swiftsuspenders.Injector;
12 |
13 | public class InjectionPoint
14 | {
15 | /*******************************************************************************************
16 | * public methods *
17 | *******************************************************************************************/
18 | public function InjectionPoint(node : XML, injectorMappings : Dictionary)
19 | {
20 | initializeInjection(node, injectorMappings);
21 | }
22 |
23 | public function applyInjection(target : Object, injector : Injector, singletons : Dictionary) : Object
24 | {
25 | return target;
26 | }
27 |
28 |
29 | /*******************************************************************************************
30 | * protected methods *
31 | *******************************************************************************************/
32 | protected function initializeInjection(node : XML, injectorMappings : Dictionary) : void
33 | {
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/swiftsuspenders/injectionpoints/NoParamsConstructorInjectionPoint.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.swiftsuspenders.injectionpoints
9 | {
10 | import flash.utils.Dictionary;
11 | import org.swiftsuspenders.Injector;
12 |
13 | public class NoParamsConstructorInjectionPoint extends InjectionPoint
14 | {
15 | public function NoParamsConstructorInjectionPoint()
16 | {
17 | super(null, null);
18 | }
19 |
20 | override public function applyInjection(target : Object, injector : Injector, singletons : Dictionary) : Object
21 | {
22 | return new target();
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/swiftsuspenders/injectionpoints/PostConstructInjectionPoint.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.swiftsuspenders.injectionpoints
9 | {
10 | import flash.utils.Dictionary;
11 |
12 | import org.swiftsuspenders.Injector;
13 |
14 | public class PostConstructInjectionPoint extends InjectionPoint
15 | {
16 | /*******************************************************************************************
17 | * private properties *
18 | *******************************************************************************************/
19 | protected var methodName : String;
20 | protected var orderValue:int;
21 |
22 |
23 | /*******************************************************************************************
24 | * public methods *
25 | *******************************************************************************************/
26 | public function PostConstructInjectionPoint(node:XML, injectorMappings:Dictionary)
27 | {
28 | super(node, injectorMappings);
29 | }
30 |
31 | public function get order():int
32 | {
33 | return orderValue;
34 | }
35 |
36 | override public function applyInjection(
37 | target : Object, injector : Injector, singletons : Dictionary) : Object
38 | {
39 | target[methodName]();
40 | return target;
41 | }
42 |
43 |
44 | /*******************************************************************************************
45 | * protected methods *
46 | *******************************************************************************************/
47 | override protected function initializeInjection(node : XML, injectorMappings : Dictionary) : void
48 | {
49 | var orderArg : XMLList = node.arg.(@key == 'order');
50 | var methodNode : XML = node.parent();
51 | orderValue = int(orderArg.@value)
52 | methodName = methodNode.@name.toString();
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/swiftsuspenders/injectionpoints/PropertyInjectionPoint.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.swiftsuspenders.injectionpoints
9 | {
10 | import flash.utils.Dictionary;
11 |
12 | import org.swiftsuspenders.InjectionConfig;
13 | import org.swiftsuspenders.Injector;
14 | import org.swiftsuspenders.InjectorError;
15 |
16 | public class PropertyInjectionPoint extends InjectionPoint
17 | {
18 | /*******************************************************************************************
19 | * private properties *
20 | *******************************************************************************************/
21 | private var mappings : Dictionary;
22 | private var propertyName : String;
23 | private var propertyType : String;
24 |
25 |
26 | /*******************************************************************************************
27 | * public methods *
28 | *******************************************************************************************/
29 | public function PropertyInjectionPoint(node : XML, injectorMappings : Dictionary)
30 | {
31 | super(node, injectorMappings);
32 | }
33 |
34 | override public function applyInjection(
35 | target : Object, injector : Injector, singletons : Dictionary) : Object
36 | {
37 | var config : InjectionConfig = mappings[propertyType];
38 | if (!config)
39 | {
40 | throw(
41 | new InjectorError(
42 | 'Injector is missing a rule to handle injection into target ' + target +
43 | '. Target dependency: ' + propertyType
44 | )
45 | );
46 | }
47 | var injection : Object = config.getResponse(injector, singletons);
48 | target[propertyName] = injection;
49 | return target;
50 | }
51 |
52 |
53 | /*******************************************************************************************
54 | * protected methods *
55 | *******************************************************************************************/
56 | override protected function initializeInjection(node : XML, injectorMappings : Dictionary) : void
57 | {
58 | var mappings : Dictionary;
59 | if (node.hasOwnProperty('arg') && node.arg.(@key == 'name').length)
60 | {
61 | var name : String = node.arg.@value.toString();
62 | mappings = injectorMappings[name];
63 | if (!mappings)
64 | {
65 | mappings = injectorMappings[name] = new Dictionary();
66 | }
67 | }
68 | else
69 | {
70 | mappings = injectorMappings;
71 | }
72 | this.mappings = mappings;
73 | propertyType = node.parent().@type.toString();
74 | propertyName = node.parent().@name.toString();
75 | }
76 | }
77 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/swiftsuspenders/injectionresults/IInjectionResult.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | * THE SOFTWARE.
21 | */
22 |
23 | package org.swiftsuspenders.injectionresults
24 | {
25 | import flash.utils.Dictionary;
26 |
27 | import org.swiftsuspenders.Injector;
28 |
29 | public interface IInjectionResult
30 | {
31 | function getResponse(injector : Injector, singletons : Dictionary) : Object;
32 | }
33 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/swiftsuspenders/injectionresults/InjectClassResult.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | * THE SOFTWARE.
21 | */
22 |
23 | package org.swiftsuspenders.injectionresults
24 | {
25 | import flash.utils.Dictionary;
26 |
27 | import org.swiftsuspenders.InjectionConfig;
28 | import org.swiftsuspenders.Injector;
29 |
30 | public class InjectClassResult implements IInjectionResult
31 | {
32 | /*******************************************************************************************
33 | * private properties *
34 | *******************************************************************************************/
35 | private var config:InjectionConfig;
36 |
37 |
38 | /*******************************************************************************************
39 | * public methods *
40 | *******************************************************************************************/
41 | public function InjectClassResult(config:InjectionConfig)
42 | {
43 | this.config = config;
44 | }
45 |
46 | public function getResponse(injector:Injector, singletons:Dictionary):Object
47 | {
48 | return injector.instantiate(Class(config.response));
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/swiftsuspenders/injectionresults/InjectNullResult.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | * THE SOFTWARE.
21 | */
22 |
23 | package org.swiftsuspenders.injectionresults
24 | {
25 | import flash.utils.Dictionary;
26 |
27 | import org.swiftsuspenders.Injector;
28 |
29 | public class InjectNullResult implements IInjectionResult
30 | {
31 | public function getResponse(injector : Injector, singletons : Dictionary) : Object
32 | {
33 | return {};
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/swiftsuspenders/injectionresults/InjectSingletonResult.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | * THE SOFTWARE.
21 | */
22 |
23 | package org.swiftsuspenders.injectionresults
24 | {
25 | import flash.utils.Dictionary;
26 |
27 | import org.swiftsuspenders.InjectionConfig;
28 | import org.swiftsuspenders.Injector;
29 |
30 | public class InjectSingletonResult implements IInjectionResult
31 | {
32 | /*******************************************************************************************
33 | * private properties *
34 | *******************************************************************************************/
35 | private var config:InjectionConfig;
36 | private var singletons:Dictionary;
37 |
38 |
39 | /*******************************************************************************************
40 | * public methods *
41 | *******************************************************************************************/
42 | public function InjectSingletonResult(config:InjectionConfig)
43 | {
44 | this.config = config;
45 | }
46 |
47 | public function getResponse(injector : Injector, singletons : Dictionary) : Object
48 | {
49 | var usedSingletonsMap : Dictionary = singletons;
50 | var result:Object;
51 | this.singletons = singletons;
52 | if (config.injectionName)
53 | {
54 | usedSingletonsMap = updateSingletonsMap();
55 | }
56 | result = usedSingletonsMap[config.request];
57 | if (!result)
58 | {
59 | result = usedSingletonsMap[config.request] = injector.instantiate(Class(config.response));
60 | }
61 | return result;
62 | }
63 |
64 |
65 | /*******************************************************************************************
66 | * private methods *
67 | *******************************************************************************************/
68 | private function updateSingletonsMap():Dictionary
69 | {
70 | var usedSingletonsMap:Dictionary = singletons[config.injectionName];
71 | if (!usedSingletonsMap)
72 | {
73 | usedSingletonsMap = singletons[config.injectionName] = new Dictionary();
74 | }
75 | return usedSingletonsMap;
76 | }
77 | }
78 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_0/org/swiftsuspenders/injectionresults/InjectValueResult.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | * THE SOFTWARE.
21 | */
22 |
23 | package org.swiftsuspenders.injectionresults
24 | {
25 | import flash.utils.Dictionary;
26 |
27 | import org.swiftsuspenders.InjectionConfig;
28 | import org.swiftsuspenders.Injector;
29 |
30 | public class InjectValueResult implements IInjectionResult
31 | {
32 | /*******************************************************************************************
33 | * private properties *
34 | *******************************************************************************************/
35 | private var config:InjectionConfig;
36 |
37 |
38 | /*******************************************************************************************
39 | * public methods *
40 | *******************************************************************************************/
41 | public function InjectValueResult(config:InjectionConfig)
42 | {
43 | this.config = config;
44 | }
45 |
46 | public function getResponse(injector:Injector, singletons:Dictionary):Object
47 | {
48 | injector.injectInto(config.response);
49 | return config.response;
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/robotlegs/adapters/SwiftSuspendersInjector.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.adapters
9 | {
10 | import flash.system.ApplicationDomain;
11 |
12 | import org.robotlegs.core.IInjector;
13 | import org.swiftsuspenders.Injector;
14 |
15 | /**
16 | * SwiftSuspender IInjector
adpater - See: SwiftSuspenders
17 | *
18 | * @author tschneidereit
19 | */
20 | public class SwiftSuspendersInjector extends Injector implements IInjector
21 | {
22 | protected static const XML_CONFIG:XML =
23 | IReflector
adpater - See: SwiftSuspenders
15 | *
16 | * @author tschneidereit
17 | */
18 | public class SwiftSuspendersReflector extends Reflector implements IReflector
19 | {
20 | }
21 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/robotlegs/base/ContextBase.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.base
9 | {
10 | import flash.events.Event;
11 | import flash.events.EventDispatcher;
12 | import flash.events.IEventDispatcher;
13 |
14 | import org.robotlegs.core.IContext;
15 |
16 | /**
17 | * An abstract IContext
implementation
18 | */
19 | public class ContextBase implements IContext, IEventDispatcher
20 | {
21 | /**
22 | * @private
23 | */
24 | protected var _eventDispatcher:IEventDispatcher;
25 |
26 | //---------------------------------------------------------------------
27 | // Constructor
28 | //---------------------------------------------------------------------
29 |
30 | /**
31 | * Abstract Context Implementation
32 | *
33 | * Extend this class to create a Framework or Application context
34 | */ 35 | public function ContextBase() 36 | { 37 | _eventDispatcher = new EventDispatcher(this); 38 | } 39 | 40 | //--------------------------------------------------------------------- 41 | // API 42 | //--------------------------------------------------------------------- 43 | 44 | /** 45 | * @inheritDoc 46 | */ 47 | public function get eventDispatcher():IEventDispatcher 48 | { 49 | return _eventDispatcher; 50 | } 51 | 52 | //--------------------------------------------------------------------- 53 | // EventDispatcher Boilerplate 54 | //--------------------------------------------------------------------- 55 | 56 | /** 57 | * @private 58 | */ 59 | public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void 60 | { 61 | eventDispatcher.addEventListener(type, listener, useCapture, priority); 62 | } 63 | 64 | /** 65 | * @private 66 | */ 67 | public function dispatchEvent(event:Event):Boolean 68 | { 69 | if(eventDispatcher.hasEventListener(event.type)) 70 | return eventDispatcher.dispatchEvent(event); 71 | return false; 72 | } 73 | 74 | /** 75 | * @private 76 | */ 77 | public function hasEventListener(type:String):Boolean 78 | { 79 | return eventDispatcher.hasEventListener(type); 80 | } 81 | 82 | /** 83 | * @private 84 | */ 85 | public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void 86 | { 87 | eventDispatcher.removeEventListener(type, listener, useCapture); 88 | } 89 | 90 | /** 91 | * @private 92 | */ 93 | public function willTrigger(type:String):Boolean 94 | { 95 | return eventDispatcher.willTrigger(type); 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /lib/robotlegs_v1_4/org/robotlegs/base/ContextError.as: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009 the original author or authors 3 | * 4 | * Permission is hereby granted to use, modify, and distribute this file 5 | * in accordance with the terms of the license agreement accompanying it. 6 | */ 7 | 8 | package org.robotlegs.base 9 | { 10 | 11 | /** 12 | * A framework Error implementation 13 | */ 14 | public class ContextError extends Error 15 | { 16 | public static const E_COMMANDMAP_NOIMPL:String = 'Command Class does not implement an execute() method'; 17 | public static const E_COMMANDMAP_OVR:String = 'Cannot overwrite map'; 18 | 19 | public static const E_MEDIATORMAP_NOIMPL:String = 'Mediator Class does not implement IMediator'; 20 | public static const E_MEDIATORMAP_OVR:String = 'Mediator Class has already been mapped to a View Class in this context'; 21 | 22 | public static const E_EVENTMAP_NOSNOOPING:String = 'Listening to the context eventDispatcher is not enabled for this EventMap'; 23 | 24 | public static const E_CONTEXT_INJECTOR:String = 'The ContextBase does not specify a concrete IInjector. Please override the injector getter in your concrete or abstract Context.'; 25 | public static const E_CONTEXT_REFLECTOR:String = 'The ContextBase does not specify a concrete IReflector. Please override the reflector getter in your concrete or abstract Context.'; 26 | 27 | public function ContextError(message:String = "", id:int = 0) 28 | { 29 | super(message, id); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /lib/robotlegs_v1_4/org/robotlegs/base/ContextEvent.as: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009 the original author or authors 3 | * 4 | * Permission is hereby granted to use, modify, and distribute this file 5 | * in accordance with the terms of the license agreement accompanying it. 6 | */ 7 | 8 | package org.robotlegs.base 9 | { 10 | import flash.events.Event; 11 | 12 | /** 13 | * A framework Event implementation 14 | */ 15 | public class ContextEvent extends Event 16 | { 17 | public static const STARTUP:String = 'startup'; 18 | public static const STARTUP_COMPLETE:String = 'startupComplete'; 19 | 20 | public static const SHUTDOWN:String = 'shutdown'; 21 | public static const SHUTDOWN_COMPLETE:String = 'shutdownComplete'; 22 | 23 | protected var _body:*; 24 | 25 | /** 26 | * A generic contextEvent
implementation
27 | *
28 | * This class is handy for prototype work, but it's usage is not considered Best Practice
29 | * 30 | * @param type TheEvent
type
31 | * @param body A loosely typed payload
32 | */
33 | public function ContextEvent(type:String, body:* = null)
34 | {
35 | super(type);
36 | _body = body;
37 | }
38 |
39 | /**
40 | * Loosely typed Event
payload
41 | * @return Payload
42 | */
43 | public function get body():*
44 | {
45 | return _body;
46 | }
47 |
48 | override public function clone():Event
49 | {
50 | return new ContextEvent(type, body);
51 | }
52 |
53 | }
54 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/robotlegs/base/ViewMapBase.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009, 2010 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.base
9 | {
10 | import flash.display.DisplayObjectContainer;
11 | import flash.events.Event;
12 |
13 | import org.robotlegs.core.IInjector;
14 |
15 | /**
16 | * A base ViewMap implementation
17 | */
18 | public class ViewMapBase
19 | {
20 | /**
21 | * @private
22 | */
23 | protected var _enabled:Boolean = true;
24 |
25 | /**
26 | * @private
27 | */
28 | protected var _contextView:DisplayObjectContainer;
29 |
30 | /**
31 | * @private
32 | */
33 | protected var injector:IInjector;
34 |
35 | /**
36 | * @private
37 | */
38 | protected var useCapture:Boolean;
39 |
40 | /**
41 | * @private
42 | */
43 | protected var viewListenerCount:uint;
44 |
45 | //---------------------------------------------------------------------
46 | // Constructor
47 | //---------------------------------------------------------------------
48 |
49 | /**
50 | * Creates a new ViewMap
object
51 | *
52 | * @param contextView The root view node of the context. The map will listen for ADDED_TO_STAGE events on this node
53 | * @param injector An IInjector
to use for this context
54 | */
55 | public function ViewMapBase(contextView:DisplayObjectContainer, injector:IInjector)
56 | {
57 | this.injector = injector;
58 |
59 | // change this at your peril lest ye understand the problem and have a better solution
60 | this.useCapture = true;
61 |
62 | // this must come last, see the setter
63 | this.contextView = contextView;
64 | }
65 |
66 | //---------------------------------------------------------------------
67 | // API
68 | //---------------------------------------------------------------------
69 | /**
70 | * @inheritDoc
71 | */
72 | public function get contextView():DisplayObjectContainer
73 | {
74 | return _contextView;
75 | }
76 |
77 | /**
78 | * @inheritDoc
79 | */
80 | public function set contextView(value:DisplayObjectContainer):void
81 | {
82 | if (value != _contextView)
83 | {
84 | removeListeners();
85 | _contextView = value;
86 | if (viewListenerCount > 0)
87 | addListeners();
88 | }
89 | }
90 |
91 | /**
92 | * @inheritDoc
93 | */
94 | public function get enabled():Boolean
95 | {
96 | return _enabled;
97 | }
98 |
99 | /**
100 | * @inheritDoc
101 | */
102 | public function set enabled(value:Boolean):void
103 | {
104 | if (value != _enabled)
105 | {
106 | removeListeners();
107 | _enabled = value;
108 | if (viewListenerCount > 0)
109 | addListeners();
110 | }
111 | }
112 |
113 | //---------------------------------------------------------------------
114 | // Internal
115 | //---------------------------------------------------------------------
116 |
117 | /**
118 | * @private
119 | */
120 | protected function addListeners():void
121 | {
122 | }
123 |
124 | /**
125 | * @private
126 | */
127 | protected function removeListeners():void
128 | {
129 | }
130 |
131 | /**
132 | * @private
133 | */
134 | protected function onViewAdded(e:Event):void
135 | {
136 | }
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/robotlegs/core/ICommandMap.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.core
9 | {
10 |
11 | /**
12 | * The Robotlegs CommandMap contract
13 | */
14 | public interface ICommandMap
15 | {
16 | /**
17 | * Detain a Command instance
18 | *
19 | * @param command The Command instance to detain
20 | */
21 | function detain(command:Object):void;
22 |
23 | /**
24 | * Release a Command instance
25 | *
26 | * @param command The Command instance to release for garbage collection
27 | */
28 | function release(command:Object):void;
29 |
30 | /**
31 | * Execute a Command with an optional payload
32 | *
33 | * The commandClass
must implement an execute() method
The commandClass
must implement an execute() method
flash.events.Event
. Your commandClass can optionally [Inject] a variable of this type to access the event that triggered the command.
52 | * @param oneshot Unmap the Class after execution?
53 | *
54 | * @throws org.robotlegs.base::ContextError
55 | */
56 | function mapEvent(eventType:String, commandClass:Class, eventClass:Class = null, oneshot:Boolean = false):void;
57 |
58 | /**
59 | * Unmap a Class to Event type mapping
60 | *
61 | * @param eventType The Event type
62 | * @param commandClass The Class to unmap
63 | * @param eventClass Optional Event class for a stronger mapping. Defaults to flash.events.Event
.
64 | */
65 | function unmapEvent(eventType:String, commandClass:Class, eventClass:Class = null):void;
66 |
67 | /**
68 | * Removes all mappings made through mapEvent
69 | */
70 | function unmapEvents():void;
71 |
72 | /**
73 | * Check if a Class has been mapped to an Event type
74 | *
75 | * @param eventType The Event type
76 | * @param commandClass The Class
77 | * @param eventClass Optional Event class for a stronger mapping. Defaults to flash.events.Event
.
78 | * @return Whether the Class is mapped to this Event type
79 | */
80 | function hasEventCommand(eventType:String, commandClass:Class, eventClass:Class = null):Boolean;
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/robotlegs/core/IContext.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.core
9 | {
10 | import flash.events.IEventDispatcher;
11 |
12 | /**
13 | * The Robotlegs Context contract
14 | */
15 | public interface IContext
16 | {
17 | /**
18 | * The IContext
's IEventDispatcher
19 | */
20 | function get eventDispatcher():IEventDispatcher;
21 |
22 | }
23 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/robotlegs/core/IContextProvider.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.core
9 | {
10 | [Deprecated("This interface is fluffy and must be destroyed. Roll Your Own.")]
11 | /**
12 | * Deprecated - The Robotlegs Context Provider contract
13 | */
14 | public interface IContextProvider
15 | {
16 | [Deprecated("This interface is fluffy and must be destroyed. Roll Your Own.")]
17 | /**
18 | * Deprecated - Retrieve the IContext
19 | * @return The IContext
20 | */
21 | function getContext():IContext;
22 | }
23 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/robotlegs/core/IEventMap.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.core
9 | {
10 | import flash.events.IEventDispatcher;
11 |
12 | /**
13 | * The Robotlegs EventMap contract
14 | */
15 | public interface IEventMap
16 | {
17 | /**
18 | * The same as calling addEventListener
directly on the IEventDispatcher
,
19 | * but keeps a list of listeners for easy (usually automatic) removal.
20 | *
21 | * @param dispatcher The IEventDispatcher
to listen to
22 | * @param type The Event
type to listen for
23 | * @param listener The Event
handler
24 | * @param eventClass Optional Event class for a stronger mapping. Defaults to flash.events.Event
.
25 | * @param useCapture
26 | * @param priority
27 | * @param useWeakReference
28 | */
29 | function mapListener(dispatcher:IEventDispatcher, type:String, listener:Function, eventClass:Class = null, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = true):void;
30 |
31 | /**
32 | * The same as calling removeEventListener
directly on the IEventDispatcher
,
33 | * but updates our local list of listeners.
34 | *
35 | * @param dispatcher The IEventDispatcher
36 | * @param type The Event
type
37 | * @param listener The Event
handler
38 | * @param eventClass Optional Event class for a stronger mapping. Defaults to flash.events.Event
.
39 | * @param useCapture
40 | */
41 | function unmapListener(dispatcher:IEventDispatcher, type:String, listener:Function, eventClass:Class = null, useCapture:Boolean = false):void;
42 |
43 | /**
44 | * Removes all listeners registered through mapListener
45 | */
46 | function unmapListeners():void;
47 | }
48 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/robotlegs/core/IMediator.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.core
9 | {
10 |
11 | /**
12 | * The Robotlegs Mediator contract
13 | */
14 | public interface IMediator
15 | {
16 | /**
17 | * Should be invoked by the IMediatorMap
during IMediator
registration
18 | */
19 | function preRegister():void;
20 |
21 | /**
22 | * Should be invoked by the IMediator
itself when it is ready to be interacted with
23 | *
24 | * Override and place your initialization code here
25 | */ 26 | function onRegister():void; 27 | 28 | /** 29 | * Invoked when theIMediator
has been removed by the IMediatorMap
30 | */
31 | function preRemove():void;
32 |
33 | /**
34 | * Should be invoked by the IMediator
itself when it is ready to for cleanup
35 | *
36 | * Override and place your cleanup code here
37 | */ 38 | function onRemove():void; 39 | 40 | /** 41 | * TheIMediator
's view component
42 | *
43 | * @return The view component
44 | */
45 | function getViewComponent():Object;
46 |
47 | /**
48 | * The IMediator
's view component
49 | *
50 | * @param The view component
51 | */
52 | function setViewComponent(viewComponent:Object):void;
53 |
54 | }
55 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/robotlegs/core/IReflector.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.core
9 | {
10 | import flash.system.ApplicationDomain;
11 |
12 | /**
13 | * The Robotlegs Reflector contract
14 | */
15 | public interface IReflector
16 | {
17 |
18 | /**
19 | * Does this class or class name implement this superclass or interface?
20 | *
21 | * @param classOrClassName
22 | * @param superclass
23 | * @param applicationDomain
24 | * @return Boolean
25 | */
26 | function classExtendsOrImplements(classOrClassName:Object, superclass:Class, applicationDomain:ApplicationDomain = null):Boolean;
27 |
28 | /**
29 | * Get the class of this instance
30 | *
31 | * @param value The instance
32 | * @param applicationDomain
33 | * @return Class
34 | */
35 | function getClass(value:*, applicationDomain:ApplicationDomain = null):Class
36 |
37 | /**
38 | * Get the Fully Qualified Class Name of this instance, class name, or class
39 | *
40 | * @param value The instance, class name, or class
41 | * @param replaceColons
42 | * @return The Fully Qualified Class Name
43 | */
44 | function getFQCN(value:*, replaceColons:Boolean = false):String;
45 |
46 | }
47 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/robotlegs/core/IViewMap.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.core
9 | {
10 | import flash.display.DisplayObjectContainer;
11 |
12 | /**
13 | * The Robotlegs ViewMap contract. All IViewMap automatic injections occur AFTER the view components are added to the stage.
14 | */
15 | public interface IViewMap
16 | {
17 | /**
18 | * Map an entire package (including sub-packages) for automatic injection
19 | *
20 | * @param packageName The substring to compare
21 | */
22 | function mapPackage(packageName:String):void;
23 |
24 | /**
25 | * Unmap a package
26 | *
27 | * @param packageName The substring to compare
28 | */
29 | function unmapPackage(packageName:String):void;
30 |
31 | /**
32 | * Check if a package has been registered for automatic injection
33 | *
34 | * @param packageName The substring to compare
35 | * @return Whether a package has been registered for automatic injection
36 | */
37 | function hasPackage(packageName:String):Boolean;
38 |
39 | /**
40 | * Map a view component class or interface for automatic injection
41 | *
42 | * @param type The concrete view Interface
43 | */
44 | function mapType(type:Class):void;
45 |
46 | /**
47 | * Unmap a view component class or interface
48 | *
49 | * @param type The concrete view Interface
50 | */
51 | function unmapType(type:Class):void;
52 |
53 | /**
54 | * Check if a class or interface has been registered for automatic injection
55 | *
56 | * @param type The concrete view interface
57 | * @return Whether an interface has been registered for automatic injection
58 | */
59 | function hasType(type:Class):Boolean;
60 |
61 | /**
62 | * The IViewMap
's DisplayObjectContainer
63 | *
64 | * @return view The DisplayObjectContainer
to use as scope for this IViewMap
65 | */
66 | function get contextView():DisplayObjectContainer;
67 |
68 | /**
69 | * The IViewMap
's DisplayObjectContainer
70 | *
71 | * @param value The DisplayObjectContainer
to use as scope for this IViewMap
72 | */
73 | function set contextView(value:DisplayObjectContainer):void;
74 |
75 | /**
76 | * The IViewMap
's enabled status
77 | *
78 | * @return Whether the IViewMap
is enabled
79 | */
80 | function get enabled():Boolean;
81 |
82 | /**
83 | * The IViewMap
's enabled status
84 | *
85 | * @param value Whether the IViewMap
should be enabled
86 | */
87 | function set enabled(value:Boolean):void;
88 |
89 | }
90 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/robotlegs/mvcs/Actor.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.mvcs
9 | {
10 | import flash.events.Event;
11 | import flash.events.IEventDispatcher;
12 |
13 | import org.robotlegs.base.EventMap;
14 | import org.robotlegs.core.IEventMap;
15 |
16 | /**
17 | * Abstract MVCS IActor
implementation
18 | *
19 | * As part of the MVCS implementation the Actor
provides core functionality to an applications
20 | * various working parts.
Some possible uses for the Actor
include, but are no means limited to:
Essentially any class where it might be advantagous to have basic dependency injection supplied is a candidate
32 | * for extending Actor
.
Event
to dispatch on the IContext
's IEventDispatcher
94 | */
95 | protected function dispatch(event:Event):Boolean
96 | {
97 | if(eventDispatcher.hasEventListener(event.type))
98 | return eventDispatcher.dispatchEvent(event);
99 | return false;
100 | }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/robotlegs/mvcs/Command.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.mvcs
9 | {
10 | import flash.display.DisplayObjectContainer;
11 | import flash.events.Event;
12 | import flash.events.IEventDispatcher;
13 |
14 | import org.robotlegs.core.ICommandMap;
15 | import org.robotlegs.core.IInjector;
16 | import org.robotlegs.core.IMediatorMap;
17 |
18 | /**
19 | * Abstract MVCS command implementation
20 | */
21 | public class Command
22 | {
23 | [Inject]
24 | public var contextView:DisplayObjectContainer;
25 |
26 | [Inject]
27 | public var commandMap:ICommandMap;
28 |
29 | [Inject]
30 | public var eventDispatcher:IEventDispatcher;
31 |
32 | [Inject]
33 | public var injector:IInjector;
34 |
35 | [Inject]
36 | public var mediatorMap:IMediatorMap;
37 |
38 | public function Command()
39 | {
40 | }
41 |
42 | /**
43 | * @inheritDoc
44 | */
45 | public function execute():void
46 | {
47 | }
48 |
49 | /**
50 | * Dispatch helper method
51 | *
52 | * @param event The Event
to dispatch on the IContext
's IEventDispatcher
53 | */
54 | protected function dispatch(event:Event):Boolean
55 | {
56 | if(eventDispatcher.hasEventListener(event.type))
57 | return eventDispatcher.dispatchEvent(event);
58 | return false;
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/robotlegs/mvcs/Mediator.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.robotlegs.mvcs
9 | {
10 | import flash.display.DisplayObjectContainer;
11 | import flash.events.Event;
12 | import flash.events.IEventDispatcher;
13 |
14 | import org.robotlegs.base.EventMap;
15 | import org.robotlegs.base.MediatorBase;
16 | import org.robotlegs.core.IEventMap;
17 | import org.robotlegs.core.IMediatorMap;
18 |
19 | /**
20 | * Abstract MVCS IMediator
implementation
21 | */
22 | public class Mediator extends MediatorBase
23 | {
24 | [Inject]
25 | public var contextView:DisplayObjectContainer;
26 |
27 | [Inject]
28 | public var mediatorMap:IMediatorMap;
29 |
30 | /**
31 | * @private
32 | */
33 | protected var _eventDispatcher:IEventDispatcher;
34 |
35 | /**
36 | * @private
37 | */
38 | protected var _eventMap:IEventMap;
39 |
40 | public function Mediator()
41 | {
42 | }
43 |
44 | /**
45 | * @inheritDoc
46 | */
47 | override public function preRemove():void
48 | {
49 | if (_eventMap)
50 | _eventMap.unmapListeners();
51 | super.preRemove();
52 | }
53 |
54 | /**
55 | * @inheritDoc
56 | */
57 | public function get eventDispatcher():IEventDispatcher
58 | {
59 | return _eventDispatcher;
60 | }
61 |
62 | [Inject]
63 | /**
64 | * @private
65 | */
66 | public function set eventDispatcher(value:IEventDispatcher):void
67 | {
68 | _eventDispatcher = value;
69 | }
70 |
71 | /**
72 | * Local EventMap
73 | *
74 | * @return The EventMap for this Actor
75 | */
76 | protected function get eventMap():IEventMap
77 | {
78 | return _eventMap || (_eventMap = new EventMap(eventDispatcher));
79 | }
80 |
81 | /**
82 | * Dispatch helper method
83 | *
84 | * @param event The Event to dispatch on the IContext
's IEventDispatcher
85 | */
86 | protected function dispatch(event:Event):Boolean
87 | {
88 | if(eventDispatcher.hasEventListener(event.type))
89 | return eventDispatcher.dispatchEvent(event);
90 | return false;
91 | }
92 |
93 | /**
94 | * Syntactical sugar for mapping a listener to the viewComponent
95 | *
96 | * @param type
97 | * @param listener
98 | * @param eventClass
99 | * @param useCapture
100 | * @param priority
101 | * @param useWeakReference
102 | *
103 | */
104 | protected function addViewListener(type:String, listener:Function, eventClass:Class = null, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = true):void
105 | {
106 | eventMap.mapListener(IEventDispatcher(viewComponent), type, listener,
107 | eventClass, useCapture, priority, useWeakReference);
108 | }
109 |
110 | /**
111 | * Syntactical sugar for mapping a listener to an IEventDispatcher
112 | *
113 | * @param dispatcher
114 | * @param type
115 | * @param listener
116 | * @param eventClass
117 | * @param useCapture
118 | * @param priority
119 | * @param useWeakReference
120 | *
121 | */
122 | protected function addContextListener(type:String, listener:Function, eventClass:Class = null, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = true):void
123 | {
124 | eventMap.mapListener(eventDispatcher, type, listener,
125 | eventClass, useCapture, priority, useWeakReference);
126 | }
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/swiftsuspenders/InjectionConfig.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.swiftsuspenders
9 | {
10 | import org.swiftsuspenders.injectionresults.InjectionResult;
11 |
12 | public class InjectionConfig
13 | {
14 | /*******************************************************************************************
15 | * public properties *
16 | *******************************************************************************************/
17 | public var request : Class;
18 | public var injectionName : String;
19 |
20 |
21 | /*******************************************************************************************
22 | * private properties *
23 | *******************************************************************************************/
24 | private var m_injector : Injector;
25 | private var m_result : InjectionResult;
26 |
27 |
28 | /*******************************************************************************************
29 | * public methods *
30 | *******************************************************************************************/
31 | public function InjectionConfig(request : Class, injectionName : String)
32 | {
33 | this.request = request;
34 | this.injectionName = injectionName;
35 | }
36 |
37 | public function getResponse(injector : Injector) : Object
38 | {
39 | if (m_result)
40 | {
41 | return m_result.getResponse(m_injector || injector);
42 | }
43 | var parentConfig : InjectionConfig =
44 | (m_injector || injector).getAncestorMapping(request, injectionName);
45 | if (parentConfig)
46 | {
47 | return parentConfig.getResponse(injector);
48 | }
49 | return null;
50 | }
51 |
52 | public function hasResponse(injector : Injector) : Boolean
53 | {
54 | if (m_result)
55 | {
56 | return true;
57 | }
58 | var parentConfig : InjectionConfig =
59 | (m_injector || injector).getAncestorMapping(request, injectionName);
60 | return parentConfig != null;
61 | }
62 |
63 | public function hasOwnResponse() : Boolean
64 | {
65 | return m_result != null;
66 | }
67 |
68 | public function setResult(result : InjectionResult) : void
69 | {
70 | m_result = result;
71 | }
72 |
73 | public function setInjector(injector : Injector) : void
74 | {
75 | m_injector = injector;
76 | }
77 | }
78 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/swiftsuspenders/InjectionType.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.swiftsuspenders
9 | {
10 | public class InjectionType
11 | {
12 | public static const VALUE : int = 0;
13 | public static const CLASS : int = 1;
14 | public static const SINGLETON : int = 2;
15 | }
16 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/swiftsuspenders/InjectorError.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.swiftsuspenders
9 | {
10 | public class InjectorError extends Error
11 | {
12 | public function InjectorError(message:*="", id:*=0)
13 | {
14 | super(message, id);
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/swiftsuspenders/Reflector.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.swiftsuspenders
9 | {
10 | import flash.system.ApplicationDomain;
11 | import flash.utils.describeType;
12 | import flash.utils.getDefinitionByName;
13 | import flash.utils.getQualifiedClassName;
14 |
15 | /**
16 | * @author tschneidereit
17 | */
18 | public class Reflector
19 | {
20 | /*******************************************************************************************
21 | * public methods *
22 | *******************************************************************************************/
23 | public function Reflector()
24 | {
25 | }
26 |
27 | public function classExtendsOrImplements(classOrClassName : Object,
28 | superclass : Class, application : ApplicationDomain = null) : Boolean
29 | {
30 | var actualClass : Class;
31 |
32 | if (classOrClassName is Class)
33 | {
34 | actualClass = Class(classOrClassName);
35 | }
36 | else if (classOrClassName is String)
37 | {
38 | try
39 | {
40 | actualClass = Class(getDefinitionByName(classOrClassName as String));
41 | }
42 | catch (e : Error)
43 | {
44 | throw new Error("The class name " + classOrClassName +
45 | " is not valid because of " + e + "\n" + e.getStackTrace());
46 | }
47 | }
48 |
49 | if (!actualClass)
50 | {
51 | throw new Error("The parameter classOrClassName must be a valid Class " +
52 | "instance or fully qualified class name.");
53 | }
54 |
55 | if (actualClass == superclass)
56 | return true;
57 |
58 | var factoryDescription : XML = describeType(actualClass).factory[0];
59 |
60 | return (factoryDescription.children().(
61 | name() == "implementsInterface" || name() == "extendsClass").(
62 | attribute("type") == getQualifiedClassName(superclass)).length() > 0);
63 | }
64 |
65 | public function getClass(value : *, applicationDomain : ApplicationDomain = null) : Class
66 | {
67 | if (value is Class)
68 | {
69 | return value;
70 | }
71 | return getConstructor(value);
72 | }
73 |
74 | public function getFQCN(value : *, replaceColons : Boolean = false) : String
75 | {
76 | var fqcn:String;
77 | if (value is String)
78 | {
79 | fqcn = value;
80 | // Add colons if missing and desired.
81 | if (!replaceColons && fqcn.indexOf('::') == -1)
82 | {
83 | var lastDotIndex:int = fqcn.lastIndexOf('.');
84 | if (lastDotIndex == -1) return fqcn;
85 | return fqcn.substring(0, lastDotIndex) + '::' + fqcn.substring(lastDotIndex + 1);
86 | }
87 | }
88 | else
89 | {
90 | fqcn = getQualifiedClassName(value);
91 | }
92 | return replaceColons ? fqcn.replace('::', '.') : fqcn;
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/swiftsuspenders/getConstructor.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.swiftsuspenders
9 | {
10 | import flash.utils.Proxy;
11 | import flash.utils.getDefinitionByName;
12 | import flash.utils.getQualifiedClassName;
13 |
14 | internal function getConstructor(value : Object) : Class
15 | {
16 | /*
17 | There are several types for which the 'constructor' property doesn't work:
18 | - instances of Proxy, XML and XMLList throw exceptions when trying to access 'constructor'
19 | - int and uint return Number as their constructor
20 | For these, we have to fall back to more verbose ways of getting the constructor.
21 |
22 | Additionally, Vector instances always return Vector.<*> when queried for their constructor.
23 | Ideally, that would also be resolved, but the SwiftSuspenders wouldn't be compatible with
24 | Flash Player < 10, anymore.
25 | */
26 | if (value is Proxy || value is Number || value is XML || value is XMLList)
27 | {
28 | var fqcn : String = getQualifiedClassName(value);
29 | return Class(getDefinitionByName(fqcn));
30 | }
31 | return value.constructor;
32 | }
33 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/swiftsuspenders/injectionpoints/InjectionPoint.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.swiftsuspenders.injectionpoints
9 | {
10 | import org.swiftsuspenders.Injector;
11 |
12 | public class InjectionPoint
13 | {
14 | /*******************************************************************************************
15 | * public methods *
16 | *******************************************************************************************/
17 | public function InjectionPoint(node : XML, injector : Injector)
18 | {
19 | initializeInjection(node, injector);
20 | }
21 |
22 | public function applyInjection(target : Object, injector : Injector) : Object
23 | {
24 | return target;
25 | }
26 |
27 |
28 | /*******************************************************************************************
29 | * protected methods *
30 | *******************************************************************************************/
31 | protected function initializeInjection(node : XML, injector : Injector) : void
32 | {
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/swiftsuspenders/injectionpoints/NoParamsConstructorInjectionPoint.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.swiftsuspenders.injectionpoints
9 | {
10 | import org.swiftsuspenders.Injector;
11 |
12 | public class NoParamsConstructorInjectionPoint extends InjectionPoint
13 | {
14 | public function NoParamsConstructorInjectionPoint()
15 | {
16 | super(null, null);
17 | }
18 |
19 | override public function applyInjection(target : Object, injector : Injector) : Object
20 | {
21 | return new target();
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/swiftsuspenders/injectionpoints/PostConstructInjectionPoint.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.swiftsuspenders.injectionpoints
9 | {
10 | import org.swiftsuspenders.Injector;
11 |
12 | public class PostConstructInjectionPoint extends InjectionPoint
13 | {
14 | /*******************************************************************************************
15 | * private properties *
16 | *******************************************************************************************/
17 | protected var methodName : String;
18 | protected var orderValue:int;
19 |
20 |
21 | /*******************************************************************************************
22 | * public methods *
23 | *******************************************************************************************/
24 | public function PostConstructInjectionPoint(node:XML, injector : Injector)
25 | {
26 | super(node, injector);
27 | }
28 |
29 | public function get order():int
30 | {
31 | return orderValue;
32 | }
33 |
34 | override public function applyInjection(target : Object, injector : Injector) : Object
35 | {
36 | target[methodName]();
37 | return target;
38 | }
39 |
40 |
41 | /*******************************************************************************************
42 | * protected methods *
43 | *******************************************************************************************/
44 | override protected function initializeInjection(node : XML, injector : Injector) : void
45 | {
46 | var orderArg : XMLList = node.arg.(@key == 'order');
47 | var methodNode : XML = node.parent();
48 | orderValue = int(orderArg.@value);
49 | methodName = methodNode.@name.toString();
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/swiftsuspenders/injectionpoints/PropertyInjectionPoint.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.swiftsuspenders.injectionpoints
9 | {
10 | import flash.utils.getDefinitionByName;
11 |
12 | import org.swiftsuspenders.InjectionConfig;
13 | import org.swiftsuspenders.Injector;
14 | import org.swiftsuspenders.InjectorError;
15 |
16 | public class PropertyInjectionPoint extends InjectionPoint
17 | {
18 | /*******************************************************************************************
19 | * private properties *
20 | *******************************************************************************************/
21 | private var propertyName : String;
22 | private var propertyType : String;
23 | private var m_injectionConfig : InjectionConfig;
24 |
25 |
26 | /*******************************************************************************************
27 | * public methods *
28 | *******************************************************************************************/
29 | public function PropertyInjectionPoint(node : XML, injector : Injector)
30 | {
31 | super(node, injector);
32 | }
33 |
34 | override public function applyInjection(target : Object, injector : Injector) : Object
35 | {
36 | var injection : Object = m_injectionConfig.getResponse(injector);
37 | if (injection == null)
38 | {
39 | throw(
40 | new InjectorError(
41 | 'Injector is missing a rule to handle injection into target ' + target +
42 | '. Target dependency: ' + propertyType
43 | )
44 | );
45 | }
46 | target[propertyName] = injection;
47 | return target;
48 | }
49 |
50 |
51 | /*******************************************************************************************
52 | * protected methods *
53 | *******************************************************************************************/
54 | override protected function initializeInjection(node : XML, injector : Injector) : void
55 | {
56 | propertyType = node.parent().@type.toString();
57 | propertyName = node.parent().@name.toString();
58 | m_injectionConfig = injector.getMapping(Class(injector.getApplicationDomain().getDefinition(propertyType)),
59 | node.arg.attribute('value').toString());
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/swiftsuspenders/injectionresults/InjectClassResult.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.swiftsuspenders.injectionresults
9 | {
10 | import org.swiftsuspenders.Injector;
11 |
12 | public class InjectClassResult extends InjectionResult
13 | {
14 | /*******************************************************************************************
15 | * private properties *
16 | *******************************************************************************************/
17 | private var m_responseType : Class;
18 |
19 |
20 | /*******************************************************************************************
21 | * public methods *
22 | *******************************************************************************************/
23 | public function InjectClassResult(responseType : Class)
24 | {
25 | m_responseType = responseType;
26 | }
27 |
28 | override public function getResponse(injector : Injector) : Object
29 | {
30 | return injector.instantiate(m_responseType);
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/swiftsuspenders/injectionresults/InjectOtherRuleResult.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.swiftsuspenders.injectionresults
9 | {
10 | import org.swiftsuspenders.InjectionConfig;
11 | import org.swiftsuspenders.Injector;
12 |
13 | public class InjectOtherRuleResult extends InjectionResult
14 | {
15 | /*******************************************************************************************
16 | * private properties *
17 | *******************************************************************************************/
18 | private var m_rule : InjectionConfig;
19 |
20 |
21 | /*******************************************************************************************
22 | * public methods *
23 | *******************************************************************************************/
24 | public function InjectOtherRuleResult(rule : InjectionConfig)
25 | {
26 | m_rule = rule;
27 | }
28 |
29 | override public function getResponse(injector : Injector) : Object
30 | {
31 | return m_rule.getResponse(injector);
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/swiftsuspenders/injectionresults/InjectSingletonResult.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.swiftsuspenders.injectionresults
9 | {
10 | import org.swiftsuspenders.Injector;
11 |
12 | public class InjectSingletonResult extends InjectionResult
13 | {
14 | /*******************************************************************************************
15 | * private properties *
16 | *******************************************************************************************/
17 | private var m_responseType : Class;
18 | private var m_response : Object;
19 |
20 |
21 | /*******************************************************************************************
22 | * public methods *
23 | *******************************************************************************************/
24 | public function InjectSingletonResult(responseType : Class)
25 | {
26 | m_responseType = responseType;
27 | }
28 |
29 | override public function getResponse(injector : Injector) : Object
30 | {
31 | return m_response ||= createResponse(injector);
32 | }
33 |
34 |
35 | /*******************************************************************************************
36 | * private methods *
37 | *******************************************************************************************/
38 | private function createResponse(injector : Injector) : Object
39 | {
40 | return injector.instantiate(m_responseType);
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/swiftsuspenders/injectionresults/InjectValueResult.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2009 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.swiftsuspenders.injectionresults
9 | {
10 | import org.swiftsuspenders.Injector;
11 |
12 | public class InjectValueResult extends InjectionResult
13 | {
14 | /*******************************************************************************************
15 | * private properties *
16 | *******************************************************************************************/
17 | private var m_value : Object;
18 |
19 |
20 | /*******************************************************************************************
21 | * public methods *
22 | *******************************************************************************************/
23 | public function InjectValueResult(value : Object)
24 | {
25 | m_value = value;
26 | }
27 |
28 | override public function getResponse(injector : Injector) : Object
29 | {
30 | return m_value;
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/lib/robotlegs_v1_4/org/swiftsuspenders/injectionresults/InjectionResult.as:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 the original author or authors
3 | *
4 | * Permission is hereby granted to use, modify, and distribute this file
5 | * in accordance with the terms of the license agreement accompanying it.
6 | */
7 |
8 | package org.swiftsuspenders.injectionresults
9 | {
10 | import org.swiftsuspenders.Injector;
11 |
12 | public class InjectionResult
13 | {
14 | /*******************************************************************************************
15 | * public methods *
16 | *******************************************************************************************/
17 | public function InjectionResult()
18 | {
19 | }
20 |
21 | public function getResponse(injector : Injector) : Object
22 | {
23 | return null;
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/rakefile.rb:
--------------------------------------------------------------------------------
1 | Dir.glob('rakefiles/*.rb').each { |r| import r }
2 |
3 | require 'sprout'
4 | # Optionally load gems from a server other than rubyforge:
5 | # set_sources 'http://gems.projectsprouts.org'
6 | sprout 'as3'
7 |
8 | ############################################
9 | # Configure your Project Model
10 | project_model :model do |m|
11 | m.project_name = 'RelaxedEventMap'
12 | m.language = 'as3'
13 | m.background_color = '#FFFFFF'
14 | m.width = 970
15 | m.height = 550
16 | m.keep_as3_metadata = 'Inject'
17 | # m.use_fdb = true
18 | # m.use_fcsh = true
19 | # m.preprocessor = 'cpp -D__DEBUG=false -P - - | tail -c +3'
20 | # m.preprocessed_path = '.preprocessed'
21 | # m.src_dir = 'src'
22 | # m.lib_dir = 'lib'
23 | # m.swc_dir = 'lib'
24 | # m.bin_dir = 'bin'
25 | # m.test_dir = 'test'
26 | # m.doc_dir = 'doc'
27 | # m.asset_dir = 'assets'
28 | # m.compiler_gem_name = 'sprout-flex4sdk-tool'
29 | # m.compiler_gem_version = '>= 4.0.0'
30 | m.source_path << "#{m.lib_dir}/robotlegs_v1_0" #1_0 and 1_4 both in lib
31 | m.source_path << "#{m.lib_dir}/mockolate"
32 | m.support_dir = 'support'
33 | m.library_path << 'lib/asx.swc'
34 | m.library_path << 'lib/hamcrest.swc'
35 | m.library_path << 'lib/FLoxy.swc'
36 |
37 | # m.libraries << :corelib
38 | end
39 |
40 | desc 'Compile and debug the application'
41 | debug :debug
42 |
43 | desc 'Compile run the test harness'
44 | unit :test do |t|
45 | t.source_path << "support"
46 | end
47 |
48 | desc 'Compile the optimized deployment'
49 | deploy :deploy
50 |
51 | desc 'Create documentation'
52 | document :doc
53 |
54 | desc 'Compile a SWC file'
55 | swc :swc
56 |
57 | desc 'Compile and run the test harness for CI'
58 | ci :cruise
59 |
60 | # set up the default rake task
61 | task :default => :debug
62 |
--------------------------------------------------------------------------------
/rakefiles/sprouts_test_extensions.rb:
--------------------------------------------------------------------------------
1 |
2 | desc 'Prepare the AllTests class to test a specific package'
3 | task :testpackage, :packageName do |t, args|
4 | tempFile = File.new("test/temp.as", "w");
5 | allTestsFile = File.open("test/AllTests.as", "r");
6 | allTestsFile.each do |line|
7 | line = line.gsub('//','')
8 | if((line.include?('addTest'))||((line.include?('import'))&&(!line.include?('asunit'))))
9 | if !(line.include?(args.packageName))
10 | line = '//' + line
11 | end
12 | end
13 | tempFile.write(line)
14 | end
15 | tempFile.close
16 | allTestsFile.close
17 | File.delete("test/AllTests.as")
18 | File.rename("test/temp.as", "test/AllTests.as")
19 |
20 | Rake::Task[ "test" ].invoke
21 |
22 | end
23 |
24 | desc 'Prepare the AllTests class to test a specific package'
25 | task :testallexcept, :packageName do |t, args|
26 | tempFile = File.new("test/temp.as", "w");
27 | allTestsFile = File.open("test/AllTests.as", "r");
28 | allTestsFile.each do |line|
29 | line = line.gsub('//','')
30 | if(line.include?('addTest'))
31 | if (line.include?(args.packageName))
32 | line = '//' + line
33 | end
34 | end
35 | tempFile.write(line)
36 | end
37 | tempFile.close
38 | allTestsFile.close
39 | File.delete("test/AllTests.as")
40 | File.rename("test/temp.as", "test/AllTests.as")
41 |
42 | Rake::Task[ "test" ].invoke
43 |
44 | end
45 |
46 | desc 'Set all tests active in the AllTests.as package'
47 | task :testall do
48 | tempFile = File.new("test/temp.as", "w");
49 | allTestsFile = File.open("test/AllTests.as", "r");
50 | allTestsFile.each do |line|
51 | line = line.gsub('//','')
52 | tempFile.write(line)
53 | end
54 | tempFile.close
55 | allTestsFile.close
56 | File.delete("test/AllTests.as")
57 | File.rename("test/temp.as", "test/AllTests.as")
58 |
59 | Rake::Task[ "test" ].invoke
60 |
61 | end
--------------------------------------------------------------------------------
/script/generate:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'rubygems'
3 | require 'sprout'
4 | sprout 'sprout-as3-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('as3', ARGV.shift, ARGV, File.dirname(File.dirname(__FILE__)))
22 |
--------------------------------------------------------------------------------
/script/generators/event/USAGE:
--------------------------------------------------------------------------------
1 | Description:
2 | Stubs out a new ActionScript RobotLegs Context class and test case and then
3 | rebuilds all test suites. Pass the fully-qualified class name, either as a
4 | shell file target 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 rlcontext com.company.projectname.MyContext`
36 |
37 | Will create the follow files:
38 |
39 | Class: src/com/company/projectname/MyContext.as
40 | Test Case: test/com/company/projectname/MyContextTest.as
41 |
42 | Test Suites: test/AllTests.as
43 |
--------------------------------------------------------------------------------
/script/generators/event/event_generator.rb:
--------------------------------------------------------------------------------
1 |
2 | class EventGenerator < Sprout::Generator::NamedBase # :nodoc:
3 |
4 | def manifest
5 | record do |m|
6 | # m.class_collisions class_dir, "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper"
7 |
8 | if(!user_requested_test)
9 | m.directory full_class_dir
10 | m.template 'Event.as', full_class_path
11 | end
12 |
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'), :collision => :force
17 | end
18 | end
19 |
20 | end
21 |
--------------------------------------------------------------------------------
/script/generators/event/templates/Component.mxml:
--------------------------------------------------------------------------------
1 |
2 |