cinch-rubydoc 0.2.0 → 0.3.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cinch/rubydoc.rb +38 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8fda38de6cded1bc4cddcf740182c702f4a6851
4
- data.tar.gz: 556b9e5b2afb8c359255f026b7ea133549bc92f3
3
+ metadata.gz: 6735fdcb01f5f645760056e563e842db5d385c35
4
+ data.tar.gz: 66f7dd565ec12d41f26b8f315e705e1b507236af
5
5
  SHA512:
6
- metadata.gz: 76404f5934c485ca11f5f65f0d2b842a9396e41243afe12fb52c749c94d23589797b11e5179c0296387ba53c621a9f01d6b8454697da757b7ce021683db8abad
7
- data.tar.gz: 98215c8c267e8ce67ad8681a8b213cd3da098ccd414b014cbed90c77b1a0e6c37262d39581fa21cca92f76592a5157c62a56dc2e5046cc93dbc20fd29d8da449
6
+ metadata.gz: 304586cd08b0685c7709d5021b55a35fa69df943a5b1dfac28cda0b8dec4ff868d5f3a82b4b31cb46b9e7afed39f94907ab1143fe148f2f4c1b75d8fa69276b8
7
+ data.tar.gz: 4f2545e376a9bb816266ef811cd4cdc87d6cec2c87ef0d569c7ea04ce190af598141820104d4c71357585edfd2cc9068d2bdcf8dd3afad9b0f74b6180f0f9a01
data/lib/cinch/rubydoc.rb CHANGED
@@ -16,7 +16,7 @@ module Cinch
16
16
  end
17
17
 
18
18
  def execute(m, request)
19
- requests = request.split
19
+ requests = request.split /[ ,]+/
20
20
  if requests.count > 3
21
21
  requests = requests.first(3)
22
22
  end
@@ -41,6 +41,28 @@ module Cinch
41
41
  obj = @store[name.sub(/\.new\z/, '#initialize')]
42
42
  end
43
43
 
44
+ if obj.nil? && name =~ /(::|#|\.)/
45
+ klass, scope, meth = name.rpartition(/(::|#|\.)/)
46
+ okls = @store[klass]
47
+
48
+ if okls
49
+ obj = okls.meths.find do |e|
50
+ e.name == meth.to_sym && e.scope == to_scope(scope)
51
+ end
52
+ end
53
+
54
+ if obj.nil? && okls && okls.type == :class && klass != 'BasicObject'
55
+ # Check if "forgotten" parts of the tree, too
56
+ [Object, BasicObject].each do |o|
57
+ obj = @store[o.name].meths.find do |e|
58
+ e.name == meth.to_sym && e.scope == to_scope(scope)
59
+ end
60
+
61
+ break if obj
62
+ end
63
+ end
64
+ end
65
+
44
66
  unless obj
45
67
  debug "Nothing found for #{name}"
46
68
  return nil
@@ -58,11 +80,23 @@ module Cinch
58
80
  def path_for(obj)
59
81
  case obj.type
60
82
  when :method
61
- "#{path_for obj.parent}##{CGI.escape obj.name.to_s}-#{obj.scope}_method"
83
+ scope = obj.module_function? ? 'instance' : obj.scope
84
+ "#{path_for obj.parent}##{CGI.escape obj.name.to_s}-#{scope}_method"
62
85
  when :constant
63
- "#{path_for obj.parent}##{obj.name}-constant"
86
+ "#{path_for obj.parent}##{obj.name}-constant"
64
87
  when :class, :module
65
- obj.path.gsub('::', '/')
88
+ obj.path.gsub('::', '/')
89
+ end
90
+ end
91
+
92
+ def to_scope(symbol)
93
+ case symbol
94
+ when '::', '.'
95
+ :class
96
+ when '#'
97
+ :instance
98
+ else
99
+ throw 'Invalid symbol'
66
100
  end
67
101
  end
68
102
  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.2.0
4
+ version: 0.3.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-25 00:00:00.000000000 Z
11
+ date: 2015-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cinch