diffy 3.2.1 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of diffy might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8126b4d4207609139dafef922f5ac9079dbe775b
4
- data.tar.gz: 9b7eb9af119aed244cf82e9caa2bc89340ac8f27
3
+ metadata.gz: f075ae98773be87371ebe062baf246c8e70187b5
4
+ data.tar.gz: b6a761844cffe0e12134fafe2e8163dafc158def
5
5
  SHA512:
6
- metadata.gz: b9a542ef87e8b5a4f7eaba863bb0cc6157d462e478153b3aa68fc0303fbd92367ec8fb8fe5a3ca215023d595164c97c7414355829c809deb511c96c5e614f60b
7
- data.tar.gz: 0cd0450cda92e1c04283fa93122284abd027a9fe9ebffc86348228aa0c37c993781fa5faaf8cbe52e00cba1412f4100006e4873a3ba0bed11b3384dedefc921f
6
+ metadata.gz: cc19ee7c97c81c4937a4c1c95221a45123f96ba730ea29908fa6c08b77bb17217db5a8bf92fd2463eb4275821ada7201b49448615765508ebf9815d72e81c9b3
7
+ data.tar.gz: 0e12bfb8ba4bec36c4c659a9157ef6353c1eed14fbb2b2178111e9573cb1a3aab7047208aa1a53cca83f0e956368197aa671885c90066d8fe4766f5263b49a72
data/CHANGELOG CHANGED
@@ -1,5 +1,9 @@
1
+ == 3.3.0 ==
2
+ Fix diff lines that begin with -- or ++. Thanks @dark-panda!
3
+
1
4
  == 3.2.1 ==
2
5
  Fix default options on alpine linux. Thanks @evgen!
6
+
3
7
  == 3.1.0 ==
4
8
  Side by side diffs. Thanks Runar Skaare Tveiten!
5
9
 
@@ -12,3 +12,4 @@
12
12
  * Skye Shaw
13
13
  * Abinoam P. Marques Jr.
14
14
  * evgen
15
+ * J Smith @dark-panda
@@ -42,7 +42,7 @@ module Diffy
42
42
 
43
43
  def diff
44
44
  @diff ||= begin
45
- paths = case options[:source]
45
+ @paths = case options[:source]
46
46
  when 'strings'
47
47
  [tempfile(string1), tempfile(string2)]
48
48
  when 'files'
@@ -51,10 +51,10 @@ module Diffy
51
51
 
52
52
  if WINDOWS
53
53
  # don't use open3 on windows
54
- cmd = sprintf '"%s" %s %s', diff_bin, diff_options.join(' '), paths.map { |s| %("#{s}") }.join(' ')
54
+ cmd = sprintf '"%s" %s %s', diff_bin, diff_options.join(' '), @paths.map { |s| %("#{s}") }.join(' ')
55
55
  diff = `#{cmd}`
56
56
  else
57
- diff = Open3.popen3(diff_bin, *(diff_options + paths)) { |i, o, e| o.read }
57
+ diff = Open3.popen3(diff_bin, *(diff_options + @paths)) { |i, o, e| o.read }
58
58
  end
59
59
  diff.force_encoding('ASCII-8BIT') if diff.respond_to?(:valid_encoding?) && !diff.valid_encoding?
60
60
  if diff =~ /\A\s*\Z/ && !options[:allow_empty_diff]
@@ -84,9 +84,20 @@ module Diffy
84
84
 
85
85
  def each
86
86
  lines = case @options[:include_diff_info]
87
- when false then diff.split("\n").reject{|x| x =~ /^(---|\+\+\+|@@|\\\\)/ }.map {|line| line + "\n" }
88
- when true then diff.split("\n").map {|line| line + "\n" }
87
+ when false
88
+ # this "primes" the diff and sets up the paths we'll reference below.
89
+ diff
90
+
91
+ # caching this regexp improves the performance of the loop by a
92
+ # considerable amount.
93
+ regexp = /^(--- "?#{@paths[0]}"?|\+\+\+ "?#{@paths[1]}"?|@@|\\\\)/
94
+
95
+ diff.split("\n").reject{|x| x =~ regexp }.map {|line| line + "\n" }
96
+
97
+ when true
98
+ diff.split("\n").map {|line| line + "\n" }
89
99
  end
100
+
90
101
  if block_given?
91
102
  lines.each{|line| yield line}
92
103
  else
@@ -1,3 +1,3 @@
1
1
  module Diffy
2
- VERSION = '3.2.1'
2
+ VERSION = '3.3.0'
3
3
  end
@@ -585,6 +585,30 @@ baz
585
585
  line
586
586
  end).to eq([" foo\n", " bar\n", "+baz\n"])
587
587
  end
588
+
589
+ it "should handle lines that begin with --" do
590
+ string1 = "a a\n-- b\nc c\n"
591
+ string2 = "a a\nb b\nc c\n"
592
+
593
+ expect(Diffy::Diff.new(string1, string2).to_s).to eq <<-DIFF
594
+ a a
595
+ --- b
596
+ +b b
597
+ c c
598
+ DIFF
599
+ end
600
+
601
+ it "should handle lines that begin with ++" do
602
+ string1 = "a a\nb b\nc c\n"
603
+ string2 = "a a\n++ b\nc c\n"
604
+
605
+ expect(Diffy::Diff.new(string1, string2).to_s).to eq <<-DIFF
606
+ a a
607
+ -b b
608
+ +++ b
609
+ c c
610
+ DIFF
611
+ end
588
612
  end
589
613
  end
590
614
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diffy
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Goldstein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-19 00:00:00.000000000 Z
11
+ date: 2018-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake