Skip to content

Commit a04a1c9

Browse files
author
Contra
committed
silly merge
2 parents 9b2c3ee + 03c8ee9 commit a04a1c9

File tree

9 files changed

+33
-17
lines changed

9 files changed

+33
-17
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2013 Fractal <contact@wearefractal.com>
1+
Copyright (c) 2015 Fractal <contact@wearefractal.com>
22

33
Permission is hereby granted, free of charge, to any person obtaining
44
a copy of this software and associated documentation files (the

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Information
44

55
<table>
6-
<tr>
6+
<tr>
77
<td>Package</td><td>goosestrap</td>
88
</tr>
99
<tr>
@@ -40,7 +40,7 @@ var Movie = db.model('Movie');
4040

4141
(MIT License)
4242

43-
Copyright (c) 2013 Fractal <contact@wearefractal.com>
43+
Copyright (c) 2015 Fractal <contact@wearefractal.com>
4444

4545
Permission is hereby granted, free of charge, to any person obtaining
4646
a copy of this software and associated documentation files (the

lib/main.coffee

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
mongoose = require 'mongoose'
2+
glob = require 'glob'
3+
path = require 'path'
4+
5+
module.exports = (url, modelPath) ->
6+
db = mongoose.createConnection url
7+
models = glob.sync modelPath
8+
for model in models
9+
name = path.basename model, path.extname model
10+
schema = require model
11+
db.model name, schema
12+
13+
return db

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "goosestrap",
33
"description": "bootstrap your mongoose",
4-
"version": "0.0.5",
4+
"version": "0.0.4",
55
"homepage": "http://github.com/wearefractal/goosestrap",
66
"repository": "git://github.com/wearefractal/goosestrap.git",
77
"author": "Fractal <contact@wearefractal.com> (http://wearefractal.com/)",
88
"main": "./index.js",
99
"dependencies": {
10-
"glob": "^4.0.2",
11-
"require-dir": "^0.1.0"
10+
"require-dir": "^0.1.0",
11+
"glob": "^4.0.2"
1212
},
1313
"peerDependencies": {
1414
"mongoose": "^3.8.11"
@@ -19,7 +19,7 @@
1919
"should": "^4.0.0"
2020
},
2121
"scripts": {
22-
"test": "mocha --compilers coffee:coffee-script/register --ui exports"
22+
"test": "mocha --compilers coffee:coffee-script/register --ui exports --reporter spec"
2323
},
2424
"engines": {
2525
"node": ">= 0.4.0"

test/main.coffee

+9-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ goosestrap = require '../'
22
should = require 'should'
33
path = require 'path'
44

5-
module.exports =
5+
module.exports =
66

77
"it should connect": =>
88
@db = goosestrap "mongodb://localhost/goosestrap", path.resolve './test/models/*'
@@ -14,13 +14,16 @@ module.exports =
1414
(typeof @db.model 'User').should.equal 'function'
1515
(typeof @db.model 'Movie').should.equal 'function'
1616

17+
"it should load all object models": =>
18+
(typeof @db.models.User).should.equal 'function'
19+
(typeof @db.models.Movie).should.equal 'function'
20+
1721
"it should support nested dir globbing": =>
1822
@db = goosestrap "mongodb://localhost/goosestrap", path.resolve './test/nested/**/models/*'
1923

20-
"db should be an object": =>
24+
"db should be an object when nested": =>
2125
(typeof @db).should.equal 'object'
2226

23-
"it should load all models": =>
24-
(typeof @db.model 'User').should.equal 'function'
25-
(typeof @db.model 'Movie').should.equal 'function'
26-
27+
"it should load all object models when nested": =>
28+
(typeof @db.models.User).should.equal 'function'
29+
(typeof @db.models.Movie).should.equal 'function'

test/models/Movie.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ Movie = new Schema
1414
required: true
1515

1616

17-
module.exports = Movie
17+
module.exports = Movie

test/models/User.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ User = new Schema
1111
required: true
1212

1313

14-
module.exports = User
14+
module.exports = User

test/nested/bar/models/User.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ User = new Schema
1111
required: true
1212

1313

14-
module.exports = User
14+
module.exports = User

test/nested/foo/models/Movie.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ Movie = new Schema
1414
required: true
1515

1616

17-
module.exports = Movie
17+
module.exports = Movie

0 commit comments

Comments
 (0)