Skip to content

Commit

Permalink
Restore access to 'directory' and 'config' inside the plugin eval env…
Browse files Browse the repository at this point in the history
…ironment

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2919 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jamis committed Nov 7, 2005
1 parent 3c31062 commit fa0a597
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions railties/lib/initializer.rb
Expand Up @@ -284,20 +284,23 @@ def plugin_path?(path)
# Returns <tt>true</tt> if the plugin is successfully loaded or
# <tt>false</tt> if it is already loaded (similar to Kernel#require).
# Raises <tt>LoadError</tt> 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
Expand Down

0 comments on commit fa0a597

Please sign in to comment.