Sha256: 31c669d48509f5dc85eacbdb1003708caa117cded5a28ed8cee447c8be2b260b

Contents?: true

Size: 949 Bytes

Versions: 18

Compression:

Stored size: 949 Bytes

Contents

require 'singleton'

module Kontena
  class PluginManager
    include Singleton

    attr_reader :plugins

    def initialize
      @plugins = []
    end

    # @return [Array<Gem::Specification>]
    def load_plugins
      Gem::Specification.to_a.each do |spec|
        spec.require_paths.to_a.each do |require_path|
          plugin = File.join(spec.gem_dir, require_path, 'kontena_cli_plugin.rb')
          if File.exist?(plugin) && !@plugins.find{ |p| p.name == spec.name }
            begin
              load(plugin)
              @plugins << spec
            rescue LoadError => exc
              STDERR.puts "failed to load plugin: #{spec.name}"
              if ENV['DEBUG']
                STDERR.puts exc.message
                STDERR.puts exc.backtrace.join("\n")
              end
              exit 1
            end
          end
        end
      end
      @plugins
    rescue => exc
      STDERR.puts exc.message
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
kontena-cli-0.16.0.pre6 lib/kontena/plugin_manager.rb
kontena-cli-0.15.5 lib/kontena/plugin_manager.rb
kontena-cli-0.15.5.rc2 lib/kontena/plugin_manager.rb
kontena-cli-0.15.5.rc1 lib/kontena/plugin_manager.rb
kontena-cli-0.16.0.pre5 lib/kontena/plugin_manager.rb
kontena-cli-0.16.0.pre4 lib/kontena/plugin_manager.rb
kontena-cli-0.16.0.pre3 lib/kontena/plugin_manager.rb
kontena-cli-0.16.0.pre2 lib/kontena/plugin_manager.rb
kontena-cli-0.16.0.pre1 lib/kontena/plugin_manager.rb
kontena-cli-0.15.4 lib/kontena/plugin_manager.rb
kontena-cli-0.15.4.rc2 lib/kontena/plugin_manager.rb
kontena-cli-0.15.4.rc1 lib/kontena/plugin_manager.rb
kontena-cli-0.15.4.pre1 lib/kontena/plugin_manager.rb
kontena-cli-0.15.3 lib/kontena/plugin_manager.rb
kontena-cli-0.15.2 lib/kontena/plugin_manager.rb
kontena-cli-0.15.1 lib/kontena/plugin_manager.rb
kontena-cli-0.15.0 lib/kontena/plugin_manager.rb
kontena-cli-0.15.0.rc3 lib/kontena/plugin_manager.rb