unified_diff 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/unified_diff/chunk.rb +21 -3
- data/test/test_chunk.rb +12 -0
- data/unified_diff.gemspec +1 -1
- metadata +8 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/unified_diff/chunk.rb
CHANGED
@@ -12,22 +12,40 @@ module UnifiedDiff
|
|
12
12
|
@raw_lines = []
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
|
16
|
+
# Return an array of lines that were removed from the original version of the chunk
|
17
|
+
#
|
18
|
+
# @return [Array] the lines that were removed from the original
|
19
|
+
def removed_lines
|
20
|
+
processed_lines_of_types('-')
|
21
|
+
end
|
22
|
+
|
23
|
+
# Return an array of lines that were added to the original version of the chunk
|
24
|
+
#
|
25
|
+
# @return [Array] the lines that were added to the original
|
26
|
+
def added_lines
|
27
|
+
processed_lines_of_types('+')
|
28
|
+
end
|
29
|
+
|
16
30
|
# Return an array of lines that are present in the modified version of the chunk
|
17
31
|
#
|
18
32
|
# @return [Array] the lines in the modified version of the chunk
|
19
33
|
def modified_lines
|
20
|
-
|
34
|
+
processed_lines_of_types(' ','+')
|
21
35
|
end
|
22
36
|
|
23
37
|
# Return an array of lines that are present in the original version of the chunk
|
24
38
|
#
|
25
39
|
# @return [Array] the lines in the original version of the chunk
|
26
40
|
def original_lines
|
27
|
-
|
41
|
+
processed_lines_of_types(' ','-')
|
28
42
|
end
|
29
43
|
|
30
44
|
private
|
45
|
+
def processed_lines_of_types(*types)
|
46
|
+
@raw_lines.select {|line| types.include?(line[0])}.map {|line| line[1..-1]}
|
47
|
+
end
|
48
|
+
|
31
49
|
# Insert a new addition line into the list of lines for this chunk
|
32
50
|
#
|
33
51
|
# @param [String] the line to be inserted (without '+' tag)
|
data/test/test_chunk.rb
CHANGED
@@ -30,4 +30,16 @@ class TestChunk < MiniTest::Unit::TestCase
|
|
30
30
|
@chunk.send(:insert_addition,"baz")
|
31
31
|
assert_equal %w{foo baz}, @chunk.modified_lines
|
32
32
|
end
|
33
|
+
|
34
|
+
def test_removed_lines
|
35
|
+
@chunk.send(:insert_removal,'foo')
|
36
|
+
@chunk.send(:insert_unchanged, 'bar')
|
37
|
+
assert_equal ['foo'], @chunk.removed_lines
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_added_lines
|
41
|
+
@chunk.send(:insert_addition,'foo')
|
42
|
+
@chunk.send(:insert_unchanged, 'bar')
|
43
|
+
assert_equal ['foo'], @chunk.added_lines
|
44
|
+
end
|
33
45
|
end
|
data/unified_diff.gemspec
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: unified_diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ryan Neufeld
|
@@ -14,7 +14,6 @@ date: 2011-06-01 00:00:00 Z
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: minitest
|
17
|
-
prerelease: false
|
18
17
|
requirement: &id001 !ruby/object:Gem::Requirement
|
19
18
|
none: false
|
20
19
|
requirements:
|
@@ -22,10 +21,10 @@ dependencies:
|
|
22
21
|
- !ruby/object:Gem::Version
|
23
22
|
version: "0"
|
24
23
|
type: :development
|
24
|
+
prerelease: false
|
25
25
|
version_requirements: *id001
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: bundler
|
28
|
-
prerelease: false
|
29
28
|
requirement: &id002 !ruby/object:Gem::Requirement
|
30
29
|
none: false
|
31
30
|
requirements:
|
@@ -33,10 +32,10 @@ dependencies:
|
|
33
32
|
- !ruby/object:Gem::Version
|
34
33
|
version: 1.0.0
|
35
34
|
type: :development
|
35
|
+
prerelease: false
|
36
36
|
version_requirements: *id002
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: jeweler
|
39
|
-
prerelease: false
|
40
39
|
requirement: &id003 !ruby/object:Gem::Requirement
|
41
40
|
none: false
|
42
41
|
requirements:
|
@@ -44,10 +43,10 @@ dependencies:
|
|
44
43
|
- !ruby/object:Gem::Version
|
45
44
|
version: 1.6.0
|
46
45
|
type: :development
|
46
|
+
prerelease: false
|
47
47
|
version_requirements: *id003
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: simplecov
|
50
|
-
prerelease: false
|
51
50
|
requirement: &id004 !ruby/object:Gem::Requirement
|
52
51
|
none: false
|
53
52
|
requirements:
|
@@ -55,6 +54,7 @@ dependencies:
|
|
55
54
|
- !ruby/object:Gem::Version
|
56
55
|
version: "0"
|
57
56
|
type: :development
|
57
|
+
prerelease: false
|
58
58
|
version_requirements: *id004
|
59
59
|
description: unified_diff parses unified diff contents into easy-to-use Ruby objects
|
60
60
|
email: ryan@ryanneufeld.ca
|
@@ -93,6 +93,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
+
hash: 4395814823410856938
|
97
|
+
segments:
|
98
|
+
- 0
|
96
99
|
version: "0"
|
97
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
101
|
none: false
|