Class: TheDude::Plugin

Inherits:
Object
  • Object
show all
Defined in:
lib/the_dude/plugin.rb

Overview

Plugins can contain additional commands or integrate other tools into the dude

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#nameObject (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

.allObject

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_nameObject



13
14
15
# File 'lib/the_dude/plugin.rb', line 13

def gem_name
  @gem_name ||= "the_dude-#{name}"
end