Class: Plugin
- Inherits:
-
Object
- Object
- Plugin
- Defined in:
- lib/loaded_plugins/plugin.rb
Overview
An instance of Plugin is created for each plugin loaded by Rails, and stored in the Rails.plugins list
Instance Attribute Summary collapse
-
#name ⇒ Object
The name of this plugin.
-
#root ⇒ Object
The directory in which this plugin is located.
Class Method Summary collapse
-
.name_for(path) ⇒ Object
Gets the name of the plugin, given the path to it.
Instance Method Summary collapse
-
#==(other_obj) ⇒ Object
:nodoc:.
-
#after_initialize ⇒ Object
Invoked during the Rails::Initializer#after_initialize callback.
-
#after_load ⇒ Object
Invoked immediately after
Rails::Initializerloads the plugin. -
#before_load ⇒ Object
Invoked immediately before
Rails::Initializerloads the plugin. -
#initialize(root) ⇒ Plugin
constructor
:nodoc:.
-
#lib_path ⇒ Object
The path to the plugin’s lib folder.
-
#lib_path? ⇒ Boolean
Does the plugin’s lib path exist?.
-
#plugins_after ⇒ Object
Gets all of the plugins that were loaded after this one.
-
#plugins_before ⇒ Object
Gets all of the plugins that were loaded before this one.
Constructor Details
Instance Attribute Details
#name ⇒ Object
The name of this plugin
5 6 7 |
# File 'lib/loaded_plugins/plugin.rb', line 5 def name @name end |
#root ⇒ Object
The directory in which this plugin is located
8 9 10 |
# File 'lib/loaded_plugins/plugin.rb', line 8 def root @root end |
Class Method Details
.name_for(path) ⇒ Object
Gets the name of the plugin, given the path to it. The following would return “plugin_xyz”:
-
plugin_xyz
-
plugin_xyz-1.2
-
plugin_xyz-1.2.0
-
plugin_xyz-1.2.0-win32
17 18 19 20 |
# File 'lib/loaded_plugins/plugin.rb', line 17 def name_for(path) name = File.basename(path) /^(.+)-#{Gem::Version::NUM_RE}(-.+)?$/.match(name) && $1 || name end |
Instance Method Details
#==(other_obj) ⇒ Object
:nodoc:
70 71 72 73 74 75 76 |
# File 'lib/loaded_plugins/plugin.rb', line 70 def ==(other_obj) #:nodoc: if other_obj.is_a?(Plugin) other_obj.name == name else other_obj.to_s == name end end |
#after_initialize ⇒ Object
Invoked during the Rails::Initializer#after_initialize callback
67 68 |
# File 'lib/loaded_plugins/plugin.rb', line 67 def after_initialize end |
#after_load ⇒ Object
Invoked immediately after Rails::Initializer loads the plugin
63 64 |
# File 'lib/loaded_plugins/plugin.rb', line 63 def after_load end |
#before_load ⇒ Object
Invoked immediately before Rails::Initializer loads the plugin
59 60 |
# File 'lib/loaded_plugins/plugin.rb', line 59 def before_load end |
#lib_path ⇒ Object
The path to the plugin’s lib folder
31 32 33 |
# File 'lib/loaded_plugins/plugin.rb', line 31 def lib_path "#{root}/lib" end |
#lib_path? ⇒ Boolean
Does the plugin’s lib path exist?
36 37 38 |
# File 'lib/loaded_plugins/plugin.rb', line 36 def lib_path? File.exists?(lib_path) end |