Sha256: 463fc048de366bf6b3a841fa032f9169f426e09a93aaff75aaec1981cb892c10

Contents?: true

Size: 1.66 KB

Versions: 4

Compression:

Stored size: 1.66 KB

Contents

# -*- coding: utf-8 -*-
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
require 'rubygems'; require 'require_relative'
require_relative '../base/subcmd'

class Trepan::Subcommand::InfoRuby < Trepan::Subcommand
  unless defined?(HELP)
    Trepanning::Subcommand.set_name_prefix(__FILE__, self)
    HELP         = <<-EOH
#{CMD} [-v|--verbose|-no-verbose]

Show Ruby version information such as you'd get from 
"rbx -v" (which is really just the value of RUBY_RELEASE_DATE),
or from "rbx -vv". 

See also constants: RUBY_DESCRIPITON, RUBY_VERSION, and RUBY_RELEASE_DATE."
    EOH
    MIN_ABBREV   = 'ru'.size
    NEED_STACK   = false
    MIN_ARGS     = 0
    MAX_ARGS     = 0
    SHORT_HELP   = 'Ruby version information'
   end

  def parse_options(args) # :nodoc
    options = {}
    parser = OptionParser.new do |opts|
      opts.on("-v", 
              "--[no-]verbose", "show additional version information") do
        |v| 
        options[:verbose] = v
      end
    end
    parser.parse(args)
    return options
  end

  def run(args)
    options = parse_options(args[2..-1])
    msg RUBY_DESCRIPTION
    if options[:verbose]
      msg "Options:"
      msg "  Interpreter type: #{Rubinius::INTERPRETER}"
      if jit = Rubinius::JIT
        msg "  JIT enabled: #{jit.join(', ')}"
      else
        msg "  JIT disabled"
      end
    end
  end

end

if __FILE__ == $0
  # Demo it.
  $0 = __FILE__ + 'notagain' # So we don't run this again
  require_relative '../../mock'
  cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoRuby, false)
  cmd.run(cmd.prefix)
  %w(-v --verbose --no-verbose).each do |opt|
    puts '-' * 10 + " #{opt}"
    cmd.run(cmd.prefix + [opt])
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rbx-trepanning-0.2.1-universal-rubinius-2.0 processor/command/info_subcmd/ruby.rb
rbx-trepanning-0.2.1-universal-rubinius-1.2 processor/command/info_subcmd/ruby.rb
rbx-trepanning-0.2.0-universal-rubinius-2.0 processor/command/info_subcmd/ruby.rb
rbx-trepanning-0.1.0-universal-rubinius-1.2 processor/command/info_subcmd/ruby.rb