git_diff_parser 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66baab1ba43527942ed9004cd7cd96f7dcf9b623
4
- data.tar.gz: b9fa9ae68e2127893ad841e36878e638ede4ec69
3
+ metadata.gz: e4af9131c4db9ebdd3a1cbaa4fdf26878478084b
4
+ data.tar.gz: a40e0b9f059e20ae87c56c2a05906e999722ec66
5
5
  SHA512:
6
- metadata.gz: 68999876ead0318ec17f62ed25fa360a3f515da7c89f754758cee546c9ccf5d2ee318a255ae1a9eafb391e33624078b64fc28eeb06d91c12c1c13b3b6db09a73
7
- data.tar.gz: 65a699e04f34385ee211e11864a3f296d0d313a2c50e0242fdb117c93414b563f73048899b9468c0b2275bedd3791e6d8edc8bf92bb317fb6529515912c4f0fe
6
+ metadata.gz: 95e802b34f9db8b38fe2b37172e11955fa294a03ea69057f61b6d319f9ac1666822275e518f1f7114e8f16e72a3a56798fa26c025feb2fe6e7691b9408a44543
7
+ data.tar.gz: 51a24c8dd8fe91779d84ca7298155a3114416fc5a844c5cc7bf4c88e59454facc10e7708e9307fe9331700ed712da71820736238e1dbd50b8250f4563dce9339
@@ -1,3 +1,11 @@
1
+ <a name="3.1.0"></a>
2
+ # [3.1.0](https://github.com/packsaddle/ruby-git_diff_parser/compare/v3.0.0...v3.1.0) (2017-07-05)
3
+
4
+ ### Features
5
+
6
+ * **patch:** Added Patch#removed_lines method ([9acc263](https://github.com/packsaddle/ruby-git_diff_parser/commit/9acc263))
7
+
8
+
1
9
  <a name="3.0.0"></a>
2
10
  # [3.0.0](https://github.com/packsaddle/ruby-git_diff_parser/compare/v2.3.0...v3.0.0) (2017-06-22)
3
11
 
@@ -3,6 +3,7 @@ module GitDiffParser
3
3
  class Patch
4
4
  RANGE_INFORMATION_LINE = /^@@ .+\+(?<line_number>\d+),/
5
5
  MODIFIED_LINE = /^\+(?!\+|\+)/
6
+ REMOVED_LINE = /^[-]/
6
7
  NOT_REMOVED_LINE = /^[^-]/
7
8
 
8
9
  attr_accessor :file, :body, :secure_hash
@@ -76,6 +77,28 @@ module GitDiffParser
76
77
  end
77
78
  end
78
79
 
80
+ # @return [Array<Line>] removed lines
81
+ def removed_lines
82
+ line_number = 0
83
+
84
+ lines.each_with_index.inject([]) do |lines, (content, patch_position)|
85
+ case content
86
+ when RANGE_INFORMATION_LINE
87
+ line_number = Regexp.last_match[:line_number].to_i
88
+ when REMOVED_LINE
89
+ line = Line.new(
90
+ content: content,
91
+ number: line_number,
92
+ patch_position: patch_position
93
+ )
94
+ lines << line
95
+ line_number += 1
96
+ end
97
+
98
+ lines
99
+ end
100
+ end
101
+
79
102
  # @return [Array<Integer>] changed line numbers
80
103
  def changed_line_numbers
81
104
  changed_lines.map(&:number)
@@ -1,3 +1,3 @@
1
1
  module GitDiffParser
2
- VERSION = '3.0.0'.freeze
2
+ VERSION = '3.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_diff_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sanemat
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-22 00:00:00.000000000 Z
11
+ date: 2017-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler