Browse files

Added a Makefile

  • Loading branch information...
1 parent 1ad3a79 commit 036e80ebf94ab4a3e5367d156085cac928623b6a @hkjels committed May 14, 2012
Showing with 92 additions and 10 deletions.
  1. +28 −0 .jshintrc
  2. +25 −0 Makefile
  3. +13 −4 Readme.md
  4. +4 −4 crud.js
  5. +3 −2 package.json
  6. +19 −0 test/crud.test.js
View
28 .jshintrc
@@ -0,0 +1,28 @@
+{
+ "node" : true,
+ "asi": true,
+ "boss" : false,
+ "curly": false,
+ "debug": false,
+ "devel": false,
+ "eqeqeq": false,
+ "eqnull": true,
+ "evil": true,
+ "forin": false,
+ "immed": false,
+ "laxbreak": true,
+ "laxcomma": true,
+ "newcap": true,
+ "noarg": true,
+ "noempty": false,
+ "nonew": false,
+ "nomen": false,
+ "onevar": false,
+ "plusplus": false,
+ "regexp": false,
+ "undef": true,
+ "sub": true,
+ "strict": false,
+ "white": false,
+ "trailing": true
+}
View
25 Makefile
@@ -0,0 +1,25 @@
+
+.PHONY: mocha lint docs clean cleandocs
+
+
+# Phony procedures
+
+docs: docs/crud.json
+
+lint:
+ ./node_modules/.bin/jshint crud.js
+
+mocha:
+ ./node_modules/.bin/mocha test/*.test.js
+
+clean: cleandocs
+
+cleandocs:
+ rm -rf docs
+
+
+# Compile
+
+docs/crud.json: crud.js
+ mkdir -p docs
+ ./node_modules/.bin/dox < $< > $@
View
17 Readme.md
@@ -8,19 +8,28 @@ __Crud functionality for mongoose-models. Fits well with express.js__
λ npm install crud
-## With express.js
+## With express.js magic
var express = require('express')
, app = module.exports = express.createServer()
- , mongoose = require('mongoose')
- , Model = require('./Model')
, crud = require('crud')
- app.get('/crud/:model', crud, function (req, res) {
+ app.get('/crud/:model', crud.middleware, function (req, res) {
res.render('crud')
})
+## Without express.js magic
+
+ var mongoose = require('mongoose')
+ , Model = mongoose.model('Model')
+ , crud = require('crud').form
+
+ crud(Model, function (err, form) {
+ console.dir(form)
+ })
+
+
## Constributors
* Henrik Kjelsberg <hkjels@me.com>
View
8 crud.js
@@ -13,14 +13,14 @@ var mongoose = require('mongoose')
, cycle = require('cycle')
/**
- * Simplify
+ * Form
*
- * Normalizes a mongoose Schema to be used with a template
+ * Normalizes a mongoose Schema to be used with a form-template
* @param {Mixed} model Model or name of a model
* @param {Function} cb Callback
*/
-var simplify = exports.simplify = function (model, cb) {
+var form = exports.form = function (model, cb) {
var err
, Model
, Schema
@@ -83,7 +83,7 @@ var simplify = exports.simplify = function (model, cb) {
*/
exports.middleware = function (req, res, next, model) {
- simplify(model, function (err, form) {
+ form(model, function (err, form) {
if (err) return next(err)
req.locals('form', form)
return next()
View
5 package.json
@@ -7,14 +7,15 @@
, "main": "crud.js"
, "scripts": {
"test": "make mocha"
- , "prepublish": "make mocha lint docs"
+ , "prepublish": "make mocha lint"
}
, "dependencies": {
"cycle": "1.0.0"
, "mongoose": ">= 2.0.0"
}
, "devDependencies": {
- "express": "2.5.9"
+ "dox": "0.3.1"
+ , "express": "2.5.9"
, "jade": "0.26.0"
, "jshint": ">= 0.7.0"
, "mocha": "1.0.3"
View
19 test/crud.test.js
@@ -0,0 +1,19 @@
+
+
+describe('Crud', function () {
+
+ describe('form', function () {
+ it ('should return a normalized version of the model passed', function (done) {
+ done()
+ })
+ })
+
+ describe('middleware', function () {
+ it ('should populate request-object with the response from the form-function', function (done) {
+ done()
+ })
+ })
+
+})
+
+

0 comments on commit 036e80e

Please sign in to comment.