Module: QAT::CLI
- Extended by:
- LittlePlugger
- Defined in:
- lib/qat/cli.rb,
lib/qat/cli/generator.rb,
lib/qat/cli/plugins/core.rb
Overview
Module for CLI functions
Defined Under Namespace
Modules: Generator, Plugins Classes: Main
Class Method Summary collapse
-
.add_module(mod, stdout, opts) ⇒ Object
Call add_module in a given plugin.
-
.has_module?(mod) ⇒ true, false
Check if a plugin exists.
-
.list_extentions ⇒ Object
Lists all registered extentions/plugins.
Class Method Details
.add_module(mod, stdout, opts) ⇒ Object
Call add_module in a given plugin.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/qat/cli.rb', line 27 def self.add_module mod, stdout, opts raise ArgumentError.new "Module #{mod} is not a plugin!" unless has_module? mod loaded_mod = plugins[mod.to_sym] if loaded_mod.respond_to? :add_module meth = loaded_mod.method :add_module unless meth.arity == 2 || meth.arity < 0 raise ArgumentError.new "Invalid implementation of add_module in #{mod}: should have 2 parameters: stdout, opts" end meth.call stdout, opts else stdout.puts "Nothing to add in #{mod}" end end |
.has_module?(mod) ⇒ true, false
Check if a plugin exists
48 49 50 |
# File 'lib/qat/cli.rb', line 48 def self.has_module? mod return plugins.has_key? mod.to_sym end |
.list_extentions ⇒ Object
Lists all registered extentions/plugins
17 18 19 |
# File 'lib/qat/cli.rb', line 17 def self.list_extentions plugins.keys.map(&:to_s).sort end |