isy 0.2.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3b170f040c49a3262f8f3138321752e89f22dcf
4
- data.tar.gz: 9e08893688c801d61ccac0de3ac2c8b6c61d81ef
3
+ metadata.gz: d069d9988e704be2859166c1a1f070b6f319761e
4
+ data.tar.gz: 844eb46166ab5e3f90e8eb2be820b26e960789b2
5
5
  SHA512:
6
- metadata.gz: 874b089ca5916fbbfaca5d55fcd20225890fefc2ccf97368f36f511658ad9eb19f491d06c55edf599fbe5dbae5903e6c0a14fad731a4536e63be807e9dcfcc4b
7
- data.tar.gz: f5178fa77edda673fb4a6cae89cfa8105407900bc31b4a86bcc4bc3d70f3493e60fac6a8191ac3233164170c2b5fce9334a4679165850fd9109934bbd5837ff8
6
+ metadata.gz: 37c2bc3fa5c1f7803c7df1361ef0dc51d813fed5d4f41cea149d13ef4d3978f3b76c76062c88374f48f61ba05d3d75b9f412e8206c2cff58d9d56acb16ca1f31
7
+ data.tar.gz: cffc758e1b3b9033585dcd2fcd2ab2ea1ad3990818783d2dcffdba96f40f3bda5e04edc633b99f906fd7eefad72c1088483be34637f602fb999c42b1a38e5192
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Isy
2
+ *(pronounced like 'izzy')*
2
3
 
3
4
  [![Build Status](https://travis-ci.org/acuppy/isy.svg?branch=master)](https://travis-ci.org/acuppy/isy)
4
5
  [![Code Climate](https://codeclimate.com/github/acuppy/isy/badges/gpa.svg)](https://codeclimate.com/github/acuppy/isy)
@@ -33,7 +34,7 @@ end
33
34
  ```
34
35
 
35
36
  The first argument is the subject of the test (i.e. what should match the proceeding assertion)
36
- The second argument is the type.
37
+ The second argument is the class, `Range`, `Regexp` or any object (type) which responds to `===`.
37
38
 
38
39
  If the subject doesn't match the provided type, then it raises a formatted exception describing
39
40
  what argument *value* was a type mismatch (as an `Isy::ArgumentTypeMismatch` exception).
@@ -34,23 +34,13 @@ module Isy
34
34
  # As illustrated above, `isy` yields to the operation the first argument (segments). The expectation
35
35
  # is that the value returned by the operation (block) is a boolen (true => passes, false => failed).
36
36
  #
37
- def isy subject, *args, &evaluation
38
- if evaluation.nil? && args[0].nil?
39
- raise ArgumentError,
40
- 'Object#isy requires either a type or evaluation block'
41
- end
42
-
43
- evaluation ||= ->(s) { s.is_a? args[0] }
44
- is_valid = !!(evaluation.call subject)
45
-
46
- unless is_valid
37
+ def isy subject, evaluation=nil, &block
38
+ unless isy? subject, evaluation, &block
47
39
  raise Isy::ArgumentTypeMismatch.new(
48
40
  subject: subject,
49
41
  caller_method: caller_locations(1,1)[0].label
50
42
  )
51
43
  end
52
-
53
- is_valid
54
44
  end
55
45
 
56
46
  # Isy::Methods#isy?
@@ -79,10 +69,15 @@ module Isy
79
69
  # As illustrated above, `isy?` yields to the operation the first argument (segments). The expectation
80
70
  # is that the value returned by the operation (block) is a boolen (true => passes, false => failed).
81
71
  #
82
- def isy? subject, *args, &evaluation
83
- isy subject, *args, &evaluation
84
- rescue ArgumentTypeMismatch
85
- false
72
+ def isy? subject, evaluation=nil, &block
73
+ tester = block || evaluation
74
+
75
+ unless tester
76
+ raise ArgumentError,
77
+ 'Object#isy requires either a type or evaluation block'
78
+ end
79
+
80
+ tester === subject
86
81
  end
87
82
  end
88
83
  end
@@ -1,3 +1,3 @@
1
1
  module Isy
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Cuppy