im_ron_burgundy 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in im_ron_burgundy?.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'bundler'
2
+ require 'rake/testtask'
3
+
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ desc 'Run tests'
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.libs << 'lib'
9
+ t.libs << 'test'
10
+ t.pattern = 'test/**/*_test.rb'
11
+ t.verbose = true
12
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "im_ron_burgundy/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "im_ron_burgundy"
7
+ s.version = ImRonBurgundy::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Brian Olore"]
10
+ s.email = ["brian@olore.net"]
11
+ s.homepage = "http://rubygems.org/gems/im_ron_burgundy"
12
+ s.summary = 'Determine if an object is Ron Burgundy or not.'
13
+ s.description = %q{Is the object you're working on Ron Burgundy?}
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+ end
@@ -0,0 +1,3 @@
1
+ module ImRonBurgundy
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,51 @@
1
+ module ImRonBurgundy
2
+
3
+ def self.included(base)
4
+ base.send :include, InstanceMethods
5
+ base.send :extend, ClassMethods
6
+ end
7
+
8
+ module InstanceMethods
9
+ def im_ron_burgundy?
10
+ check(self.to_s) || check_name || check_signature_quote
11
+ end
12
+
13
+ def check(name)
14
+ return true if name.match /Ron(ald|nie){0,1} Burgundy/i
15
+ return false
16
+ end
17
+
18
+ def check_name
19
+ return true if self.respond_to?(:name) && check(self.name)
20
+ return false
21
+ end
22
+
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
26
+ end
27
+
28
+ end
29
+
30
+ module ClassMethods
31
+ 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
43
+ end
44
+ end
45
+
46
+ CLASS_NAMES = ["RonBurgundy", "RonaldBurgundy", "RonnieBurgundy"]
47
+ end
48
+
49
+ class Object
50
+ include ImRonBurgundy
51
+ end
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class ObjectTest < Test::Unit::TestCase
4
+
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?
8
+ end
9
+
10
+ def test_ron_burgundy_class_IS_ron_burgundy
11
+ dummy_class = Class.new
12
+ Object.const_set("RonBurgundy", dummy_class)
13
+ assert RonBurgundy.im_ron_burgundy?
14
+ end
15
+
16
+ def test_object_is_ron_burgundy_if_name_is_ron_burgundy
17
+ dummy_class = Class.new {
18
+ def name
19
+ "Ron Burgundy"
20
+ end
21
+ }
22
+ Object.const_set("SomeClass", dummy_class)
23
+ assert SomeClass.new.im_ron_burgundy?
24
+ end
25
+
26
+ def test_object_is_ron_burgundy_if_signature_quote
27
+ dummy_class = Class.new {
28
+ def signature_quote
29
+ "You stay classy, San Diego!"
30
+ end
31
+ }
32
+ Object.const_set("SomeOtherClass", dummy_class)
33
+ assert SomeOtherClass.new.im_ron_burgundy?
34
+ end
35
+ end
@@ -0,0 +1,27 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class StringTest < Test::Unit::TestCase
4
+
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?
8
+ end
9
+
10
+ def test_a_string_is_not_ron_burgundy
11
+ assert ! "foo".im_ron_burgundy?
12
+ end
13
+
14
+ def test_ron_burgundy_IS_ron_burgundy
15
+ assert "Ron Burgundy".im_ron_burgundy?
16
+ assert "ron burgundy".im_ron_burgundy?
17
+ end
18
+
19
+ def test_ronald_burgundy_IS_ron_burgundy
20
+ assert "Ronald Burgundy".im_ron_burgundy?
21
+ end
22
+
23
+ def test_ronnie_burgundy_IS_ron_burgundy
24
+ assert "Ronnie Burgundy".im_ron_burgundy?
25
+ assert !"Ronaldnie Burgundy".im_ron_burgundy?
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ require 'test/unit'
2
+ ENV["RAILS_ENV"] = "test"
3
+ $:.unshift File.dirname(__FILE__)
4
+
5
+ require File.dirname(__FILE__) + '/../lib/im_ron_burgundy'
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: im_ron_burgundy
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Brian Olore
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-09-11 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Is the object you're working on Ron Burgundy?
23
+ email:
24
+ - brian@olore.net
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - Rakefile
35
+ - im_ron_burgundy.gemspec
36
+ - lib/im_ron_burgundy.rb
37
+ - lib/im_ron_burgundy/version.rb
38
+ - test/object_test.rb
39
+ - test/string_test.rb
40
+ - test/test_helper.rb
41
+ has_rdoc: true
42
+ homepage: http://rubygems.org/gems/im_ron_burgundy
43
+ licenses: []
44
+
45
+ post_install_message:
46
+ rdoc_options: []
47
+
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.3.7
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Determine if an object is Ron Burgundy or not.
75
+ test_files:
76
+ - test/object_test.rb
77
+ - test/string_test.rb
78
+ - test/test_helper.rb