im_ron_burgundy 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,33 @@
1
+ I'm Ron Burgundy?
2
+ =================
3
+
4
+
5
+ Using
6
+ -----
7
+ <pre>
8
+ $ irb
9
+ ree-1.8.7-2010.02 > require 'rubygems'
10
+ => true
11
+ ree-1.8.7-2010.02 > require 'im_ron_burgundy'
12
+ => true
13
+ ree-1.8.7-2010.02 > class RonBurgundy
14
+ ree-1.8.7-2010.02 ?> end
15
+ => nil
16
+ ree-1.8.7-2010.02 > RonBurgundy.new.im_ron_burgundy?
17
+ => true
18
+
19
+ ree-1.8.7-2010.02 > "foo".im_ron_burgundy?
20
+ => false
21
+
22
+ ree-1.8.7-2010.02 > "ron burgundy".im_ron_burgundy?
23
+ => true
24
+
25
+ ree-1.8.7-2010.02 > class Person
26
+ ree-1.8.7-2010.02 ?> def name
27
+ ree-1.8.7-2010.02 ?> "Ronald Burgundy"
28
+ ree-1.8.7-2010.02 ?> end
29
+ ree-1.8.7-2010.02 ?> end
30
+ => nil
31
+ ree-1.8.7-2010.02 > Person.new.im_ron_burgundy?
32
+ => true
33
+ </pre>
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Brian Olore"]
10
10
  s.email = ["brian@olore.net"]
11
- s.homepage = "http://rubygems.org/gems/im_ron_burgundy"
11
+ s.homepage = "http://github.com/olore/im_ron_burgundy"
12
12
  s.summary = 'Determine if an object is Ron Burgundy or not.'
13
13
  s.description = %q{Is the object you're working on Ron Burgundy?}
14
14
 
@@ -7,43 +7,36 @@ module ImRonBurgundy
7
7
 
8
8
  module InstanceMethods
9
9
  def im_ron_burgundy?
10
- check(self.to_s) || check_name || check_signature_quote
10
+ check_string(self.to_s) || check_class(self.class) ||
11
+ has_name? || has_signature_quote?
11
12
  end
12
13
 
13
- def check(name)
14
- return true if name.match /Ron(ald|nie){0,1} Burgundy/i
15
- return false
14
+ private
15
+
16
+ def check_string(name)
17
+ name.match(/Ron(ald|nie){0,1} Burgundy/i) != nil
16
18
  end
17
19
 
18
- def check_name
19
- return true if self.respond_to?(:name) && check(self.name)
20
- return false
20
+ def has_name?
21
+ respond_to?(:name) && check_string(self.name)
21
22
  end
22
23
 
23
- def check_signature_quote
24
- return true if self.respond_to?(:signature_quote) && self.signature_quote == "You stay classy, San Diego!"
25
- return false
24
+ def check_class(name)
25
+ RON_BURGUNDY_CLASS_NAMES.include?(name.to_s)
26
26
  end
27
27
 
28
+ def has_signature_quote?
29
+ respond_to?(:signature_quote) && signature_quote == "You stay classy, San Diego!"
30
+ end
28
31
  end
29
32
 
30
33
  module ClassMethods
31
34
  def im_ron_burgundy?
32
- check_class(self.name)
33
- end
34
-
35
- def check_string(name)
36
- return true if name.match /Ron(ald|nie){0,1} Burgundy/i
37
- return false
38
- end
39
-
40
- def check_class(name)
41
- return true if CLASS_NAMES.include?(self.name)
42
- return false
35
+ RON_BURGUNDY_CLASS_NAMES.include?(self.name)
43
36
  end
44
37
  end
45
38
 
46
- CLASS_NAMES = ["RonBurgundy", "RonaldBurgundy", "RonnieBurgundy"]
39
+ RON_BURGUNDY_CLASS_NAMES = ["RonBurgundy", "RonaldBurgundy", "RonnieBurgundy"]
47
40
  end
48
41
 
49
42
  class Object
@@ -1,3 +1,3 @@
1
1
  module ImRonBurgundy
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -3,14 +3,20 @@ require File.dirname(__FILE__) + '/test_helper'
3
3
  class ObjectTest < Test::Unit::TestCase
4
4
 
5
5
  def test_object_is_not_ron_burgundy
6
- assert 1, Object.methods.sort.grep(/im_ron_burgundy/).size
7
- assert !Object.im_ron_burgundy?
6
+ assert_equal 1, Object.methods.sort.grep(/im_ron_burgundy/).size
7
+ assert_equal false, Object.im_ron_burgundy?
8
8
  end
9
9
 
10
10
  def test_ron_burgundy_class_IS_ron_burgundy
11
11
  dummy_class = Class.new
12
12
  Object.const_set("RonBurgundy", dummy_class)
13
- assert RonBurgundy.im_ron_burgundy?
13
+ assert_equal true, RonBurgundy.im_ron_burgundy?
14
+ end
15
+
16
+ def test_ron_burgundy_class_instance_IS_ron_burgundy
17
+ dummy_class = Class.new
18
+ Object.const_set("RonaldBurgundy", dummy_class)
19
+ assert_equal true, RonaldBurgundy.new.im_ron_burgundy?
14
20
  end
15
21
 
16
22
  def test_object_is_ron_burgundy_if_name_is_ron_burgundy
@@ -20,7 +26,7 @@ class ObjectTest < Test::Unit::TestCase
20
26
  end
21
27
  }
