ydiffy 0.0.3 → 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: ebdabe7fec38695e1803b5d909e2c022de065545fe277f291897484e9393db0a
4
- data.tar.gz: a6d4c054837d86ebf9728699b9d7758fa40ddd76e527aaddcd3e74cf7ea1b1b4
3
+ metadata.gz: d994d61475609e251b44c01ecccfc8c7aeea9b0c47d8decc45e308ca4a278bb2
4
+ data.tar.gz: 26a3dd8b29f94967659bc87d7f70c44027cfe901ed8cac8872dddd91e990dbeb
5
5
  SHA512:
6
- metadata.gz: b283c2a765a052b9e4737bbca15f554bd31795463d3823409c88af2248f8952c82b509486d1ab8ff146b4b3674ce54743d2ccc7782b1cb2d6df5348274e30935
7
- data.tar.gz: fb54cf453e43fe74eab822d84544f39ed399d44acb9efc6ae41ce58af3610fce917ea9cef8133eaae81225b0c2def1e59ecfbf4a1d5aed3f3d12aa7b204c0cea
6
+ metadata.gz: d4ff3bfc2ede99c36b3ae68c682a18e2faa81ecca492203d45d7508bf0ec2cd4854f17fc8c2adf802d3521530404147d35d2012366cfcc904295be441812287a
7
+ data.tar.gz: 1bd4f7de09b75c1ff5d5b1dda208f7394dc527fdb93ff8b1f38e18e7c25f7fcda6a0dfe1e763520170fede72ec3884f060e424bd2106341cfd2569a1d4d73bc9
data/README.md CHANGED
@@ -30,7 +30,7 @@ Installation
30
30
  ------------
31
31
 
32
32
  ### on Unix
33
-
33
+ gem build
34
34
  gem install diffy
35
35
 
36
36
  ### on Windows:
data/lib/diffy/css.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Diffy
2
3
  CSS = <<-STYLE
3
4
  .diff{overflow:auto;}
data/lib/diffy/diff.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Diffy
2
3
  class Diff
3
4
  ORIGINAL_DEFAULT_OPTIONS = {
@@ -37,7 +38,7 @@ module Diffy
37
38
  if ! ['strings', 'files'].include?(@options[:source])
38
39
  raise ArgumentError, "Invalid :source option #{@options[:source].inspect}. Supported options are 'strings' and 'files'."
39
40
  end
40
- @string1, @string2 = to_utf8(string1), to_utf8(string2)
41
+ @string1, @string2 = string1, string2
41
42
  end
42
43
 
43
44
  def diff
@@ -141,16 +142,6 @@ module Diffy
141
142
  end
142
143
  private
143
144
 
144
- def to_utf8(line)
145
- return unless line
146
- return line if line.encoding.to_s.eql?('UTF-8')
147
- if /ISO-8859-1/.match(line.encoding.to_s)
148
- line.encode!('UTF-8')
149
- else
150
- line.force_encoding('UTF-8')
151
- end
152
- end
153
-
154
145
  @@bin = nil
155
146
  def diff_bin
156
147
  return @@bin if @@bin
data/lib/diffy/format.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Diffy
2
3
  module Format
3
4
  # ANSI color output suitable for terminal output
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Diffy
2
3
  class HtmlFormatter
3
4
 
@@ -16,7 +17,7 @@ module Diffy
16
17
 
17
18
  private
18
19
  def wrap_line(line)
19
- cleaned = clean_line(line)
20
+ cleaned = to_utf8(clean_line(line))
20
21
  case line
21
22
  when /^(---|\+\+\+|\\\\)/
22
23
  ' <li class="diff-comment"><span>' + line.chomp + '</span></li>'
@@ -41,10 +42,12 @@ module Diffy
41
42
  end
42
43
 
43
44
  def wrap_lines(lines)
45
+ encoded = lines.collect{ |s| to_utf8(s) }
46
+ joined = encoded.join("\n")
44
47
  if lines.empty?
45
48
  %'<div class="diff"></div>'
46
49
  else
47
- %'<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'
48
51
  end
49
52
  end
50
53
 
@@ -131,5 +134,15 @@ module Diffy
131
134
  # spanning block elements which get added later.
132
135
  gsub('<LINE_BOUNDARY>',"</strong>\n<strong>") + "</strong>"
133
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
134
147
  end
135
148
  end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Diffy
2
3
  class SplitDiff
3
4
  def initialize(left, right, options = {})
data/lib/diffy/version.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Diffy
2
- VERSION = '0.0.3'
3
+ VERSION = '0.0.5'
3
4
  end
data/lib/diffy.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'tempfile'
2
3
  require 'erb'
3
4
  require 'rbconfig'
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.3
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-15 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