shape_of 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shape_of.rb +6 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bc19b15cdef25be887c599f9e7f2702eff443cf137e939917c8922228fd2503
|
4
|
+
data.tar.gz: 53edce21813f01af895d7786a5ada4adb4c452d505009c0b98e003d23a91c691
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ddaec475681a32007affaa2fbc69b233960a3efca5511313846266c0f35e68739ca25d1c5998688e422789a982bb68494f73df63d3f1f7b786a02694075b12c
|
7
|
+
data.tar.gz: 38dd75becd965acbfa020874b80235c3de84b3a3a7634c1ef6e50a8936dc982f57abe062e4107c2c53b243aa982d9d90b42bd2d3ae764036c7954d3579f37a4f
|
data/lib/shape_of.rb
CHANGED
@@ -161,7 +161,7 @@ module ShapeOf
|
|
161
161
|
if @shape.respond_to? :shape_of?
|
162
162
|
@shape.shape_of? elem
|
163
163
|
elsif @shape.is_a? ::Array
|
164
|
-
Array[@shape].shape_of? elem
|
164
|
+
Array[@shape.first].shape_of? elem
|
165
165
|
elsif @shape.is_a? ::Hash
|
166
166
|
Hash[@shape].shape_of? elem
|
167
167
|
elsif @shape.is_a? Class
|
@@ -222,7 +222,7 @@ module ShapeOf
|
|
222
222
|
if @shape[key].respond_to? :shape_of?
|
223
223
|
@shape[key].shape_of? elem
|
224
224
|
elsif @shape[key].is_a? ::Array
|
225
|
-
Array[@shape[key]].shape_of? elem
|
225
|
+
Array[@shape[key].first].shape_of? elem
|
226
226
|
elsif @shape[key].is_a? ::Hash
|
227
227
|
Hash[@shape[key]].shape_of? elem
|
228
228
|
elsif @shape[key].is_a? Class
|
@@ -316,15 +316,9 @@ module ShapeOf
|
|
316
316
|
end
|
317
317
|
end
|
318
318
|
|
319
|
-
class
|
320
|
-
@internal_class = ::Regexp
|
321
|
-
|
322
|
-
def self.shape_of?(object)
|
323
|
-
object.instance_of? @internal_class
|
324
|
-
end
|
325
|
-
|
319
|
+
class Pattern < Shape
|
326
320
|
def self.[](shape)
|
327
|
-
raise TypeError, "Shape must be #{
|
321
|
+
raise TypeError, "Shape must be #{Regexp.inspect}, was #{shape.inspect}" unless shape.instance_of? Regexp
|
328
322
|
|
329
323
|
Class.new(self) do
|
330
324
|
@class_name = "#{superclass.name}[#{shape.inspect}]"
|
@@ -343,15 +337,9 @@ module ShapeOf
|
|
343
337
|
end
|
344
338
|
|
345
339
|
def self.shape_of?(object)
|
346
|
-
|
347
|
-
raise TypeError, "expected #{::Regexp.inspect} or #{String.inspect}, was instead #{object.inspect}"
|
348
|
-
end
|
340
|
+
raise TypeError, "expected #{String.inspect}, was instead #{object.inspect}" unless object.instance_of?(String)
|
349
341
|
|
350
|
-
|
351
|
-
@shape == object
|
352
|
-
else # string
|
353
|
-
@shape.match?(object)
|
354
|
-
end
|
342
|
+
@shape.match?(object)
|
355
343
|
end
|
356
344
|
end
|
357
345
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shape_of
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Isom
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|