shape_of 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/shape_of.rb +11 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2bae6d75a1270a9fe921b765b5d3d545b22c7dc50204ebad73f806960107056c
4
- data.tar.gz: 85138e3abbff51f597743cdf9e2ee299ceab2c58e359fa25c4836fafc329bdcc
3
+ metadata.gz: 28b5bdad75322342f66037bc3780c36cc38dcbd932e6daba11480e372cd9bc7d
4
+ data.tar.gz: c753cadb3a00e5656abf762dc2c0f41dfcc8c604bda53aebeab30c62e231792f
5
5
  SHA512:
6
- metadata.gz: 15446ab268e0fc1a6a3f31211b463f12f5b4a4e53b1f8b90ce581be9f594a6e10007341ac56273d0e45bedd2d2e9870f5a4c04af2fb0ae7af7bf76fb59b45223
7
- data.tar.gz: e6c37c58a73e70c9445c6787d376ccf46c3b1e198a988b37723929a059601de2af3e45693914d7e88ce7a3c74a8d6cb662228470c821830cd7aaa2687fc1e078
6
+ metadata.gz: ace4588260223b123c47a17b6f096fb3fdb5d30f84f68ecb53bd1aca7020a1cde2fe1805c05dad248fe544bcbb0cf42e77b7c5473313f2b01c096306a0e22dad
7
+ data.tar.gz: 4ac6be6efef005e115a44aa7f7a6ee32bc69a058ec13e0336b80284e05e711628f68190ecb9b81fefe181b779f3da20f72c8b3bf55d01a05768b72ed7de754c6
data/lib/shape_of.rb CHANGED
@@ -127,9 +127,9 @@ module ShapeOf
127
127
  end
128
128
  end
129
129
 
130
- # Array[Shape] denotes that it is an array of shapes.
130
+ # Array[shape] denotes that it is an array of shapes.
131
131
  # It checks every element in the array and verifies that the element is in the correct shape.
132
- # This, along with Array, are the core components of this module.
132
+ # This, along with Hash, are the core components of this module.
133
133
  # Note that a ShapeOf::Array[Integer].shape_of?([]) will pass because it is vacuously true for an empty array.
134
134
  class Array < Shape
135
135
  @internal_class = ::Array
@@ -175,7 +175,8 @@ module ShapeOf
175
175
  end
176
176
  end
177
177
 
178
- # Hash[key: Shape, ...] denotes it is a hash of shapes with a very specific structure. Hash (without square brackets) is just a hash with any shape.
178
+ # Hash[key: shape, ...] denotes it is a hash of shapes with a very specific structure.
179
+ # Hash (without square brackets) is just a hash with any shape.
179
180
  # This, along with Array, are the core components of this module.
180
181
  # Note that the keys are converted to strings for comparison for both the shape and object provided.
181
182
  class Hash < Shape
@@ -242,7 +243,7 @@ module ShapeOf
242
243
  end
243
244
  end
244
245
 
245
- # Union[Shape1, Shape2, ...] denotes that it can be of one the provided shapes
246
+ # Union[shape1, shape2, ...] denotes that it can be of one the provided shapes.
246
247
  class Union < Shape
247
248
  def self.shape_of?(object)
248
249
  false
@@ -284,7 +285,8 @@ module ShapeOf
284
285
  end
285
286
  end
286
287
 
287
- # Optional[Shape] denotes that the usual type is a Shape, but is optional (meaning if it is nil or the key is not present in the Hash, it's still true)
288
+ # Optional[shape] denotes that the usual type is a shape, but is optional
289
+ # (meaning if it is nil or the key is not present in the Hash, it's still true)
288
290
  class Optional < Shape
289
291
  def self.[](shape)
290
292
  raise TypeError, "Shape cannot be nil" if shape.nil? || shape == NilClass
@@ -303,13 +305,14 @@ module ShapeOf
303
305
  end
304
306
  end
305
307
 
308
+ # Anything matches unless key does not exist in the Hash.
306
309
  class Any < Shape
307
310
  def self.shape_of?(object)
308
311
  true
309
312
  end
310
313
  end
311
314
 
312
- # Nothing only passes when the key does not exist in the Hash.
315
+ # Only passes when the key does not exist in the Hash.
313
316
  class Nothing < Shape
314
317
  def self.shape_of?(object)
315
318
  false
@@ -320,10 +323,12 @@ module ShapeOf
320
323
  end
321
324
  end
322
325
 
326
+ # Union[Integer, Float, Rational, Complex]
323
327
  Numeric = Union[Integer, Float, Rational, Complex].tap do |this|
324
328
  this.instance_variable_set(:@class_name, this.name.sub(/Union.*/, 'Numeric'))
325
329
  end
326
330
 
331
+ # Union[TrueClass, FalseClass]
327
332
  Boolean = Union[TrueClass, FalseClass].tap do |this|
328
333
  this.instance_variable_set(:@class_name, this.name.sub(/Union.*/, 'Boolean'))
329
334
  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: 0.0.3
4
+ version: 0.0.4
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-20 00:00:00.000000000 Z
11
+ date: 2021-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest