Sha256: 771d18e362c9125c7a16c9bf31155e02961f0bcdfd632551945cd0809098b460

Contents?: true

Size: 896 Bytes

Versions: 2

Compression:

Stored size: 896 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, :alias_command, :default_command
  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

2 entries across 2 versions & 1 rubygems

Version Path
visionmedia-commander-3.1.0 lib/commander/core_ext/object.rb
visionmedia-commander-3.1.1 lib/commander/core_ext/object.rb