Sha256: f40d2b8570a3427f41228c2da9ca17f0e8fc69821804c55ab6dcf7316e21e1ff

Contents?: true

Size: 905 Bytes

Versions: 14

Compression:

Stored size: 905 Bytes

Contents

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

require 'pp'
begin require 'rubygems' rescue LoadError end
require 'parse_tree'

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
  new_classes
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)

result = result[0][3][2][1][2..-1] if $f

unless defined? $q then
  pp result
else
  p result
end

Version data entries

14 entries across 12 versions & 2 rubygems

Version Path
ParseTree-1.6.4 bin/parse_tree_show
ParseTree-1.7.0 bin/parse_tree_show
ParseTree-1.6.3 bin/parse_tree_show
ParseTree-1.6.0 bin/parse_tree_show
ParseTree-1.6.2 bin/parse_tree_show
ParseTree-1.4.1 bin/parse_tree_show
ParseTree-1.6.1 bin/parse_tree_show
ParseTree-1.5.0 bin/parse_tree_show
ParseTree-1.7.1 bin/parse_tree_show
ParseTree-2.0.0 bin/parse_tree_show
rubyjs-0.7.0 vendor/ParseTree-1.7.1-patched/bin/parse_tree_show
rubyjs-0.7.0 vendor/ParseTree-1.7.1/bin/parse_tree_show
rubyjs-0.7.1 vendor/ParseTree-1.7.1/bin/parse_tree_show
rubyjs-0.7.1 vendor/ParseTree-1.7.1-patched/bin/parse_tree_show