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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2559257b9e76344cb74a9ce8a8663c447da4e536
4
- data.tar.gz: de64a1a62c78606ba00ba658d4bf5df004e2b13d
3
+ metadata.gz: b4f973382c49755a50d602aa6f3156ea9b0ee65e
4
+ data.tar.gz: 3edb6016b64c44df65a12445f55e0c163348d87b
5
5
  SHA512:
6
- metadata.gz: 3ba875f600cad357515ea6a198be823ab669983651d3106e5e4cb7eef76f2bd05e034e6658dd6a0b0fd42d9307e7b02df521a493667574e2d2e62c63c0a778da
7
- data.tar.gz: 01f895ef2155b68a220bf085f00f3135323d91a085cd201bcb4247e595defbb27c68b911ce1644a60b9b5ff53b0b7e3018af66d8d3e8bf7ac84a2a4e3e9d108d
6
+ metadata.gz: 73851996a07ca8d493bf2c7f4f19796e574099d8fb4eb112d3b855565da6fa95d1ceba99486b147b2404792a2925e37c6a939278f65206f041bc15aff52b8cab
7
+ data.tar.gz: 25308cf157eec68e343d2caa4ad653c25bae00a46c46ac48064c1b7efa0071f2e72894c8cec701d5fb66441c74e3b59b8edea204180da2220dcc6ed5c5fc14e8
@@ -1 +1,6 @@
1
1
  language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.0
5
+ - 2.2.0
6
+ - 2.3.0
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 5, is_a: Integer
7
- => true
8
-
9
- [2] pry(main)> LazyStatic.check 5, is_a: String
10
- TypeError: Expected 5 to be String
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
@@ -1,2 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
2
3
 
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -1,7 +1,9 @@
1
1
  require "lazy_static/version"
2
2
 
3
3
  module LazyStatic
4
- def self.check(object, is_a:)
5
- is_a === object or raise TypeError, "Expected #{object} to be #{is_a}"
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
@@ -1,3 +1,3 @@
1
1
  module LazyStatic
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -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 5, is_a: Integer).to eq(true)
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 5, is_a: String }.to raise_error(
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_static
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Weaver