-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
driver.rb
1572 lines (1176 loc) · 36.8 KB
/
driver.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# frozen_string_literal: true
require 'abbrev'
require 'optparse'
begin
require 'readline'
rescue LoadError
end
begin
require 'win32console'
rescue LoadError
end
require 'rdoc'
##
# For RubyGems backwards compatibility
require_relative 'formatter'
##
# The RI driver implements the command-line ri tool.
#
# The driver supports:
# * loading RI data from:
# * Ruby's standard library
# * RubyGems
# * ~/.rdoc
# * A user-supplied directory
# * Paging output (uses RI_PAGER environment variable, PAGER environment
# variable or the less, more and pager programs)
# * Interactive mode with tab-completion
# * Abbreviated names (ri Zl shows Zlib documentation)
# * Colorized output
# * Merging output from multiple RI data sources
class RDoc::RI::Driver
##
# Base Driver error class
class Error < RDoc::RI::Error; end
##
# Raised when a name isn't found in the ri data stores
class NotFoundError < Error
def initialize(klass, suggestions = nil) # :nodoc:
@klass = klass
@suggestions = suggestions
end
##
# Name that wasn't found
def name
@klass
end
def message # :nodoc:
str = "Nothing known about #{@klass}"
if @suggestions and !@suggestions.empty?
str += "\nDid you mean? #{@suggestions.join("\n ")}"
end
str
end
end
##
# Show all method documentation following a class or module
attr_accessor :show_all
##
# An RDoc::RI::Store for each entry in the RI path
attr_accessor :stores
##
# Controls the user of the pager vs $stdout
attr_accessor :use_stdout
##
# Default options for ri
def self.default_options
options = {}
options[:interactive] = false
options[:profile] = false
options[:show_all] = false
options[:use_stdout] = !$stdout.tty?
options[:width] = 72
# By default all standard paths are used.
options[:use_system] = true
options[:use_site] = true
options[:use_home] = true
options[:use_gems] = true
options[:extra_doc_dirs] = []
return options
end
##
# Dump +data_path+ using pp
def self.dump data_path
require 'pp'
File.open data_path, 'rb' do |io|
pp Marshal.load(io.read)
end
end
##
# Parses +argv+ and returns a Hash of options
def self.process_args argv
options = default_options
opts = OptionParser.new do |opt|
opt.accept File do |file,|
File.readable?(file) and not File.directory?(file) and file
end
opt.program_name = File.basename $0
opt.version = RDoc::VERSION
opt.release = nil
opt.summary_indent = ' ' * 4
opt.banner = <<-EOT
Usage: #{opt.program_name} [options] [name ...]
Where name can be:
Class | Module | Module::Class
Class::method | Class#method | Class.method | method
gem_name: | gem_name:README | gem_name:History
All class names may be abbreviated to their minimum unambiguous form.
If a name is ambiguous, all valid options will be listed.
A '.' matches either class or instance methods, while #method
matches only instance and ::method matches only class methods.
README and other files may be displayed by prefixing them with the gem name
they're contained in. If the gem name is followed by a ':' all files in the
gem will be shown. The file name extension may be omitted where it is
unambiguous.
For example:
#{opt.program_name} Fil
#{opt.program_name} File
#{opt.program_name} File.new
#{opt.program_name} zip
#{opt.program_name} rdoc:README
Note that shell quoting or escaping may be required for method names
containing punctuation:
#{opt.program_name} 'Array.[]'
#{opt.program_name} compact\\!
To see the default directories #{opt.program_name} will search, run:
#{opt.program_name} --list-doc-dirs
Specifying the --system, --site, --home, --gems, or --doc-dir options
will limit ri to searching only the specified directories.
ri options may be set in the RI environment variable.
The ri pager can be set with the RI_PAGER environment variable
or the PAGER environment variable.
EOT
opt.separator nil
opt.separator "Options:"
opt.separator nil
opt.on("--[no-]interactive", "-i",
"In interactive mode you can repeatedly",
"look up methods with autocomplete.") do |interactive|
options[:interactive] = interactive
end
opt.separator nil
opt.on("--[no-]all", "-a",
"Show all documentation for a class or",
"module.") do |show_all|
options[:show_all] = show_all
end
opt.separator nil
opt.on("--[no-]list", "-l",
"List classes ri knows about.") do |list|
options[:list] = list
end
opt.separator nil
opt.on("--[no-]pager",
"Send output to a pager,",
"rather than directly to stdout.") do |use_pager|
options[:use_stdout] = !use_pager
end
opt.separator nil
opt.on("-T",
"Synonym for --no-pager.") do
options[:use_stdout] = true
end
opt.separator nil
opt.on("--width=WIDTH", "-w", OptionParser::DecimalInteger,
"Set the width of the output.") do |width|
options[:width] = width
end
opt.separator nil
opt.on("--server[=PORT]", Integer,
"Run RDoc server on the given port.",
"The default port is 8214.") do |port|
options[:server] = port || 8214
end
opt.separator nil
formatters = RDoc::Markup.constants.grep(/^To[A-Z][a-z]+$/).sort
formatters = formatters.sort.map do |formatter|
formatter.to_s.sub('To', '').downcase
end
formatters -= %w[html label test] # remove useless output formats
opt.on("--format=NAME", "-f",
"Use the selected formatter. The default",
"formatter is bs for paged output and ansi",
"otherwise. Valid formatters are:",
"#{formatters.join(', ')}.", formatters) do |value|
options[:formatter] = RDoc::Markup.const_get "To#{value.capitalize}"
end
opt.separator nil
opt.on("--help", "-h",
"Show help and exit.") do
puts opts
exit
end
opt.separator nil
opt.on("--version", "-v",
"Output version information and exit.") do
puts "#{opts.program_name} #{opts.version}"
exit
end
opt.separator nil
opt.separator "Data source options:"
opt.separator nil
opt.on("--[no-]list-doc-dirs",
"List the directories from which ri will",
"source documentation on stdout and exit.") do |list_doc_dirs|
options[:list_doc_dirs] = list_doc_dirs
end
opt.separator nil
opt.on("--doc-dir=DIRNAME", "-d", Array,
"List of directories from which to source",
"documentation in addition to the standard",
"directories. May be repeated.") do |value|
value.each do |dir|
unless File.directory? dir then
raise OptionParser::InvalidArgument, "#{dir} is not a directory"
end
options[:extra_doc_dirs] << File.expand_path(dir)
end
end
opt.separator nil
opt.on("--no-standard-docs",
"Do not include documentation from",
"the Ruby standard library, site_lib,",
"installed gems, or ~/.rdoc.",
"Use with --doc-dir.") do
options[:use_system] = false
options[:use_site] = false
options[:use_gems] = false
options[:use_home] = false
end
opt.separator nil
opt.on("--[no-]system",
"Include documentation from Ruby's",
"standard library. Defaults to true.") do |value|
options[:use_system] = value
end
opt.separator nil
opt.on("--[no-]site",
"Include documentation from libraries",
"installed in site_lib.",
"Defaults to true.") do |value|
options[:use_site] = value
end
opt.separator nil
opt.on("--[no-]gems",
"Include documentation from RubyGems.",
"Defaults to true.") do |value|
options[:use_gems] = value
end
opt.separator nil
opt.on("--[no-]home",
"Include documentation stored in ~/.rdoc.",
"Defaults to true.") do |value|
options[:use_home] = value
end
opt.separator nil
opt.separator "Debug options:"
opt.separator nil
opt.on("--[no-]profile",
"Run with the ruby profiler.") do |value|
options[:profile] = value
end
opt.separator nil
opt.on("--dump=CACHE", File,
"Dump data from an ri cache or data file.") do |value|
options[:dump_path] = value
end
end
argv = ENV['RI'].to_s.split(' ').concat argv
opts.parse! argv
options[:names] = argv
options[:use_stdout] ||= !$stdout.tty?
options[:use_stdout] ||= options[:interactive]
options[:width] ||= 72
options
rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
puts opts
puts
puts e
exit 1
end
##
# Runs the ri command line executable using +argv+
def self.run argv = ARGV
options = process_args argv
if options[:dump_path] then
dump options[:dump_path]
return
end
ri = new options
ri.run
end
##
# Creates a new driver using +initial_options+ from ::process_args
def initialize initial_options = {}
@paging = false
@classes = nil
options = self.class.default_options.update(initial_options)
@formatter_klass = options[:formatter]
require 'profile' if options[:profile]
@names = options[:names]
@list = options[:list]
@doc_dirs = []
@stores = []
RDoc::RI::Paths.each(options[:use_system], options[:use_site],
options[:use_home], options[:use_gems],
*options[:extra_doc_dirs]) do |path, type|
@doc_dirs << path
store = RDoc::RI::Store.new path, type
store.load_cache
@stores << store
end
@list_doc_dirs = options[:list_doc_dirs]
@interactive = options[:interactive]
@server = options[:server]
@use_stdout = options[:use_stdout]
@show_all = options[:show_all]
@width = options[:width]
# pager process for jruby
@jruby_pager_process = nil
end
##
# Adds paths for undocumented classes +also_in+ to +out+
def add_also_in out, also_in
return if also_in.empty?
out << RDoc::Markup::Rule.new(1)
out << RDoc::Markup::Paragraph.new("Also found in:")
paths = RDoc::Markup::Verbatim.new
also_in.each do |store|
paths.parts.push store.friendly_path, "\n"
end
out << paths
end
##
# Adds a class header to +out+ for class +name+ which is described in
# +classes+.
def add_class out, name, classes
heading = if classes.all? { |klass| klass.module? } then
name
else
superclass = classes.map do |klass|
klass.superclass unless klass.module?
end.compact.shift || 'Object'
superclass = superclass.full_name unless String === superclass
"#{name} < #{superclass}"
end
out << RDoc::Markup::Heading.new(1, heading)
out << RDoc::Markup::BlankLine.new
end
##
# Adds "(from ...)" to +out+ for +store+
def add_from out, store
out << RDoc::Markup::Paragraph.new("(from #{store.friendly_path})")
end
##
# Adds +extends+ to +out+
def add_extends out, extends
add_extension_modules out, 'Extended by', extends
end
##
# Adds a list of +extensions+ to this module of the given +type+ to +out+.
# add_includes and add_extends call this, so you should use those directly.
def add_extension_modules out, type, extensions
return if extensions.empty?
out << RDoc::Markup::Rule.new(1)
out << RDoc::Markup::Heading.new(1, "#{type}:")
extensions.each do |modules, store|
if modules.length == 1 then
add_extension_modules_single out, store, modules.first
else
add_extension_modules_multiple out, store, modules
end
end
end
##
# Renders multiple included +modules+ from +store+ to +out+.
def add_extension_modules_multiple out, store, modules # :nodoc:
out << RDoc::Markup::Paragraph.new("(from #{store.friendly_path})")
wout, with = modules.partition { |incl| incl.comment.empty? }
out << RDoc::Markup::BlankLine.new unless with.empty?
with.each do |incl|
out << RDoc::Markup::Paragraph.new(incl.name)
out << RDoc::Markup::BlankLine.new
out << incl.comment
end
unless wout.empty? then
verb = RDoc::Markup::Verbatim.new
wout.each do |incl|
verb.push incl.name, "\n"
end
out << verb
end
end
##
# Adds a single extension module +include+ from +store+ to +out+
def add_extension_modules_single out, store, include # :nodoc:
name = include.name
path = store.friendly_path
out << RDoc::Markup::Paragraph.new("#{name} (from #{path})")
if include.comment then
out << RDoc::Markup::BlankLine.new
out << include.comment
end
end
##
# Adds +includes+ to +out+
def add_includes out, includes
add_extension_modules out, 'Includes', includes
end
##
# Looks up the method +name+ and adds it to +out+
def add_method out, name
filtered = lookup_method name
method_out = method_document name, filtered
out.concat method_out.parts
end
##
# Adds documentation for all methods in +klass+ to +out+
def add_method_documentation out, klass
klass.method_list.each do |method|
begin
add_method out, method.full_name
rescue NotFoundError
next
end
end
end
##
# Adds a list of +methods+ to +out+ with a heading of +name+
def add_method_list out, methods, name
return if methods.empty?
out << RDoc::Markup::Heading.new(1, "#{name}:")
out << RDoc::Markup::BlankLine.new
if @use_stdout and !@interactive then
out.concat methods.map { |method|
RDoc::Markup::Verbatim.new method
}
else
out << RDoc::Markup::IndentedParagraph.new(2, methods.join(', '))
end
out << RDoc::Markup::BlankLine.new
end
##
# Returns ancestor classes of +klass+
def ancestors_of klass
ancestors = []
unexamined = [klass]
seen = []
loop do
break if unexamined.empty?
current = unexamined.shift
seen << current
stores = classes[current]
break unless stores and not stores.empty?
klasses = stores.map do |store|
store.ancestors[current]
end.flatten.uniq
klasses = klasses - seen
ancestors.concat klasses
unexamined.concat klasses
end
ancestors.reverse
end
##
# For RubyGems backwards compatibility
def class_cache # :nodoc:
end
##
# Builds a RDoc::Markup::Document from +found+, +klasess+ and +includes+
def class_document name, found, klasses, includes, extends
also_in = []
out = RDoc::Markup::Document.new
add_class out, name, klasses
add_includes out, includes
add_extends out, extends
found.each do |store, klass|
render_class out, store, klass, also_in
end
add_also_in out, also_in
out
end
##
# Adds the class +comment+ to +out+.
def class_document_comment out, comment # :nodoc:
unless comment.empty? then
out << RDoc::Markup::Rule.new(1)
if comment.merged? then
parts = comment.parts
parts = parts.zip [RDoc::Markup::BlankLine.new] * parts.length
parts.flatten!
parts.pop
out.concat parts
else
out << comment
end
end
end
##
# Adds the constants from +klass+ to the Document +out+.
def class_document_constants out, klass # :nodoc:
return if klass.constants.empty?
out << RDoc::Markup::Heading.new(1, "Constants:")
out << RDoc::Markup::BlankLine.new
list = RDoc::Markup::List.new :NOTE
constants = klass.constants.sort_by { |constant| constant.name }
list.items.concat constants.map { |constant|
parts = constant.comment.parts if constant.comment
parts << RDoc::Markup::Paragraph.new('[not documented]') if
parts.empty?
RDoc::Markup::ListItem.new(constant.name, *parts)
}
out << list
out << RDoc::Markup::BlankLine.new
end
##
# Hash mapping a known class or module to the stores it can be loaded from
def classes
return @classes if @classes
@classes = {}
@stores.each do |store|
store.cache[:modules].each do |mod|
# using default block causes searched-for modules to be added
@classes[mod] ||= []
@classes[mod] << store
end
end
@classes
end
##
# Returns the stores wherein +name+ is found along with the classes,
# extends and includes that match it
def classes_and_includes_and_extends_for name
klasses = []
extends = []
includes = []
found = @stores.map do |store|
begin
klass = store.load_class name
klasses << klass
extends << [klass.extends, store] if klass.extends
includes << [klass.includes, store] if klass.includes
[store, klass]
rescue RDoc::Store::MissingFileError
end
end.compact
extends.reject! do |modules,| modules.empty? end
includes.reject! do |modules,| modules.empty? end
[found, klasses, includes, extends]
end
##
# Completes +name+ based on the caches. For Readline
def complete name
completions = []
klass, selector, method = parse_name name
complete_klass name, klass, selector, method, completions
complete_method name, klass, selector, completions
completions.sort.uniq
end
def complete_klass name, klass, selector, method, completions # :nodoc:
klasses = classes.keys
# may need to include Foo when given Foo::
klass_name = method ? name : klass
if name !~ /#|\./ then
completions.replace klasses.grep(/^#{Regexp.escape klass_name}[^:]*$/)
completions.concat klasses.grep(/^#{Regexp.escape name}[^:]*$/) if
name =~ /::$/
completions << klass if classes.key? klass # to complete a method name
elsif selector then
completions << klass if classes.key? klass
elsif classes.key? klass_name then
completions << klass_name
end
end
def complete_method name, klass, selector, completions # :nodoc:
if completions.include? klass and name =~ /#|\.|::/ then
methods = list_methods_matching name
if not methods.empty? then
# remove Foo if given Foo:: and a method was found
completions.delete klass
elsif selector then
# replace Foo with Foo:: as given
completions.delete klass
completions << "#{klass}#{selector}"
end
completions.concat methods
end
end
##
# Converts +document+ to text and writes it to the pager
def display document
page do |io|
f = formatter(io)
f.width = @width if @width and f.respond_to?(:width)
text = document.accept f
io.write text
end
end
##
# Outputs formatted RI data for class +name+. Groups undocumented classes
def display_class name
return if name =~ /#|\./
found, klasses, includes, extends =
classes_and_includes_and_extends_for name
return if found.empty?
out = class_document name, found, klasses, includes, extends
display out
end
##
# Outputs formatted RI data for method +name+
def display_method name
out = RDoc::Markup::Document.new
add_method out, name
display out
end
##
# Outputs formatted RI data for the class or method +name+.
#
# Returns true if +name+ was found, false if it was not an alternative could
# be guessed, raises an error if +name+ couldn't be guessed.
def display_name name
if name =~ /\w:(\w|$)/ then
display_page name
return true
end
return true if display_class name
display_method name if name =~ /::|#|\./
true
rescue NotFoundError
matches = list_methods_matching name if name =~ /::|#|\./
matches = classes.keys.grep(/^#{Regexp.escape name}/) if matches.empty?
raise if matches.empty?
page do |io|
io.puts "#{name} not found, maybe you meant:"
io.puts
io.puts matches.sort.join("\n")
end
false
end
##
# Displays each name in +name+
def display_names names
names.each do |name|
name = expand_name name
display_name name
end
end
##
# Outputs formatted RI data for page +name+.
def display_page name
store_name, page_name = name.split ':', 2
store = @stores.find { |s| s.source == store_name }
return display_page_list store if page_name.empty?
pages = store.cache[:pages]
unless pages.include? page_name then
found_names = pages.select do |n|
n =~ /#{Regexp.escape page_name}\.[^.]+$/
end
if found_names.length.zero? then
return display_page_list store, pages
elsif found_names.length > 1 then
return display_page_list store, found_names, page_name
end
page_name = found_names.first
end
page = store.load_page page_name
display page.comment
end
##
# Outputs a formatted RI page list for the pages in +store+.
def display_page_list store, pages = store.cache[:pages], search = nil
out = RDoc::Markup::Document.new
title = if search then
"#{search} pages"
else
'Pages'
end
out << RDoc::Markup::Heading.new(1, "#{title} in #{store.friendly_path}")
out << RDoc::Markup::BlankLine.new
list = RDoc::Markup::List.new(:BULLET)
pages.each do |page|
list << RDoc::Markup::Paragraph.new(page)
end
out << list
display out
end
def check_did_you_mean # :nodoc:
if defined? DidYouMean::SpellChecker
true
else
begin
require 'did_you_mean'
if defined? DidYouMean::SpellChecker
true
else
false
end
rescue LoadError
false
end
end
end
##
# Expands abbreviated klass +klass+ into a fully-qualified class. "Zl::Da"
# will be expanded to Zlib::DataError.
def expand_class klass
class_names = classes.keys
ary = class_names.grep(Regexp.new("\\A#{klass.gsub(/(?=::|\z)/, '[^:]*')}\\z"))
if ary.length != 1 && ary.first != klass
if check_did_you_mean
suggestions = DidYouMean::SpellChecker.new(dictionary: class_names).correct(klass)
raise NotFoundError.new(klass, suggestions)
else
raise NotFoundError, klass
end
end
ary.first
end
##
# Expands the class portion of +name+ into a fully-qualified class. See
# #expand_class.
def expand_name name
klass, selector, method = parse_name name
return [selector, method].join if klass.empty?
case selector
when ':' then
[find_store(klass), selector, method]
else
[expand_class(klass), selector, method]
end.join
end
##
# Filters the methods in +found+ trying to find a match for +name+.
def filter_methods found, name
regexp = name_regexp name
filtered = found.find_all do |store, methods|
methods.any? { |method| method.full_name =~ regexp }
end
return filtered unless filtered.empty?
found
end