unified_diff 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YTRlODc4Y2U4MWM2M2EwM2ZkMDFlNWNhZjBkZmM4NWE0ZjNlNDI0Mw==
5
+ data.tar.gz: !binary |-
6
+ Y2IyY2EzOTY1NjVlZDVhODRkMWVkOWQ4ZjZlOTIwYWZkMmIzZWExMA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ODk5MjgyMjQ1MzRlOTgwODcxNjM4ZWQ2YmRiYmIzMjMzMjcxZjg0MTRmMmI0
10
+ MDlkYmUwNDcyZGNmOTkzNjRmYWU3YTJlZjNhM2Q4NDRlMjNkMjliY2ZlNDI5
11
+ M2I5YmQ0N2NlNTEzMGE3ZjIyMjBjZjlhYjUzMTRiN2JlNTEwYTQ=
12
+ data.tar.gz: !binary |-
13
+ ZWQ0NGJiMzBkNDAyZTBhYWYxNDljYTNjZjlkNDQwNTViMTdkZDY0NjU4Y2Ux
14
+ ZGVhYTE1YTBiNjAxZWI5NzY3ODgzY2EzMzk2MGMxZjhlNDcxYmE0NWRjNmJm
15
+ MGIxMjIzMjA5MDY1ZTczY2M5YjA4Nzc3YTFiYzgzNDRhZGIxZDU=
data/Gemfile CHANGED
@@ -2,6 +2,6 @@ source "http://rubygems.org"
2
2
 
3
3
  group :development do
4
4
  gem 'minitest'
5
- gem "jeweler", "~> 1.6.0"
5
+ gem "jeweler", "~> 2.0.1"
6
6
  gem 'simplecov'
7
7
  end
data/Gemfile.lock CHANGED
@@ -1,14 +1,43 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- git (1.2.5)
5
- jeweler (1.6.4)
6
- bundler (~> 1.0)
4
+ addressable (2.3.5)
5
+ builder (3.2.2)
6
+ faraday (0.7.6)
7
+ addressable (~> 2.2)
8
+ multipart-post (~> 1.1)
9
+ rack (~> 1.1)
10
+ git (1.2.6)
11
+ github_api (0.4.10)
12
+ faraday (~> 0.7.6)
13
+ hashie (~> 1.2.0)
14
+ multi_json (~> 1.0)
15
+ oauth2 (~> 0.5.2)
16
+ hashie (1.2.0)
17
+ highline (1.6.21)
18
+ jeweler (2.0.1)
19
+ builder
20
+ bundler (>= 1.0)
7
21
  git (>= 1.2.5)
22
+ github_api
23
+ highline (>= 1.6.15)
24
+ nokogiri (>= 1.5.10)
8
25
  rake
26
+ rdoc
27
+ json (1.8.1)
28
+ mini_portile (0.5.2)
9
29
  minitest (3.4.0)
10
30
  multi_json (1.3.6)
11
- rake (0.9.2.2)
31
+ multipart-post (1.2.0)
32
+ nokogiri (1.6.1)
33
+ mini_portile (~> 0.5.0)
34
+ oauth2 (0.5.2)
35
+ faraday (~> 0.7)
36
+ multi_json (~> 1.0)
37
+ rack (1.5.2)
38
+ rake (10.1.1)
39
+ rdoc (4.1.1)
40
+ json (~> 1.4)
12
41
  simplecov (0.6.4)
13
42
  multi_json (~> 1.0)
14
43
  simplecov-html (~> 0.5.3)
@@ -18,6 +47,6 @@ PLATFORMS
18
47
  ruby
19
48
 
20
49
  DEPENDENCIES
21
- jeweler (~> 1.6.0)
50
+ jeweler (~> 2.0.1)
22
51
  minitest
23
52
  simplecov
data/Rakefile CHANGED
@@ -34,8 +34,8 @@ end
34
34
 
35
35
  task :default => :test
36
36
 
37
- require 'rake/rdoctask'
38
- Rake::RDocTask.new do |rdoc|
37
+ require 'rdoc/task'
38
+ RDoc::Task.new do |rdoc|
39
39
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
40
 
41
41
  rdoc.rdoc_dir = 'rdoc'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.3.4
