Sha256: 78123187090bdef024aa4ff82c4e5c0381973e2738b251e92795e4b72be13489
Contents?: true
Size: 1.61 KB
Versions: 7
Compression:
Stored size: 1.61 KB
Contents
# encoding: utf-8 module FeduxOrgStdlib module GemPlugins class Plugin private attr_accessor :enabled, :active, :gem_name public attr_reader :name def initialize(name, gem_name:, enabled:) @name = name @gem_name = gem_name @enabled = enabled 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 StandardError => e warn "require '#{gem_name}' # Failed, saying: #{e}" end self.active = true self.enabled = true end # Is plugin active? def active? active == true end # Is plugin enabled? def enabled? enabled == true end # Is an existing plugin def blank? false end end end end
Version data entries
7 entries across 7 versions & 1 rubygems