interrogate 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +7 -0
- data/README.md +1 -0
- data/interrogate.gemspec +1 -1
- data/lib/interrogate.rb +4 -21
- data/lib/interrogate/object.rb +19 -0
- data/lib/interrogate/version.rb +1 -1
- metadata +56 -61
data/MIT-LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2012 Morgan Brown
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Interrogate [![Build Status](https://secure.travis-ci.org/mhgbrown/interrogate.png)](http://travis-ci.org/mhgbrown/interrogate)
|
2
2
|
Interrogate attempts to bring Scheme-like class predication to Ruby. It provides an alternate syntax using `Module#===`.
|
3
3
|
|
4
|
+
>> require "interrogate"
|
4
5
|
>> String?("Hello")
|
5
6
|
>> trues
|
6
7
|
>> Symbol?(:World)
|
data/interrogate.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = Interrogate::VERSION
|
8
8
|
s.authors = ["Morgan Brown"]
|
9
9
|
s.email = ["brown.mhg@gmail.com"]
|
10
|
-
s.homepage = "https://github.com/
|
10
|
+
s.homepage = "https://github.com/discom4rt/interrogate"
|
11
11
|
s.summary = "Scheme-like class predication for Ruby"
|
12
12
|
s.description = "String?(\"Hello\") Interrogate attempts to bring Scheme-like class predication to Ruby. It provides an alternate syntax using Module#==="
|
13
13
|
|
data/lib/interrogate.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "interrogate/version"
|
2
|
+
require "interrogate/object"
|
2
3
|
|
3
4
|
# String?("Hello")
|
4
5
|
# Interrogate attempts to bring Scheme-like class predication to Ruby.
|
@@ -10,10 +11,11 @@ module Interrogate
|
|
10
11
|
# ask each arg if it is an instance of this class.
|
11
12
|
def self.interrogate(meth, *args, &block)
|
12
13
|
raise ArgumentError, "#{meth}: requires at least one argument and/or a block" if args.length < 1 && !block
|
13
|
-
|
14
|
+
|
15
|
+
klass_name = meth.to_s[0..-2]
|
14
16
|
klass = Object.const_get(klass_name)
|
15
17
|
args << yield if block_given?
|
16
|
-
args.inject(true){|bool, obj| bool && klass === obj}
|
18
|
+
args.inject(true) { |bool, obj| bool && klass === obj }
|
17
19
|
end
|
18
20
|
|
19
21
|
# Determine if the given method matches an interrogatory
|
@@ -24,22 +26,3 @@ module Interrogate
|
|
24
26
|
|
25
27
|
end
|
26
28
|
|
27
|
-
class Object
|
28
|
-
|
29
|
-
# If the method name is interrogatory, then
|
30
|
-
# try to interrogate the arguments in question.
|
31
|
-
# Otherwise, perform the default method missing
|
32
|
-
# behavior.
|
33
|
-
def self.method_missing(meth, *args, &block)
|
34
|
-
Interrogate.is_interrogatory?(meth) ? Interrogate.interrogate(meth, *args, &block) : super
|
35
|
-
end
|
36
|
-
|
37
|
-
# If the method name is interrogatory, then
|
38
|
-
# try to interrogate the arguments in question.
|
39
|
-
# Otherwise, perform the default method missing
|
40
|
-
# behavior.
|
41
|
-
def method_missing(meth, *args, &block)
|
42
|
-
Interrogate.is_interrogatory?(meth) ? Interrogate.interrogate(meth, *args, &block) : super
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Object
|
2
|
+
|
3
|
+
# If the method name is interrogatory, then
|
4
|
+
# try to interrogate the arguments in question.
|
5
|
+
# Otherwise, perform the default method missing
|
6
|
+
# behavior.
|
7
|
+
def self.method_missing(meth, *args, &block)
|
8
|
+
Interrogate.is_interrogatory?(meth) ? Interrogate.interrogate(meth, *args, &block) : super
|
9
|
+
end
|
10
|
+
|
11
|
+
# If the method name is interrogatory, then
|
12
|
+
# try to interrogate the arguments in question.
|
13
|
+
# Otherwise, perform the default method missing
|
14
|
+
# behavior.
|
15
|
+
def method_missing(meth, *args, &block)
|
16
|
+
Interrogate.is_interrogatory?(meth) ? Interrogate.interrogate(meth, *args, &block) : super
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/lib/interrogate/version.rb
CHANGED
metadata
CHANGED
@@ -1,103 +1,98 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: interrogate
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 2
|
10
|
-
version: 0.0.2
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Morgan Brown
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-05-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rake
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
32
22
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: rspec
|
36
23
|
prerelease: false
|
37
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
38
33
|
none: false
|
39
|
-
requirements:
|
40
|
-
- -
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
|
43
|
-
segments:
|
44
|
-
- 0
|
45
|
-
version: "0"
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
46
38
|
type: :development
|
47
|
-
|
48
|
-
|
49
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: String?("Hello") Interrogate attempts to bring Scheme-like class predication
|
47
|
+
to Ruby. It provides an alternate syntax using Module#===
|
48
|
+
email:
|
50
49
|
- brown.mhg@gmail.com
|
51
50
|
executables: []
|
52
|
-
|
53
51
|
extensions: []
|
54
|
-
|
55
52
|
extra_rdoc_files: []
|
56
|
-
|
57
|
-
files:
|
53
|
+
files:
|
58
54
|
- .gitignore
|
59
55
|
- .travis.yml
|
60
56
|
- Gemfile
|
57
|
+
- MIT-LICENSE
|
61
58
|
- README.md
|
62
59
|
- Rakefile
|
63
60
|
- interrogate.gemspec
|
64
61
|
- lib/interrogate.rb
|
62
|
+
- lib/interrogate/object.rb
|
65
63
|
- lib/interrogate/version.rb
|
66
64
|
- spec/interrogate/interrogate_spec.rb
|
67
65
|
- spec/spec_helper.rb
|
68
|
-
homepage: https://github.com/
|
66
|
+
homepage: https://github.com/discom4rt/interrogate
|
69
67
|
licenses: []
|
70
|
-
|
71
68
|
post_install_message:
|
72
69
|
rdoc_options: []
|
73
|
-
|
74
|
-
require_paths:
|
70
|
+
require_paths:
|
75
71
|
- lib
|
76
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
73
|
none: false
|
78
|
-
requirements:
|
79
|
-
- -
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
|
82
|
-
segments:
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
segments:
|
83
79
|
- 0
|
84
|
-
|
85
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
hash: -1201864899983406010
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
82
|
none: false
|
87
|
-
requirements:
|
88
|
-
- -
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
|
91
|
-
segments:
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
segments:
|
92
88
|
- 0
|
93
|
-
|
89
|
+
hash: -1201864899983406010
|
94
90
|
requirements: []
|
95
|
-
|
96
91
|
rubyforge_project: interrogate
|
97
|
-
rubygems_version: 1.8.
|
92
|
+
rubygems_version: 1.8.24
|
98
93
|
signing_key:
|
99
94
|
specification_version: 3
|
100
95
|
summary: Scheme-like class predication for Ruby
|
101
|
-
test_files:
|
96
|
+
test_files:
|
102
97
|
- spec/interrogate/interrogate_spec.rb
|
103
98
|
- spec/spec_helper.rb
|