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 +4 -4
- data/CHANGELOG +4 -0
- data/CONTRIBUTORS +1 -0
- data/lib/diffy/diff.rb +16 -5
- data/lib/diffy/version.rb +1 -1
- data/spec/diffy_spec.rb +24 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f075ae98773be87371ebe062baf246c8e70187b5
|
4
|
+
data.tar.gz: b6a761844cffe0e12134fafe2e8163dafc158def
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc19ee7c97c81c4937a4c1c95221a45123f96ba730ea29908fa6c08b77bb17217db5a8bf92fd2463eb4275821ada7201b49448615765508ebf9815d72e81c9b3
|
7
|
+
data.tar.gz: 0e12bfb8ba4bec36c4c659a9157ef6353c1eed14fbb2b2178111e9573cb1a3aab7047208aa1a53cca83f0e956368197aa671885c90066d8fe4766f5263b49a72
|
data/CHANGELOG
CHANGED
data/CONTRIBUTORS
CHANGED
data/lib/diffy/diff.rb
CHANGED
@@ -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
|
88
|
-
|
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
|
data/lib/diffy/version.rb
CHANGED
data/spec/diffy_spec.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2018-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|