Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Commit

Permalink
Finshed connection
Browse files Browse the repository at this point in the history
  • Loading branch information
pksunkara committed Dec 22, 2011
1 parent dbaeeca commit 2d06133
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 18 deletions.
36 changes: 18 additions & 18 deletions Cakefile
Expand Up @@ -5,21 +5,21 @@ task 'lib', 'Generate the library from the src', ->
coffee.stdout.on 'data', (data) -> console.log data.toString().trim()

task 'docs', 'Generate the documentation from the src', ->
exec([
'rm -rf docs'
'for i in $(find src -name *.coffee)'
'do mkdir -p $(dirname $i | sed -s "s/src/docs/")'
' docco $i'
' dirs=$i; ext=""'
' while expr $(dirname $dirs) != "src"'
' do dirs=$(dirname $dirs)'
' ext="..\\/$ext"'
' done'
' ext=$ext"docco.css"'
' file="docs/"$(basename $i | sed -s "s/coffee/html/")'
' sed -i "s/docco.css/$ext/" $file'
' mv $file $(echo $i | sed -s "s/coffee/html/;s/src/docs/")'
'done'
].join('; '), (err) ->
throw err if err
)
# exec([
# 'rm -rf docs'
# 'for i in $(find src -name *.coffee)'
# 'do mkdir -p $(dirname $i | sed -s "s/src/docs/")'
# ' docco $i'
# ' dirs=$i; ext=""'
# ' while expr $(dirname $dirs) != "src"'
# ' do dirs=$(dirname $dirs)'
# ' ext="..\\/$ext"'
# ' done'
# ' ext=$ext"docco.css"'
# ' file="docs/"$(basename $i | sed -s "s/coffee/html/")'
# ' sed -i "s/docco.css/$ext/" $file'
# ' mv $file $(echo $i | sed -s "s/coffee/html/;s/src/docs/")'
# 'done'
# ].join('; '), (err) ->
# throw err if err
# )
Empty file added data/.gitkeep
Empty file.
28 changes: 28 additions & 0 deletions src/nosqlite.coffee
@@ -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
28 changes: 28 additions & 0 deletions test/connection-test.coffee
@@ -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 added test/fixtures/.gitkeep
Empty file.

0 comments on commit 2d06133

Please sign in to comment.