Title: [waffle-scm] [302] trunk: ERB::Util is now mixed in from RubyScriptComponentAdapter instead of from RhtmlServlet.

Diff

Modified: trunk/core/src/main/java/org/codehaus/waffle/context/pico/RubyAwarePicoContextContainerFactory.java (301 => 302)

--- trunk/core/src/main/java/org/codehaus/waffle/context/pico/RubyAwarePicoContextContainerFactory.java	2007-07-30 21:14:18 UTC (rev 301)
+++ trunk/core/src/main/java/org/codehaus/waffle/context/pico/RubyAwarePicoContextContainerFactory.java	2007-08-07 16:02:12 UTC (rev 302)
@@ -21,6 +21,7 @@
         ContextContainer contextContainer = super.buildApplicationContextContainer();
 
         Ruby runtime = Ruby.getDefaultInstance();
+        loadRubyScriptFromClassLoader("org/codehaus/waffle/erb_extension.rb", runtime);
         loadRubyScriptFromClassLoader("org/codehaus/waffle/waffle.rb", runtime);
 
         // I'd prefer to do the following:

Modified: trunk/core/src/main/java/org/codehaus/waffle/controller/RubyController.java (301 => 302)

--- trunk/core/src/main/java/org/codehaus/waffle/controller/RubyController.java	2007-07-30 21:14:18 UTC (rev 301)
+++ trunk/core/src/main/java/org/codehaus/waffle/controller/RubyController.java	2007-08-07 16:02:12 UTC (rev 302)
@@ -1,16 +1,14 @@
 package org.codehaus.waffle.controller;
 
 import org.jruby.Ruby;
+import org.jruby.javasupport.JavaEmbedUtils;
 import org.jruby.javasupport.JavaUtil;
-import org.jruby.javasupport.JavaEmbedUtils;
 import org.jruby.runtime.builtin.IRubyObject;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
