Class: Policial::Patch
- Inherits:
-
Object
- Object
- Policial::Patch
- Defined in:
- lib/policial/patch.rb
Overview
Public: a chunk of changed code in a commit file.
Constant Summary collapse
- RANGE_INFORMATION_LINE =
/^@@ .+\+(?<line_number>\d+),/
- MODIFIED_LINE =
/^\+(?!\+|\+)/
- NOT_REMOVED_LINE =
/^[^-]/
Instance Method Summary collapse
- #changed_lines ⇒ Object
-
#initialize(body) ⇒ Patch
constructor
A new instance of Patch.
Constructor Details
#initialize(body) ⇒ Patch
Returns a new instance of Patch.
10 11 12 |
# File 'lib/policial/patch.rb', line 10 def initialize(body) @body = body || '' end |
Instance Method Details
#changed_lines ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/policial/patch.rb', line 14 def changed_lines line_number = 0 @body.lines.each_with_index.with_object([]) do |(line, patch_pos), lines| line_number = parse_line(line, line_number, patch_pos, lines) || line_number end end |