class Kitchen::Command::Console

Command to launch a Pry-based Kitchen console..

@author Fletcher Nichol <fnichol@nichol.ca>

Public Instance Methods

call() click to toggle source

Invoke the command.

# File lib/kitchen/command/console.rb, line 27
def call
  require "pry"
  Pry.start(@config, prompt: [prompt(">"), prompt("*")])
rescue LoadError
  warn %{Make sure you have the pry gem installed. You can install it with:}
  warn %{`gem install pry` or including 'gem "pry"' in your Gemfile.}
  exit 1
end

Private Instance Methods

prompt(char) click to toggle source

Construct a custom Pry prompt proc.

@param char [String] prompt character @return [proc] a prompt proc @api private

# File lib/kitchen/command/console.rb, line 43
def prompt(char)
  proc do |target_self, nest_level, pry|
    [
      "[#{pry.input_ring.size}] ",
      "kc(#{Pry.view_clip(target_self.class)})",
      "#{":#{nest_level}" unless nest_level == 0}#{char} ",
    ].join
  end
end