ydiffy 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/diffy/diff.rb +1 -11
- data/lib/diffy/html_formatter.rb +14 -2
- data/lib/diffy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d994d61475609e251b44c01ecccfc8c7aeea9b0c47d8decc45e308ca4a278bb2
|
4
|
+
data.tar.gz: 26a3dd8b29f94967659bc87d7f70c44027cfe901ed8cac8872dddd91e990dbeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4ff3bfc2ede99c36b3ae68c682a18e2faa81ecca492203d45d7508bf0ec2cd4854f17fc8c2adf802d3521530404147d35d2012366cfcc904295be441812287a
|
7
|
+
data.tar.gz: 1bd4f7de09b75c1ff5d5b1dda208f7394dc527fdb93ff8b1f38e18e7c25f7fcda6a0dfe1e763520170fede72ec3884f060e424bd2106341cfd2569a1d4d73bc9
|
data/lib/diffy/diff.rb
CHANGED
@@ -38,7 +38,7 @@ module Diffy
|
|
38
38
|
if ! ['strings', 'files'].include?(@options[:source])
|
39
39
|
raise ArgumentError, "Invalid :source option #{@options[:source].inspect}. Supported options are 'strings' and 'files'."
|
40
40
|
end
|
41
|
-
@string1, @string2 =
|
41
|
+
@string1, @string2 = string1, string2
|
42
42
|
end
|
43
43
|
|
44
44
|
def diff
|
@@ -142,16 +142,6 @@ module Diffy
|
|
142
142
|
end
|
143
143
|
private
|
144
144
|
|
145
|
-
def to_utf8(line)
|
146
|
-
return unless line
|
147
|
-
return line if line.encoding.to_s.eql?('UTF-8')
|
148
|
-
begin
|
149
|
-
line.encode!('UTF-8')
|
150
|
-
rescue
|
151
|
-
line.force_encoding('UTF-8')
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
145
|
@@bin = nil
|
156
146
|
def diff_bin
|
157
147
|
return @@bin if @@bin
|
data/lib/diffy/html_formatter.rb
CHANGED
@@ -17,7 +17,7 @@ module Diffy
|
|
17
17
|
|
18
18
|
private
|
19
19
|
def wrap_line(line)
|
20
|
-
cleaned = clean_line(line)
|
20
|
+
cleaned = to_utf8(clean_line(line))
|
21
21
|
case line
|
22
22
|
when /^(---|\+\+\+|\\\\)/
|
23
23
|
' <li class="diff-comment"><span>' + line.chomp + '</span></li>'
|
@@ -42,10 +42,12 @@ module Diffy
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def wrap_lines(lines)
|
45
|
+
encoded = lines.collect{ |s| to_utf8(s) }
|
46
|
+
joined = encoded.join("\n")
|
45
47
|
if lines.empty?
|
46
48
|
%'<div class="diff"></div>'
|
47
49
|
else
|
48
|
-
%'<div class="diff">\n <ul>\n#{
|
50
|
+
%'<div class="diff">\n <ul>\n#{joined}\n </ul>\n</div>\n'
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
@@ -132,5 +134,15 @@ module Diffy
|
|
132
134
|
# spanning block elements which get added later.
|
133
135
|
gsub('<LINE_BOUNDARY>',"</strong>\n<strong>") + "</strong>"
|
134
136
|
end
|
137
|
+
|
138
|
+
def to_utf8(line)
|
139
|
+
return unless line
|
140
|
+
return line if line.encoding.to_s.eql?('UTF-8')
|
141
|
+
begin
|
142
|
+
line.encode!('UTF-8')
|
143
|
+
rescue
|
144
|
+
line.force_encoding('UTF-8')
|
145
|
+
end
|
146
|
+
end
|
135
147
|
end
|
136
148
|
end
|
data/lib/diffy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ydiffy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Goldstein
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|