Class: Mactag::Indexer::Plugin

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#nameObject

Returns the value of attribute name.



23
24
25
# File 'lib/mactag/indexer/plugin.rb', line 23

def name
  @name
end

Class Method Details

.allObject



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

Returns:

  • (Boolean)


37
38
39
# File 'lib/mactag/indexer/plugin.rb', line 37

def exist?
  File.directory?(path)
end

#pathObject



41
42
43
# File 'lib/mactag/indexer/plugin.rb', line 41

def path
  File.join(PLUGIN_PATH, name)
end

#tagObject



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