Sha256: 83cabe8b977fd68dfdce58abc59bb1158f34ad288a4b08214d598f056746f13e

Contents?: true

Size: 904 Bytes

Versions: 2

Compression:

Stored size: 904 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)
            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

2 entries across 2 versions & 1 rubygems

Version Path
kontena-cli-0.15.0.rc2 lib/kontena/plugin_manager.rb
kontena-cli-0.15.0.rc1 lib/kontena/plugin_manager.rb