Module: QAT::CLI

Extended by:
LittlePlugger
Defined in:
lib/qat/cli.rb,
lib/qat/cli/plugins/web.rb

Overview

CLI module from QAT::Web.

Since:

  • 6.1.0

Defined Under Namespace

Modules: Plugins

Class Method Summary collapse

Class Method Details

.add_module(mod, stdout, opts) ⇒ Object

Call add_module in a given plugin.

Parameters:

  • mod (String, Symbol)

    name of the plugin to call

  • stdout (IO)

    stdout stream

  • opts (Hash)

    options hash

Raises:

  • ArgumentError When module does not exist

Since:

  • 6.1.0



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

Parameters:

  • mod (String, Symbol)

    name of the plugin to call

Returns:

  • (true, false)

    true if the plugin exists

Since:

  • 6.1.0



48
49
50
# File 'lib/qat/cli.rb', line 48

def self.has_module? mod
  return plugins.has_key? mod.to_sym
end

.list_extentionsObject

Lists all registered extentions/plugins

Since:

  • 6.1.0



17
18
19
# File 'lib/qat/cli.rb', line 17

def self.list_extentions
  plugins.keys.map(&:to_s).sort
end