Sha256: f7d8ac2da49a2c334b7728d2d1f8f2a9a1a57871e7b45be7071eabe4dbf3534e

Contents?: true

Size: 1.68 KB

Versions: 2

Compression:

Stored size: 1.68 KB

Contents

#! /usr/bin/env ruby

Main {

  option('--root', '-r'){
    argument :required
  }

  mode(:console){
    def run
      if params['root'].given? 
        Ro.root = params['root'].value 
      end

      basename = File.basename(Ro.root) 

      ARGV.clear
      require 'irb'

      Kernel.module_eval do
        def reload!
          Object.send(:remove_const, :Ro)
          load "#{ $libdir }/ro.rb" 
          "#{ $libdir }/ro.rb" 
        end
      end

      $HACK = IRB.method(:load_modules)

      def IRB.load_modules
        $HACK.call()

        basename = File.basename(Ro.root)

        IRB.conf[:PROMPT][:RO] = {
          :PROMPT_I=>"Ro(./#{ basename }):%03n:%i> ",
          :PROMPT_N=>"Ro(./#{ basename }):%03n:%i> ",
          :PROMPT_S=>"Ro(./#{ basename }):%03n:%i%l ",
          :PROMPT_C=>"Ro(./#{ basename }):%03n:%i* ",
          :RETURN=>"=> %s\n"
        }

        IRB.conf[:PROMPT_MODE] = :RO
        IRB.conf[:AUTO_INDENT] = true
      end


      ::IRB.start
    end

=begin
    module Console
      def reload!
        Object.send(:remove_const, :Ro)
        load "#{ $libdir }/ro.rb" 
        "#{ $libdir }/ro.rb" 
      end
    end
=end

    class Console < Ro::BlankSlate
      def initialize(nodes)
        @nodes = nodes
      end

      def binding
        Kernel.binding
      end

      def reload!
        Object.send(:remove_const, :Ro)
        load "#{ $libdir }/ro.rb" 
        "#{ $libdir }/ro.rb" 
      end

      def method_missing(method, *args, &block)
        @nodes.send(method, *args, &block)
      end
    end
  }

}

BEGIN {
  require 'main'

  $bindir = File.dirname(__FILE__)
  $libdir = File.expand_path("#{ $bindir }/../lib/")

  require "#{ $libdir }/ro.rb" 
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ro-1.1.1 bin/ro
ro-1.1.0 bin/ro