shape_of 0.1.0 → 1.0.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/shape_of.rb +8 -12
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 200845fd006ae0119d06f0b1f3f8b7b908a7c3d8f8c16ebe4856bcb905af5763
4
- data.tar.gz: f046ee908eb3715e8028484dac72fa0fa411f24496ad3d71d8c984cf1a33fd7b
3
+ metadata.gz: 40c924b58fbcf750b029d9443d531492242529e8d224e5d5a8c933443498a1b4
4
+ data.tar.gz: 884e972b2ae57c5eeb884893858ba2ffee942249b2c3185296a5cf86b8604959
5
5
  SHA512:
6
- metadata.gz: f9d8e53319be78d4f3cf0aa6cc94f19f89c25decc737fecd1d16ce6e4666f35b80bca6ee9aff753ada64e85aa9d8c829cb4af06d67b33c114033c6f57838258a
7
- data.tar.gz: d70f5abeb46bd372329189755f901f5d56fa0e9d7d07d3a6724404719844c08ae4792042e6eaf417051e0bf33183f66f23fe29369003eefc0d6f7879157f9756
6
+ metadata.gz: 531a580e88cecba248bbe3709e869517950ea7b96ac5407138a13aafc5a99709925f1a28d74914d4af8f9e94b36e5ce956abf65c51295c7bcd24e65a63bf7913
7
+ data.tar.gz: 344c4ee899ec0b0b21df0bc30d6895b628e75264e5af20cbaeee72656ed649ca73201448d085a9487435193166b26c7fa087a48afb5cbe65958c1bad9b9373ef
data/lib/shape_of.rb CHANGED
@@ -89,11 +89,11 @@ module ShapeOf
89
89
  module Assertions
90
90
  def assert_shape_of(object, shape)
91
91
  if shape.respond_to? :shape_of?
92
- assert_operator shape, :shape_of?, object
92
+ assert shape.shape_of? object
93
93
  elsif shape.instance_of? ::Array
94
- assert_operator Array[shape.first], :shape_of?, object
94
+ assert Array[shape.first].shape_of? object
95
95
  elsif shape.instance_of? ::Hash
96
- assert_operator Hash[shape], :shape_of?, object
96
+ assert Hash[shape].shape_of? object
97
97
  else
98
98
  raise TypeError, "Expected #{Shape.inspect}, an #{::Array.inspect}, or a #{::Hash.inspect} as the shape"
99
99
  end
@@ -101,11 +101,11 @@ module ShapeOf
101
101
 
102
102
  def refute_shape_of(object, shape)
103
103
  if shape.respond_to? :shape_of?
104
- refute_operator shape, :shape_of?, object
104
+ refute shape.shape_of? object
105
105
  elsif shape.instance_of? ::Array
106
- refute_operator Array[shape.first], :shape_of?, object
106
+ refute Array[shape.first].shape_of? object
107
107
  elsif shape.instance_of? ::Hash
108
- refute_operator Hash[shape], :shape_of?, object
108
+ refute Hash[shape].shape_of? object
109
109
  else
110
110
  raise TypeError, "Expected #{Shape.inspect}, an #{::Array.inspect}, or a #{::Hash.inspect} as the shape"
111
111
  end
@@ -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
@@ -244,10 +244,6 @@ module ShapeOf
244
244
 
245
245
  # Union[Shape1, Shape2, ...] denotes that it can be of one the provided shapes
246
246
  class Union < Shape
247
- def self.shape_of?(object)
248
- false
249
- end
250
-
251
247
  def self.[](*shapes)
252
248
  Class.new(self) do
253
249
  @class_name = "#{superclass.name}[#{shapes.map(&:inspect).join(", ")}]"
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: 0.1.0
4
+ version: 1.0.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-17 00:00:00.000000000 Z
11
+ date: 2021-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest