Sha256: e28debd3e0beea72d9a8f878fccb4a50906bfa9d12f6348141c47c83810bdabb

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

Dir[File.join(File.dirname(__FILE__), "irb_hacks/**/*.rb")].each {|fn| require fn}

# Yet another set of IRB hacks.
#
# Summary of features brought to IRB:
#
# * <tt>a</tt> and <tt>ae</tt> methods to invoke or edit code snippets.
# * <tt>less</tt> method to interactively dump data with OS pager program (e.g. <tt>less</tt>).
# * IrbHacks::break to instantly return value from code into IRB.
module IrbHacks   #:doc:
  # Break execution, instantly return a value if caller is invoked from a snippet.
  #
  #   def myfunc
  #     puts "Reading name..."
  #     name = File.read(...)
  #     IrbHacks.break name     # Pass what's been read back to console.
  #
  #     ...
  #   end
  #
  #   irb> ae
  #   snippet>> myfunc
  #   irb> a
  #   Reading name...
  #   => "John Smith"
  def self.break(value = nil)
    raise BreakException.new(:value => value)
  end

  # Access configuration object. See IrbHacks::Config.
  #
  #   IrbHacks.conf
  #   IrbHacks.conf.snippet_history_size = 200
  def self.conf
    @conf ||= Config.new
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
irb_hacks-0.2.5 lib/irb_hacks.rb
irb_hacks-0.2.4 lib/irb_hacks.rb