respond_to_missing 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +22 -7
- data/Rakefile +7 -5
- data/lib/respond_to_missing.rb +4 -4
- data/lib/respond_to_missing/version.rb +1 -1
- data/test/respond_to_missing_test.rb +13 -3
- data/test/test_helper.rb +1 -3
- metadata +7 -10
data/README.rdoc
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
= respond_to_missing
|
2
2
|
|
3
|
-
|
3
|
+
{<img src="https://secure.travis-ci.org/shuber/respond_to_missing.png"/>}[http://travis-ci.org/shuber/respond_to_missing]
|
4
|
+
{<img src="https://d25lcipzij17d.cloudfront.net/badge.png?v=0.0.1"/>}[http://rubygems.org/gems/respond_to_missing]
|
5
|
+
{<img src="https://codeclimate.com/badge.png" />}[https://codeclimate.com/github/shuber/respond_to_missing]
|
6
|
+
|
7
|
+
Defines <tt>{Object#respond_to_missing?}[http://www.ruby-doc.org/core/classes/Object.html#M001006]</tt> and patches <tt>{Object#respond_to?}[http://www.ruby-doc.org/core/classes/Object.html#M001005]</tt> unless this functionality has already been implemented (ruby versions 1.9+)
|
4
8
|
|
5
9
|
|
6
10
|
== Installation
|
@@ -8,10 +12,21 @@ Defines <tt>{Object#respond_to_missing?}[http://www.ruby-doc.org/core/classes/Ob
|
|
8
12
|
gem install respond_to_missing
|
9
13
|
|
10
14
|
|
11
|
-
==
|
15
|
+
== Usage
|
16
|
+
|
17
|
+
Define <tt>respond_to_missing?</tt> whenever an object overrides <tt>method_missing</tt>
|
18
|
+
|
19
|
+
class User
|
20
|
+
def method_missing(method_name, *args)
|
21
|
+
method_name == :test_method ? true : super
|
22
|
+
end
|
23
|
+
|
24
|
+
def respond_to_missing?(method_name, include_super)
|
25
|
+
method_name == :test_method || super
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
== Testing
|
12
31
|
|
13
|
-
|
14
|
-
* Make your feature addition or bug fix.
|
15
|
-
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
16
|
-
* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
17
|
-
* Send me a pull request. Bonus points for topic branches.
|
32
|
+
rake
|
data/Rakefile
CHANGED
@@ -1,15 +1,17 @@
|
|
1
|
-
require 'rake'
|
2
1
|
require 'rake/testtask'
|
3
|
-
|
2
|
+
begin
|
3
|
+
require 'rdoc/task'
|
4
|
+
rescue LoadError
|
5
|
+
require 'rake/rdoctask'
|
6
|
+
end
|
4
7
|
|
5
8
|
desc 'Default: run unit tests'
|
6
9
|
task :default => :test
|
7
10
|
|
8
11
|
desc 'Test the respond_to_missing gem'
|
9
12
|
Rake::TestTask.new(:test) do |t|
|
10
|
-
t.libs
|
11
|
-
t.
|
12
|
-
t.verbose = true
|
13
|
+
t.libs.push 'lib'
|
14
|
+
t.test_files = FileList['test/*_test.rb']
|
13
15
|
end
|
14
16
|
|
15
17
|
desc 'Generate documentation for the respond_to_missing gem'
|
data/lib/respond_to_missing.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
# Defines <tt>Object#respond_to_missing?</tt> and patches <tt>Object#respond_to?</tt> unless this functionality has already been implemented (ruby
|
1
|
+
# Defines <tt>Object#respond_to_missing?</tt> and patches <tt>Object#respond_to?</tt> unless this functionality has already been implemented (ruby versions 1.9+)
|
2
2
|
module RespondToMissing
|
3
3
|
autoload :Version, 'respond_to_missing/version'
|
4
4
|
|
5
|
-
def respond_to?(
|
6
|
-
super || respond_to_missing?(
|
5
|
+
def respond_to?(method_name, include_private = false)
|
6
|
+
super || !!respond_to_missing?(method_name, include_private)
|
7
7
|
end
|
8
8
|
|
9
|
-
def respond_to_missing?(
|
9
|
+
def respond_to_missing?(method_name, include_private)
|
10
10
|
false
|
11
11
|
end
|
12
12
|
end
|
@@ -2,17 +2,27 @@ require File.expand_path('../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
class RespondToMissingTest < Test::Unit::TestCase
|
4
4
|
module Mock
|
5
|
-
def self.respond_to_missing?(
|
6
|
-
|
5
|
+
def self.respond_to_missing?(method_name, include_private)
|
6
|
+
method_name == :testing || super
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module NonBooleanMock
|
11
|
+
def self.respond_to_missing?(method_name, include_private)
|
12
|
+
'test'
|
7
13
|
end
|
8
14
|
end
|
9
15
|
|
10
16
|
def test_should_respond_to_respond_to_missing
|
11
|
-
assert respond_to?(:respond_to_missing?)
|
17
|
+
assert Object.new.respond_to?(:respond_to_missing?)
|
12
18
|
end
|
13
19
|
|
14
20
|
def test_should_pass_failing_respond_to_calls_to_respond_to_missing
|
15
21
|
assert Mock.respond_to?(:testing)
|
16
22
|
assert !Mock.respond_to?(:undefined_method)
|
17
23
|
end
|
24
|
+
|
25
|
+
def test_should_always_return_a_boolean
|
26
|
+
assert_equal true, NonBooleanMock.respond_to?(:testing)
|
27
|
+
end
|
18
28
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: respond_to_missing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sean Huber
|
@@ -15,11 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2013-01-25 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
22
|
-
description: Defines Object#respond_to_missing? and patches Object#respond_to? unless this functionality has already been implemented (ruby
|
22
|
+
description: Defines Object#respond_to_missing? and patches Object#respond_to? unless this functionality has already been implemented (ruby versions 1.9+)
|
23
23
|
email: shuber@huberry.com
|
24
24
|
executables: []
|
25
25
|
|
@@ -40,11 +40,8 @@ homepage: http://github.com/shuber/respond_to_missing
|
|
40
40
|
licenses: []
|
41
41
|
|
42
42
|
post_install_message:
|
43
|
-
rdoc_options:
|
44
|
-
|
45
|
-
- --inline-source
|
46
|
-
- --main
|
47
|
-
- README.rdoc
|
43
|
+
rdoc_options: []
|
44
|
+
|
48
45
|
require_paths:
|
49
46
|
- lib
|
50
47
|
required_ruby_version: !ruby/object:Gem::Requirement
|