method_introspection 0.0.2 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +16 -9
- data/lib/method_introspection/code_helpers.rb +85 -68
- data/lib/method_introspection/load_project.rb +15 -17
- data/lib/method_introspection/module_methods.rb +52 -25
- data/lib/method_introspection/source_location.rb +4 -17
- data/lib/method_introspection/version/version.rb +9 -2
- data/lib/method_introspection.rb +2 -51
- data/method_introspection.gemspec +6 -4
- data/test/test.rb +4 -7
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f71ee73fbfe1d022cfde4dddb654925ccfd7ad3505656040378f616d94b4632f
|
4
|
+
data.tar.gz: 9f699a8f91c817e1afd3ad0a53bfddf37c672755b0e58b9053199f4658c3dfdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa12245be5a95e4c6075ca55dd77d99490689d9bf92ae78a1f6d46e7d4f1a107aa691b63648d62512a3db13e82be478bbdde13e22bd7398da6da726b824f0469
|
7
|
+
data.tar.gz: 7e0a0456830d495f00399615413a17b7cf9fb50089ed1f7000e6d3ad65be8c301c593de568a5356715904c713214e181dcc126c05ee381e0dee7fc9afc5bb923
|
data/README.md
CHANGED
@@ -5,18 +5,25 @@ This is a simplified variant of showing comments and source code.
|
|
5
5
|
|
6
6
|
It is based on John Mair's (banisterfiend) gem called _method_source_.
|
7
7
|
|
8
|
-
|
9
|
-
for my own gems since that is what I am using
|
8
|
+
That gem is perfectly fine - however had, I found that I only required
|
9
|
+
MRI support for my own gems since that is what I am using, so the
|
10
|
+
code for other platforms was removed. Please refer to the original
|
11
|
+
gem if you need support for these platforms - this here is mostly a
|
12
|
+
stripped down variant.
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
put it into a separate gem.
|
14
|
+
I have also changed the code a bit more to my personal style to make
|
15
|
+
it easier to work with.
|
14
16
|
|
15
|
-
Credit where credit is due
|
16
|
-
|
17
|
+
Credit where credit is due - in this case the initial work was done on
|
18
|
+
the gem method_source.
|
17
19
|
|
18
|
-
The license is thus the MIT license
|
19
|
-
method_source
|
20
|
+
The license is thus the MIT license, as specified in the original variant
|
21
|
+
of the gem "method_source", which is retained here. Please refer to that
|
22
|
+
gem called method_source for a description of that gem.
|
23
|
+
|
24
|
+
The aim of method_introspection is similar but not as big in scope - it's
|
25
|
+
essentially just a stripped down variant essentially and allows us to
|
26
|
+
inspect ruby methods at runtime.
|
20
27
|
|
21
28
|
_Introspect ruby methods at runtime_
|
22
29
|
|
@@ -1,7 +1,67 @@
|
|
1
|
+
#!/System/Index/bin/ruby -w
|
2
|
+
# Encoding: ISO-8859-1
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
1
5
|
module MethodIntrospection
|
2
6
|
|
3
7
|
module CodeHelpers
|
4
8
|
|
9
|
+
# ========================================================================= #
|
10
|
+
# === extract_last_comment
|
11
|
+
#
|
12
|
+
# Get the last comment from the input. We will build up the result.
|
13
|
+
#
|
14
|
+
# @param [Array<String>] lines
|
15
|
+
# @return [String]
|
16
|
+
# ========================================================================= #
|
17
|
+
def extract_last_comment(lines)
|
18
|
+
result = ''
|
19
|
+
lines.each { |line|
|
20
|
+
# ===================================================================== #
|
21
|
+
# Add any line that is a valid ruby comment but stop the moment
|
22
|
+
# we hit a non-comment line.
|
23
|
+
# ===================================================================== #
|
24
|
+
if (line =~ /^\s*#/) || (line =~ /^\s*$/)
|
25
|
+
# =================================================================== #
|
26
|
+
# Append onto result next. In the past we called .lstrip() here but
|
27
|
+
# this is no longer legal as we modify the original comment.
|
28
|
+
# =================================================================== #
|
29
|
+
result << line
|
30
|
+
else
|
31
|
+
result.replace("")
|
32
|
+
end
|
33
|
+
}
|
34
|
+
return result
|
35
|
+
end; private :extract_last_comment
|
36
|
+
|
37
|
+
# ========================================================================= #
|
38
|
+
# === comment_describing
|
39
|
+
#
|
40
|
+
# This method will retrieve the comment describing the expression on the
|
41
|
+
# given line of the given file.
|
42
|
+
#
|
43
|
+
# This is useful to get the module or method documentation, in String
|
44
|
+
# format.
|
45
|
+
#
|
46
|
+
# @param [Array<String>, File, String] file The file to parse, either as a File or as
|
47
|
+
# a String or an Array of lines.
|
48
|
+
# @param [Fixnum] line_number The line number at which to look.
|
49
|
+
# NOTE: The first line in a file is line 1!
|
50
|
+
# @return [String] The comment
|
51
|
+
# ========================================================================= #
|
52
|
+
def comment_describing(file, line_number)
|
53
|
+
if file.is_a? Array
|
54
|
+
lines = file
|
55
|
+
else
|
56
|
+
lines = file.each_line.to_a
|
57
|
+
end
|
58
|
+
# ======================================================================= #
|
59
|
+
# At this point, lines is now an Array. We extract the proper lines
|
60
|
+
# by making use of the line number.
|
61
|
+
# ======================================================================= #
|
62
|
+
extract_last_comment(lines[0..(line_number - 2)])
|
63
|
+
end
|
64
|
+
|
5
65
|
# ========================================================================= #
|
6
66
|
# === expression_at
|
7
67
|
#
|
@@ -10,12 +70,15 @@ module CodeHelpers
|
|
10
70
|
#
|
11
71
|
# This is useful to get module or method source code.
|
12
72
|
#
|
13
|
-
# @param [Array<String>, File, String] file The file to parse, either as
|
73
|
+
# @param [Array<String>, File, String] file The file to parse, either as
|
74
|
+
# a File or as
|
75
|
+
#
|
14
76
|
# @param [Fixnum] line_number The line number at which to look.
|
15
77
|
# NOTE: The first line in a file is
|
16
78
|
# line 1!
|
17
79
|
#
|
18
80
|
# @param [Hash] options The optional configuration parameters.
|
81
|
+
#
|
19
82
|
# @option options [Boolean] :strict If set to true, then only completely
|
20
83
|
# valid expressions are returned. Otherwise heuristics are used to extract
|
21
84
|
# expressions that may have been valid inside an eval.
|
@@ -40,11 +103,9 @@ module CodeHelpers
|
|
40
103
|
else
|
41
104
|
lines = file.each_line.to_a
|
42
105
|
end
|
43
|
-
|
44
106
|
relevant_lines = lines[(line_number - 1)..-1] || []
|
45
|
-
|
46
107
|
extract_first_expression(relevant_lines, options[:consume])
|
47
|
-
|
108
|
+
rescue SyntaxError => e
|
48
109
|
raise if options[:strict]
|
49
110
|
begin
|
50
111
|
extract_first_expression(relevant_lines) { |code|
|
@@ -55,42 +116,20 @@ module CodeHelpers
|
|
55
116
|
end
|
56
117
|
end
|
57
118
|
|
58
|
-
# ========================================================================= #
|
59
|
-
# === comment_describing
|
60
|
-
#
|
61
|
-
# This method will retrieve the comment describing the expression on the
|
62
|
-
# given line of the given file.
|
63
|
-
#
|
64
|
-
# This is useful to get the module or method documentation, in String
|
65
|
-
# format.
|
66
|
-
#
|
67
|
-
# @param [Array<String>, File, String] file The file to parse, either as a File or as
|
68
|
-
# a String or an Array of lines.
|
69
|
-
# @param [Fixnum] line_number The line number at which to look.
|
70
|
-
# NOTE: The first line in a file is line 1!
|
71
|
-
# @return [String] The comment
|
72
|
-
# ========================================================================= #
|
73
|
-
def comment_describing(file, line_number)
|
74
|
-
if file.is_a? Array
|
75
|
-
lines = file
|
76
|
-
else
|
77
|
-
lines = file.each_line.to_a
|
78
|
-
end
|
79
|
-
extract_last_comment(lines[0..(line_number - 2)])
|
80
|
-
end
|
81
|
-
|
82
119
|
# ========================================================================= #
|
83
120
|
# === complete_expression?
|
84
121
|
#
|
85
122
|
# Determine if a string of code is a complete Ruby expression.
|
86
123
|
#
|
87
|
-
# @param
|
88
|
-
# @return [Boolean]
|
89
|
-
# @raise
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
# complete_expression?("class
|
124
|
+
# @param [String] code The code to validate.
|
125
|
+
# @return [Boolean] Whether or not the code is a complete Ruby expression.
|
126
|
+
# @raise [SyntaxError] Any SyntaxError that does not represent incompleteness.
|
127
|
+
#
|
128
|
+
# @Usage examples
|
129
|
+
#
|
130
|
+
# complete_expression?("class Hello") # => false
|
131
|
+
# complete_expression?("class Hello; end") # => true
|
132
|
+
# complete_expression?("class 123") # => SyntaxError: unexpected tINTEGER
|
94
133
|
# ========================================================================= #
|
95
134
|
def complete_expression?(i)
|
96
135
|
old_verbose = $VERBOSE
|
@@ -103,10 +142,9 @@ module CodeHelpers
|
|
103
142
|
rescue IncompleteExpression
|
104
143
|
false
|
105
144
|
ensure
|
106
|
-
$VERBOSE = old_verbose
|
145
|
+
$VERBOSE = old_verbose # Reinstate the old verbosity level here.
|
107
146
|
end
|
108
147
|
|
109
|
-
private
|
110
148
|
# ========================================================================= #
|
111
149
|
# === extract_first_expression
|
112
150
|
#
|
@@ -126,45 +164,24 @@ module CodeHelpers
|
|
126
164
|
return code if complete_expression?(block ? block.call(code) : code)
|
127
165
|
}
|
128
166
|
raise SyntaxError, "unexpected $end"
|
129
|
-
end
|
130
|
-
|
131
|
-
# ========================================================================= #
|
132
|
-
# === extract_last_comment
|
133
|
-
#
|
134
|
-
# Get the last comment from the input. We will build up the result.
|
135
|
-
#
|
136
|
-
# @param [Array<String>] lines
|
137
|
-
# @return [String]
|
138
|
-
# ========================================================================= #
|
139
|
-
def extract_last_comment(lines)
|
140
|
-
result = ''
|
141
|
-
lines.each { |line|
|
142
|
-
# ===================================================================== #
|
143
|
-
# Add any line that is a valid ruby comment but stop the moment
|
144
|
-
# we hit a non-comment line.
|
145
|
-
# ===================================================================== #
|
146
|
-
if (line =~ /^\s*#/) || (line =~ /^\s*$/)
|
147
|
-
result << line.lstrip
|
148
|
-
else
|
149
|
-
result.replace("")
|
150
|
-
end
|
151
|
-
}
|
152
|
-
return result
|
153
|
-
end
|
167
|
+
end; private :extract_first_expression
|
154
168
|
|
155
169
|
# ========================================================================= #
|
156
170
|
# === IncompleteExpression
|
157
171
|
#
|
158
|
-
#
|
159
|
-
# fixed by adding more input to the buffer.
|
172
|
+
# IncompleteExpression is an exception matcher that matches only subsets
|
173
|
+
# of SyntaxErrors that can be fixed by adding more input to the buffer.
|
160
174
|
# ========================================================================= #
|
161
175
|
module IncompleteExpression
|
176
|
+
# ======================================================================= #
|
177
|
+
# === GENERIC_REGEXPS
|
178
|
+
#
|
179
|
+
# We only have to handle MRI.
|
180
|
+
# ======================================================================= #
|
162
181
|
GENERIC_REGEXPS = [
|
163
|
-
/unexpected (\$end|end-of-file|end-of-input|END_OF_FILE)/, # mri
|
182
|
+
/unexpected (\$end|end-of-file|end-of-input|END_OF_FILE)/, # mri
|
164
183
|
/embedded document meets end of file/, # =begin
|
165
|
-
/unterminated (
|
166
|
-
/can not find the string ".*" anywhere before EOF/, # rbx and jruby
|
167
|
-
/missing 'end' for/, /expecting kWHEN/ # rbx
|
184
|
+
/unterminated (string|regexp) meets end of file/
|
168
185
|
]
|
169
186
|
# ======================================================================= #
|
170
187
|
# === IncompleteExpression.===
|
@@ -1,23 +1,21 @@
|
|
1
|
-
|
1
|
+
#!/System/Index/bin/ruby -w
|
2
|
+
# Encoding: ISO-8859-1
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'method_introspection/load_project.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'method_introspection/project/project_base_directory.rb'
|
2
8
|
|
3
|
-
|
4
|
-
# === PROJECT_BASE_DIRECTORY
|
5
|
-
# ========================================================================= #
|
6
|
-
PROJECT_BASE_DIRECTORY = RbConfig::CONFIG['sitelibdir']+'/method_introspection/'
|
7
|
-
|
8
|
-
# ========================================================================= #
|
9
|
-
# === MethodIntrospection.project_base_dir?
|
10
|
-
# ========================================================================= #
|
11
|
-
def self.project_base_dir?
|
12
|
-
PROJECT_BASE_DIRECTORY
|
13
|
-
end
|
9
|
+
module MethodIntrospection
|
14
10
|
|
15
11
|
# ========================================================================= #
|
16
|
-
# Next we load up the various .rb files of that project.
|
12
|
+
# Next, we load up the various .rb files of that project.
|
17
13
|
# ========================================================================= #
|
18
|
-
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
14
|
+
_ = MethodIntrospection.project_base_dir?
|
15
|
+
require _+'version/version.rb'
|
16
|
+
require _+'module_methods.rb'
|
17
|
+
require _+'proc_extensions.rb'
|
18
|
+
require _+'code_helpers.rb'
|
19
|
+
require _+'source_location.rb'
|
22
20
|
|
23
21
|
end
|
@@ -1,9 +1,29 @@
|
|
1
1
|
require 'pp'
|
2
|
+
require 'method_introspection/source_not_found_error.rb'
|
3
|
+
require 'method_introspection/module_instance_variables.rb'
|
2
4
|
|
3
5
|
module MethodIntrospection # The top namespace of this project.
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
+
# ========================================================================= #
|
8
|
+
# === MethodIntrospection.toggle_debug
|
9
|
+
# ========================================================================= #
|
10
|
+
def self.toggle_debug
|
11
|
+
@debug = !@debug
|
12
|
+
end
|
13
|
+
|
14
|
+
# ========================================================================= #
|
15
|
+
# === MethodIntrospection.debug?
|
16
|
+
# ========================================================================= #
|
17
|
+
def self.debug?
|
18
|
+
@debug
|
19
|
+
end
|
20
|
+
|
21
|
+
# ========================================================================= #
|
22
|
+
# === MethodIntrospection.enable_debug
|
23
|
+
# ========================================================================= #
|
24
|
+
def self.enable_debug
|
25
|
+
@debug = true
|
26
|
+
end
|
7
27
|
|
8
28
|
# ========================================================================= #
|
9
29
|
# === MethodIntrospection.set_this_file
|
@@ -33,18 +53,11 @@ module MethodIntrospection # The top namespace of this project.
|
|
33
53
|
@line_number
|
34
54
|
end
|
35
55
|
|
36
|
-
# ========================================================================= #
|
37
|
-
# === SourceNotFoundError
|
38
|
-
#
|
39
|
-
# An Exception to mark errors that were raised trying to find the
|
40
|
-
# source from a given source_location.
|
41
|
-
# ========================================================================= #
|
42
|
-
class SourceNotFoundError < StandardError; end
|
43
|
-
|
44
56
|
# ========================================================================= #
|
45
57
|
# === MethodIntrospection.raise_this
|
46
58
|
#
|
47
|
-
#
|
59
|
+
# The second argument to this method is optional, and allows for a
|
60
|
+
# longer description for the error message at hand.
|
48
61
|
# ========================================================================= #
|
49
62
|
def self.raise_this(name, optional_extra = nil)
|
50
63
|
result = "We could not locate the source for #{name}"
|
@@ -63,14 +76,22 @@ module MethodIntrospection # The top namespace of this project.
|
|
63
76
|
#
|
64
77
|
# This is defined here to avoid polluting the `Method` class.
|
65
78
|
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
79
|
+
# @param [Array] source_location The array returned by Method#source_location
|
80
|
+
# @param [String] method_name
|
81
|
+
# @return [String] The method body
|
69
82
|
# ========================================================================= #
|
70
83
|
def self.source_helper(source_location, name = nil)
|
71
84
|
raise_this(name) unless source_location
|
72
|
-
|
73
|
-
|
85
|
+
this_file, line_number = *source_location
|
86
|
+
# ======================================================================= #
|
87
|
+
# Set the file.
|
88
|
+
# ======================================================================= #
|
89
|
+
MethodIntrospection.set_this_file(this_file)
|
90
|
+
# ======================================================================= #
|
91
|
+
# Set the line number in that file.
|
92
|
+
# ======================================================================= #
|
93
|
+
MethodIntrospection.set_line_number(line_number)
|
94
|
+
expression_at(lines_for(this_file), line_number)
|
74
95
|
rescue SyntaxError => error
|
75
96
|
raise SourceNotFoundError,
|
76
97
|
"Could not parse source for #{name}: #{error.message}"
|
@@ -96,18 +117,19 @@ module MethodIntrospection # The top namespace of this project.
|
|
96
117
|
# ========================================================================= #
|
97
118
|
# === MethodIntrospection.comment_helper
|
98
119
|
#
|
99
|
-
#
|
100
|
-
# the comments for a specified method.
|
101
|
-
# polluting the `Method` class.
|
120
|
+
# This is a helper method responsible for opening source file and
|
121
|
+
# buffering up the comments for a specified method. It is defined here
|
122
|
+
# to avoid polluting the `Method` class.
|
102
123
|
#
|
103
124
|
# The expected input should be an Array, which is returned by the
|
104
125
|
# method Method#source_location.
|
105
126
|
#
|
106
127
|
# This will typically be in the form of:
|
107
128
|
#
|
108
|
-
#
|
129
|
+
# ["/Programs/Ruby/2.2.3/lib/ruby/site_ruby/2.2.0/config.rb", 297]
|
109
130
|
#
|
110
|
-
# The first one yields to us the name
|
131
|
+
# The first one yields to us the name of the file in question, and the
|
132
|
+
# second gives us the specific line number.
|
111
133
|
#
|
112
134
|
# @param [String] method_name
|
113
135
|
# @return [String] The comments up to the point of the method.
|
@@ -115,12 +137,17 @@ module MethodIntrospection # The top namespace of this project.
|
|
115
137
|
def self.comment_helper(source_location, name = nil)
|
116
138
|
raise_this(name) unless source_location
|
117
139
|
this_file, line_number = *source_location
|
118
|
-
pp source_location
|
119
|
-
pp this_file
|
120
|
-
pp line_number
|
121
140
|
MethodIntrospection.set_this_file(this_file)
|
122
141
|
MethodIntrospection.set_line_number(line_number)
|
123
|
-
|
142
|
+
# ======================================================================= #
|
143
|
+
# Next, we extract all the lines of a given file. lines will thus be a
|
144
|
+
# very big Array if we have a big file.
|
145
|
+
# ======================================================================= #
|
146
|
+
lines = lines_for(this_file)
|
147
|
+
# ======================================================================= #
|
148
|
+
# Next tap into comment_describing(). This resides in code_helpers.rb
|
149
|
+
# ======================================================================= #
|
150
|
+
comment_describing(lines, line_number)
|
124
151
|
end
|
125
152
|
|
126
153
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module MethodIntrospection
|
2
2
|
module SourceLocation
|
3
3
|
module MethodExtensions
|
4
|
+
|
4
5
|
# ===================================================================== #
|
5
6
|
# === trace_func
|
6
7
|
# ===================================================================== #
|
@@ -12,23 +13,9 @@ module MethodIntrospection
|
|
12
13
|
end; private :trace_func
|
13
14
|
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
#
|
19
|
-
# Return the source location for a Proc (in implementations
|
20
|
-
# without Proc#source_location)
|
21
|
-
#
|
22
|
-
# @return [Array] A two element array. First element is the
|
23
|
-
# file, second element is the line in the file where the
|
24
|
-
# proc definition is found.
|
25
|
-
# ===================================================================== #
|
26
|
-
def source_location
|
27
|
-
self.to_s =~ /@(.*):(\d+)/
|
28
|
-
[$1, $2.to_i]
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
16
|
+
# ======================================================================= #
|
17
|
+
# === UnboundMethodExtensions
|
18
|
+
# ======================================================================= #
|
32
19
|
module UnboundMethodExtensions
|
33
20
|
# ===================================================================== #
|
34
21
|
# === source_location
|
@@ -1,5 +1,12 @@
|
|
1
|
+
#!/System/Index/bin/ruby -w
|
2
|
+
# Encoding: ISO-8859-1
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
1
5
|
module MethodIntrospection
|
2
6
|
|
3
|
-
|
7
|
+
# ========================================================================= #
|
8
|
+
# === VERSION
|
9
|
+
# ========================================================================= #
|
10
|
+
VERSION = '0.0.11'
|
4
11
|
|
5
|
-
end
|
12
|
+
end
|
data/lib/method_introspection.rb
CHANGED
@@ -1,58 +1,9 @@
|
|
1
1
|
require 'method_introspection/load_project.rb'
|
2
|
+
require 'method_introspection/method.rb'
|
3
|
+
require 'method_introspection/unbound_method.rb'
|
2
4
|
|
3
5
|
module MethodIntrospection
|
4
6
|
|
5
7
|
extend MethodIntrospection::CodeHelpers
|
6
8
|
|
7
|
-
# This module is to be included by `Method` and `UnboundMethod` and
|
8
|
-
# provides the `#source` functionality
|
9
|
-
module MethodExtensions
|
10
|
-
# === source
|
11
|
-
#
|
12
|
-
# The method source() will return the sourcecode for the method as
|
13
|
-
# a String.
|
14
|
-
#
|
15
|
-
# @return [String] The method sourcecode as a string
|
16
|
-
# @raise SourceNotFoundException
|
17
|
-
#
|
18
|
-
# @example
|
19
|
-
# Set.instance_method(:clear).source.display
|
20
|
-
# =>
|
21
|
-
# def clear
|
22
|
-
# @hash.clear
|
23
|
-
# self
|
24
|
-
# end
|
25
|
-
def source
|
26
|
-
MethodIntrospection.source_helper(source_location, defined?(name) ? name : inspect)
|
27
|
-
end
|
28
|
-
|
29
|
-
# === comment
|
30
|
-
#
|
31
|
-
# Return the comments associated with the method as a string.
|
32
|
-
# @return [String] The method's comments as a string
|
33
|
-
# @raise SourceNotFoundException
|
34
|
-
#
|
35
|
-
# @example
|
36
|
-
# Set.instance_method(:clear).comment.display
|
37
|
-
# =>
|
38
|
-
# # Removes all elements and returns self.
|
39
|
-
def comment
|
40
|
-
MethodIntrospection.comment_helper(source_location, defined?(name) ? name : inspect)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
class Method
|
46
|
-
include MethodIntrospection::SourceLocation::MethodExtensions
|
47
|
-
include MethodIntrospection::MethodExtensions
|
48
|
-
end
|
49
|
-
|
50
|
-
class UnboundMethod
|
51
|
-
include MethodIntrospection::SourceLocation::UnboundMethodExtensions
|
52
|
-
include MethodIntrospection::MethodExtensions
|
53
|
-
end
|
54
|
-
|
55
|
-
class Proc
|
56
|
-
include MethodIntrospection::SourceLocation::ProcExtensions
|
57
|
-
include MethodIntrospection::MethodExtensions
|
58
9
|
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
require 'method_introspection/version/version.rb'
|
3
3
|
|
4
|
-
DESCRIPTION = '
|
4
|
+
DESCRIPTION = 'This gem allows us to inspect the source code '\
|
5
|
+
'for a method and the documentation.'
|
5
6
|
|
6
7
|
Gem::Specification.new { |s|
|
7
8
|
s.name = 'method_introspection'
|
8
9
|
s.version = MethodIntrospection::VERSION
|
9
10
|
|
10
|
-
s.authors =
|
11
|
+
s.authors = %w( Robert A. Heiler )
|
11
12
|
s.date = Time.now.strftime('%Y-%m-%d')
|
12
13
|
s.email = 'shevegen@gmail.com'
|
13
14
|
s.files = %w(
|
@@ -34,7 +35,8 @@ Gem::Specification.new { |s|
|
|
34
35
|
'test/test_helper.rb'
|
35
36
|
]
|
36
37
|
|
37
|
-
s.required_ruby_version
|
38
|
-
s.
|
38
|
+
s.required_ruby_version = '>= '+RUBY_VERSION
|
39
|
+
s.required_rubygems_version = '>= '+Gem::VERSION
|
40
|
+
s.rubygems_version = '>= '+Gem::VERSION
|
39
41
|
|
40
42
|
}
|
data/test/test.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
|
-
direc = File.expand_path(File.dirname(__FILE__))
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
1
|
require 'bacon'
|
5
|
-
require 'method_introspection
|
6
|
-
|
2
|
+
require 'method_introspection'
|
3
|
+
require_relative './test_helper.rb'
|
7
4
|
|
8
|
-
describe MethodIntrospection
|
5
|
+
describe MethodIntrospection {
|
9
6
|
|
10
7
|
describe "source_location (testing 1.8 implementation)" do
|
11
8
|
it 'should return correct source_location for a method' do
|
@@ -135,4 +132,4 @@ describe MethodIntrospection do
|
|
135
132
|
method(:comment_test5).comment.should == @comment5
|
136
133
|
end
|
137
134
|
end
|
138
|
-
|
135
|
+
}
|
metadata
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: method_introspection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Robert
|
7
|
+
- Robert
|
8
|
+
- A.
|
9
|
+
- Heiler
|
8
10
|
autorequire:
|
9
11
|
bindir: bin
|
10
12
|
cert_chain: []
|
11
|
-
date:
|
13
|
+
date: 2019-01-30 00:00:00.000000000 Z
|
12
14
|
dependencies: []
|
13
|
-
description:
|
15
|
+
description: This gem allows us to inspect the source code for a method and the documentation.
|
14
16
|
email: shevegen@gmail.com
|
15
17
|
executables: []
|
16
18
|
extensions: []
|
@@ -39,18 +41,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
39
41
|
requirements:
|
40
42
|
- - ">="
|
41
43
|
- !ruby/object:Gem::Version
|
42
|
-
version: 2.
|
44
|
+
version: 2.6.0
|
43
45
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
46
|
requirements:
|
45
47
|
- - ">="
|
46
48
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
49
|
+
version: 3.0.1
|
48
50
|
requirements: []
|
49
|
-
|
50
|
-
rubygems_version: 2.4.5.1
|
51
|
+
rubygems_version: 3.0.1
|
51
52
|
signing_key:
|
52
53
|
specification_version: 4
|
53
|
-
summary:
|
54
|
+
summary: This gem allows us to inspect the source code for a method and the documentation.
|
54
55
|
test_files:
|
55
56
|
- test/test.rb
|
56
57
|
- test/test_code_helpers.rb
|