mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* lib/require_relative.rb: check require_relative call in eval.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									9a431fd58c
								
							
						
					
					
						commit
						125c0a0d93
					
				
					 2 changed files with 11 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,7 @@
 | 
			
		|||
Sat Feb 16 11:45:31 2008  Tanaka Akira  <akr@fsij.org>
 | 
			
		||||
 | 
			
		||||
	* lib/require_relative.rb: check require_relative call in eval.
 | 
			
		||||
 | 
			
		||||
Sat Feb 16 08:00:01 2008  NARUSE, Yui  <naruse@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* ruby.c (process_options): set default_external before loading
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,11 @@
 | 
			
		|||
def require_relative(relative_feature)
 | 
			
		||||
  /:/ =~ caller.first
 | 
			
		||||
  absolute_feature = File.expand_path(File.join(File.dirname($`), relative_feature))
 | 
			
		||||
  c = caller.first
 | 
			
		||||
  e = c.rindex(/:\d+:in /)
 | 
			
		||||
  file = $`
 | 
			
		||||
  if /\A\((.*)\)/ =~ file # eval, etc.
 | 
			
		||||
    raise LoadError, "require_relative is called in #{$1}"
 | 
			
		||||
  end
 | 
			
		||||
  absolute_feature = File.expand_path(File.join(File.dirname(file), relative_feature))
 | 
			
		||||
  require absolute_feature
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue