Class: Devloop::DiffParser

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(diff) ⇒ Object



3
4
5
# File 'lib/devloop/diff_parser.rb', line 3

def self.call(diff)
  new.call(diff)
end

Instance Method Details

#call(diff) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/devloop/diff_parser.rb', line 7

def call(diff)
  lines = diff.split("\n")
  results = []
  file = ""
  lines.each_with_index do |line, index|
    if line.start_with?("+++ b/")
      file = line[6..-1]
    elsif line.start_with?("@@ -")
      line_number = line.match(/@@ -(\d+)/)[1]
      results << "#{file}:#{line_number}"
    end
  end
  results
end