mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Restore access to 'directory' and 'config' inside the plugin eval environment
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2919 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
3c31062c3d
commit
fa0a5973db
1 changed files with 9 additions and 6 deletions
|
@ -284,21 +284,24 @@ module Rails
|
||||||
# Returns <tt>true</tt> if the plugin is successfully loaded or
|
# Returns <tt>true</tt> if the plugin is successfully loaded or
|
||||||
# <tt>false</tt> if it is already loaded (similar to Kernel#require).
|
# <tt>false</tt> if it is already loaded (similar to Kernel#require).
|
||||||
# Raises <tt>LoadError</tt> if the plugin is not found.
|
# Raises <tt>LoadError</tt> if the plugin is not found.
|
||||||
def load_plugin(path)
|
def load_plugin(directory)
|
||||||
name = File.basename(path)
|
name = File.basename(directory)
|
||||||
return false if loaded_plugins.include?(name)
|
return false if loaded_plugins.include?(directory)
|
||||||
|
|
||||||
# Catch nonexistent and empty plugins.
|
# Catch nonexistent and empty plugins.
|
||||||
raise LoadError, "No such plugin: #{path}" unless plugin_path?(path)
|
raise LoadError, "No such plugin: #{directory}" unless plugin_path?(directory)
|
||||||
|
|
||||||
lib_path = File.join(path, 'lib')
|
lib_path = File.join(directory, 'lib')
|
||||||
init_path = File.join(path, 'init.rb')
|
init_path = File.join(directory, 'init.rb')
|
||||||
has_lib = File.directory?(lib_path)
|
has_lib = File.directory?(lib_path)
|
||||||
has_init = File.file?(init_path)
|
has_init = File.file?(init_path)
|
||||||
|
|
||||||
# Add lib to load path.
|
# Add lib to load path.
|
||||||
$LOAD_PATH.unshift(lib_path) if has_lib
|
$LOAD_PATH.unshift(lib_path) if has_lib
|
||||||
|
|
||||||
|
# Allow plugins to reference the current configuration object
|
||||||
|
config = configuration
|
||||||
|
|
||||||
# Evaluate init.rb.
|
# Evaluate init.rb.
|
||||||
silence_warnings { eval(IO.read(init_path), binding) } if has_init
|
silence_warnings { eval(IO.read(init_path), binding) } if has_init
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue