<commit_before>'use strict';
var _ = require( 'lodash' );
var Q = require( 'q' );

/**
 *
 * @param base
 * @returns {{getInstalled: getInstalled}}
 * @api public
 */
function Extension ( base ) {

	/**
	 * Return all installed extensions.
	 *
	 * **Example defining a filter:**
	 *
	 * **Default filter:**
	 * var defaultFilter = {
	 * 	visualization: true,
	 * 	visualizationTemplate: false,
	 * 	mashup: false,
	 * 	mashupTemplate: false
	 * }
	 *
	 * @param filter
	 * @api public
	 */
	var getInstalled = function ( filter ) {
		return base.get( '/qrs/extension/schema' );
	};

	//var getInstalledVisExtensons = function () {
	//
	//};

	/**
	 * Same as `getInstalled` but with filter �isMashupTemplate: true`
	 */
	//var getInstalledMashups = function (  ) {
	//
	//};

	//var isInstalled = function (  ) {
	//
	//};

	//var del = function (  ) {
	//
	//};

	//var upload = function (  ) {
	//
	//};

	return {
		//del: del,
		getInstalled: getInstalled
		//isInstalled: isInstalled,
		//upload: upload
	};

	//  getInstalled: function ( filter ) {
	//
	//    var defaultFilter = {
	//      isVisualizationTemplate: false,
	//      isMashupTemplate: false,
	//      isVisualization: true
	//    };
	//    defaultFilter = extend( defaultFilter, filter );
	//
	//    var defer = Q.defer();
	//
	//    this.query( 'extension/schema' )
	//      .then( function ( data ) {
	//        defer.resolve( filterExtensions( data, defaultFilter ) );
	//      } )
	//      .catch( function ( data ) {
	//        defer.reject( data );
	//      } );
	//
	//    return defer.promise;
	//  },
	//  _filterExtensions: function ( data, filter ) {
	//    var filteredList = [];
	//    _.each( data, function ( item ) {
	//      //console.log( 'item', item );
	//      if ( filter.isVisualizationTemplate && item.type === 'visualization-template' ) {
	//        filteredList.push( item );
	//      }
	//      if ( filter.isMashupTemplate && item.type === 'mashup-template' ) {
	//        filteredList.push( item );
	//      }
	//      if ( filter.isVisualization && item.type === 'visualization' ) {
	//        filteredList.push( item );
	//      }
	//    } );
	//    return filteredList;
	//  }
	//
	//}

}

module.exports = Extension;<commit_msg>Basic skeleton for ep-extension.<commit_after>'use strict';
var _ = require( 'lodash' );
var Q = require( 'q' );

/**
 * Extension plugin.
 *
 * @param {qrs} base - Base class, instance of `qrs`.
 * @api public
 */
function Extension ( base ) {

	// Borrowed from http://stackoverflow.com/questions/17251764/lodash-filter-collection-using-array-of-values
	_.mixin( {
		'findByValues': function ( collection, property, values ) {
			return _.filter( collection, function ( item ) {
				return _.contains( values, item[property] );
			} );
		}
	} );

	var defaultFilter = [
		'visualization',
		'visualization-template',
		'mashup',
		'mashup-template'
	];

	/**
	 * Return all installed extensions. Optionally pass in a filter, to get only returned those extensions matching the given filter.
	 *
	 * @param {String[]} [filter] - Optional. Filter installed extensions by `type`. Example: filter = `['visualization', 'visualization-type']` will only return visualization extensions and visualization extension templates.
	 * @returns {promise}
	 * @api public
	 */
	 this.getInstalled = function ( filter ) {
		var defer = Q.defer();
		base.get( '/qrs/extension/schema' ).then( function ( data ) {

			if ( filter ) {
				defer.resolve(_.findByValues( data, 'type', filter ));
			} else
			{
				defer.resolve( _.findByValues( data, 'type', defaultFilter));
			}

		}, function ( err ) {
			defer.reject( err );
		} );

		return defer.promise;
	};

	/**
	 * Same as getInstalled but only returns visualization extensions (type `visualization`).
	 * @returns {promise}
	 * @api public
	 */
	this.getInstalledVis = function (  ) {
		return this.getInstalled( ['visualization'] );
	};

	/**
	 * Same as `getInstalled` but only returns extensions of type `visualization-template`, which are the templates for the Extension editor in Dev Hub.
	 * @returns {promise}
	 * @api public
	 */
	this.getInstalledVisTemplates = function () {
		return this.getInstalled(['visualization-template']);
	};

	/**
	 * Same as `getInstalled` but only returns extensions of type `mashup`.
	 * @returns {promise}
	 * @api public
	 */
	this.getInstalledMashups = function () {
		return this.getInstalled(['mashup']);
	};

	/**
	 * Same as `getInstalled` but only returns extensions of type `mashup`.
	 * @returns {promise}
	 * @api public
	 */
	this.getInstalledMashupTemplates = function () {
		return this.getInstalled(['mashup-template']);
	};

	/**
	 * Deletes an extension.
	 * @param {String} name - Name of the extension.
	 */
	this.delete = function ( name ) {

	};

	/**
	 * Uploads an extension.
	 * @param zipFilePath
	 */
	var upload = function ( zipFilePath ) {

	};

	/**
	 * Returns whether an extension is installed or not.
	 * @param name
	 */
	var isInstalled = function ( name ) {

		var defer = Q.defer();

		var retVal =  {
			isInstalled: false,
			name: name,
			info: {}
		};
		defer.resolve( retVal );
		return defer.promise;
	};
}

module.exports = Extension;
{'fraction_non_alphanumeric': 0.15928351309707242, 'fraction_numerical': 0.0015408320493066256, 'mean_word_length': 2.6493323963457485, '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': '4300650', 'n_tokens_mistral': 1821, 'n_tokens_neox': 1656, 'n_words': 411}