izzy 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ea8cd88a3d1a4f422d1da5c6ff1e9bc188522f1
4
- data.tar.gz: b774560935f6bbf5ee97dc993c4753bc2266f19e
3
+ metadata.gz: 9c50a4a5a4470841c239dee6447b289e83c9a796
4
+ data.tar.gz: ba55942db205601a0a3f7bd81f04d203f23b6180
5
5
  SHA512:
6
- metadata.gz: 3393d1c4776dd90f941de98e5b19f4fcba81c7a79a2b8eedcd5c819c2d24e3622952110effcff2533e9d9bfd4c69b2d0e312e944567440d8c4c5f67f93a99943
7
- data.tar.gz: 28a25a641a3397a9ad4a5fac82e1de1df7c534326d74ca2ff487c6aaf9848afc371c69e0c6b7f80f38c7433795b95d3ffb003d8561ceaab6dea5c97870f5fe3c
6
+ metadata.gz: f260a577433a028da3017aee22ddae4008587ffbb29fc7a52010aac9137060723004178887367cba8765f446bf0738e73d1bf44d79a00aba6806846b143ed989
7
+ data.tar.gz: 1178efe9a6c7b04af9880a0d263edab852fe9dc0c69e9890ccf5684654860632ed9d486478ea8d5023f59f679c40594f8055028369962cad3a4375e5d44330ab
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
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.is_all_of(:older_than_18, :male, :me, :geek) # => true
49
- brandon.is_none_of(:younger_than_18, :female) # => true
50
- brandon.is_any_of(:male, :female, :geek) # => true
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/<my-github-username>/izzy/fork )
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
@@ -19,4 +19,5 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_development_dependency "bundler", "~> 1.5"
21
21
  spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "rspec"
22
23
  end
data/lib/izzy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Izzy
2
- VERSION = "0.0.1"
2
+ VERSION = '1.0.0'
3
3
  end
data/lib/izzy.rb CHANGED
@@ -1,17 +1,15 @@
1
- require "izzy/version"
1
+ require 'izzy/version'
2
2
 
3
3
  class Object
4
- METHOD_CHECK = -> method { "is_#{method}?".to_sym.tap { |m| self.respond_to?(m) && self.send(m) }}
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 is_any_of(*methods)
11
- methods.any?(&METHOD_CHECK)
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 is_none_of(*methods)
15
- methods.none?(&METHOD_CHECK)
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
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'izzy'
5
+
6
+ RSpec.configure do |config|
7
+ # some (optional) config here
8
+ end
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.1
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-25 00:00:00.000000000 Z
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