lazy_static 0.0.2 → 0.0.3
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 +4 -4
- data/.travis.yml +5 -0
- data/README.md +5 -6
- data/Rakefile +4 -0
- data/lib/lazy_static.rb +4 -2
- data/lib/lazy_static/version.rb +1 -1
- data/spec/lib/lazy_static_spec.rb +7 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4f973382c49755a50d602aa6f3156ea9b0ee65e
|
4
|
+
data.tar.gz: 3edb6016b64c44df65a12445f55e0c163348d87b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73851996a07ca8d493bf2c7f4f19796e574099d8fb4eb112d3b855565da6fa95d1ceba99486b147b2404792a2925e37c6a939278f65206f041bc15aff52b8cab
|
7
|
+
data.tar.gz: 25308cf157eec68e343d2caa4ad653c25bae00a46c46ac48064c1b7efa0071f2e72894c8cec701d5fb66441c74e3b59b8edea204180da2220dcc6ed5c5fc14e8
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -3,12 +3,11 @@
|
|
3
3
|
It's a lazy static type checker, simple as this:
|
4
4
|
|
5
5
|
```
|
6
|
-
[1] pry(main)> LazyStatic.check
|
7
|
-
=>
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
from /Users/lemur/dev/lazy_static/lib/lazy_static.rb:5:in `check'
|
6
|
+
[1] pry(main)> LazyStatic.check(5 => Integer, 's' => String)
|
7
|
+
=> {5=>Integer, "s"=>String}
|
8
|
+
[2] pry(main)> LazyStatic.check(5 => Integer, 's' => Integer)
|
9
|
+
TypeError: Expected s (String) to be of type Integer
|
10
|
+
from /Users/lemur/dev/lazy_static/lib/lazy_static.rb:6:in `block in check'
|
12
11
|
```
|
13
12
|
|
14
13
|
...and that's all it'll ever need to be.
|
data/Rakefile
CHANGED
data/lib/lazy_static.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require "lazy_static/version"
|
2
2
|
|
3
3
|
module LazyStatic
|
4
|
-
def self.check(
|
5
|
-
|
4
|
+
def self.check(checks)
|
5
|
+
checks.each do |object, type|
|
6
|
+
object.is_a?(type) or raise TypeError, "Expected #{object} (#{object.class}) to be of type #{type}"
|
7
|
+
end
|
6
8
|
end
|
7
9
|
end
|
data/lib/lazy_static/version.rb
CHANGED
@@ -4,14 +4,18 @@ describe LazyStatic do
|
|
4
4
|
describe 'self#check' do
|
5
5
|
context 'A Valid check' do
|
6
6
|
it 'returns true' do
|
7
|
-
expect(LazyStatic.check
|
7
|
+
expect(LazyStatic.check(5 => Integer)).to be_truthy
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'takes multiple checks' do
|
11
|
+
expect(LazyStatic.check(5 => Integer, 's' => String)).to be_truthy
|
8
12
|
end
|
9
13
|
end
|
10
14
|
|
11
15
|
context 'An Invalid check' do
|
12
16
|
it 'returns true' do
|
13
|
-
expect { LazyStatic.check
|
14
|
-
TypeError, "Expected 5 to be String"
|
17
|
+
expect { LazyStatic.check(5 => String) }.to raise_error(
|
18
|
+
TypeError, "Expected 5 (Fixnum) to be of type String"
|
15
19
|
)
|
16
20
|
end
|
17
21
|
end
|