How to use comb - 10 common examples

To help you get started, we’ve selected a few comb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github C2FO / patio / test / runner.js View on Github external
*/

var COVERAGE_HEADER = string.format('\n %s \n', string.style("Test Coverage", "bold"));
var TABLE_SEP = string.format("+%--42s+%--11s+%--6s+%--7s+%--7s+", "-", "-", "-", "-", "-");
TABLE_SEP = comb.hitch(string, "format", TABLE_SEP + "\n%s\n" + TABLE_SEP)
var PRINT_FORMAT = comb.hitch(string, "format", "| %-40s | %9s | %4s | %5s | %6s|");
/**
 * Report test coverage in tabular format
 *
 * @param  {Object} cov
 */

var reportCoverage = process.argv[2];
reportCoverage = comb.isUndefined(reportCoverage) ? false : reportCoverage == 'true';
var showFileSource = process.argv[3];
showFileSource = comb.isUndefined(showFileSource) ? false : showFileSource == 'true';
var fileMatcher = /.js$/;

var printFile = function (file) {
    sys.error(PRINT_FORMAT(file.name, "" + file.coverage, "" + file.LOC, "" + file.SLOC, "" + file.totalMisses));
};

var printFileSource = function (file) {
    if (file.name == "dataset/sql.js" && file.coverage < 100) {
        sys.error(string.format('\n %s \n %s \n' + string.style(file.name, "bold"), file.source));
    }
}

function reportCoverageTable(cov) {
    // Stats
    var print = sys.error;
    print(COVERAGE_HEADER);
github C2FO / patio / test / runner.js View on Github external
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

var COVERAGE_HEADER = string.format('\n %s \n', string.style("Test Coverage", "bold"));
var TABLE_SEP = string.format("+%--42s+%--11s+%--6s+%--7s+%--7s+", "-", "-", "-", "-", "-");
TABLE_SEP = comb.hitch(string, "format", TABLE_SEP + "\n%s\n" + TABLE_SEP)
var PRINT_FORMAT = comb.hitch(string, "format", "| %-40s | %9s | %4s | %5s | %6s|");
/**
 * Report test coverage in tabular format
 *
 * @param  {Object} cov
 */

var reportCoverage = process.argv[2];
reportCoverage = comb.isUndefined(reportCoverage) ? false : reportCoverage == 'true';
var showFileSource = process.argv[3];
showFileSource = comb.isUndefined(showFileSource) ? false : showFileSource == 'true';
var fileMatcher = /.js$/;

var printFile = function (file) {
    sys.error(PRINT_FORMAT(file.name, "" + file.coverage, "" + file.LOC, "" + file.SLOC, "" + file.totalMisses));
};

var printFileSource = function (file) {
    if (file.name == "dataset/sql.js" && file.coverage < 100) {
        sys.error(string.format('\n %s \n %s \n' + string.style(file.name, "bold"), file.source));
    }
}

function reportCoverageTable(cov) {
    // Stats
github C2FO / patio / test / runner.js View on Github external
function populateCoverage(cov) {
    cov.LOC = cov.SLOC = cov.totalHits = cov.totalMisses = cov.coverage = 0;
    var files = [];
    for (var name in cov) {
        var file = cov[name];
        if (comb.isArray(file)) {
            // Stats
            files.push(file);
            delete cov[name];
            cov.totalHits += file.totalHits = coverage(file, true);
            cov.totalMisses += file.totalMisses = coverage(file, false);
            cov.SLOC += file.SLOC = file.totalHits + file.totalMisses;
            !file.source && (file.source = []);
            cov.LOC += file.LOC = file.source.length;
            file.coverage = ((file.totalHits / file.SLOC) * 100).toFixed(2);
            // Source
            file.name = name;
            if (file.coverage < 100) {
                var width = file.source.length.toString().length;
                file.source = file.source.map(
                    function (line, i) {
                        ++i;
github C2FO / patio / example / querying.example.js View on Github external
return DB.transaction(function () {
        var ret = new comb.Promise();
        User.forUpdate().first({id: 1}).chain(function (user) {
            // SELECT * FROM user WHERE id = 1 FOR UPDATE
            user.password = null;
            user.save().chain(comb.hitch(ret, "callback"), comb.hitch(ret, "errback"));
        }, comb.hitch(ret, "errback"));
        return ret;
    });
};
github C2FO / patio / example / querying.example.js View on Github external
User.forUpdate().first({id: 1}).chain(function (user) {
            // SELECT * FROM user WHERE id = 1 FOR UPDATE
            user.password = null;
            user.save().chain(comb.hitch(ret, "callback"), comb.hitch(ret, "errback"));
        }, comb.hitch(ret, "errback"));
        return ret;
github C2FO / hare / lib / index.js View on Github external
return function connect(url, opts) {
        if (!connectionPromise) {
            connectOpts = opts;
            connectionPromise = new Promise();
            connection = amqp.createConnection(url, opts);
            connection.once('ready', ready);
            connection.once('error', connectionError);
            // use on instead of once for `close` so we can handle multiple
            // subsequent disconnects.
            connection.on("close", checkConnected);
        }
        return connectionPromise;
    };
}());

var Hare = comb.define(_Options, {

    instance: {

        _url: null,

        constructor: function () {
            this._super(arguments);
            this._url = {};
        },

        url: function (url) {
            if (isHash(url)) {
                this._url = url;
            } else {
                this._url.url = url;
            }
github C2FO / patio / test / runner.js View on Github external
(function run(files) {
        var f = files.shift();
        if (f) {
            console.log("RUNNING %s", f);
            require(f).then(comb.partial(run, files), function(err){
                console.log(err);
                run(files);
            });
        } else {
            ret.callback();
        }
    })(files);
    return ret;
github C2FO / patio / test / migrations / files / bad_up_migration / 0.create_tables.js View on Github external
exports.up = function (db) {
    return comb.when(
        db.createTable("test", function () {
            this.column("column", "integer");
        }),
        db.createTable("test2", function () {
            this.column("column", "integer");
        }),
        db.createTable("test3", function () {
            this.column("column", "integer");
        }),
        db.createTable("test4", function () {
            this.column("column", "integer");
        })
    );
};
github C2FO / patio / test / data / timestampPlugin / timestamp.default.models.js View on Github external
exports.loadModels = function () {
    var ret = new comb.Promise();
    return comb.executeInOrder(helper, patio, function (helper, patio) {
        var DB = helper.createTables();
        var Employee = patio.addModel(DB.from("employee"), {
            plugins:[patio.plugins.TimeStampPlugin]
        });
        Employee.timestamp();
        patio.syncModels();
    });
};
github C2FO / patio / test / data / oneToOne / eager.models.js View on Github external
exports.loadModels = function () {
    var ret = new comb.Promise();
    return comb.executeInOrder(helper, patio, function (helper, patio) {
        var DB = helper.createTables();
        var Works = patio.addModel(DB.from("works"), {
            static:{
                init:function () {
                    this._super(arguments);
                    this.manyToOne("employee", {fetchType:this.fetchType.EAGER});
                }
            }
        });
        var Employee = patio.addModel(DB.from("employee"), {
            static:{
                init:function () {
                    this._super(arguments);
                    this.oneToOne("works", {fetchType:this.fetchType.EAGER});
                }