UNPKG

glutenfree

Version:

A profiler/loganalyzer for nginx/Cetrea Aw.

127 lines (116 loc) 4.05 kB
// Generated by CoffeeScript 1.6.3 var Mapper, util, winston, _; _ = require("underscore"); winston = require("winston"); util = require("util"); Mapper = (function() { function Mapper() {} Mapper.prototype.unmap = function(schema) { var schematic, unmapped; unmapped = (function() { var _i, _len, _results; _results = []; for (_i = 0, _len = schema.length; _i < _len; _i++) { schematic = schema[_i]; _results.push((function(schematic) { var arg, newArg, _fn, _j, _len1; if (Array.isArray(schematic)) { newArg = schematic.original; _fn = function(arg) { return newArg[arg.key] = arg.newvalue; }; for (_j = 0, _len1 = schematic.length; _j < _len1; _j++) { arg = schematic[_j]; _fn(arg); } return JSON.stringify(newArg); } else if (typeof schematic === "object") { return schematic.newvalue.join(","); } })(schematic)); } return _results; })(); return unmapped.join("/"); }; Mapper.prototype.map = function(def, args) { var arg, idx, _i, _len, _results; args = _.map((typeof args === "string" ? args.split("/") : args), function(a) { return a.split(","); }); _results = []; for (idx = _i = 0, _len = args.length; _i < _len; idx = ++_i) { arg = args[idx]; _results.push((function(arg, idx) { var origin, original, pKey, pTypeSelector, property, schematic, type, typeProperty, _ref, _ref1; if (def[idx] != null) { if (typeof def[idx] === "string") { origin = "mapi"; typeProperty = def[idx]; if (typeProperty.indexOf("#") > 0) { _ref = def[idx].split("#"), origin = _ref[0], typeProperty = _ref[1]; } _ref1 = typeProperty.split("."), type = _ref1[0], property = _ref1[1]; return { origin: origin, type: type, property: property, currentvalue: arg, depth: 1 }; } else if (typeof def[idx] === "object") { original = JSON.parse(arg); schematic = (function() { var _ref2, _results1; _ref2 = def[idx]; _results1 = []; for (pKey in _ref2) { pTypeSelector = _ref2[pKey]; _results1.push((function(pKey, pTypeSelector) { var currentvalue, pSelector, pType, _ref3; currentvalue = original[pKey]; if (typeof pTypeSelector === "string") { _ref3 = pTypeSelector.split("."), pType = _ref3[0], pSelector = _ref3[1]; return { origin: "mapi", type: pType, property: pSelector, currentvalue: currentvalue, key: pKey, depth: 1 }; } else { return { origin: "mapi", type: pTypeSelector.type, property: pTypeSelector.property, currentvalue: currentvalue, key: pKey, depth: pTypeSelector.depth, hql: pTypeSelector.hql, filter: pTypeSelector.filter }; } })(pKey, pTypeSelector)); } return _results1; })(); schematic.original = original; return schematic; } } else { return { origin: "fixed", currentvalue: arg }; } })(arg, idx)); } return _results; }; Mapper.prototype.applySchema = function(method, action, fun, schema) { return this.unmap(schema); }; return Mapper; })(); exports.mapper = Mapper;