Sha256: 869d0df4e077a7a11716a4b9b96928418989d2e37ba7e546f2cb980394ab5ed5
Contents?: true
Size: 1.38 KB
Versions: 3
Compression:
Stored size: 1.38 KB
Contents
# encoding: utf-8 module FeduxOrgStdlib module Plugins class Plugin attr_accessor :name, :gem_name, :enabled, :spec, :active def initialize(name, gem_name, spec, enabled) @name, @gem_name, @enabled, @spec = name, gem_name, enabled, spec end # Disable a plugin. (prevents plugin from being loaded, cannot # disable an already activated plugin) def disable! self.enabled = false end # Enable a plugin. (does not load it immediately but puts on # 'white list' to be loaded) def enable! self.enabled = true 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! begin if !active? begin require gem_name rescue LoadError require gem_name.gsub(/-/, '/') end end rescue LoadError => e warn "Found plugin #{gem_name}, but could not require '#{gem_name}' or '#{gem_name.gsub(/-/, '/')}'" warn e rescue => e warn "require '#{gem_name}' # Failed, saying: #{e}" end self.active = true self.enabled = true end alias active? active alias enabled? enabled end end end
Version data entries
3 entries across 3 versions & 1 rubygems