@@ -58,7 +58,7 @@ module UnifiedDiff
58
58
  @raw_lines.select {|line| types.include?(line[0])}.map {|line| line[1..-1]}
59
59
  end
60
60
 
61
- # Insert a new addition line into the list of lines for this chunk
61
+ # Insert a new addition line into the list of lines for this chunk
62
62
  #
63
63
  # @param [String] the line to be inserted (without '+' tag)
64
64
  # @return [Array] the new list of raw lines
@@ -82,5 +82,16 @@ module UnifiedDiff
82
82
  @raw_lines << " #{line}"
83
83
  end
84
84
 
85
+ # Insert a no newline at end of file line into the list of lines for this
86
+ # chunk
87
+ #
88
+ # http://www.gnu.org/software/diffutils/manual/html_node/Incomplete-Lines.html
89
+ #
90
+ # @param [String] the line to be inserted (without '\' tag)
91
+ # @return [Array] the new list of raw lines
92
+ def insert_no_newline_at_eof(line)
93
+ @raw_lines << "\\#{line}"
94
+ end
95
+
85
96
  end
86
97
  end
@@ -24,6 +24,7 @@ module UnifiedDiff
24
24
  ADDED_PATTERN = /^\+(.*)/
25
25
  REMOVED_PATTERN = /^-(.*)/
26
26
  UNCHANGED_PATTERN = /^ (.*)/
27
+ NO_NEWLINE_PATTERN = /^\\(\s+No\s+newline\s+at\s+end\s+of\s+file)$/
27
28
 
28
29
  # Create and parse a unified diff
29
30
  #
@@ -74,6 +75,8 @@ module UnifiedDiff
74
75
  @working_chunk.send(:insert_removal, $1)
75
76
  when UNCHANGED_PATTERN
76
77
  @working_chunk.send(:insert_unchanged, $1)
78
+ when NO_NEWLINE_PATTERN
79
+ @working_chunk.send(:insert_no_newline_at_eof, $1)
77
80
  else
78
81
  raise UnifiedDiffException.new("Unknown Line Type for Line:\n#{line}")
79
82
  end
data/test/test_chunk.rb CHANGED
@@ -14,13 +14,15 @@ class TestChunk < MiniTest::Unit::TestCase
14
14
  @chunk.send(:insert_unchanged,"foo")
15
15
  @chunk.send(:insert_addition, "bar")
16
16
  @chunk.send(:insert_removal, "baz")
17
- assert_equal [" foo","+bar","-baz"], @chunk.raw_lines
17
+ @chunk.send(:insert_no_newline_at_eof, "noel")
18
+ assert_equal [" foo","+bar","-baz", "\\noel"], @chunk.raw_lines
18
19
  end
19
20
 
20
21
  def test_original_lines
21
22
  @chunk.send(:insert_unchanged,"foo")
22
23
  @chunk.send(:insert_removal,"bar")
23
24
  @chunk.send(:insert_addition,"baz")
25
+ @chunk.send(:insert_no_newline_at_eof, "noel")
24
26
  assert_equal %w{foo bar}, @chunk.original_lines
25
27
  end
26
28
 
@@ -28,18 +30,21 @@ class TestChunk < MiniTest::Unit::TestCase
28
30
  @chunk.send(:insert_unchanged,"foo")
29
31
  @chunk.send(:insert_removal,"bar")
30
32
  @chunk.send(:insert_addition,"baz")
33
+ @chunk.send(:insert_no_newline_at_eof, "noel")
31
34
  assert_equal %w{foo baz}, @chunk.modified_lines
32
35
  end
33
36
 
34
37
  def test_removed_lines
35
38
  @chunk.send(:insert_removal,'foo')
36
39
  @chunk.send(:insert_unchanged, 'bar')
40
+ @chunk.send(:insert_no_newline_at_eof, "noel")
37
41
  assert_equal ['foo'], @chunk.removed_lines
38
42
  end
39
43
 
40
44
  def test_added_lines
41
45
  @chunk.send(:insert_addition,'foo')
42
46
  @chunk.send(:insert_unchanged, 'bar')
47
+ @chunk.send(:insert_no_newline_at_eof, "noel")
43
48
  assert_equal ['foo'], @chunk.added_lines
44
49
  end
45
50
 
