Parent

ParseTreeGauntlet

Public Class Methods

new() click to toggle source
    # File lib/gauntlet_parsetree.rb, line 15
15:   def initialize
16:     super
17: 
18:     self.data = Hash.new { |h,k| h[k] = {} }
19:     old_data = load_yaml data_file
20:     self.data.merge! old_data
21:   end

Public Instance Methods

broke(name, file, msg) click to toggle source
    # File lib/gauntlet_parsetree.rb, line 52
52:   def broke name, file, msg
53:     warn "bad"
54:     self.data[name][file] = msg
55:     self.dirty = true
56:   end
diff_pp(o1, o2) click to toggle source
    # File lib/gauntlet_parsetree.rb, line 35
35:   def diff_pp o1, o2
36:     require 'pp'
37: 
38:     File.open("/tmp/a.#{$$}", "w") do |f|
39:       PP.pp o1, f
40:     end
41: 
42:     File.open("/tmp/b.#{$$}", "w") do |f|
43:       PP.pp o2, f
44:     end
45: 
46:     `diff -u /tmp/a.#{$$} /tmp/b.#{$$}`
47:   ensure
48:     File.unlink "/tmp/a.#{$$}" rescue nil
49:     File.unlink "/tmp/b.#{$$}" rescue nil
50:   end
process(path, name) click to toggle source
    # File lib/gauntlet_parsetree.rb, line 58
58:   def process path, name
59:     begin
60:       $stderr.print "  #{path}: "
61:       rp = RubyParser.new
62:       pt = ParseTree.new
63: 
64:       old_ruby = File.read(path)
65: 
66:       begin
67:         pt_sexp = pt.process old_ruby
68:       rescue SyntaxError => e
69:         warn "unparsable pt"
70:         self.data[name][path] = :unparsable_pt
71:         self.dirty = true
72:         return
73:       end
74: 
75:       begin
76:         rp_sexp = rp.process old_ruby
77:       rescue Racc::ParseError => e
78:         broke name, path, e.message
79:         return
80:       end
81: 
82:       if rp_sexp != pt_sexp then
83:         broke name, path, diff_pp(rp_sexp, pt_sexp)
84:         return
85:       end
86: 
87:       self.data[name][path] = true
88:       self.dirty = true
89: 
90:       warn "good"
91:     rescue Interrupt
92:       puts "User cancelled"
93:       exit 1
94:     rescue Exception => e
95:       broke name, path, "    UNKNOWN ERROR: #{e}: #{e.message.strip}"
96:     end
97:   end
run(name) click to toggle source
     # File lib/gauntlet_parsetree.rb, line 99
 99:   def run name
100:     warn name
101:     Dir["**/*.rb"].sort.each do |path|
102:       next if path =~ /gemspec.rb/ # HACK
103:       result = data[name][path]
104:       next if result == true || Symbol === result
105:       process path, name
106:     end
107: 
108:     if (self.data[name].empty? or
109:         self.data[name].values.all? { |v| v == true }) then
110:       warn "  ALL GOOD!"
111:       self.data[name] = true
112:       self.dirty = true
113:     end
114:   end
should_skip?(name) click to toggle source
    # File lib/gauntlet_parsetree.rb, line 23
23:   def should_skip? name
24:     if $f then
25:       if Hash === data[name] then
26:         ! data[name].empty?
27:       else
28:         data[name]
29:       end
30:     else
31:       data[name] == true # yes, == true on purpose
32:     end
33:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.