Class: RubyParserGauntlet

### Home Classes Methods

### In Files

- lib/gauntlet_rubyparser.rb

### Parent

Gauntlet

### Methods

- ::new
- #broke
- #diff_pp
- #process
- #run
- #should_skip?

### Files

- Manifest.txt
- README.txt

### Class/Module Index

Quicksearch

- RubyParserStuff
- RubyParserStuff::Environment
- RubyParserStuff::Keyword
- RubyParserStuff::Keyword::KWtable
- RubyParserStuff::Ruby18Parser
- RubyParserStuff::Ruby19Parser
- RubyParserStuff::Ruby20Parser
- RubyParserStuff::RubyParser
- RubyParserStuff::RubyParser::SyntaxError
- RubyParserStuff::Sexp
- RubyParserStuff::StackState
- RubyParserStuff::String
- RPStringScanner
- Ruby18Parser
- Ruby19Parser
- Ruby20Parser
- RubyLexer
- RubyParserGauntlet

No matching classes.

# RubyParserGauntlet

### Public Class Methods

new() click to toggle source

    # File lib/gauntlet_rubyparser.rb, line 15
    def initialize
      super

      self.data = Hash.new { |h,k| h[k] = {} }
      old_data = load_yaml data_file
      self.data.merge! old_data
    end

### Public Instance Methods

broke(name, file, msg) click to toggle source

    # File lib/gauntlet_rubyparser.rb, line 49
    def broke name, file, msg
      warn "bad"
      self.data[name][file] = msg
      self.dirty = true
    end

diff_pp(o1, o2) click to toggle source

    # File lib/gauntlet_rubyparser.rb, line 35
    def diff_pp o1, o2
      require 'pp'

      Tempfile.new('ruby_parser_a') do |file_a|
        PP.pp o1, file_a

        Tempfile.new('ruby_parser_b') do |file_b|
          PP.pp o2, file_b

          `diff -u #{file_a.path} #{file_b.path}`
        end
      end
    end

process(path, name) click to toggle source

    # File lib/gauntlet_rubyparser.rb, line 55
    def process path, name
      begin
        $stderr.print "  #{path}: "
        rp = RubyParser.new
        r2r = Ruby2Ruby.new

        old_ruby = File.read(path)

        begin
          old_sexp = rp.process old_ruby
        rescue Racc::ParseError => e
          self.data[name][path] = :unparsable
          self.dirty = true
          return
        end

        new_ruby = r2r.process old_sexp.deep_clone

        begin
          new_sexp = rp.process new_ruby
        rescue Racc::ParseError => e
          broke name, path, "couldn't parse new_ruby: #{e.message.strip}"
          return
        end

        if old_sexp != new_sexp then
          broke name, path, diff_pp(old_sexp, new_sexp)
          return
        end

        self.data[name][path] = true
        self.dirty = true

        warn "good"
      rescue Interrupt
        puts "User cancelled"
        exit 1
      rescue Exception => e
        broke name, path, "    UNKNOWN ERROR: #{e}: #{e.message.strip}"
      end
    end

run(name) click to toggle source

    # File lib/gauntlet_rubyparser.rb, line 97
    def run name
      warn name
      Dir["**/*.rb"].sort.each do |path|
        next if path =~ /gemspec.rb/ # HACK
        next if data[name][path] == true
        process path, name
      end

      if self.data[name].values.all? { |v| v == true } then
        warn "  ALL GOOD!"
        self.data[name] = true
        self.dirty = true
      end
    end

should_skip?(name) click to toggle source

    # File lib/gauntlet_rubyparser.rb, line 23
    def should_skip? name
      if $f then
        if Hash === data[name] then
          ! data[name].empty?
        else
          data[name]
        end
      else
        data[name] == true # yes, == true on purpose
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.