diff_parser 0.0.3 → 0.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 +8 -8
- data/lib/diff_parser/diff_line.rb +30 -0
- data/lib/diff_parser/parser.rb +3 -2
- data/lib/diff_parser/version.rb +1 -1
- data/lib/diff_parser.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDdjZTY3MTBhOGIzNDdiMzc2MjI4YzdiOTQ3ZmFkMjEwMGI3ZWIxOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDI0MDUxNDhmMDBmN2U1YjE1OTcxMzJhZTJkNWE4NzQ5MTlhZWFkZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODVlM2Y3NDMwNWRmODMxNjM4MTJmNGZlNjE3MGVmODhmMGU1N2EwYzBhMzNk
|
10
|
+
YTlmYTFmODJjMTViYWQ0YmU5NmRmM2JhYTg0N2FjNzQwYWRhYjlhMjU2MjQ2
|
11
|
+
N2YxMmEwMjAzNWExZDE4MThlMTk2Yzg5NTA1ZTNiMjI4N2Y2OGQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjkyMTBlNjI0NmE3Yzk0NDgxMjI2YTljMTU2Nzg1YzAyNWUyMjFmNWQ0NTM4
|
14
|
+
YTQ2MjBmYzEwMTRhMGVkODE5NWE1YjUwYjQ3NDFmZmE5YmFmNDRlYmRlMGE4
|
15
|
+
MThkNTE3YmJhYzM4N2UyYTVmMjBlMWM5NzZjMTljNTc2Njg1MGI=
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module DiffParser
|
2
|
+
class DiffLine
|
3
|
+
CODE_TYPES = %w(old new default match)
|
4
|
+
|
5
|
+
attr_reader :raw_line, :type, :line_code, :line_new, :line_old
|
6
|
+
|
7
|
+
def initialize(raw_line, type, line_code, line_new, line_old)
|
8
|
+
@raw_line = if type.to_s == 'info'
|
9
|
+
raw_line.split(' ').last.tap do |_raw_line|
|
10
|
+
_raw_line[0] = ''
|
11
|
+
end
|
12
|
+
else
|
13
|
+
raw_line
|
14
|
+
end
|
15
|
+
|
16
|
+
@type = if type == 'old' and raw_line[0] != '-'
|
17
|
+
'default'
|
18
|
+
else
|
19
|
+
type
|
20
|
+
end
|
21
|
+
@line_code = line_code
|
22
|
+
@line_new = line_new
|
23
|
+
@line_old = line_old
|
24
|
+
end
|
25
|
+
|
26
|
+
def line_of_code?
|
27
|
+
CODE_TYPES.include?(type)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/diff_parser/parser.rb
CHANGED
@@ -43,13 +43,14 @@ module DiffParser
|
|
43
43
|
line_old = line.match(/\-[0-9]*/)[0].to_i.abs rescue 0
|
44
44
|
line_new = line.match(/\+[0-9]*/)[0].to_i.abs rescue 0
|
45
45
|
|
46
|
-
yield(full_line, type, nil, nil, nil)
|
46
|
+
yield(DiffLine.new(full_line, type, nil, nil, nil))
|
47
47
|
next
|
48
48
|
else
|
49
49
|
type = identification_type(line)
|
50
50
|
line_code = generate_line_code(new_path, line_new, line_old, type, idx)
|
51
51
|
next if ["index"].include? type
|
52
|
-
|
52
|
+
|
53
|
+
yield(DiffLine.new(full_line, type, line_code, line_new, line_old))
|
53
54
|
end
|
54
55
|
|
55
56
|
|
data/lib/diff_parser/version.rb
CHANGED
data/lib/diff_parser.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diff_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- stevo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Allows parsing diffs for presentation purposes - extracted from marvelous
|
14
14
|
GitLab project
|
@@ -19,6 +19,7 @@ extensions: []
|
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
21
|
- lib/diff_parser.rb
|
22
|
+
- lib/diff_parser/diff_line.rb
|
22
23
|
- lib/diff_parser/inline_diff.rb
|
23
24
|
- lib/diff_parser/parser.rb
|
24
25
|
- lib/diff_parser/regex.rb
|