guess_html_encoding 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm use 1.9.2@guess_html_encoding --create
1
+ rvm use 1.9.3@guess_html_encoding --create
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- guess_html_encoding (0.0.4)
4
+ guess_html_encoding (0.0.5)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  module GuessHtmlEncoding
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -4,7 +4,7 @@ require "guess_html_encoding/version"
4
4
  module GuessHtmlEncoding
5
5
  # Guess the encoding of an HTML string, using HTTP headers if provided. HTTP headers can be a string or a hash.
6
6
  def self.guess(html, headers = nil)
7
- html = html.dup.force_encoding("ASCII-8BIT")
7
+ html = html.to_s.dup.force_encoding("ASCII-8BIT")
8
8
  out = nil
9
9
 
10
10
  if headers
@@ -37,7 +37,7 @@ module GuessHtmlEncoding
37
37
 
38
38
  # Force an HTML string into a guessed encoding.
39
39
  def self.encode(html, headers = nil)
40
- html_copy = html.dup
40
+ html_copy = html.to_s.dup
41
41
  encoding = guess(html_copy, (headers || '').gsub(/[\r\n]+/, "\n"))
42
42
  html_copy.force_encoding(encoding_loaded?(encoding) ? encoding : "UTF-8")
43
43
  if html_copy.valid_encoding?
@@ -47,6 +47,9 @@ describe "GuessHtmlEncoding" do
47
47
  guess.should == "UTF-8"
48
48
  end
49
49
 
50
+ it "should not raise an exception if data is nil" do
51
+ GuessHtmlEncoding.guess(nil).should_not raise_error(TypeError)
52
+ end
50
53
  end
51
54
 
52
55
  describe "#encode" do
@@ -89,6 +92,10 @@ describe "GuessHtmlEncoding" do
89
92
 
90
93
  data.encoding.to_s.should == "ASCII-8BIT"
91
94
  end
95
+
96
+ it "should not raise an exception if data is nil" do
97
+ GuessHtmlEncoding.encode(nil).should_not raise_error(TypeError)
98
+ end
92
99
  end
93
100
 
94
101
  describe "#encoding_loaded?" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guess_html_encoding
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-04 00:00:00.000000000Z
12
+ date: 2012-08-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &75762100 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *75762100
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  description: This gem helps guess the encoding of an HTML page.
26
31
  email:
27
32
  - andrew@iterationlabs.com
@@ -62,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
67
  version: '0'
63
68
  requirements: []
64
69
  rubyforge_project: guess_html_encoding
65
- rubygems_version: 1.8.16
70
+ rubygems_version: 1.8.24
66
71
  signing_key:
67
72
  specification_version: 3
68
73
  summary: This gem helps guess the encoding of an HTML page.