Sha256: 5f965e4fbff968952a4a2866c028d48537244391ecb0af71ce925178b9b11dce

Contents?: true

Size: 862 Bytes

Versions: 3

Compression:

Stored size: 862 Bytes

Contents

require 'forwardable'

##
# Delegates the following methods:
#
# * Commander::Runner#add_command
# * Commander::Runner#command
# * Commander::Runner#commands
# * Commander::Runner#program
# * Commander::UI::ProgressBar#progress
#

class Object
  
  extend Forwardable
  include Commander::UI
  
  def_delegators :$command_runner, :add_command, :command, :program, :run!, :commands
  def_delegators Commander::UI::ProgressBar, :progress

  ##
  # Return the current binding.
  
  def get_binding
    binding
  end

  ##
  # Return the current command runner.
  
  def command_runner
    $command_runner
  end
    
  ##
  # Implement #ask_for_CLASS.
  
  include Module.new {
    def method_missing meth, *args, &block
      case meth.to_s
      when /^ask_for_([\w]+)/ ; $terminal.ask(args.first, eval($1.capitalize))
      else super
      end
    end
  }

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
visionmedia-commander-3.0.0 lib/commander/core_ext/object.rb
visionmedia-commander-3.0.1 lib/commander/core_ext/object.rb
visionmedia-commander-3.0.2 lib/commander/core_ext/object.rb