method_source 0.6.5 → 0.6.6
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/.travis.yml +16 -0
- data/.yardopts +1 -0
- data/Gemfile +2 -0
- data/LICENSE +25 -0
- data/README.markdown +3 -1
- data/Rakefile +16 -7
- data/lib/method_source/source_location.rb +20 -4
- data/lib/method_source/version.rb +1 -1
- data/method_source.gemspec +36 -0
- data/test/test.rb +0 -11
- metadata +83 -44
data/.travis.yml
ADDED
data/.yardopts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-m markdown
|
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
License
|
|
2
|
+
-------
|
|
3
|
+
|
|
4
|
+
(The MIT License)
|
|
5
|
+
|
|
6
|
+
Copyright (c) 2011 John Mair (banisterfiend)
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
9
|
+
a copy of this software and associated documentation files (the
|
|
10
|
+
'Software'), to deal in the Software without restriction, including
|
|
11
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
12
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
13
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
14
|
+
the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be
|
|
17
|
+
included in all copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
20
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
21
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
22
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
23
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
24
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
25
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
CHANGED
|
@@ -16,7 +16,7 @@ Method comments can also be extracted using the `comment` method.
|
|
|
16
16
|
It is written in pure Ruby (no C).
|
|
17
17
|
|
|
18
18
|
* Some Ruby 1.8 support now available.
|
|
19
|
-
* Support for MRI, RBX, JRuby
|
|
19
|
+
* Support for MRI, RBX, JRuby, REE
|
|
20
20
|
|
|
21
21
|
`method_source` provides the `source` and `comment` methods to the `Method` and
|
|
22
22
|
`UnboundMethod` and `Proc` classes.
|
|
@@ -62,6 +62,8 @@ Special Thanks
|
|
|
62
62
|
|
|
63
63
|
[Dmitry Elastic](https://github.com/dmitryelastic) for the brilliant Ruby 1.8 `source_location` hack.
|
|
64
64
|
|
|
65
|
+
[Samuel Kadolph](https://github.com/samuelkadolph) for the JRuby 1.8 `source_location`.
|
|
66
|
+
|
|
65
67
|
License
|
|
66
68
|
-------
|
|
67
69
|
|
data/Rakefile
CHANGED
|
@@ -19,21 +19,23 @@ def apply_spec_defaults(s)
|
|
|
19
19
|
s.email = 'jrmair@gmail.com'
|
|
20
20
|
s.description = s.summary
|
|
21
21
|
s.require_path = 'lib'
|
|
22
|
-
s.add_dependency("ruby_parser","
|
|
23
|
-
|
|
24
|
-
s.add_development_dependency("bacon",">=1.1.0")
|
|
25
|
-
s.add_development_dependency("open4", "~> 1.0.1")
|
|
22
|
+
s.add_dependency("ruby_parser","~>2.0.5")
|
|
26
23
|
|
|
24
|
+
s.add_development_dependency("bacon","~>1.1.0")
|
|
25
|
+
s.add_development_dependency("rake", "~>0.9")
|
|
27
26
|
s.homepage = "http://banisterfiend.wordpress.com"
|
|
28
27
|
s.has_rdoc = 'yard'
|
|
29
|
-
s.files =
|
|
30
|
-
|
|
28
|
+
s.files = `git ls-files`.split("\n")
|
|
29
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
|
31
30
|
end
|
|
32
31
|
|
|
33
32
|
task :test do
|
|
34
|
-
sh "bacon -
|
|
33
|
+
sh "bacon -q #{direc}/test/test.rb"
|
|
35
34
|
end
|
|
36
35
|
|
|
36
|
+
desc "Set up and run tests"
|
|
37
|
+
task :default => [:test]
|
|
38
|
+
|
|
37
39
|
namespace :ruby do
|
|
38
40
|
spec = Gem::Specification.new do |s|
|
|
39
41
|
apply_spec_defaults(s)
|
|
@@ -44,6 +46,13 @@ namespace :ruby do
|
|
|
44
46
|
pkg.need_zip = false
|
|
45
47
|
pkg.need_tar = false
|
|
46
48
|
end
|
|
49
|
+
|
|
50
|
+
desc "Generate gemspec file"
|
|
51
|
+
task :gemspec do
|
|
52
|
+
File.open("#{spec.name}.gemspec", "w") do |f|
|
|
53
|
+
f << spec.to_ruby
|
|
54
|
+
end
|
|
55
|
+
end
|
|
47
56
|
end
|
|
48
57
|
|
|
49
58
|
desc "build all platform gems at once"
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
module MethodSource
|
|
2
|
+
module ReeSourceLocation
|
|
3
|
+
# Ruby enterprise edition provides all the information that's
|
|
4
|
+
# needed, in a slightly different way.
|
|
5
|
+
def source_location
|
|
6
|
+
[__file__, __line__] rescue nil
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
2
10
|
module SourceLocation
|
|
3
11
|
module MethodExtensions
|
|
4
|
-
if
|
|
12
|
+
if Proc.method_defined? :__file__
|
|
13
|
+
include ReeSourceLocation
|
|
14
|
+
|
|
15
|
+
elsif defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
|
|
5
16
|
require 'java'
|
|
6
17
|
|
|
7
18
|
# JRuby version source_location hack
|
|
@@ -41,8 +52,10 @@ module MethodSource
|
|
|
41
52
|
end
|
|
42
53
|
|
|
43
54
|
module ProcExtensions
|
|
55
|
+
if Proc.method_defined? :__file__
|
|
56
|
+
include ReeSourceLocation
|
|
44
57
|
|
|
45
|
-
|
|
58
|
+
elsif defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
|
|
46
59
|
|
|
47
60
|
# Return the source location for a Proc (Rubinius only)
|
|
48
61
|
# @return [Array] A two element array. First element is the
|
|
@@ -51,7 +64,6 @@ module MethodSource
|
|
|
51
64
|
def source_location
|
|
52
65
|
[block.file.to_s, block.line]
|
|
53
66
|
end
|
|
54
|
-
|
|
55
67
|
else
|
|
56
68
|
|
|
57
69
|
# Return the source location for a Proc (in implementations
|
|
@@ -67,7 +79,10 @@ module MethodSource
|
|
|
67
79
|
end
|
|
68
80
|
|
|
69
81
|
module UnboundMethodExtensions
|
|
70
|
-
if
|
|
82
|
+
if Proc.method_defined? :__file__
|
|
83
|
+
include ReeSourceLocation
|
|
84
|
+
|
|
85
|
+
elsif defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
|
|
71
86
|
require 'java'
|
|
72
87
|
|
|
73
88
|
# JRuby version source_location hack
|
|
@@ -75,6 +90,7 @@ module MethodSource
|
|
|
75
90
|
def source_location
|
|
76
91
|
to_java.source_location(Thread.current.to_java.getContext())
|
|
77
92
|
end
|
|
93
|
+
|
|
78
94
|
else
|
|
79
95
|
|
|
80
96
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |s|
|
|
4
|
+
s.name = %q{method_source}
|
|
5
|
+
s.version = "0.6.6"
|
|
6
|
+
|
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
8
|
+
s.authors = [%q{John Mair (banisterfiend)}]
|
|
9
|
+
s.date = %q{2011-10-03}
|
|
10
|
+
s.description = %q{retrieve the sourcecode for a method}
|
|
11
|
+
s.email = %q{jrmair@gmail.com}
|
|
12
|
+
s.files = [%q{.gemtest}, %q{.travis.yml}, %q{.yardopts}, %q{LICENSE}, %q{README.markdown}, %q{Rakefile}, %q{lib/method_source.rb}, %q{lib/method_source/source_location.rb}, %q{lib/method_source/version.rb}, %q{test/test.rb}, %q{test/test_helper.rb}]
|
|
13
|
+
s.homepage = %q{http://banisterfiend.wordpress.com}
|
|
14
|
+
s.require_paths = [%q{lib}]
|
|
15
|
+
s.rubygems_version = %q{1.8.6}
|
|
16
|
+
s.summary = %q{retrieve the sourcecode for a method}
|
|
17
|
+
s.test_files = [%q{test/test.rb}, %q{test/test_helper.rb}]
|
|
18
|
+
|
|
19
|
+
if s.respond_to? :specification_version then
|
|
20
|
+
s.specification_version = 3
|
|
21
|
+
|
|
22
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
23
|
+
s.add_runtime_dependency(%q<ruby_parser>, ["~> 2.0.5"])
|
|
24
|
+
s.add_development_dependency(%q<bacon>, ["~> 1.1.0"])
|
|
25
|
+
s.add_development_dependency(%q<rake>, ["~> 0.9"])
|
|
26
|
+
else
|
|
27
|
+
s.add_dependency(%q<ruby_parser>, ["~> 2.0.5"])
|
|
28
|
+
s.add_dependency(%q<bacon>, ["~> 1.1.0"])
|
|
29
|
+
s.add_dependency(%q<rake>, ["~> 0.9"])
|
|
30
|
+
end
|
|
31
|
+
else
|
|
32
|
+
s.add_dependency(%q<ruby_parser>, ["~> 2.0.5"])
|
|
33
|
+
s.add_dependency(%q<bacon>, ["~> 1.1.0"])
|
|
34
|
+
s.add_dependency(%q<rake>, ["~> 0.9"])
|
|
35
|
+
end
|
|
36
|
+
end
|
data/test/test.rb
CHANGED
|
@@ -2,22 +2,11 @@ direc = File.dirname(__FILE__)
|
|
|
2
2
|
|
|
3
3
|
require 'rubygems'
|
|
4
4
|
require 'bacon'
|
|
5
|
-
require 'open4'
|
|
6
5
|
require "#{direc}/../lib/method_source"
|
|
7
6
|
require "#{direc}/test_helper"
|
|
8
7
|
|
|
9
8
|
describe MethodSource do
|
|
10
9
|
|
|
11
|
-
if !jruby?
|
|
12
|
-
describe "emitted warnings" do
|
|
13
|
-
it 'should emit no warnings' do
|
|
14
|
-
Open4.popen4 'ruby -I lib -rubygems -r"method_source" -W -e "exit"' do |pid,stdin,stdout,stderr|
|
|
15
|
-
stderr.read.empty?.should == true
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
10
|
describe "source_location (testing 1.8 implementation)" do
|
|
22
11
|
it 'should return correct source_location for a method' do
|
|
23
12
|
method(:hello).source_location.first.should =~ /test_helper/
|
metadata
CHANGED
|
@@ -1,85 +1,124 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: method_source
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 11
|
|
5
5
|
prerelease:
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 6
|
|
9
|
+
- 6
|
|
10
|
+
version: 0.6.6
|
|
6
11
|
platform: ruby
|
|
7
|
-
authors:
|
|
12
|
+
authors:
|
|
8
13
|
- John Mair (banisterfiend)
|
|
9
14
|
autorequire:
|
|
10
15
|
bindir: bin
|
|
11
16
|
cert_chain: []
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
|
|
18
|
+
date: 2011-10-03 00:00:00 Z
|
|
19
|
+
dependencies:
|
|
20
|
+
- !ruby/object:Gem::Dependency
|
|
15
21
|
name: ruby_parser
|
|
16
|
-
|
|
22
|
+
prerelease: false
|
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
17
24
|
none: false
|
|
18
|
-
requirements:
|
|
19
|
-
- -
|
|
20
|
-
- !ruby/object:Gem::Version
|
|
25
|
+
requirements:
|
|
26
|
+
- - ~>
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
hash: 5
|
|
29
|
+
segments:
|
|
30
|
+
- 2
|
|
31
|
+
- 0
|
|
32
|
+
- 5
|
|
21
33
|
version: 2.0.5
|
|
22
34
|
type: :runtime
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- !ruby/object:Gem::Dependency
|
|
35
|
+
version_requirements: *id001
|
|
36
|
+
- !ruby/object:Gem::Dependency
|
|
26
37
|
name: bacon
|
|
27
|
-
|
|
38
|
+
prerelease: false
|
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
28
40
|
none: false
|
|
29
|
-
requirements:
|
|
30
|
-
- -
|
|
31
|
-
- !ruby/object:Gem::Version
|
|
41
|
+
requirements:
|
|
42
|
+
- - ~>
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
hash: 19
|
|
45
|
+
segments:
|
|
46
|
+
- 1
|
|
47
|
+
- 1
|
|
48
|
+
- 0
|
|
32
49
|
version: 1.1.0
|
|
33
50
|
type: :development
|
|
51
|
+
version_requirements: *id002
|
|
52
|
+
- !ruby/object:Gem::Dependency
|
|
53
|
+
name: rake
|
|
34
54
|
prerelease: false
|
|
35
|
-
|
|
36
|
-
- !ruby/object:Gem::Dependency
|
|
37
|
-
name: open4
|
|
38
|
-
requirement: &70251253610760 !ruby/object:Gem::Requirement
|
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
39
56
|
none: false
|
|
40
|
-
requirements:
|
|
57
|
+
requirements:
|
|
41
58
|
- - ~>
|
|
42
|
-
- !ruby/object:Gem::Version
|
|
43
|
-
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
hash: 25
|
|
61
|
+
segments:
|
|
62
|
+
- 0
|
|
63
|
+
- 9
|
|
64
|
+
version: "0.9"
|
|
44
65
|
type: :development
|
|
45
|
-
|
|
46
|
-
version_requirements: *70251253610760
|
|
66
|
+
version_requirements: *id003
|
|
47
67
|
description: retrieve the sourcecode for a method
|
|
48
68
|
email: jrmair@gmail.com
|
|
49
69
|
executables: []
|
|
70
|
+
|
|
50
71
|
extensions: []
|
|
72
|
+
|
|
51
73
|
extra_rdoc_files: []
|
|
52
|
-
|
|
74
|
+
|
|
75
|
+
files:
|
|
76
|
+
- .gemtest
|
|
77
|
+
- .travis.yml
|
|
78
|
+
- .yardopts
|
|
79
|
+
- Gemfile
|
|
80
|
+
- LICENSE
|
|
81
|
+
- README.markdown
|
|
82
|
+
- Rakefile
|
|
83
|
+
- lib/method_source.rb
|
|
53
84
|
- lib/method_source/source_location.rb
|
|
54
85
|
- lib/method_source/version.rb
|
|
55
|
-
-
|
|
86
|
+
- method_source.gemspec
|
|
56
87
|
- test/test.rb
|
|
57
88
|
- test/test_helper.rb
|
|
58
|
-
- README.markdown
|
|
59
|
-
- Rakefile
|
|
60
|
-
- .gemtest
|
|
61
89
|
homepage: http://banisterfiend.wordpress.com
|
|
62
90
|
licenses: []
|
|
91
|
+
|
|
63
92
|
post_install_message:
|
|
64
93
|
rdoc_options: []
|
|
65
|
-
|
|
94
|
+
|
|
95
|
+
require_paths:
|
|
66
96
|
- lib
|
|
67
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
68
98
|
none: false
|
|
69
|
-
requirements:
|
|
70
|
-
- -
|
|
71
|
-
- !ruby/object:Gem::Version
|
|
72
|
-
|
|
73
|
-
|
|
99
|
+
requirements:
|
|
100
|
+
- - ">="
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
hash: 3
|
|
103
|
+
segments:
|
|
104
|
+
- 0
|
|
105
|
+
version: "0"
|
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
107
|
none: false
|
|
75
|
-
requirements:
|
|
76
|
-
- -
|
|
77
|
-
- !ruby/object:Gem::Version
|
|
78
|
-
|
|
108
|
+
requirements:
|
|
109
|
+
- - ">="
|
|
110
|
+
- !ruby/object:Gem::Version
|
|
111
|
+
hash: 3
|
|
112
|
+
segments:
|
|
113
|
+
- 0
|
|
114
|
+
version: "0"
|
|
79
115
|
requirements: []
|
|
116
|
+
|
|
80
117
|
rubyforge_project:
|
|
81
118
|
rubygems_version: 1.8.6
|
|
82
119
|
signing_key:
|
|
83
120
|
specification_version: 3
|
|
84
121
|
summary: retrieve the sourcecode for a method
|
|
85
|
-
test_files:
|
|
122
|
+
test_files:
|
|
123
|
+
- test/test.rb
|
|
124
|
+
- test/test_helper.rb
|