You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by jk...@apache.org on 2015/10/20 16:16:16 UTC

[1/2] tapestry-5 git commit: TAP5-2511: don't rewrite define calls for named AMD modules

Repository: tapestry-5
Updated Branches:
  refs/heads/master 19e4f016c -> 5473e9a53


TAP5-2511: don't rewrite define calls for named AMD modules


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/ae25e238
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/ae25e238
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/ae25e238

Branch: refs/heads/master
Commit: ae25e238e2559d33a218f5cbeaa8049b002c5c7b
Parents: 19e4f01
Author: Jochen Kemnade <jo...@eddyson.de>
Authored: Tue Oct 20 15:59:28 2015 +0200
Committer: Jochen Kemnade <jo...@eddyson.de>
Committed: Tue Oct 20 15:59:55 2015 +0200

----------------------------------------------------------------------
 .../assets/JavaScriptStackAssemblerImpl.java    | 11 +++--
 .../services/assets/ModuleReaderSpec.groovy     | 44 ++++++++++++++++++++
 2 files changed, 52 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/ae25e238/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/JavaScriptStackAssemblerImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/JavaScriptStackAssemblerImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/JavaScriptStackAssemblerImpl.java
index 76a9824..49728f2 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/JavaScriptStackAssemblerImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/JavaScriptStackAssemblerImpl.java
@@ -162,9 +162,9 @@ public class JavaScriptStackAssemblerImpl implements JavaScriptStackAssembler
         }
     };
 
-    private final static Pattern DEFINE = Pattern.compile("\\bdefine\\s*\\(");
+    private final static Pattern DEFINE = Pattern.compile("\\bdefine\\s*\\((?=\\s*\\[)");
 
