core_docs 0.9.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/.gitignore +10 -0
- data/.travis.yml +13 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +3 -0
- data/LICENSE +25 -0
- data/README.md +18 -0
- data/Rakefile +107 -0
- data/core_docs.gemspec +27 -0
- data/lib/core_docs.rb +228 -0
- data/lib/core_docs/core_docs_20/checksums +262 -0
- data/lib/core_docs/core_docs_20/object_types +0 -0
- data/lib/core_docs/core_docs_20/objects/root.dat +0 -0
- data/lib/core_docs/core_docs_20/proxy_types +0 -0
- data/lib/core_docs/core_docs_21/checksums +290 -0
- data/lib/core_docs/core_docs_21/object_types +0 -0
- data/lib/core_docs/core_docs_21/objects/root.dat +0 -0
- data/lib/core_docs/core_docs_21/proxy_types +0 -0
- data/lib/core_docs/core_docs_22/checksums +474 -0
- data/lib/core_docs/core_docs_22/object_types +0 -0
- data/lib/core_docs/core_docs_22/objects/root.dat +0 -0
- data/lib/core_docs/core_docs_22/proxy_types +0 -0
- data/lib/core_docs/version.rb +3 -0
- data/spec/core_docs_spec.rb +199 -0
- data/spec/gem_with_cext/gems/ext/extconf.rb +2 -0
- data/spec/gem_with_cext/gems/ext/sample.c +17 -0
- data/spec/gem_with_cext/gems/lib/sample.rb +18 -0
- data/spec/gem_with_cext/gems/sample.rb +4 -0
- data/spec/helper.rb +11 -0
- metadata +123 -0
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,199 @@
|
|
1
|
+
direc = File.dirname(__FILE__)
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require "#{direc}/../lib/core_docs"
|
5
|
+
require "#{direc}/helper"
|
6
|
+
require "#{direc}/gem_with_cext/gems/sample"
|
7
|
+
require 'bacon'
|
8
|
+
require 'set'
|
9
|
+
require 'fileutils'
|
10
|
+
require 'readline'
|
11
|
+
|
12
|
+
puts "Testing core_docs version #{CoreDocs::VERSION}..."
|
13
|
+
puts "Ruby version: #{RUBY_VERSION}"
|
14
|
+
|
15
|
+
describe CoreDocs do
|
16
|
+
|
17
|
+
describe "core C methods" do
|
18
|
+
it 'should look up core (C) methods' do
|
19
|
+
obj = CoreDocs::MethodInfo.info_for(method(:puts))
|
20
|
+
obj.source.should.not == nil
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should look up core (C) instance methods' do
|
24
|
+
Module.module_eval do
|
25
|
+
obj = CoreDocs::MethodInfo.info_for(instance_method(:include))
|
26
|
+
obj.source.should.not == nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should look up core (C) class method (by Method object)' do
|
31
|
+
Module.module_eval do
|
32
|
+
obj = CoreDocs::MethodInfo.info_for(Dir.method(:glob))
|
33
|
+
obj.source.should.not == nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should look up core (C) class method (by UnboundMethod object)' do
|
38
|
+
Module.module_eval do
|
39
|
+
obj = CoreDocs::MethodInfo.info_for(class << Dir; instance_method(:glob); end)
|
40
|
+
obj.source.should.not == nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "eval methods" do
|
46
|
+
it 'should return nil for eval methods' do
|
47
|
+
TOPLEVEL_BINDING.eval("def hello; end")
|
48
|
+
obj = CoreDocs::MethodInfo.info_for(method(:hello))
|
49
|
+
obj.should == nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "pure ruby methods" do
|
54
|
+
it 'should look up ruby methods' do
|
55
|
+
obj = CoreDocs::MethodInfo.info_for(C.new.method(:message))
|
56
|
+
obj.should.not == nil
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should look up ruby instance methods' do
|
60
|
+
obj = CoreDocs::MethodInfo.info_for(C.instance_method(:message))
|
61
|
+
obj.should.not == nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "Ruby stdlib methods" do
|
66
|
+
it "should look up ruby stdlib method" do
|
67
|
+
obj = CoreDocs::MethodInfo.info_for(Set.instance_method(:union))
|
68
|
+
obj.should.not == nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "C ext methods" do
|
73
|
+
|
74
|
+
it "should lookup C ext methods" do
|
75
|
+
obj = CoreDocs::MethodInfo.info_for(Sample.instance_method(:gleezor))
|
76
|
+
obj.should.not == nil
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should lookup aliased C ext methods" do
|
80
|
+
obj = CoreDocs::MethodInfo.info_for(Sample.instance_method(:remove))
|
81
|
+
obj.should.not == nil
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should lookup C ext instance methods even when its owners don't have any ruby methods" do
|
85
|
+
obj = CoreDocs::MethodInfo.info_for(Sample::A::B.instance_method(:gleezor))
|
86
|
+
obj.should.not == nil
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should lookup C ext class methods even when its owners don't have any ruby methods" do
|
90
|
+
obj = CoreDocs::MethodInfo.info_for(Sample::A::B.method(:gleezor))
|
91
|
+
obj.should.not == nil
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "C stdlib methods" do
|
96
|
+
it "finds them" do
|
97
|
+
obj = CoreDocs::MethodInfo.info_for(Readline.method(:readline))
|
98
|
+
obj.should.not == nil
|
99
|
+
end
|
100
|
+
|
101
|
+
it "finds well hidden docs like BigDecimal docs" do
|
102
|
+
require 'bigdecimal'
|
103
|
+
obj = CoreDocs::MethodInfo.info_for(BigDecimal.instance_method(:finite?))
|
104
|
+
obj.should.not == nil
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe ".aliases" do
|
109
|
+
it "should return empty array if method does not have any alias" do
|
110
|
+
aliases = CoreDocs::MethodInfo.aliases(Sample.instance_method(:some_meth))
|
111
|
+
aliases.should == []
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should return aliases of a (C) method" do
|
115
|
+
orig = Sample.instance_method(:gleezor)
|
116
|
+
copy = Sample.instance_method(:remove)
|
117
|
+
|
118
|
+
aliases = CoreDocs::MethodInfo.aliases(orig)
|
119
|
+
aliases.should == [copy]
|
120
|
+
|
121
|
+
aliases = CoreDocs::MethodInfo.aliases(copy)
|
122
|
+
aliases.should == [orig]
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should return aliases of a ruby method" do
|
126
|
+
C.class_eval { alias msg message }
|
127
|
+
|
128
|
+
orig = C.instance_method(:message)
|
129
|
+
copy = C.instance_method(:msg)
|
130
|
+
|
131
|
+
aliases = CoreDocs::MethodInfo.aliases(orig)
|
132
|
+
aliases.should == [copy]
|
133
|
+
|
134
|
+
aliases = CoreDocs::MethodInfo.aliases(copy)
|
135
|
+
aliases.should == [orig]
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should return aliases of protected method" do
|
139
|
+
orig = Sample.instance_method(:gleezor_1)
|
140
|
+
copy = Sample.instance_method(:remove_1)
|
141
|
+
|
142
|
+
aliases = CoreDocs::MethodInfo.aliases(orig)
|
143
|
+
aliases.should == [copy]
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should return aliases of private method" do
|
147
|
+
orig = Sample.instance_method(:gleezor_2)
|
148
|
+
copy = Sample.instance_method(:remove_2)
|
149
|
+
|
150
|
+
aliases = CoreDocs::MethodInfo.aliases(orig)
|
151
|
+
aliases.should == [copy]
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'does not error when given a singleton method' do
|
155
|
+
c = Class.new do
|
156
|
+
def self.my_method; end
|
157
|
+
end
|
158
|
+
|
159
|
+
lambda { CoreDocs::MethodInfo.aliases(c.method(:my_method)) }.should.not.raise NameError
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe ".gem_root" do
|
164
|
+
# it "should return the path to the gem" do
|
165
|
+
# path = Pry::WrappedModule.new(Sample).source_location[0]
|
166
|
+
|
167
|
+
# CoreDocs::MethodInfo.gem_root(path).should ==
|
168
|
+
# File.expand_path("gem_with_cext/gems", direc)
|
169
|
+
# end
|
170
|
+
|
171
|
+
it "should not be fooled by a parent 'lib' or 'ext' dir" do
|
172
|
+
path = "/foo/.rbenv/versions/1.9.3-p429/lib/ruby/gems/"\
|
173
|
+
"1.9.1/gems/activesupport-4.0.2/lib/active_support/"\
|
174
|
+
"core_ext/kernel/reporting.rb"
|
175
|
+
|
176
|
+
CoreDocs::MethodInfo.gem_root(path).should ==
|
177
|
+
"/foo/.rbenv/versions/1.9.3-p429/lib/ruby/"\
|
178
|
+
"gems/1.9.1/gems/activesupport-4.0.2"
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
describe "1.9 and higher specific docs" do
|
183
|
+
it "finds Kernel#require_relative" do
|
184
|
+
obj = CoreDocs::MethodInfo.info_for(Kernel.instance_method(:require_relative))
|
185
|
+
obj.should.not == nil
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
# For the time being, Pry doesn't define `mri_20?` helper method.
|
190
|
+
if RUBY_VERSION =~ /2.0/ && RbConfig::CONFIG['ruby_install_name'] == 'ruby'
|
191
|
+
describe "2.0 specific docs" do
|
192
|
+
it "finds Module#refine" do
|
193
|
+
obj = CoreDocs::MethodInfo.info_for(Module.instance_method(:refine))
|
194
|
+
obj.should.not == nil
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#include "ruby.h"
|
2
|
+
|
3
|
+
static VALUE gleezor(VALUE self)
|
4
|
+
{
|
5
|
+
return 1;
|
6
|
+
}
|
7
|
+
|
8
|
+
void Init_sample(void)
|
9
|
+
{
|
10
|
+
VALUE klass = rb_define_class("Sample", rb_cObject);
|
11
|
+
VALUE A = rb_define_module_under(klass, "A");
|
12
|
+
VALUE B = rb_define_module_under(A, "B");
|
13
|
+
|
14
|
+
rb_define_method(klass, "gleezor", gleezor, 0);
|
15
|
+
rb_define_method(B, "gleezor", gleezor, 0);
|
16
|
+
rb_define_singleton_method(B, "gleezor", gleezor, 0);
|
17
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Sample
|
2
|
+
# ruby method
|
3
|
+
def some_meth; end
|
4
|
+
|
5
|
+
# aliasing a C method
|
6
|
+
alias :remove :gleezor
|
7
|
+
|
8
|
+
protected
|
9
|
+
|
10
|
+
def gleezor_1; end
|
11
|
+
alias :remove_1 :gleezor_1
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def gleezor_2; end
|
16
|
+
|
17
|
+
alias :remove_2 :gleezor_2
|
18
|
+
end
|
data/spec/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: core_docs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Mair (banisterfiend)
|
8
|
+
- Jan Lelis (non-pry version)
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-03-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: yard
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0.8'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0.8'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: latest_ruby
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bacon
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.1'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.1'
|
56
|
+
description: |
|
57
|
+
Pry Doc is a Pry REPL plugin. It provides extended documentation support for the
|
58
|
+
REPL by means of improving the `show-doc` and `show-source` commands. With help
|
59
|
+
of the plugin the commands are be able to display the source code and the docs
|
60
|
+
of Ruby methods and classes implemented in C.
|
61
|
+
documentation
|
62
|
+
email:
|
63
|
+
- jrmair@gmail.com
|
64
|
+
- mail@janlelis.de
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- ".gitignore"
|
70
|
+
- ".travis.yml"
|
71
|
+
- ".yardopts"
|
72
|
+
- CHANGELOG.md
|
73
|
+
- Gemfile
|
74
|
+
- LICENSE
|
75
|
+
- README.md
|
76
|
+
- Rakefile
|
77
|
+
- core_docs.gemspec
|
78
|
+
- lib/core_docs.rb
|
79
|
+
- lib/core_docs/core_docs_20/checksums
|
80
|
+
- lib/core_docs/core_docs_20/object_types
|
81
|
+
- lib/core_docs/core_docs_20/objects/root.dat
|
82
|
+
- lib/core_docs/core_docs_20/proxy_types
|
83
|
+
- lib/core_docs/core_docs_21/checksums
|
84
|
+
- lib/core_docs/core_docs_21/object_types
|
85
|
+
- lib/core_docs/core_docs_21/objects/root.dat
|
86
|
+
- lib/core_docs/core_docs_21/proxy_types
|
87
|
+
- lib/core_docs/core_docs_22/checksums
|
88
|
+
- lib/core_docs/core_docs_22/object_types
|
89
|
+
- lib/core_docs/core_docs_22/objects/root.dat
|
90
|
+
- lib/core_docs/core_docs_22/proxy_types
|
91
|
+
- lib/core_docs/version.rb
|
92
|
+
- spec/core_docs_spec.rb
|
93
|
+
- spec/gem_with_cext/gems/ext/extconf.rb
|
94
|
+
- spec/gem_with_cext/gems/ext/sample.c
|
95
|
+
- spec/gem_with_cext/gems/lib/sample.rb
|
96
|
+
- spec/gem_with_cext/gems/sample.rb
|
97
|
+
- spec/helper.rb
|
98
|
+
homepage: https://github.com/janlelis/core_docs
|
99
|
+
licenses:
|
100
|
+
- MIT
|
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: '2.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.4.6
|
119
|
+
signing_key:
|
120
|
+
specification_version: 4
|
121
|
+
summary: Provides YARD and extended documentation support for Pry
|
122
|
+
test_files: []
|
123
|
+
has_rdoc:
|