Class: Mactag::Indexer::Plugin
- Inherits:
-
Object
- Object
- Mactag::Indexer::Plugin
- Defined in:
- lib/mactag/indexer/plugin.rb
Overview
Tag plugins in Rails project.
Examples
Mactag do
# Index single plugin.
plugin 'whenever'
# Index multiple plugins.
plugins 'thinking-sphinx', 'formtastic'
# Index all plugins.
plugins
do
Constant Summary collapse
- PLUGIN_PATH =
%w(vendor plugins)
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #exist? ⇒ Boolean
-
#initialize(name) ⇒ Plugin
constructor
A new instance of Plugin.
- #path ⇒ Object
- #tag ⇒ Object
Constructor Details
#initialize(name) ⇒ Plugin
Returns a new instance of Plugin.
25 26 27 |
# File 'lib/mactag/indexer/plugin.rb', line 25 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
23 24 25 |
# File 'lib/mactag/indexer/plugin.rb', line 23 def name @name end |
Class Method Details
.all ⇒ Object
45 46 47 48 49 50 |
# File 'lib/mactag/indexer/plugin.rb', line 45 def self.all pattern = File.join(PLUGIN_PATH, '*') Dir.glob(pattern).map do |file| new(File.basename(file)) end end |
Instance Method Details
#exist? ⇒ Boolean
37 38 39 |
# File 'lib/mactag/indexer/plugin.rb', line 37 def exist? File.directory?(path) end |
#path ⇒ Object
41 42 43 |
# File 'lib/mactag/indexer/plugin.rb', line 41 def path File.join(PLUGIN_PATH, name) end |
#tag ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/mactag/indexer/plugin.rb', line 29 def tag if exist? File.join(PLUGIN_PATH, name, 'lib', '**', '*.rb') else raise PluginNotFoundError.new(self) end end |