-    private class ModuleReader implements StreamableReader
+    private static class ModuleReader implements StreamableReader
     {
         final String moduleName;
 
@@ -177,7 +177,12 @@ public class JavaScriptStackAssemblerImpl implements JavaScriptStackAssembler
         {
             String content = getContent(resource);
 
-            return DEFINE.matcher(content).replaceFirst("define(\"" + moduleName + "\",");
+            return transform(content);
+        }
+
+        public String transform(String moduleContent)
+        {
+            return DEFINE.matcher(moduleContent).replaceFirst("define(\"" + moduleName + "\",");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/ae25e238/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/assets/ModuleReaderSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/assets/ModuleReaderSpec.groovy b/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/assets/ModuleReaderSpec.groovy
new file mode 100644
index 0000000..7f2f079
--- /dev/null
+++ b/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/assets/ModuleReaderSpec.groovy
@@ -0,0 +1,44 @@
+package org.apache.tapestry5.internal.services.assets
+
+import org.apache.tapestry5.internal.services.IdentityAssetPathConverter
+import org.apache.tapestry5.internal.services.assets.JavaScriptStackAssemblerImpl.ModuleReader;
+import org.apache.tapestry5.internal.util.VirtualResource;
+import org.apache.tapestry5.ioc.test.TestBase
+import org.apache.tapestry5.services.BaseURLSource
+import org.apache.tapestry5.services.PathConstructor
+import org.apache.tapestry5.services.Request
+import org.apache.tapestry5.services.assets.AssetChecksumGenerator
+import org.apache.tapestry5.services.assets.CompressionStatus
+import org.apache.tapestry5.services.assets.StreamableResource
+import org.testng.annotations.Test
+
+class ModuleReaderTest extends TestBase {
+
+
+    @Test
+    void "convert anonymous define into named define"() {
+      def moduleContent = '''define([], function(){
+  return "constant";
+});'''
+      ModuleReader moduleReader = new ModuleReader("constants-module")
+      def transformed = moduleReader.transform(moduleContent)
+      assertEquals(transformed, '''define("constants-module",[], function(){
+  return "constant";
+});''')
+           
+    }
+
+    @Test
+    void "named define calls are not modified"() {
+      def moduleContent = '''define("foobar", [], function(){
+  return "constant";
+});'''
+      ModuleReader moduleReader = new ModuleReader("constants-module")
+      def transformed = moduleReader.transform(moduleContent)
+      assertEquals(transformed, '''define("foobar", [], function(){
+  return "constant";
+});''')
+           
+    }
+   
+}


[2/2] tapestry-5 git commit: TAP5-2487: fix replace and extension-point attribute declarations in XSD

Posted by jk...@apache.org.
TAP5-2487: fix replace and extension-point attribute declarations in XSD


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/5473e9a5
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/5473e9a5
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/5473e9a5

Branch: refs/heads/master
Commit: 5473e9a538faa512f5bd83d58a68697f6ce79565
Parents: ae25e23
Author: Jochen Kemnade <jo...@eddyson.de>
Authored: Tue Oct 20 16:15:05 2015 +0200
Committer: Jochen Kemnade <jo...@eddyson.de>
Committed: Tue Oct 20 16:15:05 2015 +0200

----------------------------------------------------------------------
 .../org/apache/tapestry5/internal/services/tapestry_5_4.xsd      | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/5473e9a5/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/tapestry_5_4.xsd
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/tapestry_5_4.xsd b/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/tapestry_5_4.xsd
index 05d99e9..01d0f75 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/tapestry_5_4.xsd
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/tapestry_5_4.xsd
@@ -28,7 +28,7 @@
             </xs:documentation>
         </xs:annotation>
         <xs:complexType>
-            <xs:attribute name="name" type="xs:string" use="required">
+            <xs:attribute name="id" type="xs:string" use="required">
                 <xs:annotation>
                     <xs:documentation>
                         Unique id for the replaceable block.
@@ -45,7 +45,7 @@
             </xs:documentation>
         </xs:annotation>
         <xs:complexType>
-            <xs:attribute name="name" type="xs:string" use="required">
+            <xs:attribute name="id" type="xs:string" use="required">
                 <xs:annotation>
                     <xs:documentation>
                         Unique id for the replaceable block, which must match an id of an inheritable extension-point


[2/2] tapestry-5 git commit: TAP5-2487: fix replace and extension-point attribute declarations in XSD

Posted by jk...@apache.org.
TAP5-2487: fix replace and extension-point attribute declarations in XSD


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/5473e9a5
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/5473e9a5
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/5473e9a5

Branch: refs/heads/master
Commit: 5473e9a538faa512f5bd83d58a68697f6ce79565
Parents: ae25e23
Author: Jochen Kemnade <jo...@eddyson.de>
Authored: Tue Oct 20 16:15:05 2015 +0200
Committer: Jochen Kemnade <jo...@eddyson.de>
Committed: Tue Oct 20 16:15:05 2015 +0200

----------------------------------------------------------------------
 .../org/apache/tapestry5/internal/services/tapestry_5_4.xsd      | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/5473e9a5/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/tapestry_5_4.xsd
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/tapestry_5_4.xsd b/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/tapestry_5_4.xsd
index 05d99e9..01d0f75 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/tapestry_5_4.xsd
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/internal/services/tapestry_5_4.xsd
@@ -28,7 +28,7 @@
             </xs:documentation>
         </xs:annotation>
         <xs:complexType>
-            <xs:attribute name="name" type="xs:string" use="required">
+            <xs:attribute name="id" type="xs:string" use="required">
                 <xs:annotation>
                     <xs:documentation>
                         Unique id for the replaceable block.
@@ -45,7 +45,7 @@
             </xs:documentation>
         </xs:annotation>
         <xs:complexType>
-            <xs:attribute name="name" type="xs:string" use="required">
+            <xs:attribute name="id" type="xs:string" use="required">
                 <xs:annotation>
                     <xs:documentation>
                         Unique id for the replaceable block, which must match an id of an inheritable extension-point