unified_diff 0.3.5 → 0.3.6
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 +4 -4
- data/Gemfile.lock +37 -26
- data/VERSION +1 -1
- data/lib/unified_diff/diff.rb +2 -2
- data/test/test_chunk.rb +1 -1
- data/test/test_unified_diff.rb +49 -6
- data/unified_diff.gemspec +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c097d48e44a0fe16367b5522145d280ccf3772c
|
4
|
+
data.tar.gz: d3d26d208a1d2941595137c4ec2356f53f863e88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74b9087bf68d10c2c7e1c7d8a8a10b1b416ffed7d0e846481d4f902846e04d1f2b4da6d8ee798e0cac85807bed7398d58117b33c8e1ffa1d27d051d1dad37c36
|
7
|
+
data.tar.gz: 8f17bc3572c9fbd896aa45e69b3d8be26eb4c5411cb424a11b9fe78a9fa45fd43032300f6a14cb119a3d6d782805d308c7d5a2889e6e4388a8e6afa227c97bf2
|
data/Gemfile.lock
CHANGED
@@ -1,19 +1,23 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
addressable (2.3.
|
4
|
+
addressable (2.3.6)
|
5
5
|
builder (3.2.2)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
descendants_tracker (0.0.4)
|
7
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
8
|
+
docile (1.1.5)
|
9
|
+
faraday (0.9.0)
|
10
|
+
multipart-post (>= 1.2, < 3)
|
11
|
+
git (1.2.8)
|
12
|
+
github_api (0.12.0)
|
13
|
+
addressable (~> 2.3)
|
14
|
+
descendants_tracker (~> 0.0.4)
|
15
|
+
faraday (~> 0.8, < 0.10)
|
16
|
+
hashie (>= 3.2)
|
17
|
+
multi_json (>= 1.7.5, < 2.0)
|
18
|
+
nokogiri (~> 1.6.3)
|
19
|
+
oauth2
|
20
|
+
hashie (3.2.0)
|
17
21
|
highline (1.6.21)
|
18
22
|
jeweler (2.0.1)
|
19
23
|
builder
|
@@ -25,23 +29,30 @@ GEM
|
|
25
29
|
rake
|
26
30
|
rdoc
|
27
31
|
json (1.8.1)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
jwt (1.0.0)
|
33
|
+
mini_portile (0.6.0)
|
34
|
+
minitest (5.4.0)
|
35
|
+
multi_json (1.10.1)
|
36
|
+
multi_xml (0.5.5)
|
37
|
+
multipart-post (2.0.0)
|
38
|
+
nokogiri (1.6.3.1)
|
39
|
+
mini_portile (= 0.6.0)
|
40
|
+
oauth2 (1.0.0)
|
41
|
+
faraday (>= 0.8, < 0.10)
|
42
|
+
jwt (~> 1.0)
|
43
|
+
multi_json (~> 1.3)
|
44
|
+
multi_xml (~> 0.5)
|
45
|
+
rack (~> 1.2)
|
37
46
|
rack (1.5.2)
|
38
|
-
rake (10.
|
47
|
+
rake (10.3.2)
|
39
48
|
rdoc (4.1.1)
|
40
49
|
json (~> 1.4)
|
41
|
-
simplecov (0.
|
42
|
-
|
43
|
-
|
44
|
-
|
50
|
+
simplecov (0.9.0)
|
51
|
+
docile (~> 1.1.0)
|
52
|
+
multi_json
|
53
|
+
simplecov-html (~> 0.8.0)
|
54
|
+
simplecov-html (0.8.0)
|
55
|
+
thread_safe (0.3.4)
|
45
56
|
|
46
57
|
PLATFORMS
|
47
58
|
ruby
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.6
|
data/lib/unified_diff/diff.rb
CHANGED
@@ -5,8 +5,8 @@ module UnifiedDiff
|
|
5
5
|
class UnifiedDiffException < Exception; end
|
6
6
|
|
7
7
|
FILE_PATTERN = /([^\t\n]+)(?:\t'{2}?([^']+)'{2}?)?/
|
8
|
-
OLD_FILE_PATTERN =
|
9
|
-
NEW_FILE_PATTERN =
|
8
|
+
OLD_FILE_PATTERN = /^--- #{FILE_PATTERN}/
|
9
|
+
NEW_FILE_PATTERN = /^\+\+\+ #{FILE_PATTERN}/
|
10
10
|
# Match assignment is tricky for CHUNK_PATTERN
|
11
11
|
# $1 and $3 are static, but $2 and $4 can be nil
|
12
12
|
#
|
data/test/test_chunk.rb
CHANGED
data/test/test_unified_diff.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
class TestUnifiedDiff <
|
3
|
+
class TestUnifiedDiff < Minitest::Test
|
4
4
|
def setup
|
5
5
|
@original = <<-DIFF.unindent
|
6
6
|
--- original.txt 2011-05-31 11:14:13.000000000 -0500
|
@@ -147,7 +147,7 @@ class TestUnifiedDiff < MiniTest::Unit::TestCase
|
|
147
147
|
# containing one line:
|
148
148
|
# foo
|
149
149
|
#
|
150
|
-
# and
|
150
|
+
# and
|
151
151
|
# odd_line_modified
|
152
152
|
# containing five lines:
|
153
153
|
# foo
|
@@ -178,7 +178,7 @@ class TestUnifiedDiff < MiniTest::Unit::TestCase
|
|
178
178
|
# Hand modified git diff -U of this file to create this diff.
|
179
179
|
# The git version of unified does not have a timestamp after
|
180
180
|
# the filename.
|
181
|
-
#
|
181
|
+
#
|
182
182
|
# The lines:
|
183
183
|
# --- a/test/test_unified_diff.rb 2012-09-06 16:56:08.320483113 -0400
|
184
184
|
# +++ b/test/test_unified_diff.rb 2012-09-06 16:56:44.488483939 -0400
|
@@ -189,7 +189,7 @@ class TestUnifiedDiff < MiniTest::Unit::TestCase
|
|
189
189
|
diff = <<-DIFF.unindent
|
190
190
|
--- a/test/test_unified_diff.rb 2012-09-06 16:56:08.320483113 -0400
|
191
191
|
+++ b/test/test_unified_diff.rb 2012-09-06 16:56:44.488483939 -0400
|
192
|
-
@@ -5,7 +5,7 @@ class TestUnifiedDiff <
|
192
|
+
@@ -5,7 +5,7 @@ class TestUnifiedDiff < Minitest::Test
|
193
193
|
@original = <<-DIFF.unindent
|
194
194
|
--- original.txt 2011-05-31 11:14:13.000000000 -0500
|
195
195
|
+++ modified.txt 2011-05-31 11:14:44.000000000 -0500
|
@@ -207,8 +207,8 @@ class TestUnifiedDiff < MiniTest::Unit::TestCase
|
|
207
207
|
|
208
208
|
def test_no_newline_at_eof
|
209
209
|
header = <<-HEADER.unindent
|
210
|
-
--- a
|
211
|
-
+++ b
|
210
|
+
--- a 2014-02-26 16:19:13.000000000 -0800
|
211
|
+
+++ b 2014-02-26 16:19:13.000000000 -0800
|
212
212
|
HEADER
|
213
213
|
|
214
214
|
chunk = <<-'CHUNK'.unindent
|
@@ -225,4 +225,47 @@ class TestUnifiedDiff < MiniTest::Unit::TestCase
|
|
225
225
|
assert_equal ["noel"], @chunk.original_lines
|
226
226
|
assert_equal ["noll"], @chunk.modified_lines
|
227
227
|
end
|
228
|
+
|
229
|
+
def test_pluses
|
230
|
+
header = <<-HEADER.unindent
|
231
|
+
--- a 2014-07-26 21:44:41.068596411 -0700
|
232
|
+
+++ b 2014-08-03 05:18:34.411245070 -0700
|
233
|
+
HEADER
|
234
|
+
|
235
|
+
chunk = <<-'CHUNK'.unindent
|
236
|
+
@@ -0,0 +1,5 @@
|
237
|
+
++++++++ ++++++ +++
|
238
|
+
++ some heading
|
239
|
+
+ stuff +++++++++ stuff
|
240
|
+
++++ a
|
241
|
+
+some body
|
242
|
+
CHUNK
|
243
|
+
|
244
|
+
@diff = UnifiedDiff.parse(header + chunk)
|
245
|
+
@chunk = @diff.chunks.first
|
246
|
+
assert_equal chunk, @chunk.to_s
|
247
|
+
assert_equal 5, @chunk.added_lines.length
|
248
|
+
end
|
249
|
+
|
250
|
+
def test_hyphens
|
251
|
+
header = <<-HEADER.unindent
|
252
|
+
--- a 2014-07-26 21:44:41.068596411 -0700
|
253
|
+
+++ b 2014-08-03 05:18:34.411245070 -0700
|
254
|
+
HEADER
|
255
|
+
|
256
|
+
chunk = <<-'CHUNK'.unindent
|
257
|
+
@@ -1,5 +0,0 @@
|
258
|
+
-------- ------ ---
|
259
|
+
-- some heading
|
260
|
+
- stuff --------- stuff
|
261
|
+
---- a
|
262
|
+
-some body
|
263
|
+
CHUNK
|
264
|
+
|
265
|
+
@diff = UnifiedDiff.parse(header + chunk)
|
266
|
+
@chunk = @diff.chunks.first
|
267
|
+
assert_equal chunk, @chunk.to_s
|
268
|
+
assert_equal 5, @chunk.removed_lines.length
|
269
|
+
end
|
270
|
+
|
228
271
|
end
|
data/unified_diff.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: unified_diff 0.3.
|
5
|
+
# stub: unified_diff 0.3.6 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "unified_diff"
|
9
|
-
s.version = "0.3.
|
9
|
+
s.version = "0.3.6"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|