Class: FeduxOrgStdlib::GemPlugins::Plugin
- Inherits:
-
Object
- Object
- FeduxOrgStdlib::GemPlugins::Plugin
- Includes:
- Comparable
- Defined in:
- lib/fedux_org_stdlib/gem_plugins/plugin.rb
Overview
Plugin
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#homepage ⇒ Object
readonly
Returns the value of attribute homepage.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#activate ⇒ Object
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.
-
#active? ⇒ Boolean
Is plugin active?.
-
#blank? ⇒ Boolean
Is an existing plugin.
-
#initialize(spec:) ⇒ Plugin
constructor
A new instance of Plugin.
-
#require_file ⇒ Object
Path of require file.
Constructor Details
#initialize(spec:) ⇒ Plugin
Returns a new instance of Plugin.
14 15 16 17 18 19 20 |
# File 'lib/fedux_org_stdlib/gem_plugins/plugin.rb', line 14 def initialize(spec:) @name = spec.name @author = Array(spec.).zip(Array(spec.email)).map { |a, e| format('%s (%s)', a, e) }.to_list @version = spec.version @homagepage = spec.homepage @active = false end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
12 13 14 |
# File 'lib/fedux_org_stdlib/gem_plugins/plugin.rb', line 12 def @author end |
#homepage ⇒ Object (readonly)
Returns the value of attribute homepage.
12 13 14 |
# File 'lib/fedux_org_stdlib/gem_plugins/plugin.rb', line 12 def homepage @homepage end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/fedux_org_stdlib/gem_plugins/plugin.rb', line 12 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
12 13 14 |
# File 'lib/fedux_org_stdlib/gem_plugins/plugin.rb', line 12 def version @version end |
Instance Method Details
#<=>(other) ⇒ Object
57 58 59 |
# File 'lib/fedux_org_stdlib/gem_plugins/plugin.rb', line 57 def <=>(other) name <=> other.name end |
#activate ⇒ Object
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.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fedux_org_stdlib/gem_plugins/plugin.rb', line 26 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 |
#active? ⇒ Boolean
Is plugin active?
42 43 44 |
# File 'lib/fedux_org_stdlib/gem_plugins/plugin.rb', line 42 def active? @active == true end |
#blank? ⇒ Boolean
Is an existing plugin
47 48 49 |
# File 'lib/fedux_org_stdlib/gem_plugins/plugin.rb', line 47 def blank? false end |
#require_file ⇒ Object
Path of require file
52 53 54 |
# File 'lib/fedux_org_stdlib/gem_plugins/plugin.rb', line 52 def require_file "#{name}.rb" end |