Class: GridCLI::Plugins
Instance Method Summary collapse
- #default_config ⇒ Object
- #include! ⇒ Object
-
#initialize ⇒ Plugins
constructor
A new instance of Plugins.
- #install(name) ⇒ Object
- #uninstall(name) ⇒ Object
Methods inherited from YMLHash
Constructor Details
#initialize ⇒ Plugins
Returns a new instance of Plugins.
6 7 8 |
# File 'lib/gridcli/plugins.rb', line 6 def initialize super "plugins" end |
Instance Method Details
#default_config ⇒ Object
10 11 12 13 14 15 |
# File 'lib/gridcli/plugins.rb', line 10 def default_config { 'enabled' => [], 'disabled' => [] } end |
#include! ⇒ Object
38 39 40 41 42 |
# File 'lib/gridcli/plugins.rb', line 38 def include! fetch('enabled', []).each { |m| require m } end |
#install(name) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gridcli/plugins.rb', line 17 def install(name) name = "grid-plugin-#{name}" unless name.start_with?("grid-plugin-") Process.fork { Gem::GemRunner.new.run ["install", name, "--no-rdoc", "--no-ri"]; puts "done" } Process.wait if Gem::Specification.find_all_by_name(name).length == 0 puts "There was an issue installing the plugin." elsif not fetch('enabled', []).include? name self['enabled'] << name save end end |
#uninstall(name) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/gridcli/plugins.rb', line 30 def uninstall(name) name = "grid-plugin-#{name}" unless name.start_with?("grid-plugin-") return unless fetch('enabled', []).include? name self['enabled'].delete(name) save Gem::GemRunner.new.run ["uninstall", name] end |