ensure_valid_encoding 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -70,6 +70,9 @@ module EnsureValidEncoding
|
|
70
70
|
#
|
71
71
|
# ensure_valid_encoding!( some_string, :invalid => :replace )
|
72
72
|
def self.ensure_valid_encoding!(str, options = {})
|
73
|
+
# convenient to allow nil to be passed in, and just returned
|
74
|
+
return nil if str.nil?
|
75
|
+
|
73
76
|
str.replace( ensure_valid_encoding(str, options) )
|
74
77
|
end
|
75
78
|
|
@@ -83,4 +83,14 @@ describe EnsureValidEncoding do
|
|
83
83
|
|
84
84
|
end
|
85
85
|
|
86
|
+
describe "works for nil input" do
|
87
|
+
it "with ensure_valid_encoding" do
|
88
|
+
EnsureValidEncoding.ensure_valid_encoding(nil).must_be_nil
|
89
|
+
end
|
90
|
+
|
91
|
+
it "with ensure_valid_encoding!" do
|
92
|
+
EnsureValidEncoding.ensure_valid_encoding!(nil).must_be_nil
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
86
96
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ensure_valid_encoding
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-06 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|
@@ -55,3 +55,4 @@ summary: For ruby 1.9 strings, replace bad bytes in given encoding with replacem
|
|
55
55
|
encoding.
|
56
56
|
test_files:
|
57
57
|
- test/ensure_valid_encoding_test.rb
|
58
|
+
has_rdoc:
|