izzy 0.0.1 → 1.0.0
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/.rspec +2 -0
- data/README.md +5 -5
- data/izzy.gemspec +1 -0
- data/lib/izzy/version.rb +1 -1
- data/lib/izzy.rb +7 -9
- data/spec/izzy_spec.rb +67 -0
- data/spec/spec_helper.rb +8 -0
- metadata +22 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c50a4a5a4470841c239dee6447b289e83c9a796
|
4
|
+
data.tar.gz: ba55942db205601a0a3f7bd81f04d203f23b6180
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f260a577433a028da3017aee22ddae4008587ffbb29fc7a52010aac9137060723004178887367cba8765f446bf0738e73d1bf44d79a00aba6806846b143ed989
|
7
|
+
data.tar.gz: 1178efe9a6c7b04af9880a0d263edab852fe9dc0c69e9890ccf5684654860632ed9d486478ea8d5023f59f679c40594f8055028369962cad3a4375e5d44330ab
|
data/.rspec
ADDED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Izzy
|
2
2
|
|
3
|
-
Monkey patch to object to make for a nicer time of conditionals!
|
3
|
+
Monkey patch to object to make for a nicer time of conditionals! Just install the gem and you're ready to go!
|
4
4
|
|
5
5
|
Let's take our class, Person:
|
6
6
|
|
@@ -45,9 +45,9 @@ brandon = Person.new('brandon', 23, 'm')
|
|
45
45
|
|
46
46
|
...and do some comparisons!
|
47
47
|
```ruby
|
48
|
-
brandon.
|
49
|
-
brandon.
|
50
|
-
brandon.
|
48
|
+
brandon.all_of?(:older_than_18, :male, :me, :geek) # => true
|
49
|
+
brandon.none_of?(:younger_than_18, :female) # => true
|
50
|
+
brandon.any_of?(:male, :female, :geek) # => true
|
51
51
|
```
|
52
52
|
|
53
53
|
Simple to the point, no more mess of && or || checks for the same object.
|
@@ -72,7 +72,7 @@ It patches object, just use it with any method that matches the pattern is_foo?
|
|
72
72
|
|
73
73
|
## Contributing
|
74
74
|
|
75
|
-
1. Fork it ( http://github.com
|
75
|
+
1. Fork it ( http://github.com/baweaver/izzy/fork )
|
76
76
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
77
77
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
78
78
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/izzy.gemspec
CHANGED
data/lib/izzy/version.rb
CHANGED
data/lib/izzy.rb
CHANGED
@@ -1,17 +1,15 @@
|
|
1
|
-
require
|
1
|
+
require 'izzy/version'
|
2
2
|
|
3
3
|
class Object
|
4
|
-
|
5
|
-
|
6
|
-
def is_all_of(*methods)
|
7
|
-
methods.all?(&METHOD_CHECK)
|
4
|
+
def all_of?(*methods)
|
5
|
+
methods.all? { |method| (m = "is_#{method}?".to_sym) && self.respond_to?(m) && self.send(m) }
|
8
6
|
end
|
9
7
|
|
10
|
-
def
|
11
|
-
methods.any?(
|
8
|
+
def any_of?(*methods)
|
9
|
+
methods.any? { |method| (m = "is_#{method}?".to_sym) && self.respond_to?(m) && self.send(m) }
|
12
10
|
end
|
13
11
|
|
14
|
-
def
|
15
|
-
methods.none?(
|
12
|
+
def none_of?(*methods)
|
13
|
+
methods.none? { |method| (m = "is_#{method}?".to_sym) && self.respond_to?(m) && self.send(m) }
|
16
14
|
end
|
17
15
|
end
|
data/spec/izzy_spec.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Person
|
4
|
+
def initialize(name, age, sex)
|
5
|
+
@name = name
|
6
|
+
@age = age
|
7
|
+
@sex = sex
|
8
|
+
end
|
9
|
+
|
10
|
+
def is_older_than_18?
|
11
|
+
@age > 18
|
12
|
+
end
|
13
|
+
|
14
|
+
def is_younger_than_18?
|
15
|
+
@age < 18
|
16
|
+
end
|
17
|
+
|
18
|
+
def is_male?
|
19
|
+
@sex.eql? 'm'
|
20
|
+
end
|
21
|
+
|
22
|
+
def is_female?
|
23
|
+
@sex.eql? 'f'
|
24
|
+
end
|
25
|
+
|
26
|
+
def is_me?
|
27
|
+
@name.eql?('brandon') && @sex.eql?('m')
|
28
|
+
end
|
29
|
+
|
30
|
+
def is_geek?
|
31
|
+
@name.eql? 'brandon'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'Person' do
|
36
|
+
before(:all) { @person = Person.new('brandon', 23, 'm') }
|
37
|
+
|
38
|
+
describe '#all_of?' do
|
39
|
+
it 'returns true if Person matches all of the conditions' do
|
40
|
+
expect(@person.all_of? :older_than_18, :male, :geek).to be_true
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'returns false if Person does not match all of the conditions' do
|
44
|
+
expect(@person.all_of? :younger_than_18, :male).to be_false
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#any_of?' do
|
49
|
+
it 'returns true if Person matches any of the conditions' do
|
50
|
+
expect(@person.any_of? :older_than_18, :female, :geek).to be_true
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'returns false if Person matches none of the conditions' do
|
54
|
+
expect(@person.any_of? :younger_than_18, :female).to be_false
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#none_of?' do
|
59
|
+
it 'returns true if Person matches none of the conditions' do
|
60
|
+
expect(@person.none_of? :younger_than_18, :female).to be_true
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'returns false if Person matches any of the conditions' do
|
64
|
+
expect(@person.none_of? :older_than_18, :female, :geek).to be_false
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: izzy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Weaver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description:
|
42
56
|
email:
|
43
57
|
- keystonelemur@gmail.com
|
@@ -46,6 +60,7 @@ extensions: []
|
|
46
60
|
extra_rdoc_files: []
|
47
61
|
files:
|
48
62
|
- .gitignore
|
63
|
+
- .rspec
|
49
64
|
- Gemfile
|
50
65
|
- LICENSE.txt
|
51
66
|
- README.md
|
@@ -53,6 +68,8 @@ files:
|
|
53
68
|
- izzy.gemspec
|
54
69
|
- lib/izzy.rb
|
55
70
|
- lib/izzy/version.rb
|
71
|
+
- spec/izzy_spec.rb
|
72
|
+
- spec/spec_helper.rb
|
56
73
|
homepage: http://www.github.com/baweaver/izzy
|
57
74
|
licenses:
|
58
75
|
- MIT
|
@@ -77,4 +94,6 @@ rubygems_version: 2.1.10
|
|
77
94
|
signing_key:
|
78
95
|
specification_version: 4
|
79
96
|
summary: Gives you methods to mitigate long conditionals
|
80
|
-
test_files:
|
97
|
+
test_files:
|
98
|
+
- spec/izzy_spec.rb
|
99
|
+
- spec/spec_helper.rb
|