Permalink
Browse files

simplified #changed_methods, #added_methods, and #removed_methods

  • Loading branch information...
michaelfeathers committed May 19, 2011
1 parent fbcc223 commit b3ffa52cb89e0a60f102f74c003c721d7b08802a
Showing with 14 additions and 6 deletions.
  1. +14 −6 delta.rb
View
@@ -9,18 +9,26 @@ def initialize events, first_commit, second_commit
end
def removed_methods
- @repository.methods.select { |m| m.events.count == 1 }
- .select { |m| m.events.first.commit == @first_commit }
+ methods_with_only @first_commit
end
def added_methods
- @repository.methods.select {|m| m.events.count == 1 }
- .select { |m| m.events.first.commit == @second_commit }
+ methods_with_only @second_commit
end
def changed_methods
- @repository.methods.select { |m| m.events.count == 2 }
- .select { |m| m.events[0].complexity != m.events[1].complexity }
+ methods_with_both_commits.select { |m| m.events[0].complexity != m.events[1].complexity }
+ end
+
+ private
+
+ def methods_with_only commit
+ @repository.methods.select { |m| m.events.count == 1 }
+ .select { |m| m.events.first.commit == commit }
+ end
+
+ def methods_with_both_commits
+ @repository.methods.select { |m| m.events.count == 2 }
end
end

0 comments on commit b3ffa52

Please sign in to comment.