Sha256: 6eb96fcee1273390a639565d1c473af190ce40b9531f71031bd995723967024c

Contents?: true

Size: 929 Bytes

Versions: 11

Compression:

Stored size: 929 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 Commander::UI::ProgressBar, :progress
  def_delegators :$command_runner, :add_command, :command, :program, :run!,
                 :commands, :alias_command, :default_command, :global_option

  ##
  # 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

11 entries across 11 versions & 1 rubygems

Version Path
visionmedia-commander-3.1.2 lib/commander/core_ext/object.rb
visionmedia-commander-3.1.4 lib/commander/core_ext/object.rb
visionmedia-commander-3.1.5 lib/commander/core_ext/object.rb
visionmedia-commander-3.1.6 lib/commander/core_ext/object.rb
visionmedia-commander-3.1.7 lib/commander/core_ext/object.rb
visionmedia-commander-3.1.8 lib/commander/core_ext/object.rb
visionmedia-commander-3.2.0 lib/commander/core_ext/object.rb
visionmedia-commander-3.2.2 lib/commander/core_ext/object.rb
visionmedia-commander-3.2.3 lib/commander/core_ext/object.rb
visionmedia-commander-3.2.4 lib/commander/core_ext/object.rb
visionmedia-commander-3.2.5 lib/commander/core_ext/object.rb