Class: Hunkify::Hunk
- Inherits:
-
Struct
- Object
- Struct
- Hunkify::Hunk
- Defined in:
- lib/hunkify/hunk.rb
Instance Attribute Summary collapse
-
#file_header ⇒ Object
Returns the value of attribute file_header.
-
#file_path ⇒ Object
Returns the value of attribute file_path.
-
#hunk_header ⇒ Object
Returns the value of attribute hunk_header.
-
#id ⇒ Object
Returns the value of attribute id.
-
#lines ⇒ Object
Returns the value of attribute lines.
Instance Method Summary collapse
Instance Attribute Details
#file_header ⇒ Object
Returns the value of attribute file_header
4 5 6 |
# File 'lib/hunkify/hunk.rb', line 4 def file_header @file_header end |
#file_path ⇒ Object
Returns the value of attribute file_path
4 5 6 |
# File 'lib/hunkify/hunk.rb', line 4 def file_path @file_path end |
#hunk_header ⇒ Object
Returns the value of attribute hunk_header
4 5 6 |
# File 'lib/hunkify/hunk.rb', line 4 def hunk_header @hunk_header end |
#id ⇒ Object
Returns the value of attribute id
4 5 6 |
# File 'lib/hunkify/hunk.rb', line 4 def id @id end |
#lines ⇒ Object
Returns the value of attribute lines
4 5 6 |
# File 'lib/hunkify/hunk.rb', line 4 def lines @lines end |
Instance Method Details
#to_patch ⇒ Object
5 6 7 8 9 |
# File 'lib/hunkify/hunk.rb', line 5 def to_patch body = lines.join("\n") body += "\n" unless body.end_with?("\n") "#{file_header}\n#{hunk_header}\n#{body}" end |
#to_summary ⇒ Object
11 12 13 14 15 16 |
# File 'lib/hunkify/hunk.rb', line 11 def to_summary added = lines.count { |l| l.start_with?("+") } removed = lines.count { |l| l.start_with?("-") } preview = lines.first(6).join("\n") "[HUNK #{id}] #{file_path} #{hunk_header}\n#{preview}\n(+#{added} / -#{removed} lines)" end |