diff_parser 1.2.0 → 1.3.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 +8 -8
- data/lib/diff_parser/diff_files_collection.rb +18 -1
- data/lib/diff_parser/file.rb +9 -10
- data/lib/diff_parser/version.rb +1 -1
- data/lib/diff_parser.rb +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjAwOWVhZjIzMzExNDMxZDEyM2M2ZDBkYjU4ZWRmNmIwMjBkYTVmOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDAzNWVkYTIzYjE1YTJlNWRiZTg5M2Y5YjdjOTg1ODQ5ZWQxM2E5Yg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzA0YTQ0YjAzNmJjODBlNjk3ZDgzMjM5NWQ3YTk2ZjBjYmQ2MzQyNTAzZDIz
|
10
|
+
ZjBmMWI0Yzk3ZjUxMzk2ZDFmODRhZTdjM2NiYThhZmY2OWIxYjcyOTg1ZTdi
|
11
|
+
YjM4NjcyMjEwMWFhNzYxOWZiZDQ2M2VlYTVkYjkyNzdkYjgxYzA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTUzOTUyMWIwOGViMjhmY2MzMTllNTZlY2QwNTUxMmJiNTQxNWJmMjM3OWRk
|
14
|
+
YTE4ZmQ0MjRhYWVmMmJiZTM2OWVhYzQwYzhkZjJjY2IwMDgzNTQ0ZjMzYzJk
|
15
|
+
OTg5NGFiNmEyOWRhYmJlYWRjODI5OWY5ZWE3NmE4ZWExOWJlYjY=
|
@@ -22,12 +22,29 @@ module DiffParser
|
|
22
22
|
if raw_line.info?
|
23
23
|
yield current_file if current_file
|
24
24
|
current_file = DiffParser::File.new(raw_line.full_line, diff)
|
25
|
-
elsif
|
25
|
+
elsif fold_file?(current_file)
|
26
|
+
if options[:full] == current_file.path || options[:full] == true
|
27
|
+
current_file.push_line(raw_line, idx)
|
28
|
+
else
|
29
|
+
current_file.folded!
|
30
|
+
current_file.lines.empty? and (current_file.lines = [DiffLine.new(current_file.path, 'fold', nil, nil, 0, nil)])
|
31
|
+
end
|
32
|
+
else
|
26
33
|
current_file.push_line(raw_line, idx)
|
27
34
|
end
|
28
35
|
end
|
29
36
|
|
30
37
|
yield current_file
|
31
38
|
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def fold_file?(file)
|
43
|
+
file.file_max_changes_exceeded? || diff_size_exceeded?
|
44
|
+
end
|
45
|
+
|
46
|
+
def diff_size_exceeded?
|
47
|
+
diff.raw.bytesize > DiffParser.max_unfolded_diff_size
|
48
|
+
end
|
32
49
|
end
|
33
50
|
end
|
data/lib/diff_parser/file.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module DiffParser
|
2
2
|
class File
|
3
|
-
attr_accessor :line_old, :line_new
|
4
|
-
attr_reader :
|
3
|
+
attr_accessor :line_old, :line_new, :lines
|
4
|
+
attr_reader :path, :file_info, :diff
|
5
5
|
delegate :additions, :deletions, to: :file_info
|
6
6
|
|
7
7
|
def initialize(path, diff)
|
@@ -39,21 +39,20 @@ module DiffParser
|
|
39
39
|
diff.sha
|
40
40
|
end
|
41
41
|
|
42
|
-
def folded
|
43
|
-
@folded
|
44
|
-
lines << DiffLine.new(path, 'fold', nil, nil, 0, nil)
|
45
|
-
true
|
46
|
-
else
|
47
|
-
false
|
48
|
-
end
|
42
|
+
def folded!
|
43
|
+
@folded = true
|
49
44
|
end
|
50
45
|
|
51
|
-
|
46
|
+
def folded?
|
47
|
+
!!@folded
|
48
|
+
end
|
52
49
|
|
53
50
|
def file_max_changes_exceeded?
|
54
51
|
!file_info || (file_info.changes > DiffParser.max_changes_to_render)
|
55
52
|
end
|
56
53
|
|
54
|
+
private
|
55
|
+
|
57
56
|
def preprocess_path(path)
|
58
57
|
path.split(' ').last[2..-1]
|
59
58
|
end
|
data/lib/diff_parser/version.rb
CHANGED
data/lib/diff_parser.rb
CHANGED