<commit_before>var http = require('http');
var logger = require('./logger');
var Client = require('node-rest-client').Client;

var publicBowerUrl = 'http://bower.herokuapp.com/packages/';

module.exports = function PublicPackageStore(config) {
    var _packages = {};
    var _config = config;

    _init();
    function _init() {
        logger.log('Refreshing public packages...');

        _loadPublicPackages();
    }

    function _getPackage(packageName) {
        return _packages[packageName];
    }

    function _loadPublicPackages() {

        var options;
        if (_config.proxySettings.enabled) {
            var options_proxy={
                    proxy:{
                        host:_config.proxySettings.host,
                        port:_config.proxySettings.port,
                        user:_config.proxySettings.username,
                        password:_<PASSWORD>,
                        tunnel:true
                    }
                },

                client = new Client(options_proxy);
        } else {
            client = new Client();
        }

        client.get(publicBowerUrl, function(data, response) {

            console.log('repsponse '+response)

            console.log('data ---');
            console.log(data);
            console.log('--- data');

            var body = '';

            response.on('data', function(chunk) {
                console.log('ddd' +chunk)
                body += chunk;
            });

            response.on('end', function() {
                processData(body);
            });
        }).on('error',function(err){
            console.log('something went wrong on the request', err.request.options);
        });

        client.on('error',function(err){
            console.error('Something went wrong on the client', err);
        });

        setTimeout(_loadPublicPackages, 1000 * 60 * 30);

        function processData(data) {
            if(data.indexOf('Not Found')!== -1) {
                return;
            }

            var jsonData = JSON.parse(data);

            for(var i = 0, len = jsonData.length; i < len; i++) {
                var item = jsonData[i];

                _packages[item.name] = item;
            }<commit_msg>processdata directly because json is parsed into data object by node-rest-client.<commit_after>var http = require('http');
var logger = require('./logger');
var Client = require('node-rest-client').Client;

var publicBowerUrl = 'http://bower.herokuapp.com/packages/';

module.exports = function PublicPackageStore(config) {
    var _packages = {};
    var _config = config;

    _init();
    function _init() {
        logger.log('Refreshing public packages...');

        _loadPublicPackages();
    }

    function _getPackage(packageName) {
        return _packages[packageName];
    }

    function _loadPublicPackages() {

        var options;
        if (_config.proxySettings.enabled) {
            var options_proxy={
                    proxy:{
                        host:_config.proxySettings.host,
                        port:_config.proxySettings.port,
                        user:_config.proxySettings.username,
                        password:_config.<PASSWORD>,
                        tunnel:true
                    }
                },

                client = new Client(options_proxy);
        } else {
            client = new Client();
        }

        client.get(publicBowerUrl, function(data, response) {
            processData(data);
        }).on('error',function(err){
            console.log('something went wrong on the request', err.request.options);
        });

        client.on('error',function(err){
            console.error('Something went wrong on the client', err);
        });

        setTimeout(_loadPublicPackages, 1000 * 60 * 30);

        function processData(data) {
            if(data.indexOf('Not Found')!== -1) {
                return;
            }

            var jsonData = JSON.parse(data);

            for(var i = 0, len = jsonData.length; i < len; i++) {
                var item = jsonData[i];

                _packages[item.name] = item;
            }
{'fraction_non_alphanumeric': 0.12108810784785749, 'fraction_numerical': 0.004814636494944632, 'mean_word_length': 1.6280834914611007, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '4794246', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1031, 'n_words': 222}