method_source 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/Rakefile +1 -0
- data/lib/method_source/code_helpers.rb +23 -0
- data/lib/method_source/version.rb +1 -1
- data/method_source.gemspec +22 -21
- data/spec/method_source_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -2
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb42b7f77ca24259bb26b26ff3e862d051d33aa9
|
4
|
+
data.tar.gz: '01769899a37ee328c75cd352fa560212c83f051a'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f8a3cc1ce051ad79750c4aa096f5e54c0fb7730908c669bd215f1ec98433dfa29bbfd383716344235c0a1dff5abd054d87e4c3b96fc5744b02ad120b4a26fd0
|
7
|
+
data.tar.gz: 649cf3eb91ab3fc6c1d2e32736a3a37f90abdfb7334db2b4f3e4d51e9a45a93ca03bd769a230c49230473f2b92f8dcbd4e72f255d8709e7991b01d0945587dff
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
module MethodSource
|
2
2
|
|
3
3
|
module CodeHelpers
|
4
|
+
# @return [Boolean]
|
5
|
+
JRUBY_9200 = (defined?(JRUBY_VERSION) || false) && JRUBY_VERSION == '9.2.0.0'
|
6
|
+
|
4
7
|
# Retrieve the first expression starting on the given line of the given file.
|
5
8
|
#
|
6
9
|
# This is useful to get module or method source code.
|
@@ -29,6 +32,26 @@ module MethodSource
|
|
29
32
|
|
30
33
|
extract_first_expression(relevant_lines, options[:consume])
|
31
34
|
rescue SyntaxError => e
|
35
|
+
# JRuby 9.2.0.0 breaks #source_location for Procs (it reports line number
|
36
|
+
# as the last line of the Proc). This raises SyntaxError.
|
37
|
+
# See https://github.com/pry/pry/issues/1804 for details.
|
38
|
+
#
|
39
|
+
# To fix this, this hack rewinds source location one step at a time and
|
40
|
+
# tries to see if the new location is a complete expression.
|
41
|
+
#
|
42
|
+
# TODO: delete this once latest JRuby version is bumped.
|
43
|
+
# See https://github.com/banister/method_source/issues/52
|
44
|
+
if JRUBY_9200 && line_number > 0
|
45
|
+
loop do
|
46
|
+
line_number -= 1
|
47
|
+
|
48
|
+
# Skip empty lines since they are not real expressions.
|
49
|
+
break unless lines[line_number - 1] == "\n"
|
50
|
+
end
|
51
|
+
|
52
|
+
retry
|
53
|
+
end
|
54
|
+
|
32
55
|
raise if options[:strict]
|
33
56
|
|
34
57
|
begin
|
data/method_source.gemspec
CHANGED
@@ -1,34 +1,35 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
# stub: method_source 0.9.1 ruby lib
|
2
3
|
|
3
4
|
Gem::Specification.new do |s|
|
4
|
-
s.name = "method_source"
|
5
|
-
s.version = "0.
|
5
|
+
s.name = "method_source".freeze
|
6
|
+
s.version = "0.9.1"
|
6
7
|
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.
|
9
|
-
s.
|
10
|
-
s.date = "
|
11
|
-
s.description = "retrieve the sourcecode for a method"
|
12
|
-
s.email = "jrmair@gmail.com"
|
13
|
-
s.files = [".gemtest", ".travis.yml", ".yardopts", "Gemfile", "LICENSE", "README.markdown", "Rakefile", "lib/method_source.rb", "lib/method_source/code_helpers.rb", "lib/method_source/source_location.rb", "lib/method_source/version.rb", "method_source.gemspec", "spec/method_source/code_helpers_spec.rb", "spec/method_source_spec.rb", "spec/spec_helper.rb"]
|
14
|
-
s.homepage = "http://banisterfiend.wordpress.com"
|
15
|
-
s.
|
16
|
-
s.rubygems_version = "
|
17
|
-
s.summary = "retrieve the sourcecode for a method"
|
18
|
-
s.test_files = ["spec/method_source/code_helpers_spec.rb", "spec/method_source_spec.rb", "spec/spec_helper.rb"]
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
|
+
s.require_paths = ["lib".freeze]
|
10
|
+
s.authors = ["John Mair (banisterfiend)".freeze]
|
11
|
+
s.date = "2018-11-02"
|
12
|
+
s.description = "retrieve the sourcecode for a method".freeze
|
13
|
+
s.email = "jrmair@gmail.com".freeze
|
14
|
+
s.files = [".gemtest".freeze, ".travis.yml".freeze, ".yardopts".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.markdown".freeze, "Rakefile".freeze, "lib/method_source.rb".freeze, "lib/method_source/code_helpers.rb".freeze, "lib/method_source/source_location.rb".freeze, "lib/method_source/version.rb".freeze, "method_source.gemspec".freeze, "spec/method_source/code_helpers_spec.rb".freeze, "spec/method_source_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
15
|
+
s.homepage = "http://banisterfiend.wordpress.com".freeze
|
16
|
+
s.licenses = ["MIT".freeze]
|
17
|
+
s.rubygems_version = "2.6.14".freeze
|
18
|
+
s.summary = "retrieve the sourcecode for a method".freeze
|
19
|
+
s.test_files = ["spec/method_source/code_helpers_spec.rb".freeze, "spec/method_source_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
19
20
|
|
20
21
|
if s.respond_to? :specification_version then
|
21
|
-
s.specification_version =
|
22
|
+
s.specification_version = 4
|
22
23
|
|
23
24
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
24
|
-
s.add_development_dependency(%q<rspec
|
25
|
-
s.add_development_dependency(%q<rake
|
25
|
+
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.6"])
|
26
|
+
s.add_development_dependency(%q<rake>.freeze, ["~> 0.9"])
|
26
27
|
else
|
27
|
-
s.add_dependency(%q<rspec
|
28
|
-
s.add_dependency(%q<rake
|
28
|
+
s.add_dependency(%q<rspec>.freeze, ["~> 3.6"])
|
29
|
+
s.add_dependency(%q<rake>.freeze, ["~> 0.9"])
|
29
30
|
end
|
30
31
|
else
|
31
|
-
s.add_dependency(%q<rspec
|
32
|
-
s.add_dependency(%q<rake
|
32
|
+
s.add_dependency(%q<rspec>.freeze, ["~> 3.6"])
|
33
|
+
s.add_dependency(%q<rake>.freeze, ["~> 0.9"])
|
33
34
|
end
|
34
35
|
end
|
data/spec/method_source_spec.rb
CHANGED
@@ -31,7 +31,7 @@ describe MethodSource do
|
|
31
31
|
@hello_comment = "# A comment for hello\n# It spans two lines and is indented by 2 spaces\n"
|
32
32
|
@lambda_comment = "# This is a comment for MyLambda\n"
|
33
33
|
@lambda_source = "MyLambda = lambda { :lambda }\n"
|
34
|
-
@proc_source = "MyProc = Proc.new
|
34
|
+
@proc_source = "MyProc = Proc.new do\n\n\nend\n"
|
35
35
|
@hello_instance_evaled_source = " def hello_\#{name}(*args)\n send_mesg(:\#{name}, *args)\n end\n"
|
36
36
|
@hello_instance_evaled_source_2 = " def \#{name}_two()\n if 44\n 45\n end\n end\n"
|
37
37
|
@hello_class_evaled_source = " def hello_\#{name}(*args)\n send_mesg(:\#{name}, *args)\n end\n"
|
data/spec/spec_helper.rb
CHANGED
@@ -49,9 +49,11 @@ def comment_test5; end
|
|
49
49
|
|
50
50
|
# This is a comment for MyLambda
|
51
51
|
MyLambda = lambda { :lambda }
|
52
|
-
MyProc = Proc.new
|
52
|
+
MyProc = Proc.new do
|
53
53
|
|
54
54
|
|
55
|
+
end
|
56
|
+
|
55
57
|
name = "name"
|
56
58
|
|
57
59
|
M.instance_eval <<-METHOD, __FILE__, __LINE__ + 1
|
@@ -98,4 +100,3 @@ EOF
|
|
98
100
|
# class_eval without filename and lineno + 1 parameter
|
99
101
|
|
100
102
|
M.class_eval "def #{name}_three; @tempfile.#{name}; end"
|
101
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: method_source
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mair (banisterfiend)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -60,7 +60,8 @@ files:
|
|
60
60
|
- spec/method_source_spec.rb
|
61
61
|
- spec/spec_helper.rb
|
62
62
|
homepage: http://banisterfiend.wordpress.com
|
63
|
-
licenses:
|
63
|
+
licenses:
|
64
|
+
- MIT
|
64
65
|
metadata: {}
|
65
66
|
post_install_message:
|
66
67
|
rdoc_options: []
|
@@ -78,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
79
|
version: '0'
|
79
80
|
requirements: []
|
80
81
|
rubyforge_project:
|
81
|
-
rubygems_version: 2.6.
|
82
|
+
rubygems_version: 2.6.14
|
82
83
|
signing_key:
|
83
84
|
specification_version: 4
|
84
85
|
summary: retrieve the sourcecode for a method
|