@@ -204,4 +204,25 @@ class TestUnifiedDiff < MiniTest::Unit::TestCase
204
204
  assert_equal (5...12), @chunk.original_range
205
205
  assert_equal (5...12), @chunk.modified_range
206
206
  end
207
+
208
+ def test_no_newline_at_eof
209
+ header = <<-HEADER.unindent
210
+ --- a 2014-02-26 16:19:13.000000000 -0800
211
+ +++ b 2014-02-26 16:19:13.000000000 -0800
212
+ HEADER
213
+
214
+ chunk = <<-'CHUNK'.unindent
215
+ @@ -1,1 +1,1 @@
216
+ -noel
217
+
218
+ +noll
219
+
220
+ CHUNK
221
+
222
+ @diff = UnifiedDiff.parse(header + chunk)
223
+ @chunk = @diff.chunks.first
224
+ assert_equal chunk, @chunk.to_s
225
+ assert_equal ["noel"], @chunk.original_lines
226
+ assert_equal ["noll"], @chunk.modified_lines
227
+ end
207
228
  end
data/unified_diff.gemspec CHANGED
@@ -2,14 +2,16 @@
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.4 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "unified_diff"
8
- s.version = "0.3.3"
9
+ s.version = "0.3.4"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["Ryan Neufeld"]
12
- s.date = "2013-04-16"
14
+ s.date = "2014-03-12"
13
15
  s.description = "unified_diff parses unified diff contents into easy-to-use Ruby objects"
14
16
  s.email = "ryan@ryanneufeld.ca"
15
17
  s.extra_rdoc_files = [
@@ -34,25 +36,24 @@ Gem::Specification.new do |s|
34
36
  ]
35
37
  s.homepage = "http://github.com/rkneufeld/unified_diff"
36
38
  s.licenses = ["MIT"]
37
- s.require_paths = ["lib"]
38
- s.rubygems_version = "1.8.24"
39
+ s.rubygems_version = "2.2.2"
39
40
  s.summary = "Parse unified diffs in style"
40
41
 
41
42
  if s.respond_to? :specification_version then
42
- s.specification_version = 3
43
+ s.specification_version = 4
43
44
 
44
45
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
46
  s.add_development_dependency(%q<minitest>, [">= 0"])
46
- s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
47
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
47
48
  s.add_development_dependency(%q<simplecov>, [">= 0"])
48
49
  else
49
50
  s.add_dependency(%q<minitest>, [">= 0"])
50
- s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
51
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
51
52
  s.add_dependency(%q<simplecov>, [">= 0"])
52
53
  end
53
54
  else
54
55
  s.add_dependency(%q<minitest>, [">= 0"])
55
- s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
56
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
56
57
  s.add_dependency(%q<simplecov>, [">= 0"])
57
58
  end
58
59
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unified_diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
5
- prerelease:
4
+ version: 0.3.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ryan Neufeld
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-16 00:00:00.000000000 Z
11
+ date: 2014-03-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: minitest
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,23 +27,20 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: jeweler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
37
- version: 1.6.0
33
+ version: 2.0.1
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
45
- version: 1.6.0
40
+ version: 2.0.1
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: simplecov
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -84,29 +77,25 @@ files:
84
77
  homepage: http://github.com/rkneufeld/unified_diff
85
78
  licenses:
86
79
  - MIT
80
+ metadata: {}
87
81
  post_install_message:
88
82
  rdoc_options: []
89
83
  require_paths:
90
84
  - lib
91
85
  required_ruby_version: !ruby/object:Gem::Requirement
92
- none: false
93
86
  requirements:
94
87
  - - ! '>='
95
88
  - !ruby/object:Gem::Version
96
89
  version: '0'
97
- segments:
98
- - 0
99
- hash: -685931603
100
90
  required_rubygems_version: !ruby/object:Gem::Requirement
101
- none: false
102
91
  requirements:
103
92
  - - ! '>='
104
93
  - !ruby/object:Gem::Version
105
94
  version: '0'
106
95
  requirements: []
107
96
  rubyforge_project:
108
- rubygems_version: 1.8.24
97
+ rubygems_version: 2.2.2
109
98
  signing_key:
110
- specification_version: 3
99
+ specification_version: 4
111
100
  summary: Parse unified diffs in style
112
101
  test_files: []