This repository has been archived by the owner on Apr 29, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
74 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,30 @@ | ||
path = require 'path' | ||
fs = require 'fs' | ||
|
||
nosqlite = module.exports | ||
|
||
nosqlite.path = path.join path.resolve(__dirname, '..'), 'data' | ||
|
||
nosqlite.Connection = (arg) -> | ||
options = {} | ||
this.path = nosqlite.path | ||
|
||
if typeof(arg) is 'object' | ||
options = arg | ||
this.path = options.path | ||
else if typeof(arg) is 'string' | ||
this.path = arg | ||
|
||
nosqlite.Connection::database = (name) -> | ||
that = this | ||
connection = this | ||
|
||
dir = path.resolve this.dir, name | ||
|
||
name: name | ||
|
||
exists: (cb) -> | ||
path.exists dir, cb | ||
|
||
existsSync: -> | ||
path.existsSync dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
vows = require 'vows' | ||
assert = require 'assert' | ||
path = require 'path' | ||
|
||
vows | ||
.describe('connection') | ||
.addBatch | ||
'Connection': | ||
topic: require '../src/nosqlite' | ||
|
||
'should have default path': (nosqlite) -> | ||
assert.equal nosqlite.path, path.resolve(__dirname, '..', 'data') | ||
|
||
'without options': | ||
topic: (nosqlite) -> | ||
return new(nosqlite.Connection)() | ||
|
||
'should be successful': (topic) -> | ||
assert.equal topic.path, path.resolve(__dirname, '..', 'data') | ||
|
||
'with options': | ||
topic: (nosqlite) -> | ||
return new(nosqlite.Connection) path.resolve(__dirname, 'fixtures') | ||
|
||
'should be successful': (topic) -> | ||
assert.equal topic.path, path.resolve(__dirname, 'fixtures') | ||
|
||
.export(module) |
Empty file.