fastri 0.1.0.1 → 0.1.1.1
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/CHANGES +19 -0
- data/Rakefile +2 -2
- data/bin/fastri-server +22 -3
- data/bin/fri +48 -4
- data/bin/ri-emacs +1 -1
- data/lib/fastri/name_descriptor.rb +71 -0
- data/lib/fastri/ri_index.rb +10 -5
- data/lib/fastri/ri_service.rb +168 -48
- data/lib/fastri/version.rb +1 -1
- data/pre-install.rb +8 -0
- data/test/test_name_descriptor.rb +35 -0
- metadata +7 -2
data/CHANGES
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
User-visible changes in FastRI
|
3
|
+
|
4
|
+
Since version 0.1.0 (2006-11-08)
|
5
|
+
================================
|
6
|
+
Features
|
7
|
+
--------
|
8
|
+
* the search strategy can be specified with --order
|
9
|
+
* added case-insensitive search strategies
|
10
|
+
* --show-matches returns a list of matching entries
|
11
|
+
* default output format defaults to 'plain' on win32
|
12
|
+
|
13
|
+
Bugfixes
|
14
|
+
--------
|
15
|
+
* the home directory is detected correctly on win32
|
16
|
+
* no more SecurityErrors due to calls to #require after $SAFE=1
|
17
|
+
* index creation doesn't bomb when RubyGems is not installed
|
18
|
+
* executables are added the .rb extension when installing on win32 with
|
19
|
+
setup.rb
|
data/Rakefile
CHANGED
@@ -30,9 +30,9 @@ require 'fastri/version'
|
|
30
30
|
PKG_REVISION = ".1"
|
31
31
|
PKG_FILES = FileList[
|
32
32
|
"bin/fri", "bin/fastri-server", "bin/ri-emacs",
|
33
|
-
"lib/**/*.rb",
|
33
|
+
"lib/**/*.rb", "CHANGES",
|
34
34
|
"COPYING", "LEGAL", "LICENSE", "Rakefile", "README.*", "test/*.rb",
|
35
|
-
"setup.rb",
|
35
|
+
"setup.rb", "pre-install.rb",
|
36
36
|
]
|
37
37
|
|
38
38
|
require 'rake/gempackagetask'
|
data/bin/fastri-server
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
|
1
|
+
#! /home/batsman/usr//bin/ruby
|
2
2
|
# fastri-server: serve RI documentation over DRb
|
3
3
|
# Copyright (C) 2006 Mauricio Fernandez <mfp@acm.org>
|
4
4
|
|
5
5
|
require 'fastri/version'
|
6
6
|
require 'fastri/ri_index'
|
7
7
|
require 'fastri/ri_service'
|
8
|
+
require 'enumerator'
|
8
9
|
|
9
10
|
FASTRI_SERVER_VERSION = "0.0.1"
|
10
11
|
|
@@ -51,12 +52,31 @@ EOF
|
|
51
52
|
ri_reader
|
52
53
|
end
|
53
54
|
|
55
|
+
# stolen from RubyGems
|
56
|
+
def find_home
|
57
|
+
['HOME', 'USERPROFILE'].each do |homekey|
|
58
|
+
return ENV[homekey] if ENV[homekey]
|
59
|
+
end
|
60
|
+
if ENV['HOMEDRIVE'] && ENV['HOMEPATH']
|
61
|
+
return "#{ENV['HOMEDRIVE']}:#{ENV['HOMEPATH']}"
|
62
|
+
end
|
63
|
+
begin
|
64
|
+
File.expand_path("~")
|
65
|
+
rescue StandardError => ex
|
66
|
+
if File::ALT_SEPARATOR
|
67
|
+
"C:/"
|
68
|
+
else
|
69
|
+
"/"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
54
74
|
#{{{ Main program
|
55
75
|
|
56
76
|
require 'optparse'
|
57
77
|
|
58
78
|
options = {:allowed_hosts => ["127.0.0.1"], :addr => "127.0.0.1",
|
59
|
-
:index_file => File.
|
79
|
+
:index_file => File.join(find_home, ".fastri-index")}
|
60
80
|
OptionParser.new do |opts|
|
61
81
|
opts.banner = "Usage: fastri-server.rb [options]"
|
62
82
|
|
@@ -139,7 +159,6 @@ EOF
|
|
139
159
|
end
|
140
160
|
|
141
161
|
# {{{ Init message
|
142
|
-
require 'enumerator'
|
143
162
|
puts "fastri-server #{FASTRI_SERVER_VERSION} (FastRI #{FastRI::FASTRI_VERSION}) listening on #{DRb.uri}"
|
144
163
|
puts "ACL:"
|
145
164
|
acl_opt.each_slice(2){|action, host| puts "%-5s %s" % [action, host]}
|
data/bin/fri
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
#! /home/batsman/usr//bin/ruby
|
2
2
|
# fri: access RI documentation through DRb
|
3
3
|
# Copyright (C) 2006 Mauricio Fernandez <mfp@acm.org>
|
4
4
|
#
|
@@ -10,7 +10,23 @@ require 'optparse'
|
|
10
10
|
# 0.0.0.0, which results in a DNS request, adding way too much latency
|
11
11
|
options = {
|
12
12
|
:addr => "127.0.0.1",
|
13
|
-
:format =>
|
13
|
+
:format =>
|
14
|
+
case RUBY_PLATFORM
|
15
|
+
when /win/
|
16
|
+
if /darwin|cygwin/ =~ RUBY_PLATFORM
|
17
|
+
"ansi"
|
18
|
+
else
|
19
|
+
"plain"
|
20
|
+
end
|
21
|
+
else
|
22
|
+
"ansi"
|
23
|
+
end,
|
24
|
+
:width => 72,
|
25
|
+
:lookup_order => [
|
26
|
+
:exact, :exact_ci, :nested, :nested_ci, :partial, :partial_ci,
|
27
|
+
:nested_partial, :nested_partial_ci,
|
28
|
+
],
|
29
|
+
:show_matches => false,
|
14
30
|
}
|
15
31
|
override_addr_env = false
|
16
32
|
optparser = OptionParser.new do |opts|
|
@@ -22,11 +38,30 @@ optparser = OptionParser.new do |opts|
|
|
22
38
|
override_addr_env = true
|
23
39
|
end
|
24
40
|
|
41
|
+
order_mapping = {
|
42
|
+
'e' => :exact, 'E' => :exact_ci, 'n' => :nested, 'N' => :nested_ci,
|
43
|
+
'p' => :partial, 'P' => :partial_ci, 'x' => :nested_partial,
|
44
|
+
'X' => :nested_partial_ci
|
45
|
+
}
|
46
|
+
opts.on("-O", "--order ORDER", "Specify lookup order.",
|
47
|
+
"(default: eEnNpPxX)", "Uppercase: case-indep.",
|
48
|
+
"e: exact, n: nested, p: partial",
|
49
|
+
"x: nested and partial") do |order|
|
50
|
+
options[:lookup_order] = order.split(//).map{|x| order_mapping[x]}.compact
|
51
|
+
end
|
52
|
+
|
53
|
+
opts.on("--show-matches", "Only show matching entries."){ options[:show_matches] = true }
|
54
|
+
|
25
55
|
opts.on("-f", "--format FMT", "Format to use when displaying output:",
|
26
|
-
" ansi, plain (default:
|
56
|
+
" ansi, plain (default: #{options[:format]})") do |format|
|
27
57
|
options[:format] = format
|
28
58
|
end
|
29
59
|
|
60
|
+
opts.on("-w", "--width WIDTH", "Set the width of the output.") do |width|
|
61
|
+
w = width.to_i
|
62
|
+
options[:width] = w > 0 ? w : options[:width]
|
63
|
+
end
|
64
|
+
|
30
65
|
opts.on("-h", "--help", "Show this help message") do
|
31
66
|
puts opts
|
32
67
|
exit
|
@@ -63,5 +98,14 @@ EOF
|
|
63
98
|
exit(-1)
|
64
99
|
end
|
65
100
|
service = ring_server.read([:name, :FastRI, nil, nil])[2]
|
66
|
-
|
101
|
+
info_options = {
|
102
|
+
:formatter => options[:format],
|
103
|
+
:width => options[:width],
|
104
|
+
:lookup_order => options[:lookup_order],
|
105
|
+
}
|
106
|
+
if options[:show_matches]
|
107
|
+
puts service.matches(ARGV[0], info_options).sort
|
108
|
+
else
|
109
|
+
puts service.info(ARGV[0], info_options)
|
110
|
+
end
|
67
111
|
# vi: set sw=2 expandtab:
|
data/bin/ri-emacs
CHANGED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Copyright (C) 2006 Mauricio Fernandez <mfp@acm.org>
|
2
|
+
#
|
3
|
+
|
4
|
+
module FastRI
|
5
|
+
|
6
|
+
# Alternative NameDescriptor implementation which doesn't require class/module
|
7
|
+
# names to be properly capitalized.
|
8
|
+
#
|
9
|
+
# Rules:
|
10
|
+
# * <tt>#foo</tt>: instance method +foo+
|
11
|
+
# * <tt>.foo</tt>: method +foo+ (either singleton or instance)
|
12
|
+
# * <tt>::foo</tt>: singleton method +foo+
|
13
|
+
# * <tt>foo::bar#bar<tt>: instance method +bar+ under <tt>foo::bar</tt>
|
14
|
+
# * <tt>foo::bar.bar<tt>: either singleton or instance method +bar+ under
|
15
|
+
# <tt>foo::bar</tt>
|
16
|
+
# * <tt>foo::bar::Baz<tt>: module/class foo:bar::Baz
|
17
|
+
# * <tt>foo::bar::baz</tt>: singleton method +baz+ from <tt>foo::bar</tt>
|
18
|
+
# * other: raise RiError
|
19
|
+
class NameDescriptor
|
20
|
+
attr_reader :class_names
|
21
|
+
attr_reader :method_name
|
22
|
+
|
23
|
+
# true and false have the obvious meaning. nil means we don't care
|
24
|
+
attr_reader :is_class_method
|
25
|
+
|
26
|
+
def initialize(arg)
|
27
|
+
@class_names = []
|
28
|
+
@method_name = nil
|
29
|
+
@is_class_method = nil
|
30
|
+
|
31
|
+
case arg
|
32
|
+
when /((?:[^:]*::)*[^:]*)(#|::|\.)(.*)$/
|
33
|
+
ns, sep, meth_or_class = $~.captures
|
34
|
+
# optimization attempt: try to guess the real capitalization,
|
35
|
+
# so we get a direct hit
|
36
|
+
@class_names = ns.split(/::/).map{|x| x[0,1] = x[0,1].upcase; x }
|
37
|
+
if %w[# .].include? sep
|
38
|
+
@method_name = meth_or_class
|
39
|
+
@is_class_method =
|
40
|
+
case sep
|
41
|
+
when "#"; false
|
42
|
+
when "."; nil
|
43
|
+
end
|
44
|
+
else
|
45
|
+
if ("A".."Z").include? meth_or_class[0,1] # 1.9 compatibility
|
46
|
+
@class_names << meth_or_class
|
47
|
+
else
|
48
|
+
@method_name = meth_or_class
|
49
|
+
@is_class_method = true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
when /^[^#:.]+/
|
53
|
+
if ("A".."Z").include? arg[0,1]
|
54
|
+
@class_names = [arg]
|
55
|
+
else
|
56
|
+
@method_name = arg.dup
|
57
|
+
@is_class_method = nil
|
58
|
+
end
|
59
|
+
else
|
60
|
+
raise RiError, "Cannot create NameDescriptor from #{arg}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Return the full class name (with '::' between the components)
|
65
|
+
# or "" if there's no class name
|
66
|
+
def full_class_name
|
67
|
+
@class_names.join("::")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end #module FastRI
|
data/lib/fastri/ri_index.rb
CHANGED
@@ -189,12 +189,17 @@ class RiIndex
|
|
189
189
|
@gem_names = paths.map do |p|
|
190
190
|
fullp = File.expand_path(p)
|
191
191
|
gemname = nil
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
192
|
+
begin
|
193
|
+
require 'rubygems'
|
194
|
+
Gem.path.each do |gempath|
|
195
|
+
re = %r!^#{Regexp.escape(File.expand_path(gempath))}/doc/!
|
196
|
+
if re =~ fullp
|
197
|
+
gemname = fullp.gsub(re,"")[%r{^[^/]+}]
|
198
|
+
break
|
199
|
+
end
|
197
200
|
end
|
201
|
+
rescue LoadError
|
202
|
+
# no RubyGems, no gems installed, skip it
|
198
203
|
end
|
199
204
|
gemname ? gemname : "system"
|
200
205
|
end
|
data/lib/fastri/ri_service.rb
CHANGED
@@ -8,6 +8,8 @@ require 'rdoc/ri/ri_formatter'
|
|
8
8
|
require 'rdoc/ri/ri_display'
|
9
9
|
|
10
10
|
require 'fastri/ri_index.rb'
|
11
|
+
require 'fastri/name_descriptor'
|
12
|
+
|
11
13
|
|
12
14
|
module FastRI
|
13
15
|
|
@@ -67,57 +69,72 @@ class RedirectedTextFormatter < RI::TextFormatter
|
|
67
69
|
end
|
68
70
|
|
69
71
|
class RiService
|
72
|
+
|
73
|
+
class MatchFinder
|
74
|
+
def self.new
|
75
|
+
ret = super
|
76
|
+
yield ret if block_given?
|
77
|
+
ret
|
78
|
+
end
|
79
|
+
|
80
|
+
def initialize
|
81
|
+
@matchers = {}
|
82
|
+
end
|
83
|
+
|
84
|
+
def add_matcher(name, &block)
|
85
|
+
@matchers[name] = block
|
86
|
+
end
|
87
|
+
|
88
|
+
def get_matches(methods)
|
89
|
+
catch(:MatchFinder_return) do
|
90
|
+
methods.each do |name|
|
91
|
+
matcher = @matchers[name]
|
92
|
+
matcher.call(self) if matcher
|
93
|
+
end
|
94
|
+
[]
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def yield(matches)
|
99
|
+
case matches
|
100
|
+
when nil, []; nil
|
101
|
+
when Array
|
102
|
+
throw :MatchFinder_return, matches
|
103
|
+
else
|
104
|
+
throw :MatchFinder_return, [matches]
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end # MatchFinder
|
108
|
+
|
109
|
+
|
70
110
|
Options = Struct.new(:formatter, :use_stdout, :width)
|
71
111
|
|
72
112
|
def initialize(ri_reader)
|
73
113
|
@ri_reader = ri_reader
|
74
114
|
end
|
75
115
|
|
76
|
-
|
116
|
+
DEFAULT_OBTAIN_ENTRIES_OPTIONS = {
|
117
|
+
:lookup_order => [
|
118
|
+
:exact, :exact_ci, :nested, :nested_ci, :partial, :partial_ci,
|
119
|
+
:nested_partial, :nested_partial_ci,
|
120
|
+
],
|
121
|
+
}
|
122
|
+
def obtain_entries(descriptor, options = {})
|
123
|
+
options = DEFAULT_OBTAIN_ENTRIES_OPTIONS.merge(options)
|
77
124
|
if descriptor.class_names.empty?
|
78
|
-
|
79
|
-
return
|
80
|
-
|
81
|
-
# try with partial matches: foo -> foobar, foobaz anywhere in the
|
82
|
-
# hierarchy
|
83
|
-
meths = @ri_reader.methods_under_matching("", /(#|\.)#{descriptor.method_name}/, true)
|
84
|
-
return meths
|
125
|
+
seps = separators(descriptor.is_class_method)
|
126
|
+
return obtain_unqualified_method_entries(descriptor.method_name, seps,
|
127
|
+
options[:lookup_order])
|
85
128
|
end
|
86
129
|
|
87
130
|
# if we're here, some namespace was given
|
88
131
|
full_ns_name = descriptor.class_names.join("::")
|
89
132
|
if descriptor.method_name == nil
|
90
|
-
|
91
|
-
return [ns] if ns
|
92
|
-
# nested namespace
|
93
|
-
namespaces = @ri_reader.namespaces_under_matching("", /::#{full_ns_name}$/, true)
|
94
|
-
return namespaces unless namespaces.empty?
|
95
|
-
return [] unless try_partial
|
96
|
-
# partial match
|
97
|
-
namespaces = @ri_reader.namespaces_under_matching("", /^#{full_ns_name}/, false)
|
98
|
-
return namespaces unless namespaces.empty?
|
99
|
-
# partial and nested
|
100
|
-
namespaces = @ri_reader.namespaces_under_matching("", /::#{full_ns_name}[^:]*$/, true)
|
101
|
-
return namespaces
|
133
|
+
return obtain_namespace_entries(full_ns_name, options[:lookup_order])
|
102
134
|
else # both namespace and method
|
103
135
|
seps = separators(descriptor.is_class_method)
|
104
|
-
|
105
|
-
|
106
|
-
return [entry] if entry
|
107
|
-
end
|
108
|
-
# no exact matches
|
109
|
-
sep_re = "(" + seps.map{|x| Regexp.escape(x)}.join("|") + ")"
|
110
|
-
# nested
|
111
|
-
methods = @ri_reader.methods_under_matching("", /::#{full_ns_name}#{sep_re}#{descriptor.method_name}$/, true)
|
112
|
-
return methods unless methods.empty?
|
113
|
-
|
114
|
-
return [] unless try_partial
|
115
|
-
# partial
|
116
|
-
methods = @ri_reader.methods_under_matching(full_ns_name, /#{sep_re}#{descriptor.method_name}/, false)
|
117
|
-
return methods unless methods.empty?
|
118
|
-
# partial and nested
|
119
|
-
methods = @ri_reader.methods_under_matching("", /::#{full_ns_name}#{sep_re}#{descriptor.method_name}/, true)
|
120
|
-
return methods
|
136
|
+
return obtain_qualified_method_entries(full_ns_name, descriptor.method_name,
|
137
|
+
seps, options[:lookup_order])
|
121
138
|
end
|
122
139
|
end
|
123
140
|
|
@@ -160,26 +177,42 @@ class RiService
|
|
160
177
|
return nil
|
161
178
|
end
|
162
179
|
|
163
|
-
|
180
|
+
DEFAULT_INFO_OPTIONS = {
|
181
|
+
:formatter => :ansi,
|
182
|
+
:width => 72,
|
183
|
+
}
|
184
|
+
|
185
|
+
def matches(keyword, options = {})
|
186
|
+
options = DEFAULT_INFO_OPTIONS.merge(options)
|
187
|
+
return nil if keyword.strip.empty?
|
188
|
+
descriptor = NameDescriptor.new(keyword)
|
189
|
+
ret = obtain_entries(descriptor, options).map{|x| x.full_name}
|
190
|
+
ret ? ret : nil
|
191
|
+
rescue RiError
|
192
|
+
return nil
|
193
|
+
end
|
194
|
+
|
195
|
+
def info(keyw, options = {})
|
196
|
+
options = DEFAULT_INFO_OPTIONS.merge(options)
|
164
197
|
return nil if keyw.strip.empty?
|
165
198
|
descriptor = NameDescriptor.new(keyw)
|
166
|
-
entries = obtain_entries(descriptor,
|
199
|
+
entries = obtain_entries(descriptor, options)
|
167
200
|
|
168
201
|
case entries.size
|
169
202
|
when 0; nil
|
170
203
|
when 1
|
171
204
|
case entries[0].type
|
172
205
|
when :namespace
|
173
|
-
capture_stdout(display(
|
206
|
+
capture_stdout(display(options)) do |display|
|
174
207
|
display.display_class_info(@ri_reader.get_class(entries[0]), @ri_reader)
|
175
208
|
end
|
176
209
|
when :method
|
177
|
-
capture_stdout(display(
|
210
|
+
capture_stdout(display(options)) do |display|
|
178
211
|
display.display_method_info(@ri_reader.get_method(entries[0]))
|
179
212
|
end
|
180
213
|
end
|
181
214
|
else
|
182
|
-
capture_stdout(display(
|
215
|
+
capture_stdout(display(options)) do |display|
|
183
216
|
formatter = display.formatter
|
184
217
|
formatter.draw_line("Multiple choices:")
|
185
218
|
formatter.blankline
|
@@ -190,16 +223,17 @@ class RiService
|
|
190
223
|
return nil
|
191
224
|
end
|
192
225
|
|
193
|
-
def args(keyword,
|
226
|
+
def args(keyword, options = {})
|
227
|
+
options = DEFAULT_INFO_OPTIONS.merge(options)
|
194
228
|
return nil if keyword.strip.empty?
|
195
229
|
descriptor = NameDescriptor.new(keyword)
|
196
|
-
entries = obtain_entries(descriptor,
|
230
|
+
entries = obtain_entries(descriptor, options)
|
197
231
|
return nil if entries.empty? || RiIndex::ClassEntry === entries[0]
|
198
232
|
|
199
233
|
params_text = ""
|
200
234
|
entries.each do |entry|
|
201
235
|
desc = @ri_reader.get_method(entry)
|
202
|
-
params_text << capture_stdout(display(
|
236
|
+
params_text << capture_stdout(display(options)) do |display|
|
203
237
|
display.full_params(desc)
|
204
238
|
end
|
205
239
|
end
|
@@ -224,6 +258,86 @@ class RiService
|
|
224
258
|
|
225
259
|
private
|
226
260
|
|
261
|
+
def obtain_unqualified_method_entries(name, separators, order)
|
262
|
+
sep_re = "(" + separators.map{|x| Regexp.escape(x)}.join("|") + ")"
|
263
|
+
matcher = MatchFinder.new do |m|
|
264
|
+
m.add_matcher(:exact) do
|
265
|
+
m.yield @ri_reader.methods_under_matching("", /#{sep_re}#{name}$/, true)
|
266
|
+
end
|
267
|
+
m.add_matcher(:exact_ci) do
|
268
|
+
m.yield @ri_reader.methods_under_matching("", /#{sep_re}#{name}$/i, true)
|
269
|
+
end
|
270
|
+
m.add_matcher(:partial) do
|
271
|
+
m.yield @ri_reader.methods_under_matching("", /#{sep_re}#{name}/, true)
|
272
|
+
end
|
273
|
+
m.add_matcher(:partial_ci) do
|
274
|
+
m.yield @ri_reader.methods_under_matching("", /#{sep_re}#{name}/i, true)
|
275
|
+
end
|
276
|
+
end
|
277
|
+
matcher.get_matches(order)
|
278
|
+
end
|
279
|
+
|
280
|
+
def obtain_qualified_method_entries(namespace, method, separators, order)
|
281
|
+
matcher = MatchFinder.new do |m|
|
282
|
+
m.add_matcher(:exact) do
|
283
|
+
separators.each do |sep|
|
284
|
+
m.yield @ri_reader.get_method_entry("#{namespace}#{sep}#{method}")
|
285
|
+
end
|
286
|
+
end
|
287
|
+
sep_re = "(" + separators.map{|x| Regexp.escape(x)}.join("|") + ")"
|
288
|
+
m.add_matcher(:exact_ci) do
|
289
|
+
m.yield @ri_reader.methods_under_matching("", /^#{namespace}#{sep_re}#{method}$/i, true)
|
290
|
+
end
|
291
|
+
m.add_matcher(:nested) do
|
292
|
+
m.yield @ri_reader.methods_under_matching("", /::#{namespace}#{sep_re}#{method}$/, true)
|
293
|
+
end
|
294
|
+
m.add_matcher(:nested_ci) do
|
295
|
+
m.yield @ri_reader.methods_under_matching("", /::#{namespace}#{sep_re}#{method}$/i, true)
|
296
|
+
end
|
297
|
+
m.add_matcher(:partial) do
|
298
|
+
m.yield @ri_reader.methods_under_matching(namespace, /#{sep_re}#{method}/, false)
|
299
|
+
end
|
300
|
+
m.add_matcher(:partial_ci) do
|
301
|
+
m.yield @ri_reader.methods_under_matching("", /^#{namespace}#{sep_re}#{method}/i, true)
|
302
|
+
end
|
303
|
+
m.add_matcher(:nested_partial) do
|
304
|
+
m.yield @ri_reader.methods_under_matching("", /::#{namespace}#{sep_re}#{method}/, true)
|
305
|
+
end
|
306
|
+
m.add_matcher(:nested_partial_ci) do
|
307
|
+
m.yield @ri_reader.methods_under_matching("", /::#{namespace}#{sep_re}#{method}/i, true)
|
308
|
+
end
|
309
|
+
end
|
310
|
+
matcher.get_matches(order)
|
311
|
+
end
|
312
|
+
|
313
|
+
def obtain_namespace_entries(name, order)
|
314
|
+
matcher = MatchFinder.new do |m|
|
315
|
+
m.add_matcher(:exact){ m.yield @ri_reader.get_class_entry(name) }
|
316
|
+
m.add_matcher(:exact_ci) do
|
317
|
+
m.yield @ri_reader.namespaces_under_matching("", /^#{name}$/i, true)
|
318
|
+
end
|
319
|
+
m.add_matcher(:nested) do
|
320
|
+
m.yield @ri_reader.namespaces_under_matching("", /::#{name}$/, true)
|
321
|
+
end
|
322
|
+
m.add_matcher(:nested_ci) do
|
323
|
+
m.yield @ri_reader.namespaces_under_matching("", /::#{name}$/i, true)
|
324
|
+
end
|
325
|
+
m.add_matcher(:partial) do
|
326
|
+
m.yield @ri_reader.namespaces_under_matching("", /^#{name}/, true)
|
327
|
+
end
|
328
|
+
m.add_matcher(:partial_ci) do
|
329
|
+
m.yield @ri_reader.namespaces_under_matching("", /^#{name}/i, true)
|
330
|
+
end
|
331
|
+
m.add_matcher(:nested_partial) do
|
332
|
+
m.yield @ri_reader.namespaces_under_matching("", /::#{name}[^:]*$/, true)
|
333
|
+
end
|
334
|
+
m.add_matcher(:nested_partial_ci) do
|
335
|
+
m.yield @ri_reader.namespaces_under_matching("", /::#{name}[^:]*$/i, true)
|
336
|
+
end
|
337
|
+
end
|
338
|
+
matcher.get_matches(order)
|
339
|
+
end
|
340
|
+
|
227
341
|
def _class_list(keyword, rep)
|
228
342
|
return nil if keyword.strip.empty?
|
229
343
|
entries = @ri_reader.methods_under_matching("", /#{keyword}$/, true)
|
@@ -242,16 +356,22 @@ class RiService
|
|
242
356
|
when nil; [".","#"]
|
243
357
|
end
|
244
358
|
end
|
245
|
-
|
359
|
+
|
360
|
+
DEFAULT_DISPLAY_OPTIONS = {
|
361
|
+
:formatter => :ansi,
|
362
|
+
:width => 72,
|
363
|
+
}
|
364
|
+
def display(opt = {})
|
365
|
+
opt = DEFAULT_DISPLAY_OPTIONS.merge(opt)
|
246
366
|
options = Options.new
|
247
367
|
options.use_stdout = true
|
248
|
-
case
|
368
|
+
case opt[:formatter].to_sym
|
249
369
|
when :ansi
|
250
370
|
options.formatter = RedirectedAnsiFormatter
|
251
371
|
else
|
252
372
|
options.formatter = RedirectedTextFormatter
|
253
373
|
end
|
254
|
-
options.width =
|
374
|
+
options.width = opt[:width]
|
255
375
|
StringRedirectedDisplay.new(options)
|
256
376
|
end
|
257
377
|
|
data/lib/fastri/version.rb
CHANGED
data/pre-install.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Copyright (C) 2006 Mauricio Fernandez <mfp@acm.org>
|
2
|
+
#
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
6
|
+
$:.unshift "lib"
|
7
|
+
require 'fastri/name_descriptor'
|
8
|
+
|
9
|
+
class TestNameDescriptor < Test::Unit::TestCase
|
10
|
+
include FastRI
|
11
|
+
def helper(text)
|
12
|
+
desc = NameDescriptor.new(text)
|
13
|
+
[desc.class_names, desc.method_name, desc.is_class_method]
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_unqualified_methods
|
17
|
+
assert_equal([[], "foo", nil], helper("foo"))
|
18
|
+
assert_equal([[], "foo", false], helper("#foo"))
|
19
|
+
assert_equal([[], "foo", nil], helper(".foo"))
|
20
|
+
assert_equal([[], "foo", true], helper("::foo"))
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_qualified_methods
|
24
|
+
assert_equal([["Foo"], "bar", nil], helper("foo.bar"))
|
25
|
+
assert_equal([["Foo"], "bar", true], helper("foo::bar"))
|
26
|
+
assert_equal([["Foo"], "bar", false], helper("foo#bar"))
|
27
|
+
assert_equal([["Foo", "Bar"], "baz", true], helper("foo::bar::baz"))
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_namespaces
|
31
|
+
assert_equal([["Foo"], nil, nil], helper("Foo"))
|
32
|
+
assert_equal([["Foo", "Bar"], nil, nil], helper("foo::Bar"))
|
33
|
+
assert_equal([["Foo", "Bar", "Baz"], nil, nil], helper("Foo::Bar::Baz"))
|
34
|
+
end
|
35
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: fastri
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2006-11-
|
6
|
+
version: 0.1.1.1
|
7
|
+
date: 2006-11-10 00:00:00 +01:00
|
8
8
|
summary: RI docs across machines, faster and smarter than ri.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -60,6 +60,8 @@ files:
|
|
60
60
|
- lib/fastri/ri_index.rb
|
61
61
|
- lib/fastri/ri_service.rb
|
62
62
|
- lib/fastri/version.rb
|
63
|
+
- lib/fastri/name_descriptor.rb
|
64
|
+
- CHANGES
|
63
65
|
- COPYING
|
64
66
|
- LEGAL
|
65
67
|
- LICENSE
|
@@ -67,10 +69,13 @@ files:
|
|
67
69
|
- README.en
|
68
70
|
- test/test_ri_index.rb
|
69
71
|
- test/test_functional_ri_service.rb
|
72
|
+
- test/test_name_descriptor.rb
|
70
73
|
- setup.rb
|
74
|
+
- pre-install.rb
|
71
75
|
test_files:
|
72
76
|
- test/test_ri_index.rb
|
73
77
|
- test/test_functional_ri_service.rb
|
78
|
+
- test/test_name_descriptor.rb
|
74
79
|
rdoc_options:
|
75
80
|
- --title
|
76
81
|
- "FastRI: better, faster ri"
|