-import java.util.ArrayList;
 
 /**
  * This is a wrapper for the underlying ruby script
@@ -32,13 +30,13 @@
     }
 
     // todo need to ensure this doesn't allow non-public methods to be called ... NEED test in general
-    public Object execute(HttpServletRequest request, HttpServletResponse response) {
+    public Object execute() {
         Ruby runtime = rubyObject.getRuntime();
         IRubyObject result;
 
         String[] strings = methodName.split("\\|");
 
-        if(strings.length == 0) {
+        if (strings.length == 0) {
             result = rubyObject.callMethod(runtime.getCurrentContext(), methodName);
         } else {
             Iterator<String> iterator = Arrays.asList(strings).iterator();
@@ -49,8 +47,10 @@
             while (iterator.hasNext()) {
                 arguments.add(JavaEmbedUtils.javaToRuby(runtime, iterator.next()));
             }
-            
-            result = rubyObject.callMethod(runtime.getCurrentContext(), methodName, arguments.toArray(new IRubyObject[0]));
+
+            result = rubyObject.callMethod(runtime.getCurrentContext(),
+                    methodName,
+                    arguments.toArray(new IRubyObject[arguments.size()]));
         }
 
         return JavaUtil.convertRubyToJava(result);

Modified: trunk/core/src/main/java/org/codehaus/waffle/controller/RubyControllerDefinitionFactory.java (301 => 302)

--- trunk/core/src/main/java/org/codehaus/waffle/controller/RubyControllerDefinitionFactory.java	2007-07-30 21:14:18 UTC (rev 301)
+++ trunk/core/src/main/java/org/codehaus/waffle/controller/RubyControllerDefinitionFactory.java	2007-08-07 16:02:12 UTC (rev 302)
@@ -16,7 +16,7 @@
 
     static {
         try {
-            executeMethod = RubyController.class.getMethod("execute", HttpServletRequest.class, HttpServletResponse.class);
+            executeMethod = RubyController.class.getMethod("execute");
         } catch (NoSuchMethodException e) {
             throw new WaffleException("FATAL: Waffle's RubyController does not define an execute() method.");
         }

Modified: trunk/core/src/main/java/org/codehaus/waffle/registrar/pico/RubyScriptComponentAdapter.java (301 => 302)

--- trunk/core/src/main/java/org/codehaus/waffle/registrar/pico/RubyScriptComponentAdapter.java	2007-07-30 21:14:18 UTC (rev 301)
+++ trunk/core/src/main/java/org/codehaus/waffle/registrar/pico/RubyScriptComponentAdapter.java	2007-08-07 16:02:12 UTC (rev 302)
@@ -31,7 +31,8 @@
 
         String script =
                 "controller = " + rubyClassName + ".new\n" + // instantiate controller
-                "controller.extend(Waffle::Controller)"; // mixin Waffle module
+                "controller.extend(Waffle::Controller)\n" + // mixin Waffle module
+                "controller.extend(ERB::Util)"; // mixin ERB::Util
         IRubyObject controller = runtime.evalScript(script);
 
         // inject pico container

Modified: trunk/core/src/main/java/org/codehaus/waffle/servlet/RhtmlServlet.java (301 => 302)

--- trunk/core/src/main/java/org/codehaus/waffle/servlet/RhtmlServlet.java	2007-07-30 21:14:18 UTC (rev 301)
+++ trunk/core/src/main/java/org/codehaus/waffle/servlet/RhtmlServlet.java	2007-08-07 16:02:12 UTC (rev 302)
@@ -31,7 +31,6 @@
         String template = loadRhtml(request.getServletPath());
 
         Ruby runtime = RequestLevelContainer.get().getComponentInstanceOfType(Ruby.class);
-        runtime.evalScript("require 'erb'\n");
         RubyModule module = runtime.getClassFromPath("ERB");
 
         IRubyObject erb = (IRubyObject) JavaEmbedUtils.invokeMethod(runtime, module, "new",
@@ -40,9 +39,6 @@
         // TODO: Test with a non-ruby controller
         Object controller = extractController(request);
 
-        JavaEmbedUtils.invokeMethod(runtime, controller, "extend",
-                new Object[]{runtime.getClassFromPath("ERB::Util")}, Object.class);
-
         IRubyObject binding = (IRubyObject) JavaEmbedUtils.invokeMethod(runtime, controller, "send",
                 new Object[]{runtime.newSymbol("binding")}, IRubyObject.class);
 

Added: trunk/core/src/main/ruby/org/codehaus/waffle/erb_extension.rb (0 => 302)

--- trunk/core/src/main/ruby/org/codehaus/waffle/erb_extension.rb	                        (rev 0)
+++ trunk/core/src/main/ruby/org/codehaus/waffle/erb_extension.rb	2007-08-07 16:02:12 UTC (rev 302)
@@ -0,0 +1,3 @@
+require 'erb'
+
+# TODO Implement render for "partial" views

Modified: trunk/core/src/main/ruby/org/codehaus/waffle/waffle.rb (301 => 302)

--- trunk/core/src/main/ruby/org/codehaus/waffle/waffle.rb	2007-07-30 21:14:18 UTC (rev 301)
+++ trunk/core/src/main/ruby/org/codehaus/waffle/waffle.rb	2007-08-07 16:02:12 UTC (rev 302)
@@ -17,7 +17,7 @@
         ScriptLoader.load_from_file_system
       else
         servlet_context.getResourcePaths(prefix).each do |path| # this would be for production!!
-          require(path.gsub(Regexp.new("^#{prefix}\/"), ''))
+          require(path.gsub(%r{#{prefix}\/}, ''))
         end
       end
     end

Modified: trunk/core/src/test/java/org/codehaus/waffle/controller/RubyControllerTest.java (301 => 302)

--- trunk/core/src/test/java/org/codehaus/waffle/controller/RubyControllerTest.java	2007-07-30 21:14:18 UTC (rev 301)
+++ trunk/core/src/test/java/org/codehaus/waffle/controller/RubyControllerTest.java	2007-08-07 16:02:12 UTC (rev 302)
@@ -18,6 +18,6 @@
 
         RubyController rubyController = new RubyController(runtime.evalScript("Foo.new"));
         rubyController.setMethodName("my_method");
-        assertEquals("Hello World", rubyController.execute(null, null));
+        assertEquals("Hello World", rubyController.execute());
     }
 }

Modified: trunk/core/src/test/java/org/codehaus/waffle/registrar/pico/RubyScriptComponentAdapterTest.java (301 => 302)

--- trunk/core/src/test/java/org/codehaus/waffle/registrar/pico/RubyScriptComponentAdapterTest.java	2007-07-30 21:14:18 UTC (rev 301)
+++ trunk/core/src/test/java/org/codehaus/waffle/registrar/pico/RubyScriptComponentAdapterTest.java	2007-08-07 16:02:12 UTC (rev 302)
@@ -21,6 +21,7 @@
         runtime.evalScript("$my_global = 'Waffle'\n");
 
         String script =
+                "require 'erb'\n" +
                 "module Waffle\n" +
                 "  module Controller\n" +
                 "   def __pico_container=(pico)\n" +
@@ -29,7 +30,7 @@
                 "end\n" +
                 "class FooBar\n" +
                 "  def execute\n" +
-                "    \"JRuby and #{$my_global}\"\n" +
+                "    h(\"JRuby & #{$my_global}\")\n" + // Ensuring ERB::Util has been mixed in
                 "  end\n" +
                 "end";
         runtime.evalScript(script);
@@ -42,6 +43,7 @@
 
         // call a method on the ruby instance ... enuring it was instantiated and that the runtime was set
         IRubyObject response = instance.callMethod(runtime.getCurrentContext(), "execute");
-        assertEquals("JRuby and Waffle", JavaUtil.convertRubyToJava(response));
+        assertEquals("JRuby &amp; Waffle", JavaUtil.convertRubyToJava(response));
+
     }
 }

Modified: trunk/examples/freemarker-example/freemarker-example.iml (301 => 302)

--- trunk/examples/freemarker-example/freemarker-example.iml	2007-07-30 21:14:18 UTC (rev 301)
+++ trunk/examples/freemarker-example/freemarker-example.iml	2007-08-07 16:02:12 UTC (rev 302)
@@ -148,6 +148,10 @@
           <attribute name="method" value="0" />
           <attribute name="URI" value="&lt;N/A&gt;" />
         </containerElement>
+        <containerElement type="module" name="freemarker-example">
+          <attribute name="method" value="1" />
+          <attribute name="URI" value="/WEB-INF/classes" />
+        </containerElement>
         <building>
           <setting name="EXPLODED_URL" value="file://$MODULE_DIR$/exploded" />
           <setting name="EXPLODED_ENABLED" value="true" />
@@ -297,6 +301,10 @@
             <attribute name="method" value="0" />
             <attribute name="URI" value="&lt;N/A&gt;" />
           </containerElement>
+          <containerElement type="module" name="freemarker-example">
+            <attribute name="method" value="1" />
+            <attribute name="URI" value="/WEB-INF/classes" />
+          </containerElement>
         </packaging>
       </configuration>
     </facet>

Modified: trunk/examples/jruby-example/jruby-example.iml (301 => 302)

--- trunk/examples/jruby-example/jruby-example.iml	2007-07-30 21:14:18 UTC (rev 301)
+++ trunk/examples/jruby-example/jruby-example.iml	2007-08-07 16:02:12 UTC (rev 302)
@@ -114,6 +114,10 @@
           <attribute name="method" value="0" />
           <attribute name="URI" value="&lt;N/A&gt;" />
         </containerElement>
+        <containerElement type="module" name="jruby-example">
+          <attribute name="method" value="1" />
+          <attribute name="URI" value="/WEB-INF/classes" />
+        </containerElement>
         <building>
           <setting name="EXPLODED_URL" value="file://$MODULE_DIR$/exploded" />
           <setting name="EXPLODED_ENABLED" value="true" />
@@ -229,6 +233,10 @@
             <attribute name="method" value="0" />
             <attribute name="URI" value="&lt;N/A&gt;" />
           </containerElement>
+          <containerElement type="module" name="jruby-example">
+            <attribute name="method" value="1" />
+            <attribute name="URI" value="/WEB-INF/classes" />
+          </containerElement>
         </packaging>
       </configuration>
     </facet>

Modified: trunk/examples/jruby-example/src/test/java/org/codehaus/waffle/example/jruby/RubyRegistrarTest.java (301 => 302)

--- trunk/examples/jruby-example/src/test/java/org/codehaus/waffle/example/jruby/RubyRegistrarTest.java	2007-07-30 21:14:18 UTC (rev 301)
+++ trunk/examples/jruby-example/src/test/java/org/codehaus/waffle/example/jruby/RubyRegistrarTest.java	2007-08-07 16:02:12 UTC (rev 302)
@@ -129,26 +129,6 @@
         System.out.println("o = " + o);
     }
 
-//    public void testRSpec() {
-//        Ruby runtime = Ruby.getDefaultInstance();
-//        runtime.getLoadService().init(new ArrayList());
-//        runtime.defineGlobalConstant("ARGV", runtime.newArray());
-//
-//        String script =
-//                "require 'rubygems'\n" +
-//                "require 'java'\n" +
-//                "require 'spec'\n" +
-//                "\n" +
-//                "p \"#{File.dirname(__FILE__)}/../**/*_spec.rb\"\n" +
-//                "specs = Dir[\"#{File.dirname(__FILE__)}/**/*_spec.rb\"]\n" +
-//                "specs << '-f'; specs << 's'\n" +
-//                "p specs" +
-//                "\n" +
-//                "::Spec::Runner::CommandLine.run(specs, STDERR, STDOUT, false, true)";
-//
-//        runtime.evalScript(script);
-//    }
-
     public void testRubyErb() {
        String script =
                "require \"erb\"\n" +
@@ -214,12 +194,4 @@
         Ruby runtime = Ruby.getDefaultInstance();
         runtime.evalScript(script);
     }
