<commit_before>var url = require('url');
var librets = require('rets-client');

Object.defineProperties(module.exports,{
	connect: {
		value: function(source, callback){
            var uri = url.parse(source.uri);

            var client = librets.createConnection({
                host: uri.hostname,
                port: uri.port,
                protocol: uri.protocol,
                path: uri.path,
                user: source.auth.username,
                pass: <PASSWORD>,
                version: source.version || '1.7.2',
                agent: { user: source.auth.userAgentHeader, password: source.auth.userAgentPassword }
            });

            client.once('connection.success',function(client){
                // console.log( 'Connected to RETS as %s.', client.get( 'provider.name' ) );
                callback(null, client);
            });

            client.once('connection.error',function(error, client){
                // console.error( 'Connection failed: %s.', error.message );
                callback(error, null);
            });
		},
		enumerable: true
	},
	validate: {
		value: function(source, callback){
            this.connect(source, function(err, client){
            	if (!client) {
	                console.error( 'Connection failed: %s.', error.message );
	                callback(error, null);
            	}
            	else {
	                console.log( 'Connected to RETS as %s.', client.get( 'provider.name' ) );
	                callback(null, client);
            	}
            });
		},
		enumerable: true
	},
	getClassifications: {
		value: function(source, callback, client) {
			if (client) client.getClassifications( source.rets.resource, callback);
			else {
		        this.connect(source, function(error,client){
		            client.getClassifications( source.rets.resource, callback);
		        });
			}
		},
		enumerable: true<commit_msg>updates rets transport to use rets.js<commit_after>var url = require('url');
var rets = require('rets.js');

Object.defineProperties(module.exports,{
	connect: {
		value: function(source, callback){
            var uri = url.parse(source.uri);
			uri.auth = options.source.auth.username + ':' + options.source.auth.password;

		    var client = new rets({
		        url: uri,
		        version: options.source.version || 'RETS/1.7.2',
		        ua: {
		            name: options.source.auth.userAgentHeader,
		            pass: options.source.auth.userAgentPassword
		        }
		    });

			client.on('login',function(err, res){
				callback(err, client);
			}).login()
	        .on('error',function(){
	            console.trace( 'Connection failed: %s.', error.message );
	            callback(error, null);
	        });
		},
		enumerable: true
	},
	validate: {
		value: function(source, callback){
            this.connect(source, function(err, client){
            	if (!client) {
	                console.error( 'Connection failed: %s.', error.message );
	                callback(error, null);
            	}
            	else {
	                console.log( 'Connected to RETS as %s.', client.get( 'provider.name' ) );
	                callback(null, client);
            	}
            });
		},
		enumerable: true
	},
	getClassifications: {
		value: function(source, callback, client) {
			if (client) client.getClassifications( source.rets.resource, callback);
			else {
		        this.connect(source, function(error,client){
		            client.getClassifications( source.rets.resource, callback);
		        });
			}
		},
		enumerable: true
{'fraction_non_alphanumeric': 0.13503649635036497, 'fraction_numerical': 0.0016844469399213925, 'mean_word_length': 1.9252873563218391, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '7462175', 'n_tokens_mistral': 1064, 'n_tokens_neox': 957, 'n_words': 203}