Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Got rid of a hash which I had created for no good reason. It should b…

…e an array. And now it is.
  • Loading branch information...
commit 7dfc054c31b7ab98f7d180a7a39064c2c9c9101f 1 parent f6ad2db
@gilesbowkett authored
Showing with 18 additions and 2 deletions.
  1. +18 −2 lib/towelie.rb
View
20 lib/towelie.rb
@@ -4,6 +4,9 @@
require 'ruby2ruby'
module Towelie
+
+ # model
+
def files(dir)
# Find supplies no #inject
accumulator = []
@@ -14,8 +17,8 @@ def files(dir)
accumulator
end
def parse(dir)
- @nodes = files(dir).inject({}) do |hash, filename|
- hash[filename] = ParseTree.translate File.read(filename) ; hash
+ @nodes = files(dir).inject([]) do |array, filename|
+ array << (ParseTree.translate File.read(filename)) ; array
end
end
def method_definitions(accumulator = [], nodes = @nodes)
@@ -39,6 +42,9 @@ def body
end
accumulator
end
+
+ # controller
+
def duplication?(dir)
parse dir
method_definitions.uniq != method_definitions
@@ -74,6 +80,9 @@ def diff(threshold)
end
diff_nodes.values
end
+
+ # view
+
def to_ruby(nodes)
nodes.inject("") do |string, node|
string += Ruby2Ruby.new.process(node) + "\n\n"
@@ -85,3 +94,10 @@ def to_ruby(nodes)
# loads it) on init. also a new Ruby2Ruby might belong in the initializer, who knows.
# ironically, Towelie itself is very not-DRY. lots of "parse dir".
+
+# one thing I've been doing consistently is parsing the dir and collecting the method definitions.
+# further, everything here assumes that this has happened. therefore! I think A) I should write some
+# code which *ensures* it always happens and B) I think I should incorporate method definition
+# collecting into the process where I loop through filenames. the reason, of course, is that it
+# allows me to trivially collect filenames in the process, and thereby obtain at least the most
+# basic metadata.
Please sign in to comment.
Something went wrong with that request. Please try again.