Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
frankrousseau committed Aug 5, 2013
0 parents commit be4ddb3
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
*.js
node_modules
*.swp
4 changes: 4 additions & 0 deletions .npmignore
@@ -0,0 +1,4 @@
*.coffee
todo
.git*
.project
4 changes: 4 additions & 0 deletions .travis.yml
@@ -0,0 +1,4 @@
language: node_js
node_js:
- "0.10"
- "0.8"
30 changes: 30 additions & 0 deletions Cakefile
@@ -0,0 +1,30 @@
fs = require 'fs'
{exec} = require 'child_process'

task 'tests', 'run tests through mocha', ->
console.log "Run tests with Mocha..."
command = "mocha tests.coffee --reporter spec "
command += "--compilers coffee:coffee-script --colors"
exec command, (err, stdout, stderr) ->
console.log stdout
if err
console.log "Running mocha caught exception: \n" + err
process.exit 1
else
process.exit 0

task "build", "", ->
console.log "Compile main file..."
command = "coffee -c main.coffee"
exec command, (err, stdout, stderr) ->
if err
console.log "Running coffee-script compiler caught exception: \n" + err
else
console.log "Compilation succeeded."

console.log stdout

task "lint", "Run coffeelint on source files", ->
command = "coffeelint -f coffeelint.json main.coffee"
exec command, (err, stdout, stderr) ->
console.log stdout
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
Copyright 2012 Cozy Cloud (contact@cozycloud.cc))

This project is free software released under the MIT/X11 license:

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
1 change: 1 addition & 0 deletions README.md
@@ -0,0 +1 @@
Make Express opiniated
6 changes: 6 additions & 0 deletions coffeelint.json
@@ -0,0 +1,6 @@
{
"indentation" : {
"value" : 4,
"level" : "error"
}
}
39 changes: 39 additions & 0 deletions main.coffee
@@ -0,0 +1,39 @@
async = require 'async'

_loadModels = (root, requests) ->
models = []
for docType, docRequests of requests
models[docType] = require "#{root}/models/#{docType}"
models


_getRequestCreator = (root, models, docType, requestName, request) ->
(cb) ->
console.log "#{docType} - #{requestName} request creation..."
models[docType].defineRequest requestName, request, (err) ->
if err then console.log "... fail"
else console.log "... ok"
cb err

_loadRequestCreators = (root, models, requests) ->
requestsToSave = []
for docType, docRequests of requests
for requestName, docRequest of docRequests
requestsToSave.push(
_getRequestCreator(root, models, docType, \
requestName, docRequest))
requestsToSave

module.exports = (root, app, callback) ->
requests = require "#{root}/models/requests"
models = _loadModels root, requests
requestsToSave = _loadRequestCreators root, models, requests

async.series requestsToSave, (err) ->
if err and err.code isnt 'EEXIST'
console.log "A request creation failed, abandon."
console.log err
callback err if callback?
else
console.log "All requests have been created"
callback() if callback?
40 changes: 40 additions & 0 deletions package.json
@@ -0,0 +1,40 @@
{
"name": "americano-cozy",
"version": "0.1.0",
"description": "Americanp helpers to build Cozy applications faster",
"main": "./main.js",
"dependencies": {
"async": "*"
},
"devDependencies": {
"coffee-script": "*",
"chai": "*",
"mocha": "*"
},
"optionalDependencies": {},
"scripts": {
"prepublish": "cake build",
"test": "cake tests"
},
"keywords": [
"plugin"
],
"licenses": [
{
"type": "MIT",
"url": "https://github.com/frankrousseau/americano-cozy/blob/master/LICENSE"
}
],
"bugs": {
"url": "https://github.com/frankrousseau/americano/issues"
},
"author": "Frank R",
"contributors": [],
"engines": {
"node": "*"
},
"repository": {
"type": "git",
"url": "https://github.com/frankrousseau/americano-cozy.git"
}
}

0 comments on commit be4ddb3

Please sign in to comment.