Add scripts to create myops-getqueryview:
[myops.git] / web / query / vendor / couchapp / lib / code.js
1 exports.ddoc = function(ddoc) {
2   // only return the parts of the app that we use
3   var i, j, path, key, obj, ref, out = {},
4     resources = ddoc.couchapp && ddoc.couchapp.load && ddoc.couchapp.load.app || [];
5   for (i=0; i < resources.length; i++) {
6     path = resources[i].split('/');
7     obj = ddoc;
8     ref = out;
9     for (j=0; j < path.length; j++) {
10       key = path[j];
11       ref[key] = ref[key] || {};
12       if (j < path.length - 1) {
13         obj = obj[key];
14         ref = ref[key];
15       }
16     };
17     ref[key] = obj[key];
18   };
19   return out;
20 };