From fa0a5973dbc306651c4d7bb90020b9a92506a8bf Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Mon, 7 Nov 2005 14:01:56 +0000 Subject: [PATCH] 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 --- railties/lib/initializer.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index f0eceb0a4e..e412091d18 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -284,20 +284,23 @@ module Rails # Returns true if the plugin is successfully loaded or # false if it is already loaded (similar to Kernel#require). # Raises LoadError if the plugin is not found. - def load_plugin(path) - name = File.basename(path) - return false if loaded_plugins.include?(name) + def load_plugin(directory) + name = File.basename(directory) + return false if loaded_plugins.include?(directory) # 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') - init_path = File.join(path, 'init.rb') + lib_path = File.join(directory, 'lib') + init_path = File.join(directory, 'init.rb') has_lib = File.directory?(lib_path) has_init = File.file?(init_path) # Add lib to load path. $LOAD_PATH.unshift(lib_path) if has_lib + + # Allow plugins to reference the current configuration object + config = configuration # Evaluate init.rb. silence_warnings { eval(IO.read(init_path), binding) } if has_init