1## 2# A file loaded by \#require 3 4class RDoc::Require < RDoc::CodeObject 5 6 ## 7 # Name of the required file 8 9 attr_accessor :name 10 11 ## 12 # Creates a new Require that loads +name+ with +comment+ 13 14 def initialize(name, comment) 15 super() 16 @name = name.gsub(/'|"/, "") #' 17 @top_level = nil 18 self.comment = comment 19 end 20 21 def inspect # :nodoc: 22 "#<%s:0x%x require '%s' in %s>" % [ 23 self.class, 24 object_id, 25 @name, 26 parent_file_name, 27 ] 28 end 29 30 def to_s # :nodoc: 31 "require #{name} in: #{parent}" 32 end 33 34 ## 35 # The RDoc::TopLevel corresponding to this require, or +nil+ if not found. 36 37 def top_level 38 @top_level ||= begin 39 tl = RDoc::TopLevel.all_files_hash[name + '.rb'] 40 41 if tl.nil? and RDoc::TopLevel.all_files.first.full_name =~ %r(^lib/) then 42 # second chance 43 tl = RDoc::TopLevel.all_files_hash['lib/' + name + '.rb'] 44 end 45 46 tl 47 end 48 end 49 50end 51 52