Sha256: 135db4366f3c0b3613545ea143447fdcb2b8fd130bd598760008d7fcd0171286

Contents?: true

Size: 878 Bytes

Versions: 1

Compression:

Stored size: 878 Bytes

Contents

#!/usr/local/bin/ruby -ws

require 'pp'

begin
  require 'rubygems'
  require_gem 'ParseTree'
rescue LoadError
  require 'parse_tree'
end

def discover_new_classes_from
  old_classes = []
  ObjectSpace.each_object(Module) do |klass|
    old_classes << klass
  end

  yield

  new_classes = []
  ObjectSpace.each_object(Module) do |klass|
    new_classes << klass
  end

  new_classes - old_classes
  new_classes = [ eval($c) ] if defined? $c
end

$f = false unless defined? $f

new_classes = discover_new_classes_from do
  ARGV.unshift "-" if ARGV.empty?
  ARGV.each do |name|
    if name == "-" then
      code = $stdin.read
      code = "class Example; def example; #{code}; end; end" if $f
      eval code unless code.nil?
    else
      require name
    end
  end
end

result = ParseTree.new.parse_tree(*new_classes)
unless defined? $q then
  pp result
else
  p result
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ParseTree-1.3.5 bin/parse_tree_show