add contains and tstamp to support timestamping urls

Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/e7db8ee8
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/e7db8ee8
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/e7db8ee8

Branch: refs/heads/develop
Commit: e7db8ee87c1cb6368ba89cd10ed01fbbb0c8149c
Parents: 9b3a6cf
Author: Alex Harui <aha...@apache.org>
Authored: Fri May 30 15:41:06 2014 -0700
Committer: Alex Harui <aha...@apache.org>
Committed: Fri May 30 15:41:06 2014 -0700

----------------------------------------------------------------------
 ant_on_air/src/AntClasses.as                    |  2 +
 .../src/org/apache/flex/ant/tags/Contains.as    | 58 +++++++++++++++++
 .../src/org/apache/flex/ant/tags/TStamp.as      | 67 ++++++++++++++++++++
 ant_on_air/tests/test.xml                       |  4 ++
 4 files changed, 131 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e7db8ee8/ant_on_air/src/AntClasses.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/AntClasses.as b/ant_on_air/src/AntClasses.as
index e291943..5626ddf 100644
--- a/ant_on_air/src/AntClasses.as
+++ b/ant_on_air/src/AntClasses.as
@@ -30,6 +30,7 @@ package
             import org.apache.flex.ant.tags.Available; Available;
             import org.apache.flex.ant.tags.Checksum; Checksum;
             import org.apache.flex.ant.tags.Condition; Condition;
+            import org.apache.flex.ant.tags.Contains; Contains;
             import org.apache.flex.ant.tags.Copy; Copy;
             import org.apache.flex.ant.tags.Delete; Delete;
             import org.apache.flex.ant.tags.Echo; Echo;
@@ -54,6 +55,7 @@ package
             import org.apache.flex.ant.tags.PropertyFile; PropertyFile;
             import org.apache.flex.ant.tags.Replace; Replace;
                        import org.apache.flex.ant.tags.Touch; Touch;
+            import org.apache.flex.ant.tags.TStamp; TStamp;
             import org.apache.flex.ant.tags.Untar; Untar;
             import org.apache.flex.ant.tags.Unzip; Unzip;
             import org.apache.flex.ant.tags.XmlProperty; XmlProperty;

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e7db8ee8/ant_on_air/src/org/apache/flex/ant/tags/Contains.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/Contains.as 
b/ant_on_air/src/org/apache/flex/ant/tags/Contains.as
new file mode 100644
index 0000000..64f8738
--- /dev/null
+++ b/ant_on_air/src/org/apache/flex/ant/tags/Contains.as
@@ -0,0 +1,58 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.ant.tags
+{
+    import mx.core.IFlexModuleFactory;
+    
+    import org.apache.flex.ant.Ant;
+    import org.apache.flex.ant.tags.supportClasses.IValueTagHandler;
+    import org.apache.flex.ant.tags.supportClasses.TagHandler;
+    
+    [Mixin]
+    public class Contains extends TagHandler implements IValueTagHandler
+    {
+        public static function init(mf:IFlexModuleFactory):void
+        {
+            Ant.antTagProcessors["contains"] = Contains;
+        }
+
+        public function Contains()
+        {
+            super();
+        }
+        
+        private function get string():String
+               {
+                       return getAttributeValue("@string");
+               }
+                       
+        private function get substring():String
+               {
+                       return getAttributeValue("@substring");
+               }
+        
+        public function getValue(context:Object):Object
+        {
+                       this.context = context;
+                       var pat:String = substring;
+                       return string.indexOf(substring) != -1;
+        }
+        
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e7db8ee8/ant_on_air/src/org/apache/flex/ant/tags/TStamp.as
----------------------------------------------------------------------
diff --git a/ant_on_air/src/org/apache/flex/ant/tags/TStamp.as 
b/ant_on_air/src/org/apache/flex/ant/tags/TStamp.as
new file mode 100644
index 0000000..8b7f88b
--- /dev/null
+++ b/ant_on_air/src/org/apache/flex/ant/tags/TStamp.as
@@ -0,0 +1,67 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.ant.tags
+{    
+    import mx.core.IFlexModuleFactory;
+    import mx.resources.ResourceManager;
+    
+    import spark.formatters.DateTimeFormatter;
+    
+    import org.apache.flex.ant.Ant;
+    import org.apache.flex.ant.tags.supportClasses.TaskHandler;
+    
+    [ResourceBundle("ant")]
+    [Mixin]
+    public class TStamp extends TaskHandler
+    {
+        public static function init(mf:IFlexModuleFactory):void
+        {
+            Ant.antTagProcessors["tstamp"] = TStamp;
+        }
+        
+        public function TStamp()
+        {
+        }
+        
+        override public function execute(callbackMode:Boolean, 
context:Object):Boolean
+        {
+            super.execute(callbackMode, context);
+            
+            var d:Date = new Date();
+            var df:DateTimeFormatter = new DateTimeFormatter();
+            df.dateTimePattern = "yyyyMMdd";
+            var dstamp:String = df.format(d);
+            context["DSTAMP"] = dstamp;
+            df.dateTimePattern = "hhmm";
+            var tstamp:String = df.format(d);
+            context["TSTAMP"] = tstamp;
+            df.dateTimePattern = "MMMM dd yyyy";
+            var today:String = df.format(d);
+            context["TODAY"] = today;
+            
+            return true;
+        }
+        
+        private function get prefix():String
+        {
+            return getAttributeValue("@prefix");
+        }        
+        
+    } 
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e7db8ee8/ant_on_air/tests/test.xml
----------------------------------------------------------------------
diff --git a/ant_on_air/tests/test.xml b/ant_on_air/tests/test.xml
index ebf9d0f..244862a 100644
--- a/ant_on_air/tests/test.xml
+++ b/ant_on_air/tests/test.xml
@@ -50,6 +50,10 @@
     </condition>
 
        <target name="test" depends="copy-test,confirm-delete,delete-test">
+        <tstamp />
+        <echo>${DSTAMP}</echo>
+        <echo>${TSTAMP}</echo>
+        <echo>${TODAY}</echo>
         <exec executable="where.exe" osfamily="windows" 
outputproperty="java.executable" failonerror="true">
             <arg value="java"/>
         </exec>

Reply via email to