var through = require('through2');
var _ = require('lodash');
var gutil = require('gulp-util');

module.exports = function extractMepData(){
	var pipe = through.obj(function(file, enc, cb) {
		var lang = file.path.split('\\')[3];
		var data = JSON.parse(file.contents.toString());
		var filters = {};
		_.forEach(data,function(mep){
			var mepFile = new gutil.File({
				path: lang + '/mep/' + mep.id + '.json',
				contents: new Buffer(JSON.stringify(mep))
			})
			pipe.push(mepFile);
		})
		filters.country = uniqPluck(data,'country');
		filters.politicalGroup = uniqPluck(data,'politicalGroup')
		filters.nationalPoliticalGroup = uniqPluck(data,'nationalPoliticalGroup')
		var filtersFile = new gutil.File({
			path: lang +'/filter.json',
			contents: new Buffer(JSON.stringify(filters))
		})
		this.push(filtersFile)
		this.push(file)
    	cb();
    })

    return pipe;
}

function uniqPluck(data,key){
	var result = _.uniq(_.pluck(data,key));
	return result
}
@@ -184,16 +184,41 @@
 , cb) %7B%0A
+%09%09console.log(file.path)%0A
 %09%09var la

test wercker