introspect 0.1.0
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.
- checksums.yaml +7 -0
- data/.codeclimate.yml +18 -0
- data/.gitignore +9 -0
- data/.rspec +1 -0
- data/.rubocop.yml +1156 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +14 -0
- data/Guardfile +9 -0
- data/LICENSE +202 -0
- data/NOTICE +14 -0
- data/README.markdown +81 -0
- data/Rakefile +6 -0
- data/exe/introspect +5 -0
- data/introspect.gemspec +27 -0
- data/lib/introspect.rb +29 -0
- data/lib/introspect/cli.rb +16 -0
- data/lib/introspect/contents.rb +58 -0
- data/lib/introspect/core_ext.rb +3 -0
- data/lib/introspect/version.rb +3 -0
- data/lib/introspect/which.rb +33 -0
- metadata +122 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
module Introspect
|
2
|
+
class Which
|
3
|
+
def self.which object, method_name
|
4
|
+
self.new(object).which method_name
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize object
|
8
|
+
@object = object
|
9
|
+
end
|
10
|
+
|
11
|
+
def which method_name
|
12
|
+
ometh = proc { |obj,sym| return obj if obj.methods(false).include? sym }
|
13
|
+
imeth = proc { |obj,sym| return obj if obj.instance_methods(false).include? sym }
|
14
|
+
|
15
|
+
begin
|
16
|
+
# first check the eigenclass
|
17
|
+
imeth[(class << @object; self; end),method_name]
|
18
|
+
rescue TypeError => err
|
19
|
+
raise unless err.message.include? 'singleton'
|
20
|
+
end
|
21
|
+
|
22
|
+
obj = @object.is_a?(::Module) ? @object : @object.class
|
23
|
+
|
24
|
+
# then we check the normal class heirarchy
|
25
|
+
obj.ancestors.each.with_object method_name, &imeth
|
26
|
+
# check the metaclasses
|
27
|
+
obj.class.ancestors.each.with_object method_name, &ometh
|
28
|
+
obj.class.ancestors.each.with_object method_name, &imeth
|
29
|
+
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: introspect
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anthony Cook
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
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'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: open4
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Makes digging deeper into Ruby objects easier.
|
70
|
+
email:
|
71
|
+
- github@anthonymcook.com
|
72
|
+
executables:
|
73
|
+
- introspect
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".codeclimate.yml"
|
78
|
+
- ".gitignore"
|
79
|
+
- ".rspec"
|
80
|
+
- ".rubocop.yml"
|
81
|
+
- ".ruby-gemset"
|
82
|
+
- ".ruby-version"
|
83
|
+
- ".travis.yml"
|
84
|
+
- Gemfile
|
85
|
+
- Guardfile
|
86
|
+
- LICENSE
|
87
|
+
- NOTICE
|
88
|
+
- README.markdown
|
89
|
+
- Rakefile
|
90
|
+
- exe/introspect
|
91
|
+
- introspect.gemspec
|
92
|
+
- lib/introspect.rb
|
93
|
+
- lib/introspect/cli.rb
|
94
|
+
- lib/introspect/contents.rb
|
95
|
+
- lib/introspect/core_ext.rb
|
96
|
+
- lib/introspect/version.rb
|
97
|
+
- lib/introspect/which.rb
|
98
|
+
homepage: http://github.com/acook/introspect
|
99
|
+
licenses:
|
100
|
+
- Apache-2.0
|
101
|
+
metadata: {}
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options: []
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 2.6.7
|
119
|
+
signing_key:
|
120
|
+
specification_version: 4
|
121
|
+
summary: A tool to examine your Ruby environment.
|
122
|
+
test_files: []
|