Title: [waffle-scm] [812] trunk/waffle-ruby/src/main/ruby/org/codehaus/waffle: Renamed waffle erb extension to waffle_erb.rb.

Diff

Modified: trunk/waffle-ruby/src/main/java/org/codehaus/waffle/context/pico/RubyPicoContextContainerFactory.java (811 => 812)

--- trunk/waffle-ruby/src/main/java/org/codehaus/waffle/context/pico/RubyPicoContextContainerFactory.java	2008-09-04 08:07:35 UTC (rev 811)
+++ trunk/waffle-ruby/src/main/java/org/codehaus/waffle/context/pico/RubyPicoContextContainerFactory.java	2008-09-04 08:27:29 UTC (rev 812)
@@ -39,7 +39,7 @@
         MutablePicoContainer picoContainer = (MutablePicoContainer) contextContainer.getDelegate();
         Ruby runtime = Ruby.newInstance();
         runtime.getLoadService().init(new ArrayList<Object>()); // this must be called, else we won't be able to load scripts!!
-        loadRubyScriptFromClassLoader("org/codehaus/waffle/erb_extension.rb", runtime);
+        loadRubyScriptFromClassLoader("org/codehaus/waffle/waffle_erb.rb", runtime);
         loadRubyScriptFromClassLoader("org/codehaus/waffle/waffle.rb", runtime);
 
         // I'd prefer to do the following:

Deleted: trunk/waffle-ruby/src/main/ruby/org/codehaus/waffle/erb_extension.rb (811 => 812)

--- trunk/waffle-ruby/src/main/ruby/org/codehaus/waffle/erb_extension.rb	2008-09-04 08:07:35 UTC (rev 811)
+++ trunk/waffle-ruby/src/main/ruby/org/codehaus/waffle/erb_extension.rb	2008-09-04 08:27:29 UTC (rev 812)
@@ -1,59 +0,0 @@
-require 'erb'
-
-module Waffle
-  class PartialController
-
-    def initialize(delegate, locals = {})
-
-      def self.metaclass; class << self; self; end; end
-
-      delegate.instance_variables.each do |key|
-        self.instance_variable_set(key, delegate.instance_variable_get(key))
-      end
-
-      # Add locals to virtual class
-      unless locals.empty?
-        locals.keys.each do |key|
-          metaclass.send(:attr_reader, key)
-        end
-
-        locals.each_pair do |key, value|
-          self.instance_variable_set("@#{key}", value)
-        end
-      end
-
-    end
-  end
-end
-
-class ERB
-
-  module Util
-
-    #
-    # renders partial page (rhtml).
-    #
-    # This will be mixed in to ruby based Waffle Controllers
-    #
-    def partial(file_name, locals = {})
-      controller = Waffle::PartialController.new(self, locals)
-
-      # Locate full path to template (*.rhtml)
-      path = Waffle::ScriptLoader.locate_template(file_name)
-
-      return "File Not Found: Unable to render file '#{path}'." unless File.exist?(path)
-
-
-      # TODO can't we just call open() ??
-      template = ''
-      File.open(path).each { |line| template << line }
-
-      erb = ERB.new(template)
-      return erb.result(controller.send(:binding))
-    end
-
-    module_function :partial
-
-  end
-  
-end

Copied: trunk/waffle-ruby/src/main/ruby/org/codehaus/waffle/waffle_erb.rb (from rev 799, trunk/waffle-ruby/src/main/ruby/org/codehaus/waffle/erb_extension.rb) (0 => 812)

--- trunk/waffle-ruby/src/main/ruby/org/codehaus/waffle/waffle_erb.rb	                        (rev 0)
+++ trunk/waffle-ruby/src/main/ruby/org/codehaus/waffle/waffle_erb.rb	2008-09-04 08:27:29 UTC (rev 812)
@@ -0,0 +1,59 @@
+require 'erb'
+
+module Waffle
+  class PartialController
+
+    def initialize(delegate, locals = {})
+
+      def self.metaclass; class << self; self; end; end
+
+      delegate.instance_variables.each do |key|
+        self.instance_variable_set(key, delegate.instance_variable_get(key))
+      end
+
+      # Add locals to virtual class
+      unless locals.empty?
+        locals.keys.each do |key|
+          metaclass.send(:attr_reader, key)
+        end
+
+        locals.each_pair do |key, value|
+          self.instance_variable_set("@#{key}", value)
+        end
+      end
+
+    end
+  end
+end
+
+class ERB
+
+  module Util
+
+    #
+    # renders partial page (rhtml).
+    #
+    # This will be mixed in to ruby based Waffle Controllers
+    #
+    def partial(file_name, locals = {})
+      controller = Waffle::PartialController.new(self, locals)
+
+      # Locate full path to template (*.rhtml)
+      path = Waffle::ScriptLoader.locate_template(file_name)
+
+      return "File Not Found: Unable to render file '#{path}'." unless File.exist?(path)
+
+
+      # TODO can't we just call open() ??
+      template = ''
+      File.open(path).each { |line| template << line }
+
+      erb = ERB.new(template)
+      return erb.result(controller.send(:binding))
+    end
+
+    module_function :partial
+
+  end
+  
+end

Property changes: trunk/waffle-ruby/src/main/ruby/org/codehaus/waffle/waffle_erb.rb

Name: svn:mergeinfo
   + 

Deleted: trunk/waffle-ruby/src/test/ruby/org/codehaus/waffle/servlet/erb_extension_spec.rb (811 => 812)

