Class: SSP::App

Inherits:
Thor
  • Object
show all
Extended by:
ThorExtensions
Defined in:
lib/ssp/app.rb

Defined Under Namespace

Classes: Bags, Chef, Domain, Node, OfficeNode, Pair, Remote

Instance Method Summary collapse

Methods included from ThorExtensions

banner

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object

If a task is not found on SSP::App, method missing is invoked and SSP::App is then responsable for finding the task in all classes.



36
37
38
39
40
41
42
# File 'lib/ssp/app.rb', line 36

def method_missing(meth, *args)
  meth = meth.to_s
  initialize_commands
  klass, task = Thor::Util.find_class_and_task_by_namespace(meth)
  args.unshift(task) if task
  klass.start(args, :shell => self.shell)
end

Instance Method Details

#help(meth = nil) ⇒ Object

Override Thor#help so it can give information about any class and any method.



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ssp/app.rb', line 19

def help(meth=nil)
  if meth && !self.respond_to?(meth)
    initialize_commands
    klass, task = Thor::Util.find_class_and_task_by_namespace(meth)
    if klass
      klass.start(["-h", task].compact, :shell => self.shell)
    else
      super
    end
  else
    super
  end
end

#list(search = "") ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ssp/app.rb', line 52

def list(search="")
  initialize_commands

  search = ".*#{search}" if options["substring"]
  search = /^#{search}.*/i
  group  = options[:group] || "standard"

  klasses = Thor::Base.subclasses.select do |k|
    (options[:all] || k.group == group) && k.namespace =~ search
  end

  display_klasses(klasses)
end

#versionObject



45
46
47
48
# File 'lib/ssp/app.rb', line 45

def version
  require 'ssp/version'
  say "SSP #{SSP::VERSION}"
end