Sha256: 210f79fe2d10740932352973c20e54854ae0e1d5c5a2663d2ce66d497a3ccc3b
Contents?: true
Size: 1.49 KB
Versions: 8
Compression:
Stored size: 1.49 KB
Contents
# encoding: utf-8 require 'fedux_org_stdlib/require_files' require 'fedux_org_stdlib/core_ext/array/list' require_library %w(active_support/core_ext/object/blank) module FeduxOrgStdlib module GemPlugins # Plugin class Plugin include Comparable attr_reader :name, :version, :author, :homepage def initialize(spec:) @name = spec.name @author = Array(spec.authors).zip(Array(spec.email)).map { |a, e| format( '%s (%s)', a, e) }.to_list @version = spec.version @homagepage = spec.homepage @active = false end # Activate the plugin (require the gem - enables/loads the # plugin immediately at point of call, even if plugin is # disabled) # Does not reload plugin if it's already active. def activate return if active? begin require name rescue LoadError => e warn "Found plugin \"#{name}\", but could not require \"#{require_file}\"" warn e rescue StandardError => e warn "Require plugin \"#{name}\" failed, saying: #{e}\n#{e.backtrace.join("\n")}" end @active = true end # Is plugin active? def active? @active == true end # Is an existing plugin def blank? false end # Path of require file def require_file "#{name}.rb" end # @private def <=>(other) name <=> other.name end end end end
Version data entries
8 entries across 8 versions & 1 rubygems