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
|
# File 'lib/print_members/librarian.rb', line 5
def libs opts={}
opts[:libs] ||= {}
path = opts[:path] || $LOAD_PATH
if path.is_a? Array
path.each {|lp| libs(opts.merge :path => lp) }
else
sub = opts[:sub_path] || ''
full = File.join(path, sub)
if File.exist? full
if File.directory? full
if opts[:depth].nil? || opts[:depth] > 0
Dir.new(full).
reject{|p| ['.','..'].include? File.basename(p) }.
each {|p| libs opts.merge :sub_path => File.join(sub,p),
:depth => (if opts[:depth]
then opts[:depth]-1
else nil end) }
end
elsif full =~ /\.rb$/
opts[:libs][sub.gsub(/^[\.\/]*|\.rb$/,'')] = full
end
end
end
return opts[:libs]
end
|