Class: RuboCop::Git::DiffParser
- Inherits:
-
Object
- Object
- RuboCop::Git::DiffParser
- Defined in:
- lib/rubocop/git/diff_parser.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.parse(diff) ⇒ Object
5 6 7 |
# File 'lib/rubocop/git/diff_parser.rb', line 5 def parse(diff) new.parse(diff) end |
Instance Method Details
#parse(diff) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rubocop/git/diff_parser.rb', line 10 def parse(diff) files = [] in_patch = false diff.each_line do |line| case line when /^diff --git/ in_patch = false when %r{^\+{3} b/(?<path>[^\t\n\r]+)} files << PseudoResource.new(Regexp.last_match[:path]) when /^@@/ in_patch = true end files.last.patch << line if in_patch end files end |