tasks/generator/Scraper.js
function()
    {
        var url   = this.docsUrl;
        var _this = this;

        var d = Q.defer();

        // Need to create an array of promises for all the pages and their hash
        Q.nfcall(request, url + '/api-docs').then(function(data) {
            var $        = cheerio.load(data);
            var list     = $('ul.nav-list li a');
            var requests = [];

            list.each(function() {
                var href = $(this).attr('href');

                // If a service, get the promise for the scraped data and
                // notify when we've got it
                if (/service$/.test(href)) {
                    var p = _this.getServiceInterface(url + href);
                    p.then(function(s) { d.notify(s.serviceName); });
                    requests.push(p);
                }
            });

            // Spread out over all of the promises, when they're all done,
            // we've got the data in the arguments var, iterate over that and
            // build the hash to return
            Q.spread(requests, function() {
                d.resolve(_(arguments).toArray());
            });
        });

        return d.promise;
    }
function()
    {
        var url   = this.docsUrl;
        var _this = this;

        var d = Q.defer();

        // Need to create an array of promises for all the pages and their hash
        Q.nfcall(request, url + '/api-docs').then(function(data) {
            var $        = cheerio.load(data);
            var list     = $('ul.nav-list li a');
            var requests = [];

            list.each(function() {
                var href = $(this).attr('href');

                // If a service, get the promise for the scraped data and
                // notify when we've got it
                if (/service$/.test(href)) {
                    var p = _this.getServiceInterface(url + href);
                    p.then(function(s) { d.notify(s.serviceName); });
                    requests.push(p);
                }
            });

            // Spread out over all of the promises, when they're all done,
            // we've got the data in the arguments var, iterate over that and
            // build the hash to return
            Q.spread(requests, function() {
                d.resolve(_(arguments).toArray());
            });
        });

        return d.promise;
    }
function ( ) { var url = this . docsUrl ; var _this = this ; var d = Q . defer ( ) ; // Need to create an array of promises for all the pages and their hash Q . nfcall ( request , url + '/api-docs' ) . then ( function ( data ) { var $ = cheerio . load ( data ) ; var list = $ ( 'ul.nav-list li a' ) ; var requests = [ ] ; list . each ( function ( ) { var href = $ ( this ) . attr ( 'href' ) ; // If a service, get the promise for the scraped data and // notify when we've got it if ( / service$ / . test ( href ) ) { var p = _this . getServiceInterface ( url + href ) ; p . then ( function ( s ) { d . notify ( s . serviceName ) ; } ) ; requests . push ( p ) ; } } ) ; // Spread out over all of the promises, when they're all done, // we've got the data in the arguments var, iterate over that and // build the hash to return Q . spread ( requests , function ( ) { d . resolve ( _ ( arguments ) . toArray ( ) ) ; } ) ; } ) ; return d . promise ; }
Get a promise representing an eventua lhash for all the infusionsoft API service calls
Get a promise representing an eventua lhash for all the infusionsoft API service calls