isy 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -0
- data/isy.gemspec +2 -0
- data/lib/isy/exceptions.rb +2 -2
- data/lib/isy/version.rb +1 -1
- data/lib/isy.rb +4 -1
- metadata +29 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1924fef98cb5aaaf39ed180fe2fd14db37bc072a
|
4
|
+
data.tar.gz: 79661c9517afc68bf60dcb6db5f916249d633a6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2192aa293532cfa148aaed6a2b54604a0505389ff77a7e2cafca582dbcc2bb0aeee3a8af0425786980d00930880ce136f1f5b7717b90f52e287b8a50c03cb3a6
|
7
|
+
data.tar.gz: 89dba2c5ae9aa5bc706a30b4f2ed2057263118a6de96aa8a9711c258d03feaadb48351144ffb17c4ad9fa8f60e5badbdfc3a148276799d64d744109a8636bb22
|
data/README.md
CHANGED
@@ -19,6 +19,24 @@ def fullname segments=[]
|
|
19
19
|
end
|
20
20
|
```
|
21
21
|
|
22
|
+
`Isy` takes a declarative approach to solving the problem. Instead of
|
23
|
+
dictating the contraints (and resulting response) to each argument type,
|
24
|
+
you can levelage Isy's simple interface.
|
25
|
+
|
26
|
+
## Performance
|
27
|
+
|
28
|
+
It's not great against a more "native" implementation; but, where you lose a little
|
29
|
+
in performance, you (may) gain in an ability to quickly reason about the
|
30
|
+
code.
|
31
|
+
|
32
|
+
A native implementation is incredibly light (see above): no additional dependencies
|
33
|
+
and logistical overhead. Using `Isy` you're introducing an additional dependency and
|
34
|
+
better support for evaluation routines (by providing a block).
|
35
|
+
|
36
|
+
To run a comparison benchmark:
|
37
|
+
|
38
|
+
`$ ruby spec/benchmark.rb`
|
39
|
+
|
22
40
|
## Installation
|
23
41
|
|
24
42
|
Add this line to your application's Gemfile:
|
data/isy.gemspec
CHANGED
@@ -21,4 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.10"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
spec.add_development_dependency "rspec", "~> 3.4.0"
|
24
|
+
spec.add_development_dependency "pry-byebug"
|
25
|
+
spec.add_development_dependency "benchmark-ips"
|
24
26
|
end
|
data/lib/isy/exceptions.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Isy
|
2
2
|
class ArgumentTypeMismatch < ArgumentError
|
3
|
-
def initialize subject
|
4
|
-
super "#{subject.inspect} isn't a valid argument"
|
3
|
+
def initialize subject:, caller_method:
|
4
|
+
super "#{subject.inspect} isn't a valid argument for ##{caller_method}"
|
5
5
|
end
|
6
6
|
end
|
7
7
|
end
|
data/lib/isy/version.rb
CHANGED
data/lib/isy.rb
CHANGED
@@ -18,7 +18,10 @@ module Isy
|
|
18
18
|
evaluation ||= lambda { |s| s.is_a? args[0] }
|
19
19
|
|
20
20
|
unless evaluation.call(subject)
|
21
|
-
raise Isy::ArgumentTypeMismatch
|
21
|
+
raise Isy::ArgumentTypeMismatch.new(
|
22
|
+
subject: subject,
|
23
|
+
caller_method: caller_locations(1,1)[0].label
|
24
|
+
)
|
22
25
|
end
|
23
26
|
end
|
24
27
|
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cuppy
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 3.4.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: benchmark-ips
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
55
83
|
description:
|
56
84
|
email:
|
57
85
|
- adam@codingzeal.com
|
@@ -97,4 +125,3 @@ signing_key:
|
|
97
125
|
specification_version: 4
|
98
126
|
summary: Type assertion library for method arguments
|
99
127
|
test_files: []
|
100
|
-
has_rdoc:
|