r112592 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112591‎ | r112592 | r112593 >
Date:13:21, 28 February 2012
Author:gwicke
Status:deferred
Tags:
Comment:
Implement onlyinclude transformer. 254 tests passing.
Modified paths:
  • /trunk/extensions/VisualEditor/tests/parser/dumpGrepper.js (modified) (history)
  • /trunk/extensions/VisualEditor/tests/parser/parserTests.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js
@@ -334,7 +334,8 @@
335335 ParserTests.prototype.normalizeOut = function ( out ) {
336336 // TODO: Do not strip newlines in pre and nowiki blocks!
337337 return out.replace(/[\r\n]| data-mw-[a-zA-Z-]+="[^">]*"/g, '')
338 - .replace(/<!--.*?-->\n?/gm, '');
 338+ .replace(/<!--.*?-->\n?/gm, '')
 339+ .replace(/<\/?meta[^>]*>/g, '');
339340 };
340341
341342 ParserTests.prototype.formatHTML = function ( source ) {
Index: trunk/extensions/VisualEditor/tests/parser/dumpGrepper.js
@@ -1,6 +1,7 @@
22 var dumpReader = require('./dumpReader.js'),
33 events = require('events'),
4 - optimist = require('optimist');
 4+ optimist = require('optimist'),
 5+ colors = require('colors');
56
67 function DumpGrepper ( regexp ) {
78 // inherit from EventEmitter
@@ -16,7 +17,7 @@
1718 if ( bits.length > 1 ) {
1819 this.emit( 'match', revision, bits );
1920 }
20 -}
 21+};
2122
2223 module.exports.DumpGrepper = DumpGrepper;
2324
@@ -34,14 +35,20 @@
3536 flags += 'i';
3637 }
3738
 39+ var re = new RegExp( '(' + argv._[0] + ')', flags );
 40+
3841 var reader = new dumpReader.DumpReader(),
39 - grepper = new DumpGrepper( new RegExp( '(' + argv._[0] + ')', flags ) );
 42+ grepper = new DumpGrepper( re );
4043
4144 reader.on( 'revision', grepper.grepRev.bind( grepper ) );
4245 grepper.on( 'match', function ( revision, bits ) {
43 - console
44 - console.log( 'Match:' + revision.page.title )
45 - console.log( bits.map( function ( s ) { return s.substr(0, 40) } ) );
 46+ console.log( 'Match:' + revision.page.title );
 47+ for ( var i = 0, l = bits.length; i < l-1; i++ ) {
 48+ var m = bits[i+1].match( re )[0];
 49+ console.log( 'm: ' + m );
 50+ console.log( bits[i].substr(-40) + m.green + bits[i+1].substr( m.length, 40 ) );
 51+ }
 52+ //console.log( bits.map( function ( s ) { return s.substr(0, 40) } ) );
4653 } );
4754 process.stdin.setEncoding('utf8');
4855 process.stdin.on('data', reader.push.bind(reader) );

Follow-up revisions

RevisionCommit summaryAuthorDate
r112593Actually commit onlyinclude, as already announced in r112592.gwicke13:24, 28 February 2012
r112594Finish color highlighting for dump grepper / fix broken commit r112592.gwicke13:48, 28 February 2012

Status & tagging log