forked from michaelfeathers/repodepot-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delta.rb
35 lines (26 loc) · 792 Bytes
/
delta.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module RepoDepot
class Delta
def initialize events, first_commit, second_commit
@repository = Repository.new('', events)
@first_commit = first_commit
@second_commit = second_commit
end
def removed_methods
methods_with_only @first_commit
end
def added_methods
methods_with_only @second_commit
end
def changed_methods
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
end