Ruby on grml

Ruby is a dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.

Software

The following Debian packages are shipped with grml out-of-the-box:

  • dpkg-ruby: ruby interface for dpkg
  • irb: Interactive Ruby
  • rake: a ruby build program
  • rdoc: Generate documentation from ruby source files
  • ruby1.8-examples: Examples for Ruby 1.8
  • ruby-prof: A fast code profiler for Ruby
  • vim-ruby: Vi IMproved - enhanced vi editor - with Ruby support

Not shipped with grml but interesting Debian packages/software anyway:

  • rails: MVC ruby based framework geared for web application development
  • ri: Ruby Interactive reference (ri)
  • ruby-full: Ruby full installation
  • ruby-pkg-tools: Tools for building Debian Ruby packages
  • ruby1.9-examples: Examples for Ruby 1.9
  • rubybook: the “Programming Ruby” book
  • rubygems: package management framework for Ruby libraries/applications

Programming Ruby with Vim

See ':help if_ruby' in vim-ruby and vim-ruby.rubyforge.org.

Using irb

irb is an Interactive Ruby shell, tune its configuration via ~/.irbrc. The following configuration file it the one shipped with grml by default:

# we want to be able to use tab-completion in irb:
require 'irb/completion'
ARGV.concat [ "--readline", "--prompt-mode", "simple" ]

# we want to get a history file of our session:
module Readline
  module History
    LOG = "#{ENV['HOME']}/.irb-history"

    def self.write_log(line)
      File.open(LOG, 'ab') {|f| f << "#{line}\n"}
    end

    def self.start_session_log
      write_log("\n# session start: #{Time.now}\n\n")
      at_exit { write_log("\n# session stop: #{Time.now}\n") }
    end
  end

  alias :old_readline :readline
  def readline(*args)
    ln = old_readline(*args)
    begin
      History.write_log(ln)
    rescue
    end
    ln
  end
end

Readline::History.start_session_log

# simple prompt?
# IRB.conf[:PROMPT_MODE] = :SIMPLE

# prompt for easy copy/paste? start with irb --prompt xmp
IRB.conf[:PROMPT][:XMP][:RETURN] = "\# => %s\n"

# copy/paste from manpage:
# IRB.conf[:IRB_NAME]="irb"
# IRB.conf[:MATH_MODE]=false
# IRB.conf[:USE_TRACER]=false
# IRB.conf[:USE_LOADER]=false
# IRB.conf[:IGNORE_SIGINT]=true
# IRB.conf[:IGNORE_EOF]=false
# IRB.conf[:INSPECT_MODE]=nil
# IRB.conf[:IRB_RC] = nil
# IRB.conf[:BACK_TRACE_LIMIT]=16
# IRB.conf[:USE_LOADER] = false
# IRB.conf[:USE_READLINE] = nil
# IRB.conf[:USE_TRACER] = false
# IRB.conf[:IGNORE_SIGINT] = true
# IRB.conf[:IGNORE_EOF] = false
# IRB.conf[:PROMPT_MODE] = :DEFALUT
# IRB.conf[:PROMPT] = {...}
# IRB.conf[:DEBUG_LEVEL]=0
# IRB.conf[:VERBOSE]=true

Ressources

english

german

 
ruby.txt · Last modified: 2011/10/13 23:55 (external edit)
 
Recent changes RSS feed Creative Commons License Valid XHTML 1.0 Valid CSS Grml homepage Driven by DokuWiki