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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ba6d4ccacd12fd0225293d29cc5c827718cf3b55f2b2ce665b382c2a489fa24
4
- data.tar.gz: 6a5dc28e465b9ae4c0796ad23cbfe5950e4f802ec0def086f8e2580586a641d0
3
+ metadata.gz: d994d61475609e251b44c01ecccfc8c7aeea9b0c47d8decc45e308ca4a278bb2
4
+ data.tar.gz: 26a3dd8b29f94967659bc87d7f70c44027cfe901ed8cac8872dddd91e990dbeb
5
5
  SHA512:
6
- metadata.gz: 5f66bdf4b7b2d7f9f882215bdf5f13312f5a1fa3bcf5203a1d0f09d81a454bcece5aa06016b7793b8cc27fc214b5470a85847baacef4ebb3e9d974bd84b68094
7
- data.tar.gz: 8e6517141b2b2302d37a7d633b55b8bfc36cac7440968d006963f4154a82189447cb2835d5db200c6a7b750e602f0b442926a4f715db2fb745babbf0e30aab12
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 = to_utf8(string1), to_utf8(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
@@ -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#{lines.join("\n")}\n </ul>\n</div>\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
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Diffy
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
  end
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
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-16 00:00:00.000000000 Z
11
+ date: 2023-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake