Class: Vop::PluginFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/vop/parts/plugin_finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePluginFinder

Returns a new instance of PluginFinder.



9
10
11
# File 'lib/vop/parts/plugin_finder.rb', line 9

def initialize
  reset
end

Instance Attribute Details

#pluginsObject (readonly)

Returns the value of attribute plugins.



7
8
9
# File 'lib/vop/parts/plugin_finder.rb', line 7

def plugins
  @plugins
end

#templatesObject (readonly)

Returns the value of attribute templates.



7
8
9
# File 'lib/vop/parts/plugin_finder.rb', line 7

def templates
  @templates
end

Instance Method Details

#find(paths) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/vop/parts/plugin_finder.rb', line 18

def find(paths)
  reset

  $logger.debug "scanning #{paths} for plugins..."
  paths = [ paths ] unless paths.is_a? Array

  if paths.size > 0
    paths.each do |path|
      begin
        next unless File.exists? path
      rescue => e
        if e.message =~ /Fixnum/
          $logger.warn "unexpected Fixnum path : #{path}"
        end
        raise e
      end


      @plugins += Dir.glob("#{path}/**/*.plugin").map { |x| Pathname.new(File.dirname(x)).realpath.to_s }
      @templates += Dir.glob("#{path}/**/plugin.vop").map { |x| Pathname.new(x).realpath.to_s }
    end
  end

  self
end

#resetObject



13
14
15
16
# File 'lib/vop/parts/plugin_finder.rb', line 13

def reset
  @plugins = []
  @templates = []
end