Class: Finder

Inherits:
Object
  • Object
show all
Defined in:
lib/finder.rb

Class Method Summary collapse

Class Method Details

.parse(diff) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/finder.rb', line 12

def self.parse(diff)
  files = []

  diff.each do |f|
    name = f.path

    if f.type != 'modified'
      files << FileInfo.new(name, 0)
      next
    end

    lines = f.patch.split(/\n/).reject(&:empty?)

    count = 0
    lines[4..-1].each do |line|
      count += 1 if line.start_with?('-', '+')
    end

    files << FileInfo.new(name, count)
  end

  files = files.sort_by(&:changed_lines).reverse
  files.map(&:name)
end