-
-
-
-
-
-
-
-
 }

Added: trunk/examples/mydvds-example/mydvds-example.iml (0 => 302)

--- trunk/examples/mydvds-example/mydvds-example.iml	                        (rev 0)
+++ trunk/examples/mydvds-example/mydvds-example.iml	2007-08-07 16:02:12 UTC (rev 302)
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module relativePaths="true" type="JAVA_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="hibernate" name="Hibernate">
+      <configuration>
+        <option name="myHibernateValidationEnabled" value="true" />
+        <datasource-map>
+          <unit-entry name="&lt;anonymous&gt;[EMAIL PROTECTED]" />
+        </datasource-map>
+        <deploymentDescriptor name="hibernate.cfg.xml" url="" optional="false" version="3.0" />
+      </configuration>
+    </facet>
+    <facet type="web" name="Web" implicit="true">
+      <configuration>
+        <descriptors>
+          <deploymentDescriptor name="web.xml" url="" optional="false" version="2.4" />
+        </descriptors>
+        <webroots>
+          <root url="" relative="/" />
+        </webroots>
+        <containerElement type="module" name="mydvds-example">
+          <attribute name="method" value="1" />
+          <attribute name="URI" value="/WEB-INF/classes" />
+        </containerElement>
+        <building>
+          <setting name="EXPLODED_URL" value="file://" />
+          <setting name="EXPLODED_ENABLED" value="false" />
+          <setting name="JAR_URL" value="file://" />
+          <setting name="JAR_ENABLED" value="false" />
+          <setting name="BUILD_MODULE_ON_FRAME_DEACTIVATION" value="false" />
+          <setting name="BUILD_EXTERNAL_DEPENDENCIES" value="false" />
+          <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
+          <setting name="RUN_JASPER_VALIDATION" value="true" />
+        </building>
+        <packaging>
+          <containerElement type="module" name="mydvds-example">
+            <attribute name="method" value="1" />
+            <attribute name="URI" value="/WEB-INF/classes" />
+          </containerElement>
+        </packaging>
+      </configuration>
+    </facet>
+    <facet type="web" name="Web2" implicit="true">
+      <configuration>
+        <descriptors>
+          <deploymentDescriptor name="web.xml" url="" optional="false" version="2.4" />
+        </descriptors>
+        <webroots>
+          <root url="" relative="/" />
+        </webroots>
+        <containerElement type="module" name="mydvds-example">
+          <attribute name="method" value="1" />
+          <attribute name="URI" value="/WEB-INF/classes" />
+        </containerElement>
+        <building>
+          <setting name="EXPLODED_URL" value="file://" />
+          <setting name="EXPLODED_ENABLED" value="false" />
+          <setting name="JAR_URL" value="file://" />
+          <setting name="JAR_ENABLED" value="false" />
+          <setting name="BUILD_MODULE_ON_FRAME_DEACTIVATION" value="false" />
+          <setting name="BUILD_EXTERNAL_DEPENDENCIES" value="false" />
+          <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
+          <setting name="RUN_JASPER_VALIDATION" value="true" />
+        </building>
+        <packaging>
+          <containerElement type="module" name="mydvds-example">
+            <attribute name="method" value="1" />
+            <attribute name="URI" value="/WEB-INF/classes" />
+          </containerElement>
+        </packaging>
+      </configuration>
+    </facet>
+  </component>
+  <component name="NewModuleRootManager" inherit-compiler-output="false">
+    <output url="" />
+    <exclude-output />
+    <output-test url="" />
+    <content url=""
+      <sourceFolder url="" isTestSource="false" />
+      <sourceFolder url="" isTestSource="true" />
+      <sourceFolder url="" isTestSource="true" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="core" exported="" />
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="" />
+          <root url="" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntryProperties />
+  </component>
+</module>
+

