method_info 0.1.8 → 0.1.9
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/README.rdoc +1 -1
- data/VERSION +1 -1
- data/lib/method_info/ancestor_method_structure.rb +24 -8
- data/lib/method_info/object_method.rb +1 -0
- data/lib/method_info/option_handler.rb +2 -1
- data/spec/method_info/option_handler_spec.rb +1 -0
- metadata +26 -13
data/README.rdoc
CHANGED
@@ -23,7 +23,7 @@ Defines a method_info method on every Object which will show the methods that ea
|
|
23
23
|
* :module_color Set colour for a line printing out a module (only used when :enable_colors is true)
|
24
24
|
* :message_color Set colour for a line with a message (only used when :enable_colors is true)
|
25
25
|
* :methods_color Set colour for a line with methods (only used when :enable_colors is true)
|
26
|
-
|
26
|
+
* :match Shows only those methods that match this option. It's value can be either a string or a regexp (default: nil)
|
27
27
|
You can set default options which will override the inbuild defaults. Here is an example which
|
28
28
|
will hide the methods defined on all instances of Object and show colour in the output (this
|
29
29
|
requires the ansi-termcolor gem):
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.9
|
@@ -21,6 +21,7 @@ module MethodInfo
|
|
21
21
|
# :methods_color Set colour for a line with methods (only used when :enable_colors is true)
|
22
22
|
# :punctuation_color Set colour for punctuation (only used when :enable_colors is true)
|
23
23
|
# :suppress_slowness_warning Does not print out the warning about slowness on older ruby versions (default: false)
|
24
|
+
# :match Shows only those methods that match this option. It's value can be either a string or a regexp (default: nil)
|
24
25
|
def self.build(object, options)
|
25
26
|
if VERSION < "1.8.7" && !options[:suppress_slowness_warning]
|
26
27
|
STDERR.puts "You are using Ruby #{VERSION}, this may take a while. It will be faster for >=1.8.7."
|
@@ -34,6 +35,13 @@ module MethodInfo
|
|
34
35
|
|
35
36
|
ancestor_method_structure = AncestorMethodStructure.new(object, options)
|
36
37
|
|
38
|
+
if(match = options[:match])
|
39
|
+
unless match.is_a?(Regexp)
|
40
|
+
match = Regexp.new(match)
|
41
|
+
end
|
42
|
+
methods = methods.select { |m| m =~ match }
|
43
|
+
end
|
44
|
+
|
37
45
|
methods.each do |method|
|
38
46
|
ancestor_method_structure.add_method_to_ancestor(method)
|
39
47
|
end
|
@@ -95,15 +103,23 @@ module MethodInfo
|
|
95
103
|
punctuation_color = ""
|
96
104
|
end
|
97
105
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
methods_color,
|
102
|
-
@ancestor_methods[ancestor].sort.join("#{punctuation_color}, #{methods_color}")]
|
103
|
-
end.join('')
|
104
|
-
if @options[:include_names_of_methodless_ancestors] && ! methodless_ancestors.empty?
|
105
|
-
s += "#{message_color}Methodless:#{reset_color} " + methodless_ancestors.join(', ') + "\n"
|
106
|
+
ancestors_to_show = @ancestor_filter.picked
|
107
|
+
unless @options[:include_names_of_methodless_ancestors]
|
108
|
+
ancestors_to_show = ancestors_with_methods
|
106
109
|
end
|
110
|
+
|
111
|
+
s = ancestors_to_show.map do |ancestor|
|
112
|
+
result = "%s::: %s :::\n" % [ancestor.is_a?(Class) ? class_color : module_color,
|
113
|
+
ancestor.to_s]
|
114
|
+
unless @ancestor_methods[ancestor].empty?
|
115
|
+
result += "%s%s\n" % [methods_color,
|
116
|
+
@ancestor_methods[ancestor].sort.join("#{punctuation_color}, #{methods_color}")]
|
117
|
+
end
|
118
|
+
result
|
119
|
+
end.join('')
|
120
|
+
# if @options[:include_names_of_methodless_ancestors] && ! methodless_ancestors.empty?
|
121
|
+
# s += "#{message_color}Methodless:#{reset_color} " + methodless_ancestors.join(', ') + "\n"
|
122
|
+
# end
|
107
123
|
if @options[:include_names_of_excluded_ancestors] && ! @ancestor_filter.excluded.empty?
|
108
124
|
s += "#{message_color}Excluded:#{reset_color} " + @ancestor_filter.excluded.join(', ') + "\n"
|
109
125
|
end
|
@@ -26,6 +26,7 @@ module MethodInfo
|
|
26
26
|
# :message_color Set colour for a line with a message (only used when :enable_colors is true)
|
27
27
|
# :methods_color Set colour for a line with methods (only used when :enable_colors is true)
|
28
28
|
# :punctuation_color Set colour for punctuation (only used when :enable_colors is true)
|
29
|
+
# :match Shows only those methods that match this option. It's value can be either a string or a regexp (default: nil)
|
29
30
|
def method_info(options = {})
|
30
31
|
OptionHandler.handle(self, options)
|
31
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: method_info
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 9
|
9
|
+
version: 0.1.9
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Tom ten Thij
|
@@ -9,29 +14,35 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-02-
|
17
|
+
date: 2010-02-27 00:00:00 +00:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: rspec
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 2
|
30
|
+
- 9
|
23
31
|
version: 1.2.9
|
24
|
-
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
25
34
|
- !ruby/object:Gem::Dependency
|
26
35
|
name: cucumber
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
38
|
requirements:
|
31
39
|
- - ">="
|
32
40
|
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
33
43
|
version: "0"
|
34
|
-
|
44
|
+
type: :development
|
45
|
+
version_requirements: *id002
|
35
46
|
description: Defines a method_info method on every Object instance which provides information about methods that are defined on the object and the location where they were defined
|
36
47
|
email: method_info@tomtenthij.nl
|
37
48
|
executables: []
|
@@ -76,18 +87,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
87
|
requirements:
|
77
88
|
- - ">="
|
78
89
|
- !ruby/object:Gem::Version
|
90
|
+
segments:
|
91
|
+
- 0
|
79
92
|
version: "0"
|
80
|
-
version:
|
81
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
94
|
requirements:
|
83
95
|
- - ">="
|
84
96
|
- !ruby/object:Gem::Version
|
97
|
+
segments:
|
98
|
+
- 0
|
85
99
|
version: "0"
|
86
|
-
version:
|
87
100
|
requirements: []
|
88
101
|
|
89
102
|
rubyforge_project:
|
90
|
-
rubygems_version: 1.3.
|
103
|
+
rubygems_version: 1.3.6
|
91
104
|
signing_key:
|
92
105
|
specification_version: 3
|
93
106
|
summary: Get info about an object's methods
|