22
28
  Object.const_set("SomeClass", dummy_class)
23
- assert SomeClass.new.im_ron_burgundy?
29
+ assert_equal true, SomeClass.new.im_ron_burgundy?
24
30
  end
25
31
 
26
32
  def test_object_is_ron_burgundy_if_signature_quote
@@ -30,6 +36,35 @@ class ObjectTest < Test::Unit::TestCase
30
36
  end
31
37
  }
32
38
  Object.const_set("SomeOtherClass", dummy_class)
33
- assert SomeOtherClass.new.im_ron_burgundy?
39
+ assert_equal true, SomeOtherClass.new.im_ron_burgundy?
40
+ end
41
+
42
+ def test_private_class_methods
43
+ assert_raise NoMethodError do
44
+ Object.check_class("foo")
45
+ end
46
+ assert_raise NoMethodError do
47
+ Object.check_string("foo")
48
+ end
34
49
  end
50
+
51
+ def test_private_instance_methods
52
+ dummy_class = Class.new
53
+ Object.const_set("RonnieBurgundy", dummy_class)
54
+ assert_equal true, RonnieBurgundy.new.im_ron_burgundy?
55
+
56
+ assert_raise NoMethodError do
57
+ RonnieBurgundy.new.check_string("foo")
58
+ end
59
+ assert_raise NoMethodError do
60
+ RonnieBurgundy.new.check_class("foo")
61
+ end
62
+ assert_raise NoMethodError do
63
+ RonnieBurgundy.new.has_name?
64
+ end
65
+ assert_raise NoMethodError do
66
+ RonnieBurgundy.new.has_signature_quote?
67
+ end
68
+ end
69
+
35
70
  end
@@ -3,25 +3,25 @@ require File.dirname(__FILE__) + '/test_helper'
3
3
  class StringTest < Test::Unit::TestCase
4
4
 
5
5
  def test_string_is_not_ron_burgundy
6
- assert 1, String.methods.sort.grep(/im_ron_burgundy/).size
7
- assert !String.im_ron_burgundy?
6
+ assert_equal 1, String.methods.sort.grep(/im_ron_burgundy/).size
7
+ assert_equal false, String.im_ron_burgundy?
8
8
  end
9
9
 
10
10
  def test_a_string_is_not_ron_burgundy
11
- assert ! "foo".im_ron_burgundy?
11
+ assert_equal false, "foo".im_ron_burgundy?
12
12
  end
13
13
 
14
14
  def test_ron_burgundy_IS_ron_burgundy
15
- assert "Ron Burgundy".im_ron_burgundy?
16
- assert "ron burgundy".im_ron_burgundy?
15
+ assert_equal true, "Ron Burgundy".im_ron_burgundy?
16
+ assert_equal true, "ron burgundy".im_ron_burgundy?
17
17
  end
18
18
 
19
19
  def test_ronald_burgundy_IS_ron_burgundy
20
- assert "Ronald Burgundy".im_ron_burgundy?
20
+ assert_equal true, "Ronald Burgundy".im_ron_burgundy?
21
21
  end
22
22
 
23
23
  def test_ronnie_burgundy_IS_ron_burgundy
24
- assert "Ronnie Burgundy".im_ron_burgundy?
25
- assert !"Ronaldnie Burgundy".im_ron_burgundy?
24
+ assert_equal true, "Ronnie Burgundy".im_ron_burgundy?
25
+ assert_equal false, "Ronaldnie Burgundy".im_ron_burgundy?
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: im_ron_burgundy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
5
- prerelease: false
4
+ hash: 27
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Olore
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-11 00:00:00 -04:00
19
- default_executable:
18
+ date: 2012-01-06 00:00:00 Z
20
19
  dependencies: []
21
20
 
22
21
  description: Is the object you're working on Ron Burgundy?
@@ -31,6 +30,7 @@ extra_rdoc_files: []
31
30
  files:
32
31
  - .gitignore
33
32
  - Gemfile
33
+ - README.md
34
34
  - Rakefile
35
35
  - im_ron_burgundy.gemspec
36
36
  - lib/im_ron_burgundy.rb
@@ -38,8 +38,7 @@ files:
38
38
  - test/object_test.rb
39
39
  - test/string_test.rb
40
40
  - test/test_helper.rb
41
- has_rdoc: true
42
- homepage: http://rubygems.org/gems/im_ron_burgundy
41
+ homepage: http://github.com/olore/im_ron_burgundy
43
42
  licenses: []
44
43
 
45
44
  post_install_message:
@@ -68,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
67
  requirements: []
69
68
 
70
69
  rubyforge_project:
71
- rubygems_version: 1.3.7
70
+ rubygems_version: 1.8.10
72
71
  signing_key:
73
72
  specification_version: 3
74
73
  summary: Determine if an object is Ron Burgundy or not.