Class: Plugin

Inherits:
Object
  • Object
show all
Defined in:
lib/quartz_flow/plugin.rb

Overview

This class is used to load QuartzFlow plugins (loadAll), and represents a single plugin. Plugins contain:

- a links.rb file that defines menu links that show up on the main QuartzFlow page
- a routes.rb file that defines new Sinatra routes
- a views directory that contains new templates for use with the routes defined in routes.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(links, routesFile) ⇒ Plugin

Returns a new instance of Plugin.



22
23
24
25
# File 'lib/quartz_flow/plugin.rb', line 22

def initialize(links, routesFile)
  @links = links
  @routesFile = routesFile
end

Instance Attribute Details

Returns the value of attribute links.



27
28
29
# File 'lib/quartz_flow/plugin.rb', line 27

def links
  @links
end

#routesFileObject (readonly)

Returns the value of attribute routesFile.



28
29
30
# File 'lib/quartz_flow/plugin.rb', line 28

def routesFile
  @routesFile
end

Class Method Details

.loadAllObject

Load all plugins under plugins/ and return an array of the loaded Plugin objects.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/quartz_flow/plugin.rb', line 31

def self.loadAll
  plugins = []
  Dir.new("plugins").each do |e|
    next if e =~ /^\./
    path = "plugins" + File::SEPARATOR + e
    if File.directory?(path)
   
      puts "Loading plugin #{e}"
 
      links = loadPluginLinks(path)
      routesFile = path + File::SEPARATOR + "routes.rb"
      if ! File.exists?(routesFile)
        routesFile = nil 
        puts "  plugin has no routes.rb file"
      end

      plugins.push Plugin.new(links, routesFile)
    end
  end
  plugins
end