Sha256: 34030c2670d551f7faf19d64f89c53d7f015f675a01c6e28604ff89517ed4964

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

#!/usr/bin/env ruby
=begin legal crap
    rubylexer - a ruby lexer written in ruby
    Copyright (C) 2004,2005,2008, 2011  Caleb Clausen

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
=end

module DeleteWarns
FN='[^\n]+'
DATETIME='\d+-\d\d?-\d\d? \d\d:\d\d:\d\d\.\d+ -?\d+'
INDENTLINE='(?: [^\n]*\n)'

WARNERRREX='(?:Reading a token: )?-:(\d+): (warning|(?:syntax )?error)(?:: ([^\n]+))?'

RE=%r"(?#--- #{FN}	#{DATETIME}
\+\+\+ #{FN}	#{DATETIME}
)^@@ -\d+,\d+ \+\d+,\d+ @@
#{INDENTLINE}+\
-(?:Reading a token: )?-:(\d+): (warning|error): ([^\n]+)\n\
\+(?:Reading a token: )?-:(\d+): \2: \3
#{INDENTLINE}+"mo

RE2=%r"^@@ -\d+,\d+ \+\d+,\d+ @@
#{INDENTLINE}*\
\+#{WARNERRREX}\n\
#{INDENTLINE}*"mo

RE3=%r"^@@ -\d+,\d+ \+\d+,\d+ @@
#{INDENTLINE}+\
-(?:Reading a token: )?-:(\d+): (warning|error): ([^\n]+)\n\
#{INDENTLINE}+"mo

def DeleteWarns.deletewarns(input)
input.each('\n--- ') {|match|
   yield match.gsub(RE,"\\2 moved from \\1 to \\4: \\3\n")  \
              .gsub(RE2,"Created \\2(s) in new file, line \\1: \\3\n") \
              .gsub(RE3,"Removed \\2(s) from old file (?!), line \\1: \\3\n")
}
end
end

if __FILE__==$0
  DeleteWarns.deletewarns($stdin){|s| $stdout.print s}
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubylexer-0.8.0 test/code/deletewarns.rb