Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactoring.

  • Loading branch information...
commit b7b0a77668acaa9fe31e1a9acbdcef9f0e190e5b 1 parent 3e7dfcd
@gilesbowkett authored
View
0  lib/console.erb → lib/duplicates.erb
File renamed without changes
View
3  lib/node_analysis.rb
@@ -3,9 +3,6 @@ module NodeAnalysis
def duplication?
not duplicates.empty?
end
- def duplicated
- duplicates
- end
def duplicates
(@method_definitions.collect do |node|
node if @method_definitions.duplicates? node
View
1  lib/text.erb
@@ -1 +0,0 @@
-<%= to_ruby(nodes) %>
View
7 lib/towelie.rb
@@ -6,13 +6,14 @@
class Towelie
def initialize
@model = Model.new
- @view = View.new("console.erb")
+ @view = View.new
end
def parse(dir)
@model.parse(dir)
end
- delegate_thru_view :duplicated
def duplicates
- @view.render(:nodes => @model.duplicates, :unique_nodes => @model.duplicates.uniq)
+ @view.render(:template => "duplicates.erb",
+ :nodes => @model.duplicates,
+ :unique_nodes => @model.duplicates.uniq)
end
end
View
5 lib/view.rb
@@ -1,11 +1,8 @@
class View
- def initialize(template_name)
- @template_name = template_name
- end
def to_ruby(nodes)
Ruby2Ruby.new.process(nodes) + "\n"
end
def render(options = {})
- ERB.new(File.read("#{File.dirname(__FILE__) + "/" + @template_name}"), nil, ">").result(binding)
+ ERB.new(File.read("#{File.dirname(__FILE__) + "/" + options[:template]}"), nil, ">").result(binding)
end
end
View
4 spec/model_spec.rb
@@ -117,10 +117,10 @@
end
it "isolates duplicated blocks" do
@model.parse("spec/test_data")
- @model.duplicated.should == @duplicated_nodes
+ @model.duplicates.should == @duplicated_nodes
@model.parse("spec/classes_modules")
- @model.duplicated.should == @duplicated_nodes
+ @model.duplicates.should == @duplicated_nodes
end
it "reports unique code" do
@model.parse("spec/test_data")
Please sign in to comment.
Something went wrong with that request. Please try again.