Skip to content
Browse files

squashed some bugs

  • Loading branch information...
1 parent 6420d57 commit 47d505f122cc32ccb8a7445b0d3b0d788fbc5a07 @dgreisen committed
Showing with 3 additions and 11 deletions.
  1. +3 −2 bin/generate.js
  2. +0 −9 lib/template.js
View
5 bin/generate.js
@@ -23,7 +23,8 @@ handler_code = "\ncouchdb['{{db}}']['{{ddoc}}'].{{handler}} = {}"
method_code = "\n\
couchdb['{{db}}']['{{ddoc}}'].{{handler}}['{{method}}'] = method_factories['{{handler}}']('{{path}}')"
-handlers = {views:'',shows:'',lists:'',updates:'',rewrites:''};
+handlers = {views:'_view/',shows:'_show/',lists:'_list/',updates:'_update/',rewrites:'_rewrite/'};
+
function gen_interface(uri, filename, admin) {
host = uri || 'http://127.0.0.1:5984/'
host += (host.slice(-1) == '/') ? '' : '/' // ensure ends in slash
@@ -113,7 +114,7 @@ function gen_interface(uri, filename, admin) {
for (handler_name in ddoc) {
if (handler_name in handlers && JSON.stringify(ddoc[handler_name]) != JSON.stringify({})) {
handler = ddoc[handler_name]
- handler_path = ddoc_path + handlers[handler_name].path;
+ handler_path = ddoc_path + handlers[handler_name];
write_line(handler_code.replace(handler_rx, handler_name)
.replace(ddoc_rx, ddoc_name)
.replace(database_rx, db_name) )
View
9 lib/template.js
@@ -35,23 +35,14 @@ var ddoc_factory = factory_factory(proto_ddoc)
// ** Handlers **
var proto_view = proto_helper(['get', 'post']);
-proto_view.constructor = function(path) {this._path = path+'_view/';}
proto_view.call = function(query, callback) {
if (!callback) return couchdb._request('', this._path, null, query)
return couchdb._request({query:query}, this._path, null, callback)
}
-
var proto_show = proto_helper(['get', 'post'], 'get');
-proto_show.constructor = function(path) {this._path = path+'_show/';}
-
var proto_list = proto_helper(['get', 'post'], 'get');
-proto_list.constructor = function(path) {this._path = path+'_list/';}
-
var proto_update = proto_helper(['put', 'post'], 'put');
-proto_update.constructor = function(path) {this._path = path+'_update/';}
-
var proto_rewrite = proto_helper(['get', 'put', 'post', 'del'], 'get');
-proto_rewrite.constructor = function(path) {this._path = path+'_rewrite/';}
method_factories =
{ views: factory_factory(proto_view)

0 comments on commit 47d505f

Please sign in to comment.
Something went wrong with that request. Please try again.