Modified: trunk/examples/paranamer-example/paranamer-example.iml (301 => 302)

--- trunk/examples/paranamer-example/paranamer-example.iml	2007-07-30 21:14:18 UTC (rev 301)
+++ trunk/examples/paranamer-example/paranamer-example.iml	2007-08-07 16:02:12 UTC (rev 302)
@@ -104,6 +104,10 @@
           <attribute name="method" value="0" />
           <attribute name="URI" value="&lt;N/A&gt;" />
         </containerElement>
+        <containerElement type="module" name="paranamer-example">
+          <attribute name="method" value="1" />
+          <attribute name="URI" value="/WEB-INF/classes" />
+        </containerElement>
         <building>
           <setting name="EXPLODED_URL" value="file://$MODULE_DIR$/exploded" />
           <setting name="EXPLODED_ENABLED" value="true" />
@@ -209,6 +213,10 @@
             <attribute name="method" value="0" />
             <attribute name="URI" value="&lt;N/A&gt;" />
           </containerElement>
+          <containerElement type="module" name="paranamer-example">
+            <attribute name="method" value="1" />
+            <attribute name="URI" value="/WEB-INF/classes" />
+          </containerElement>
         </packaging>
       </configuration>
     </facet>

Modified: trunk/examples/simple-example/simple-example.iml (301 => 302)

