class Pione::Util::Completion

Attributes

completion_command[R]
completion_exec[R]
name2[R]
name3[R]

Public Class Methods

compile(source, target) click to toggle source
# File lib/pione/util/completion.rb, line 4
def self.compile(source, target)
  context = self.new.context
  target.write(ERB.new(source.read, nil, "-").result(context))
end

Public Instance Methods

context() click to toggle source
# File lib/pione/util/completion.rb, line 20
def context
  binding
end
descendants(keys, cmd) click to toggle source
# File lib/pione/util/completion.rb, line 24
def descendants(keys, cmd)
  if cmd.subcommand.empty?
    [[keys, cmd]]
  else
    cmd.subcommand.inject([[keys, cmd]]) do |list, (key, child)|
      _keys = keys + [key]
      if child.subcommand.empty?
        list << [_keys, child]
      else
        list.concat(descendants(_keys, child))
      end
    end
  end
end
toplevel_commands(mod) click to toggle source
# File lib/pione/util/completion.rb, line 14
def toplevel_commands(mod)
  mod.constants.map{|c| mod.const_get(c)}.select do |c|
    c.is_a?(Class) and c < Command::BasicCommand and c.toplevel?
  end.map {|cmd| [cmd.scenario_name, cmd]}
end