Class: Nib::Plugin
- Inherits:
-
Object
- Object
- Nib::Plugin
- Defined in:
- lib/nib/plugin.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #applies? ⇒ Boolean
- #basename ⇒ Object
- #binstub ⇒ Object
- #constant ⇒ Object
-
#initialize(path) ⇒ Plugin
constructor
A new instance of Plugin.
- #name ⇒ Object
Constructor Details
#initialize(path) ⇒ Plugin
Returns a new instance of Plugin.
4 5 6 |
# File 'lib/nib/plugin.rb', line 4 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
2 3 4 |
# File 'lib/nib/plugin.rb', line 2 def path @path end |
Instance Method Details
#applies? ⇒ Boolean
20 21 22 23 24 25 26 |
# File 'lib/nib/plugin.rb', line 20 def applies? @applies ||= begin require path constant.applies? end end |
#basename ⇒ Object
8 9 10 |
# File 'lib/nib/plugin.rb', line 8 def basename @basename ||= File.basename(path, '_plugin.rb') end |
#binstub ⇒ Object
28 29 30 |
# File 'lib/nib/plugin.rb', line 28 def binstub "#{path[0..-"/lib/#{basename}_plugin.rb".length]}bin/#{name}" end |
#constant ⇒ Object
16 17 18 |
# File 'lib/nib/plugin.rb', line 16 def constant @constant ||= Object.const_get(name.split('-').map(&:capitalize).join('::')) end |
#name ⇒ Object
12 13 14 |
# File 'lib/nib/plugin.rb', line 12 def name @name ||= basename.tr('_', '-') end |