--- trunk/examples/simple-example/simple-example.iml	2007-07-30 21:14:18 UTC (rev 301)
+++ trunk/examples/simple-example/simple-example.iml	2007-08-07 16:02:12 UTC (rev 302)
@@ -129,6 +129,10 @@
           <attribute name="method" value="1" />
           <attribute name="URI" value="/WEB-INF/lib/velocity-tools-view-1.1.jar" />
         </containerElement>
+        <containerElement type="module" name="simple-example">
+          <attribute name="method" value="1" />
+          <attribute name="URI" value="/WEB-INF/classes" />
+        </containerElement>
         <building>
           <setting name="EXPLODED_URL" value="file://$MODULE_DIR$/exploded" />
           <setting name="EXPLODED_ENABLED" value="true" />
@@ -259,6 +263,10 @@
             <attribute name="method" value="1" />
             <attribute name="URI" value="/WEB-INF/lib/velocity-tools-view-1.1.jar" />
           </containerElement>
+          <containerElement type="module" name="simple-example">
+            <attribute name="method" value="1" />
+            <attribute name="URI" value="/WEB-INF/classes" />
+          </containerElement>
         </packaging>
       </configuration>
     </facet>

Modified: trunk/root.iml (301 => 302)

--- trunk/root.iml	2007-07-30 21:14:18 UTC (rev 301)
+++ trunk/root.iml	2007-08-07 16:02:12 UTC (rev 302)
@@ -1,5 +1,67 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <module relativePaths="true" type="JAVA_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="web" name="Web" implicit="true">
+      <configuration>
+        <descriptors>
+          <deploymentDescriptor name="web.xml" url="" optional="false" version="2.4" />
+        </descriptors>
+        <webroots>
+          <root url="" relative="/" />
+        </webroots>
+        <containerElement type="module" name="root">
+          <attribute name="method" value="1" />
+          <attribute name="URI" value="/WEB-INF/classes" />
+        </containerElement>
+        <building>
+          <setting name="EXPLODED_URL" value="file://" />
+          <setting name="EXPLODED_ENABLED" value="false" />
+          <setting name="JAR_URL" value="file://" />
+          <setting name="JAR_ENABLED" value="false" />
+          <setting name="BUILD_MODULE_ON_FRAME_DEACTIVATION" value="false" />
+          <setting name="BUILD_EXTERNAL_DEPENDENCIES" value="false" />
+          <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
+          <setting name="RUN_JASPER_VALIDATION" value="true" />
+        </building>
+        <packaging>
+          <containerElement type="module" name="root">
+            <attribute name="method" value="1" />
+            <attribute name="URI" value="/WEB-INF/classes" />
+          </containerElement>
+        </packaging>
+      </configuration>
+    </facet>
+    <facet type="web" name="Web2" implicit="true">
+      <configuration>
+        <descriptors>
+          <deploymentDescriptor name="web.xml" url="" optional="false" version="2.4" />
+        </descriptors>
+        <webroots>
+          <root url="" relative="/" />
+        </webroots>
+        <containerElement type="module" name="root">
+          <attribute name="method" value="1" />
+          <attribute name="URI" value="/WEB-INF/classes" />
+        </containerElement>
+        <building>
+          <setting name="EXPLODED_URL" value="file://" />
+          <setting name="EXPLODED_ENABLED" value="false" />
+          <setting name="JAR_URL" value="file://" />
+          <setting name="JAR_ENABLED" value="false" />
+          <setting name="BUILD_MODULE_ON_FRAME_DEACTIVATION" value="false" />
+          <setting name="BUILD_EXTERNAL_DEPENDENCIES" value="false" />
+          <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
+          <setting name="RUN_JASPER_VALIDATION" value="true" />
+        </building>
+        <packaging>
+          <containerElement type="module" name="root">
+            <attribute name="method" value="1" />
+            <attribute name="URI" value="/WEB-INF/classes" />
+          </containerElement>
+        </packaging>
+      </configuration>
+    </facet>
+  </component>
   <component name="NewModuleRootManager" inherit-compiler-output="true">
     <content url=""
       <excludeFolder url="" />


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to