--- trunk/waffle-ruby/src/test/ruby/org/codehaus/waffle/servlet/erb_extension_spec.rb	2008-09-04 08:07:35 UTC (rev 811)
+++ trunk/waffle-ruby/src/test/ruby/org/codehaus/waffle/servlet/erb_extension_spec.rb	2008-09-04 08:27:29 UTC (rev 812)
@@ -1,68 +0,0 @@
-require 'erb'
-require 'org/codehaus/waffle/waffle'
-require 'org/codehaus/waffle/erb_extension'
-require 'ostruct'
-
-
-describe Waffle::PartialController do
-
-  it "should expose locals as readable attributes" do
-    controller = Waffle::PartialController.new(Object.new, {:foo => 'bar', :hello => 'world'})
-
-    controller.foo.should == 'bar'
-    controller.hello.should == 'world'
-
-    # Ensuring attributes do not propogate to subsequent instances
-    other = Waffle::PartialController.new(Object.new)
-    other.should_not respond_to(:foo)
-    other.should_not respond_to(:bar)
-  end
-
-  it "should define the same instance variables as the provided delegate controller" do
-    delegate = Object.new
-    delegate.instance_variable_set("@foo", 54)
-    delegate.instance_variable_set("@bar", 99)
-
-    controller = Waffle::PartialController.new(delegate)
-    controller.instance_variables.should include("@foo")
-    controller.instance_variables.should include("@bar")
-
-    controller.instance_variable_get("@foo").should == 54
-    controller.instance_variable_get("@bar").should == 99
-  end
-
-end
-
-describe ERB::Util, "partial method" do
-
-  class FakeController
-    include ERB::Util  # Mix-in what's under test
-
-    attr :name
-
-    def initialize
-      @name = 'waffle'
-    end
-  end
-
-  it "should locate file and render through ERB" do
-    controller = FakeController.new
-
-    File.should_receive(:exist?).with('file path').and_return(true)
-    Waffle::ScriptLoader.should_receive(:locate_template).with('file name').and_return("file path")
-    File.should_receive(:open).with('file path').and_return([%{Name: <[EMAIL PROTECTED]> Foo: <%=foo%>}])
-
-    response = controller.send(:partial, 'file name', {:foo => 'bar'})
-    response.should == "Name: waffle Foo: bar"
-  end
-
-  it "should gracefully handle file does not exist" do
-    controller = FakeController.new
-
-    Waffle::ScriptLoader.should_receive(:locate_template).with('bad_file.rhtml').and_return("bad file path")
-
-    response = controller.send(:partial, "bad_file.rhtml")
-    response.should == %Q{File Not Found: Unable to render file 'bad file path'.}
-  end
-
-end
\ No newline at end of file

Copied: trunk/waffle-ruby/src/test/ruby/org/codehaus/waffle/servlet/waffle_erb_spec.rb (from rev 810, trunk/waffle-ruby/src/test/ruby/org/codehaus/waffle/servlet/erb_extension_spec.rb) (0 => 812)

--- trunk/waffle-ruby/src/test/ruby/org/codehaus/waffle/servlet/waffle_erb_spec.rb	                        (rev 0)
+++ trunk/waffle-ruby/src/test/ruby/org/codehaus/waffle/servlet/waffle_erb_spec.rb	2008-09-04 08:27:29 UTC (rev 812)
@@ -0,0 +1,68 @@
+require 'erb'
+require 'org/codehaus/waffle/waffle'
+require 'org/codehaus/waffle/waffle_erb'
+require 'ostruct'
+
+
+describe Waffle::PartialController do
+
+  it "should expose locals as readable attributes" do
+    controller = Waffle::PartialController.new(Object.new, {:foo => 'bar', :hello => 'world'})
+
+    controller.foo.should == 'bar'
+    controller.hello.should == 'world'
+
+    # Ensuring attributes do not propogate to subsequent instances
+    other = Waffle::PartialController.new(Object.new)
+    other.should_not respond_to(:foo)
+    other.should_not respond_to(:bar)
+  end
+
+  it "should define the same instance variables as the provided delegate controller" do
+    delegate = Object.new
+    delegate.instance_variable_set("@foo", 54)
+    delegate.instance_variable_set("@bar", 99)
+
+    controller = Waffle::PartialController.new(delegate)
+    controller.instance_variables.should include("@foo")
+    controller.instance_variables.should include("@bar")
+
+    controller.instance_variable_get("@foo").should == 54
+    controller.instance_variable_get("@bar").should == 99
+  end
+
+end
+
+describe ERB::Util, "partial method" do
+
+  class FakeController
+    include ERB::Util  # Mix-in what's under test
+
+    attr :name
+
+    def initialize
+      @name = 'waffle'
+    end
+  end
+
+  it "should locate file and render through ERB" do
+    controller = FakeController.new
+
+    File.should_receive(:exist?).with('file path').and_return(true)
+    Waffle::ScriptLoader.should_receive(:locate_template).with('file name').and_return("file path")
+    File.should_receive(:open).with('file path').and_return([%{Name: <[EMAIL PROTECTED]> Foo: <%=foo%>}])
+
+    response = controller.send(:partial, 'file name', {:foo => 'bar'})
+    response.should == "Name: waffle Foo: bar"
+  end
+
+  it "should gracefully handle file does not exist" do
+    controller = FakeController.new
+
+    Waffle::ScriptLoader.should_receive(:locate_template).with('bad_file.rhtml').and_return("bad file path")
+
+    response = controller.send(:partial, "bad_file.rhtml")
+    response.should == %Q{File Not Found: Unable to render file 'bad file path'.}
+  end
+
+end
\ No newline at end of file

Property changes: trunk/waffle-ruby/src/test/ruby/org/codehaus/waffle/servlet/waffle_erb_spec.rb

Name: svn:mergeinfo
   + 


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to