cinch-rubydoc 0.1.0 → 0.2.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 +4 -4
- data/lib/cinch/rubydoc.rb +47 -46
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8fda38de6cded1bc4cddcf740182c702f4a6851
|
4
|
+
data.tar.gz: 556b9e5b2afb8c359255f026b7ea133549bc92f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76404f5934c485ca11f5f65f0d2b842a9396e41243afe12fb52c749c94d23589797b11e5179c0296387ba53c621a9f01d6b8454697da757b7ce021683db8abad
|
7
|
+
data.tar.gz: 98215c8c267e8ce67ad8681a8b213cd3da098ccd414b014cbed90c77b1a0e6c37262d39581fa21cca92f76592a5157c62a56dc2e5046cc93dbc20fd29d8da449
|
data/lib/cinch/rubydoc.rb
CHANGED
@@ -1,68 +1,69 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
|
1
|
+
require 'yard'
|
2
|
+
require 'cgi'
|
3
|
+
|
4
4
|
|
5
5
|
module Cinch
|
6
6
|
class Rubydoc
|
7
7
|
include Cinch::Plugin
|
8
|
-
BASE_URL = '
|
9
|
-
UNSAFE_CHARS = /[^0-9a-zA-Z\$_\.\+!\*'\(\)-]/
|
10
|
-
|
11
|
-
match /ri ([\w:-]+)([#.][^:\s]+)?$/
|
12
|
-
|
13
|
-
def execute(m, klass, method = nil)
|
14
|
-
real_klass = find_class klass
|
15
|
-
if real_klass.nil?
|
16
|
-
m.reply "I'm sorry, I don't know anything about #{klass}."
|
17
|
-
return
|
18
|
-
end
|
8
|
+
BASE_URL = 'http://www.rubydoc.info/stdlib'
|
19
9
|
|
20
|
-
|
21
|
-
real_method = nil
|
22
|
-
unless method.nil?
|
23
|
-
type = method.slice!(0) == '#' ? :instance : :class
|
24
|
-
real_method = find_method(real_klass, method.to_sym, type)
|
10
|
+
match /ri (.+)\z/
|
25
11
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
12
|
+
def initialize(*args)
|
13
|
+
super
|
14
|
+
@store = YARD::RegistryStore.new
|
15
|
+
@store.load '.yardoc'
|
16
|
+
end
|
30
17
|
|
31
|
-
|
32
|
-
|
18
|
+
def execute(m, request)
|
19
|
+
requests = request.split
|
20
|
+
if requests.count > 3
|
21
|
+
requests = requests.first(3)
|
33
22
|
end
|
34
23
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
unless real_method.nil?
|
39
|
-
url.merge!("#method-#{type.to_s[0]}-#{URI.encode(method, UNSAFE_CHARS).gsub(/%/, '-')}")
|
24
|
+
uris = requests.map do |request|
|
25
|
+
url_for(request)
|
40
26
|
end
|
41
27
|
|
42
|
-
|
28
|
+
uris.compact!
|
29
|
+
if uris.empty?
|
30
|
+
m.reply 'No results'
|
31
|
+
else
|
32
|
+
m.reply uris.join ', '
|
33
|
+
end
|
43
34
|
end
|
44
35
|
|
45
|
-
|
46
|
-
|
47
|
-
|
36
|
+
private
|
37
|
+
|
38
|
+
def url_for(name)
|
39
|
+
obj = @store[name]
|
40
|
+
if obj.nil? && name.end_with?('.new')
|
41
|
+
obj = @store[name.sub(/\.new\z/, '#initialize')]
|
42
|
+
end
|
48
43
|
|
49
|
-
|
50
|
-
|
44
|
+
unless obj
|
45
|
+
debug "Nothing found for #{name}"
|
46
|
+
return nil
|
51
47
|
end
|
52
48
|
|
53
|
-
|
54
|
-
|
55
|
-
nil
|
49
|
+
section = section_for obj
|
50
|
+
"#{BASE_URL}/#{section}/#{path_for obj}"
|
56
51
|
end
|
57
52
|
|
58
|
-
def
|
59
|
-
if
|
60
|
-
|
61
|
-
|
62
|
-
|
53
|
+
def section_for(obj)
|
54
|
+
return :core if obj.files.any? { |f, _| !f.include?('/') }
|
55
|
+
File.basename(obj.file.split('/', 3)[1], '.rb')
|
56
|
+
end
|
57
|
+
|
58
|
+
def path_for(obj)
|
59
|
+
case obj.type
|
60
|
+
when :method
|
61
|
+
"#{path_for obj.parent}##{CGI.escape obj.name.to_s}-#{obj.scope}_method"
|
62
|
+
when :constant
|
63
|
+
"#{path_for obj.parent}##{obj.name}-constant"
|
64
|
+
when :class, :module
|
65
|
+
obj.path.gsub('::', '/')
|
63
66
|
end
|
64
|
-
rescue NameError
|
65
|
-
nil
|
66
67
|
end
|
67
68
|
end
|
68
69
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch-rubydoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thibault `Adædra` Hamel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cinch
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: yard
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.8'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.8'
|
27
41
|
description: This provides a Cinch plugin to give ruby doc links for doc requests
|
28
42
|
email:
|
29
43
|
- me@adaedra.eu
|
@@ -57,3 +71,4 @@ signing_key:
|
|
57
71
|
specification_version: 4
|
58
72
|
summary: A ruby doc matcher for Cinch
|
59
73
|
test_files: []
|
74
|
+
has_rdoc:
|