power_assert 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/power_assert.rb +17 -7
- data/lib/power_assert/version.rb +1 -1
- data/test/test_power_assert.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4114043b958f530bf1b005c95b52c283e196b2dd
|
4
|
+
data.tar.gz: ca1573692d996d86479bdbfd412071543074a4d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2dad87631bbcfe83d491276b325d85f9a6f3ff9a23f4057c8a0aaec7b00fc24b512db5a095b7092e79aa3e672e542670b407acf8772f3303dd70598adb702c89
|
7
|
+
data.tar.gz: c454a8d8a07e2eca899c3e43b4a895de55680cf4de23dde7eb92a49ace1fe4f10e4bcc7eb0f8403894cacfd539db4a09994c01ba26a7b4df17835ee0d0d9255c
|
data/lib/power_assert.rb
CHANGED
@@ -64,14 +64,14 @@ module PowerAssert
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def inspect
|
67
|
-
|
68
|
-
if Encoding.compatible?(Encoding.default_external,
|
69
|
-
|
67
|
+
inspected = @value.inspect
|
68
|
+
if Encoding.compatible?(Encoding.default_external, inspected)
|
69
|
+
inspected
|
70
70
|
else
|
71
71
|
begin
|
72
|
-
"#{
|
72
|
+
"#{inspected.encode(Encoding.default_external)}(#{inspected.encoding})"
|
73
73
|
rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError
|
74
|
-
|
74
|
+
inspected.force_encoding(Encoding.default_external)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
rescue => e
|
@@ -165,8 +165,7 @@ module PowerAssert
|
|
165
165
|
inspected_vals = vals.each_with_object({}) do |j, h|
|
166
166
|
h[j.column.to_s.to_sym] = [SafeInspectable.new(i.value).inspect, '|', ' '][i.column <=> j.column]
|
167
167
|
end
|
168
|
-
|
169
|
-
ret << (l.valid_encoding? ? l.rstrip : l)
|
168
|
+
ret << encoding_safe_rstrip(sprintf(fmt, inspected_vals))
|
170
169
|
end
|
171
170
|
ret.join("\n")
|
172
171
|
end
|
@@ -181,6 +180,17 @@ module PowerAssert
|
|
181
180
|
end
|
182
181
|
end
|
183
182
|
|
183
|
+
def encoding_safe_rstrip(str)
|
184
|
+
str.rstrip
|
185
|
+
rescue ArgumentError, Encoding::CompatibilityError
|
186
|
+
enc = str.encoding
|
187
|
+
if enc.ascii_compatible?
|
188
|
+
str.b.rstrip.force_encoding(enc)
|
189
|
+
else
|
190
|
+
str
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
184
194
|
def extract_idents(sexp)
|
185
195
|
tag, * = sexp
|
186
196
|
case tag
|
data/lib/power_assert/version.rb
CHANGED
data/test/test_power_assert.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: power_assert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuki Tsujimoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit
|