<commit_before>var csv = require('csv');
var Bouteille = require('./bouteille').Bouteille;

var csvFormatOptions = { delimiter: ';', columns: true };

var OpenCellarImporter = function (cave) {
	this.cave = cave;
}

OpenCellarImporter.prototype.importCsv = function(csvFilePathOrString, callback) {
	csv()
		.from(csvFilePathOrString, csvFormatOptions)
		.on('record', this.importRow.bind(this))
		.on('end', callback);
};

OpenCellarImporter.prototype.importCsvString = function(content, callback) {
	csv()
		.from.string(content, csvFormatOptions)
		.on('record', this.importRow.bind(this))
		.on('end', callback);
};

OpenCellarImporter.prototype.importRow = function(row) {
	this.cave.ajouteBouteille(new Bouteille(row.Nom));
}

module.exports = OpenCellarImporter;<commit_msg>Refactoring de l'importer OpenCellar pour suppression de duplication<commit_after>var csv = require('csv');
var Bouteille = require('./bouteille').Bouteille;

var csvFormatOptions = { delimiter: ';', columns: true };

var OpenCellarImporter = function (cave) {
	this.cave = cave;
}

OpenCellarImporter.prototype.importCsv = function(csvFilePathOrString, callback) {
	this.csvParser(callback).from(csvFilePathOrString, csvFormatOptions);
};

OpenCellarImporter.prototype.importCsvString = function(content, callback) {
	this.csvParser(callback).from.string(content, csvFormatOptions);
};

OpenCellarImporter.prototype.csvParser = function(callback) {
	return csv()
		.on('record', this.importRow.bind(this))
		.on('end', callback);
}

OpenCellarImporter.prototype.importRow = function(row) {
	this.cave.ajouteBouteille(new Bouteille(row.Nom));
}

module.exports = OpenCellarImporter;
{'fraction_non_alphanumeric': 0.1413108839446783, 'fraction_numerical': 0.0, 'mean_word_length': 6.529411764705882, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2940550', 'n_tokens_mistral': 568, 'n_tokens_neox': 545, 'n_words': 90}