npmtest-dredd (v0.0.1)

Code coverage report for node-npmtest-dredd/node_modules/dredd/lib/handle-runtime-problems.js

Statements: 17.24% (5 / 29)      Branches: 0% (0 / 12)      Functions: 0% (0 / 1)      Lines: 17.86% (5 / 28)      Ignored: none     

All files » node-npmtest-dredd/node_modules/dredd/lib/ » handle-runtime-problems.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  1     1   1   1                                                                   1    
// Generated by CoffeeScript 1.12.5
var blueprintUtils, handleRuntimeProblems, logger,
  hasProp = {}.hasOwnProperty;
 
blueprintUtils = require('./blueprint-utils');
 
logger = require('./logger');
 
handleRuntimeProblems = function(blueprintData) {
  var annotation, apiDescriptionDocument, data, error, filename, i, len, log, message, ranges, ref, transactionName;
  error = false;
  for (filename in blueprintData) {
    if (!hasProp.call(blueprintData, filename)) continue;
    data = blueprintData[filename];
    apiDescriptionDocument = data.raw;
    ref = data.annotations;
    for (i = 0, len = ref.length; i < len; i++) {
      annotation = ref[i];
      if (annotation.type === 'warning') {
        log = logger.warn;
      } else {
        error = true;
        log = logger.error;
      }
      if (annotation.component === 'apiDescriptionParser') {
        ranges = blueprintUtils.warningLocationToRanges(annotation.location, apiDescriptionDocument);
        message = "Parser " + annotation.type + " in file '" + filename + "': (" + annotation.type + " code " + annotation.code + ") " + annotation.message + " ";
        if (ranges != null ? ranges.length : void 0) {
          message += "on " + (blueprintUtils.rangesToLinesText(ranges));
        }
        log(message);
      } else {
        transactionName = [annotation.origin.resourceGroupName, annotation.origin.resourceName, annotation.origin.actionName].join(' > ');
        log("Compilation " + annotation.type + " in file '" + filename + "': " + annotation.message + " (" + transactionName + ") ");
      }
    }
  }
  if (error) {
    return new Error('Error when processing API description.');
  }
};
 
module.exports = handleRuntimeProblems;