Module: FFWD::Plugin

Included in:
JsonLine, Log
Defined in:
lib/ffwd/plugin.rb,
lib/ffwd/plugin/log.rb

Defined Under Namespace

Modules: ClassMethods, JsonLine, Log Classes: Loaded, Setup

Class Method Summary collapse

Class Method Details

.categoryObject



107
108
109
# File 'lib/ffwd/plugin.rb', line 107

def self.category
  'plugin'
end

.discoveredObject



83
84
85
# File 'lib/ffwd/plugin.rb', line 83

def self.discovered
  @@discovered ||= {}
end

.included(mod) ⇒ Object



103
104
105
# File 'lib/ffwd/plugin.rb', line 103

def self.included mod
  mod.extend ClassMethods
end

.load_discovered(source) ⇒ Object



111
112
113
114
115
116
117
# File 'lib/ffwd/plugin.rb', line 111

def self.load_discovered source
  FFWD::Plugin.discovered.each do |name, options|
    FFWD::Plugin.loaded[name] = Loaded.new source, name, options
  end

  FFWD::Plugin.discovered.clear
end

.load_plugins(log, kind_name, config, kind) ⇒ Object



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/ffwd/plugin.rb', line 119

def self.load_plugins log, kind_name, config, kind
  result = []

  if config.nil?
    return result
  end

  config.each_with_index do |plugin_config, index|
    d = "#{kind_name} plugin ##{index}"

    if (name = plugin_config[:type]).nil?
      log.error "#{d}: Missing :type attribute for '#{kind_name}'"
    end

    if (plugin = FFWD::Plugin.loaded[name]).nil?
      log.error "#{d}: Not an available plugin '#{name}'"
      next
    end

    unless plugin.can?(kind)
      log.error "#{d}: Not an #{kind_name} plugin '#{name}'"
      next
    end

    result << Setup.new(name, plugin.get(kind), plugin_config)
  end

  return result
end

.loadedObject



87
88
89
# File 'lib/ffwd/plugin.rb', line 87

def self.loaded
  @@loaded ||= {}
end