Skip to content

Commit b63ff85

Browse files
committed
First push.
1 parent 3daf4cf commit b63ff85

22 files changed

+954
-2
lines changed

.eslintrc

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
{
2+
"env": {
3+
"node": true
4+
},
5+
"rules": {
6+
"eol-last": 0,
7+
"no-alert": 2,
8+
"no-array-constructor": 2,
9+
"no-bitwise": 0,
10+
"no-caller": 2,
11+
"no-catch-shadow": 2,
12+
"comma-dangle": 2,
13+
"no-console": 0,
14+
"no-control-regex": 2,
15+
"no-debugger": 2,
16+
"no-delete-var": 2,
17+
"no-div-regex": 2,
18+
"no-dupe-keys": 2,
19+
"no-else-return": 0,
20+
"no-empty": 2,
21+
"no-empty-character-class": 2,
22+
"no-empty-label": 2,
23+
"no-eq-null": 0,
24+
"no-eval": 2,
25+
"no-ex-assign": 2,
26+
"no-fallthrough": 2,
27+
"no-floating-decimal": 2,
28+
"no-func-assign": 2,
29+
"no-global-strict": 0,
30+
"no-implied-eval": 2,
31+
"no-iterator": 2,
32+
"no-label-var": 2,
33+
"no-loop-func": 0,
34+
"no-mixed-requires": [0, false],
35+
"no-multi-str": 2,
36+
"no-native-reassign": 2,
37+
"no-new": 0,
38+
"no-new-func": 2,
39+
"no-new-object": 2,
40+
"no-new-wrappers": 2,
41+
"no-obj-calls": 2,
42+
"no-octal": 2,
43+
"no-octal-escape": 2,
44+
"no-plusplus": 0,
45+
"no-proto": 2,
46+
"no-redeclare": 2,
47+
"no-regex-spaces": 2,
48+
"no-return-assign": 0,
49+
"no-script-url": 2,
50+
"no-self-compare": 2,
51+
"no-sequences": 0,
52+
"no-shadow": 0,
53+
"no-sync": 0,
54+
"no-ternary": 0,
55+
"no-trailing-spaces": 0,
56+
"no-undef": 0,
57+
"no-undef-init": 2,
58+
"no-underscore-dangle": 0,
59+
"no-unreachable": 2,
60+
"no-unused-expressions": 0,
61+
"no-unused-vars": 0,
62+
"no-use-before-define": 0,
63+
"no-with": 2,
64+
"no-extra-parens": 2,
65+
"no-yoda": 0,
66+
"block-scoped-var": 0,
67+
"brace-style": 0,
68+
"camelcase": 0,
69+
"complexity": [0, 11],
70+
"consistent-return": 0,
71+
"consistent-this": [0, "that"],
72+
"curly": 0,
73+
"dot-notation": 0,
74+
"eqeqeq": 2,
75+
"guard-for-in": 0,
76+
"max-depth": [0, 4],
77+
"max-len": [0, 80, 4],
78+
"max-params": [0, 3],
79+
"max-statements": [0, 10],
80+
"new-cap": 0,
81+
"new-parens": 2,
82+
"one-var": 0,
83+
"quote-props": 0,
84+
"quotes": [0, "single"],
85+
"radix": 0,
86+
"semi": 0,
87+
"strict": 0,
88+
"unnecessary-strict": 0,
89+
"use-isnan": 2,
90+
"valid-jsdoc": 2,
91+
"wrap-iife": 0,
92+
"wrap-regex": 0,
93+
"yoda": 0
94+
}
95+
}

.istanbul.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
verbose: false
2+
instrumentation:
3+
root: .
4+
default-excludes: true
5+
excludes: []
6+
embed-source: false
7+
variable: __coverage__
8+
compact: true
9+
preserve-comments: false
10+
complete-copy: false
11+
save-baseline: false
12+
baseline-file: ./coverage/coverage-baseline.json
13+
include-all-sources: false
14+
reporting:
15+
print: summary
16+
reports:
17+
- lcov
18+
dir: ./coverage
19+
watermarks:
20+
statements: [50, 80]
21+
lines: [50, 80]
22+
functions: [50, 80]
23+
branches: [50, 80]
24+
report-config:
25+
clover: {file: clover.xml}
26+
cobertura: {file: cobertura-coverage.xml}
27+
json: {file: coverage-final.json}
28+
json-summary: {file: coverage-summary.json}
29+
lcovonly: {file: lcov.info}
30+
teamcity: {file: null}
31+
text: {file: null, maxCols: 0}
32+
text-summary: {file: null}
33+
hooks:
34+
hook-run-in-context: false
35+
post-require-hook: null
36+
handle-sigint: false
37+
check:
38+
global:
39+
statements: 0
40+
lines: 0
41+
branches: 0
42+
functions: 0
43+
excludes: []
44+
each:
45+
statements: 0
46+
lines: 0
47+
branches: 0
48+
functions: 0
49+
excludes: []

.npmignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.eslintrc
2+
.idea
3+
.npmrc
4+
gulpfile.js
5+
node_modules
6+
npm-debug.log
7+
tests
8+
NOTES.md

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
language: node_js
2+
node_js:
3+
- 0.10
4+
- 0.12
5+
- iojs
6+
before_script:
7+
- npm install -g gulp
8+
script: gulp

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Change Log
2+
3+
## 1.0.0
4+
* Initial release.

CONTRIBUTING.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Contributing
2+
3+
To contribute:
4+
5+
* Install the [Gulp](http://gulpjs.com/) task runner.
6+
* Create a feature or bugfix branch of master.
7+
* Clone your branch.
8+
* Run `$ node install` from the project's root folder.
9+
10+
Contributions are welcome as long provided the follow the guidelines outlined below. Failure to satisfy all guidelines will result in rejection.
11+
12+
* All modifications must be made via pull request.
13+
14+
* This library is designed to be a drop-in replacement for the Couchnode module. All functionality must be non-breaking extensions of the base Couchnode module.
15+
16+
* All updates must update the version number according to the [semver](http://semver.org/) guideline.
17+
18+
* All updates must include a description of the changes in the [Change Log](CHANGELOG.md).
19+
20+
* All changes to the core module code must include proper test coverage. Tests must reach 100% code coverage.
21+
22+
* All commits to master must result in a successful build and test run.

README.md

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,48 @@
1-
# couchbase-promises
2-
A lightweight A+ Promises wrapper for the Couchbase SDK.
1+
# Couchbase Promises
2+
A lightweight, drop-in replacement for the Couchnode module with added support for A+ Promises.
3+
4+
[![Build Status](https://secure.travis-ci.org/dsfields/couchbase-promises.svg)](https://travis-ci.org/dsfields/couchbase-promises)
5+
6+
## Overview
7+
Just like the [Couchbase Node.js module](http://developer.couchbase.com/documentation/server/4.0/sdks/node-2.0/introduction.html), but with the addition of `*Async()` methods that return A+ Promises for all methods that contain a Node.js callback parameter. Both the normal Couchnode and the mock Couchnode APIs have been fully promisified.
8+
9+
The current version supports Couchbase Node.js SDK version 2.1.2.
10+
11+
Promises are created using the [Bluebird](http://bluebirdjs.com/docs/getting-started.html) Promises library.
12+
13+
## General Usage
14+
Usage is almost exactly the same as the native SDK, but with the added ability to use Promises instead of callbacks.
15+
16+
A user repository module with a simple lookup...
17+
18+
```js
19+
var couchbase = require('couchbase-promises');
20+
var cluster = new couchbase.Cluster('couchbase://127.0.0.1');
21+
var bucket = cluster.openBucket();
22+
23+
function UserNotFoundError() {
24+
Error.call(this);
25+
Error.captureStackTrace(this, UserNotFoundError);
26+
this.message = "User not found.";
27+
}
28+
29+
module.exports = {
30+
UserNotFoundError: UserNotFoundError,
31+
getUserAsync: function(userId) {
32+
return bucket.getAsync(userId)
33+
.then(function(result) {
34+
return {
35+
user: result.value,
36+
meta: {
37+
etag: result.cas
38+
}
39+
};
40+
}).catch(couchbase.Error, function(e) {
41+
if (e.code == couchbase.errors.keyNotFound)
42+
throw new UserNotFoundError();
43+
44+
throw e;
45+
});
46+
}
47+
};
48+
```

gulpfile.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var gulp = require('gulp');
2+
var eslint = require('gulp-eslint');
3+
var istanbul = require('gulp-istanbul');
4+
var jsvalidate = require('gulp-jsvalidate')
5+
var mocha = require('gulp-mocha');
6+
7+
gulp.task('lint', function() {
8+
return gulp.src(['./**/*.js', '!./node_modules/**', '!./coverage/**'])
9+
.pipe(eslint())
10+
.pipe(eslint.format());
11+
});
12+
13+
gulp.task('test', function() {
14+
return gulp.src('tests/unit/**/*.js')
15+
.pipe(mocha({ reporter: 'spec' }))
16+
.pipe(istanbul.writeReports())
17+
.pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } }));
18+
});
19+
20+
gulp.task('jsvalidate', function() {
21+
return gulp.src('**/*.js')
22+
.pipe(jsvalidate());
23+
});
24+
25+
gulp.task('default', ['lint', 'test']);

0 commit comments

Comments
 (0)