Code coverage report for modules/get.js

Statements: 100% (23 / 23)      Branches: 100% (2 / 2)      Functions: 100% (7 / 7)      Lines: 100% (23 / 23)      Ignored: none     

All files » modules/ » get.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66            1 1 1 1 1 1   1   3   3   3 3 3     3   3   1       3   3     3         3         3         3               1   3      
/**
 * Created by armin on 10/21/14.
 */
 
'use strict';
 
var url = require('url');
var BPromise = require('bluebird');
var helpers = require('./helpers.js');
var css = require('./css');
var scripts = require('./scripttags.js');
var media = require('./media.js');
 
function getPage(urlArg) {
 
    console.log('getPage: Starting %s', urlArg);
 
    return new BPromise(function(resolve) {
 
        var urlObj = url.parse(urlArg);
        var baseUrl = urlObj.protocol + '//' + urlObj.host;
        console.log('Base URL: ' + baseUrl);
 
        // Determine the filename of the url.  If it is not in the path, assume index.html.
        var filename = urlObj.pathname.slice(urlObj.pathname.lastIndexOf('/') + 1);
 
        if (filename === '') {
 
            filename = 'index.html';
 
        }
 
        console.log(filename);
 
        helpers.getHTTP(urlArg)
            .then(function(response) {
 
                return css.inlineAllCSS(urlArg, response.body);
 
            })
            .then(function(html) {
 
                return scripts.inlineScripts(urlArg, html);
 
            })
            .then(function(html) {
 
                return media.processMedia(urlArg, html);
 
            })
            .then(function(html) {
 
                resolve({filename: filename, html: html });
 
            });
 
    });
 
}
 
exports.getPage = function(urlArg) {
 
    return getPage(urlArg);
 
};