{"_id":"_design/raw_data","language":"javascript","views":{"modules":{"map":"function (doc) {\n var path = doc._id.split('::');\n if ((path[0] == 'RevisionHistory') && (path[path.length - 2] == 'Module') && (doc.currentRevision > 0) && (doc.revisionHistory[doc.currentRevision - 1].status == 'active'))\n emit(path[path.length - 1], doc.currentRevision);\n else if ((path[0] == 'Revision') && (path[path.length - 3] == 'Module')) {\n var res = {};\n res['revision'] = path[path.length - 1];\n emit(path[path.length - 2], res);\n }\n }","reduce":"function (keys, values, rereduce) {\n function isNumber(no) {\n return typeof no == 'number';\n }\n\n var revision;\n var revIndex = {};\n for (var i = 0; i < values.length; i++) {\n if (isNumber(values[i]))\n revision = values[i];\n else {\n var revObj = values[i];\n var curRev = values[i].revision;\n delete revObj.revision;\n revIndex[curRev] = revObj;\n }\n }\n if (!revision) return;\n return (revIndex[revision] ? revIndex[revision] : [revision]);\n }"},"modules-with-drafts":{"map":"function (doc) {\n var path = doc._id.split('::');\n if ((path[0] == 'RevisionHistory') && (path[path.length - 2] == 'Module') && (doc.revisionHistory[doc.revisionHistory.length - 1].status != 'deleted'))\n emit(path[path.length - 1], doc.revisionHistory[doc.revisionHistory.length - 1].revision);\n else if ((path[0] == 'Revision') && (path[path.length - 3] == 'Module')) {\n var res = {};\n res['revision'] = path[path.length - 1];\n emit(path[path.length - 2], res);\n }\n }","reduce":"function (keys, values, rereduce) {\n return values[0];\n }"},"classes":{"map":"function (doc) {\n var path = doc._id.split('::');\n if ((path[0] == 'RevisionHistory') && (path[path.length - 2] == 'Class') && (doc.currentRevision > 0) && (doc.revisionHistory[doc.currentRevision - 1].status == 'active'))\n emit(path[path.length - 1], doc.currentRevision);\n else if ((path[0] == 'Revision') && (path[path.length - 3] == 'Class')) {\n var res = {};\n res['revision'] = path[path.length - 1];\n emit(path[path.length - 2], res);\n }\n }","reduce":"function (keys, values, rereduce) {\n function isNumber(no) {\n return typeof no == 'number';\n }\n\n var revision;\n var revIndex = {};\n for (var i = 0; i < values.length; i++) {\n if (isNumber(values[i]))\n revision = values[i];\n else {\n var revObj = values[i];\n var curRev = values[i].revision;\n delete revObj.revision;\n revIndex[curRev] = revObj;\n }\n }\n if (!revision) return;\n return (revIndex[revision] ? revIndex[revision] : [revision]);\n }"},"classes-with-drafts":{"map":"function (doc) {\n var path = doc._id.split('::');\n if ((path[0] == 'RevisionHistory') && (path[path.length - 2] == 'Class') && (doc.revisionHistory[doc.revisionHistory.length - 1].status != 'deleted'))\n emit(path[path.length - 1], doc.revisionHistory[doc.revisionHistory.length - 1].revision);\n else if ((path[0] == 'Revision') && (path[path.length - 3] == 'Class')) {\n var res = {};\n res['revision'] = path[path.length - 1];\n emit(path[path.length - 2], res);\n }\n }","reduce":"function (keys, values, rereduce) {\n return values[0];\n }"},"methods":{"map":"function (doc) {\n var path = doc._id.split('::');\n if ((path[0] == 'RevisionHistory') && (path[path.length - 2] == 'Method') && (doc.currentRevision > 0) && (doc.revisionHistory[doc.currentRevision - 1].status == 'active'))\n emit(path[path.length - 1], doc.currentRevision);\n else if ((path[0] == 'Revision') && (path[path.length - 3] == 'Method')) {\n var parentPath = doc.parent.split('::');\n var res = {};\n res['revision'] = path[path.length - 1];\n for (var i = 0; i < parentPath.length; i += 2)\n res[parentPath[i]] = parentPath[i + 1];\n emit(path[path.length - 2], res);\n }\n }","reduce":"function (keys, values, rereduce) {\n function isNumber(no) {\n return typeof no == 'number';\n }\n var revision;\n var revIndex = {};\n for (var i = 0; i < values.length; i++) {\n if (isNumber(values[i]))\n revision = values[i];\n else {\n var revObj = values[i];\n var curRev = values[i].revision;\n delete revObj.revision;\n revIndex[curRev] = revObj;\n }\n }\n if (!revision) return;\n return (revIndex[revision] ? revIndex[revision] : [revision]);\n }"},"methods-with-drafts":{"map":"function (doc) {\n var path = doc._id.split('::');\n if ((path[0] == 'RevisionHistory') && (path[path.length - 2] == 'Method') && (doc.revisionHistory[doc.revisionHistory.length - 1].status != 'deleted'))\n emit(path[path.length - 1], doc.revisionHistory[doc.revisionHistory.length - 1].revision);\n else if ((path[0] == 'Revision') && (path[path.length - 3] == 'Method')) {\n var parentPath = doc.parent.split('::');\n var res = {};\n res['revision'] = path[path.length - 1];\n for (var i = 0; i < parentPath.length; i += 2)\n res[parentPath[i]] = parentPath[i + 1];\n emit(path[path.length - 2], res);\n }\n }","reduce":"function (keys, values, rereduce) {\n function isNumber(no) {\n return typeof no == 'number';\n }\n\n var revision;\n var revIndex = {};\n for (var i = 0; i < values.length; i++) {\n if (isNumber(values[i]))\n revision = values[i];\n else {\n var revObj = values[i];\n var curRev = values[i].revision;\n delete revObj.revision;\n revIndex[curRev] = revObj;\n }\n }\n if (!revision) return;\n return (revIndex[revision] ? revIndex[revision] : [revision]);\n }"},"for-module":{"map":"function (doc) {\n var path = doc._id.split('::');\n // if (doc._id.indexOf('RevisionHistory::') == 0)\n // emit(['history', doc._id.substring(17)], doc);\n // else\\n if (path[0] == 'Revision') {\n if (path[1] == 'Module') {\n for (var i = 0; i < doc.immediates.length; i++)\n emit(['module', doc.name, doc.immediates[i]], doc);\n } else {\n emit(['object', (doc.parent ? doc.parent : null), path.slice(1, -1).join('::')], doc);\n }\n }"}},"shows":{"module":"function (doc, req) {\n return {\n body: \"module('\" + doc._attachments[doc.currentRevision].data + \"').requires('projects.CodeDB.base-cdb').toRun(function() { });\",\n headers: { 'Content-Type': 'application/x-javascript' }\n }\n}","class":"function (doc, req) {\n return {\n body: \"Object.subclass('\" + doc._attachments[doc.currentRevision].data + \"', { });\",\n headers: { 'Content-Type': 'application/x-javascript' }\n }\n}"},"lists":{"by-type":"function (head, req) {\n var row;\n var i = 0;\n var query = req.query;\n delete query.key;\n delete query.group;\n\n send('[');\n while(row = getRow()) {\n var fits = true;\n if (row.value == null) continue;\n for (var key in query) {\n fits &= ((row.value[key]) && (row.value[key] == query[key]))\n };\n if (fits) {\n if (i != 0) send(', ');\n send(JSON.stringify(row));\n i++;\n }\n }\n send(']');\n}","javascript":"function (head, req) {\n start({\n 'headers': {\n 'Content-Type': 'application/x-javascript'\n }\n });\n\n function ownProperties(object) {\n var a = [];\n for (var name in object) {\n if (object.hasOwnProperty(name) && (typeof object[name] != 'function'))\n a.push(name);\n }\n return a;\n }\n\n function isNumber(no) {\n return typeof no == 'number';\n }\n\n var row;\n var currentRevisions = {};\n var moduleDoc;\n var srcTree = {};\n while(row = getRow()) {\n var doc = row.value;\n var idPath = row.key;\n var docType = idPath.shift();\n if ((docType == 'History')) {\n currentRevisions[idPath.join('::')] = doc.currentRevision;\n continue;\n }\n var rev = idPath.pop();\n var uri = idPath.join('::');\n if (!isNumber(currentRevisions[uri]) || (rev != currentRevisions[uri]))\n continue;\n\n currentRevisions[uri] = doc;\n if (uri == 'Module::' + req.query['module'])\n moduleDoc = doc;\n }\n\n function buildTree(moduleDoc) {\n var srcTree = [];\n var lastPath = [];\n for (var j = 0; j < moduleDoc.children.length; j++) {\n var uri = moduleDoc.children[j];\n\n var path = [uri];\n while (!isNumber(currentRevisions[uri]) && currentRevisions[uri].parent) {\n uri = currentRevisions[uri].parent;\n path.push(uri);\n }\n path.reverse();\n\n var maxLen = Math.min(lastPath.length, path.length);\n var found = 0;\n var subTree = srcTree;\n for (; found < maxLen; found++) {\n if (lastPath[found] != path[found])\n break;\n else\n subTree = subTree[subTree.length - 1].children;\n }\n\n for (; found < path.length; found++) {\n subTree.push({\n '_doc': currentRevisions[path[found]],\n 'children': []\n });\n subTree = subTree[subTree.length - 1].children;\n }\n lastPath = path;\n }\n return srcTree;\n }\n\n var srcTree = buildTree(moduleDoc);\n var lastCategory;\n\n function treePrint(tree, indentation) {\n indentation = indentation || '';\n var doc = tree._doc;\n\n switch (doc.type) {\n case 'module':\n send(indentation + \"module('$\" + req.info.db_name + \".\" + doc.name + \"').requires(\");\n if (doc.requirements.length > 0)\n send(\"'\" + doc.requirements.join(\"', '\") + \"'\");\n send(\").toRun(function() {\\n\\n\");\n for (var idx = 0; idx < tree.children.length; idx++)\n treePrint(tree.children[idx], indentation);\n send(indentation + \"});\");\n break;\n\n case 'class':\n lastCategory = 'documentation';\n send(indentation + doc.superclass + \".subclass('\" + doc.name + \"',\\n\");\n send(indentation + \"'documentation', {\\n\");\n send(indentation + \"\\tdocumentation: '\" + doc.documentation + \"',\\n\");\n for (var idx = 0; idx < tree.children.length; idx++)\n treePrint(tree.children[idx], indentation);\n send(indentation + \"});\\n\\n\");\n break;\n\n case 'method':\n var source = doc.source.split('\\n').join('\\n' + indentation + '\\t');\n if (doc.category != lastCategory) {\n if (lastCategory)\n send(indentation + \"},\\n\");\n lastCategory = doc.category || 'default category';\n send(indentation + \"'\" + lastCategory + \"', {\\n\");\n } else\n send(\"\\n\");\n send(indentation + \"\\t\" + doc.name + \": \" + source + \",\\n\");\n break;\n }\n }\n\n treePrint({ '_doc': moduleDoc, 'children': srcTree });\n}","children":"function (head, req) {\n function uniq(arr) {\n var res = [];\n var l = arr.length;\n for (var i = 0; i < l; i++) {\n for(var j = i + 1; j < l; j++) {\n if (arr[i] === arr[j]) j = ++i;\n }\n res.push(arr[i]);\n }\n return res;\n };\n\n var row;\n var modules = {};\n var objectMap = {};\n var query = req.query;\n delete query.key;\n delete query.group;\n\n while(row = getRow()) {\n if (row['key'][0] == 'module' && ((query['module'] == undefined) || (query['module'] == row['key'][1]))) {\n if (!modules[row['key'][1]])\n modules[row['key'][1]] = [];\n modules[row['key'][1]].push(row['key'][2]);\n } else if (row['key'][0] == 'object') {\n objectMap[row['key'][2]] = row['key'][1];\n }\n }\n var parent;\n for (var module in modules) {\n for (var i = 0; i < modules[module].length; i++) {\n while ((parent = objectMap[modules[module][i]]) != null)\n modules[module][i] = parent;\n }\n modules[module] = uniq(modules[module]);\n }\n\n if (query['module'])\n send(JSON.stringify(modules[query['module']]));\n else\n send(JSON.stringify(modules));\n}"},"attachments_md5":{}}