Permalink
Browse files

Refactoring - removed unnecessary classes, I think.

  • Loading branch information...
1 parent d3e7059 commit d4e81afc37a3686512d6fd3ee2b8c8ccbffe36f8 @gilesbowkett committed Oct 2, 2008
Showing with 14 additions and 6 deletions.
  1. 0 lib/{view.erb → console.erb}
  2. +1 −0 lib/text.erb
  3. +5 −4 lib/towelie.rb
  4. +6 −0 lib/view.rb
  5. +1 −1 spec/erb_spec.rb
  6. +1 −1 spec/towelie_spec.rb
File renamed without changes.
View
@@ -0,0 +1 @@
+<%= to_ruby(nodes) %>
View
@@ -18,12 +18,13 @@
class Towelie
def initialize(view_format)
@model = Model.new
- @view = case view_format
+ template = case view_format
when :text
- TextView.new
- when :erb
- ErbView.new
+ "text.erb"
+ when :console
+ "console.erb"
end
+ @view = View.new(template)
end
delegate_thru_model :parse, :duplication?, :method_definitions
delegate_thru_view :duplicated, :unique, :homonyms, :diff
View
@@ -1,7 +1,13 @@
class View
+ def initialize(template_name)
+ @template_name = template_name
+ end
def to_ruby(nodes)
nodes.inject("") do |string, node|
string += Ruby2Ruby.new.process(node) + "\n\n"
end
end
+ def render(nodes)
+ ERB.new(File.read("#{File.dirname(__FILE__) + "/" + @template_name}")).result(binding)
+ end
end
View
@@ -2,7 +2,7 @@
describe Towelie do
before(:each) do
- @towelie = Towelie.new(:erb)
+ @towelie = Towelie.new(:console)
end
before(:all) do
@the_nodes = [
@@ -2,7 +2,7 @@
describe Towelie do
before(:each) do
- @towelie = Towelie.new(:erb)
+ @towelie = Towelie.new(:text)
end
before(:all) do
@the_nodes = [

0 comments on commit d4e81af

Please sign in to comment.