Class: TheDude::Plugin
- Inherits:
-
Object
- Object
- TheDude::Plugin
- Defined in:
- lib/the_dude/plugin.rb
Overview
Plugins can contain additional commands or integrate other tools into the dude
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
- String
-
The name of the plugin.
Class Method Summary collapse
-
.all ⇒ Object
Returns all the plugins that are installed.
Instance Method Summary collapse
- #gem_name ⇒ Object
-
#initialize(name) ⇒ Plugin
constructor
Intializes a new TheDude::Plugin instance.
Constructor Details
#initialize(name) ⇒ Plugin
Intializes a new TheDude::Plugin instance
9 10 11 |
# File 'lib/the_dude/plugin.rb', line 9 def initialize name @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
- String
-
The name of the plugin
6 7 8 |
# File 'lib/the_dude/plugin.rb', line 6 def name @name end |
Class Method Details
.all ⇒ Object
Returns all the plugins that are installed. This works by examining the installed gems. Any installed gem whose name begins with the_dude- is assumed to be a plugin for The Dude
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/the_dude/plugin.rb', line 21 def all begin Gem::Specification.latest_specs. # Get all the installed gems collect{|s| s.name}. # Collect the names grep(/the_dude\-/). # Filter for those beginning with the_dude- map{|s| TheDude::Plugin.new s[9..s.length]} # Trim off the prefix # and convert to Plugin instance rescue [] end end |
Instance Method Details
#gem_name ⇒ Object
13 14 15 |
# File 'lib/the_dude/plugin.rb', line 13 def gem_name @gem_name ||= "the_dude-#{name}" end |