Skip to content

Commit

Permalink
merge skim master
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesgassert committed May 6, 2013
2 parents 39bde83 + 8881e44 commit 1b974ee
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Dialect is a painless nodejs module to manage your translations.
* `host`: _127.0.0.1_
* `port`: _27017_
* `collection`: _translations_
* `username` (optional)
* `password` (optional)
* `sqlite`
* `database`: _dialect.db_
* `table`: _dialect_
Expand Down
2 changes: 1 addition & 1 deletion lib/dialect.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = function (options) {
*/
DIALECT.connect = function (cb) {
if (DIALECT.store.is_connected()) {
cb('already connected', null);
cb(null);
} else {
DIALECT.store.connect(cb);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/helpers/plurals.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module.exports = function plurals(locale) {
// 2 Plurals
default:
if (parts.length === 2) {
plurals(parts[0]);
return plurals(parts[0]);
} else {
return function (n) {
return n === 1 ? 0 : 1;
Expand Down
1 change: 0 additions & 1 deletion lib/stores/mongodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ module.exports = function (options) {
});
}
});
}

callback = _default(callback);

Expand Down
13 changes: 11 additions & 2 deletions lib/stores/sqlite.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ module.exports = function (options) {
return callback || function () { };
},

_is_connected = false;
_is_connected = false,
_connecting = false;

Object.defineProperty(STORE, 'db', {value : new sqlite.Database()});

Expand All @@ -42,6 +43,12 @@ module.exports = function (options) {

callback = _default(callback);

STORE.db.on('dialectReady', callback);

if (_connecting) {
return;
}

STORE.db.open(options.database || 'dialect.db', function (err) {
if (err) {
callback(err, null);
Expand All @@ -54,7 +61,9 @@ module.exports = function (options) {
if (data) {
_is_connected = true;
}
callback(err, data);

_connecting = false;
STORE.db.emit('dialectReady', err);
}
);
}
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"name": "dialect",
"description": "Translations manager for nodejs",
"version": "1.0.3",
"version": "1.0.5",
"author": "Pau Ramon <masylum@gmail.com>",
"dependencies": {
"mongodb": "0.9.6-23",
"sqlite": "1.0.4",
"funk": "1.0.1"
},
"devDependencies": {
Expand Down

0 comments on commit 1b974ee

Please sign in to comment.