Skip to content

Commit

Permalink
Preparing for release 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Mat Carey committed Apr 3, 2015
1 parent 56c0e44 commit 73fed1e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,31 @@ expect(myConfig.get('collection.nothing.this.would.usually.cause.problems')).toB

To use this with Node.JS or IO.JS you can do things like:

(using environment variables MY_OWN_PASSWORD=secret ONE_OPTIONAL_VALUE=abc)

```javascript
var myConfig = new JsConfig({
someKey: 'someValue',
optionalValueTwo: 'defghi',
collection: {
item: 'a',
thePassword: 'default password'
}
});

expect(myConfig.get('collection.thePassword')).toEqual('default password');

myConfig.readFromObject(process.env, {
collection: {
thePassword: 'MY_OWN_PASSWORD'
},
optionalValueOne: 'ONE_OPTIONAL_VALUE',
optionalValueTwo: 'ANOTHER_OPTIONAL_VALUE'
});

expect(myConfig.get('collection.thePassword')).toEqual('secret');
expect(myConfig.get('optionalValueOne')).toEqual('abc');
expect(myConfig.get('optionalValueTwo')).toEqual('defghi');
```

This will give you an object which includes the environment variable values for MUST_BE_PRESENT, AN_ENV_VAR and NO_DEFAULT but blows up if one of them doesn't exist.
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-config",
"version": "1.0.1",
"version": "1.0.2",
"homepage": "https://github.com/dorightdigital/js-config",
"authors": [
"Mat Carey <[email protected]>"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-config",
"version": "1.0.1",
"version": "1.0.2",
"description": "A helper for config management in JS - for any browser, node.js and io.js",
"main": "src/JsConfig.js",
"directories": {
Expand Down
31 changes: 31 additions & 0 deletions spec/usageExamplesSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,37 @@ describe('Usage Examples', function () {
expect(myConfig.get('collection.nothing')).toBe(undefined);
expect(myConfig.get('collection.nothing.this.would.usually.cause.problems')).toBe(undefined);
});

it('should give a node/io example', function () {
var process = {
env: {
MY_OWN_PASSWORD: 'secret',
ONE_OPTIONAL_VALUE: 'abc'
}
},
myConfig = new JsConfig({
someKey: 'someValue',
optionalValueTwo: 'defghi',
collection: {
item: 'a',
thePassword: 'default password'
}
});

expect(myConfig.get('collection.thePassword')).toEqual('default password');

myConfig.readFromObject(process.env, {
collection: {
thePassword: 'MY_OWN_PASSWORD'
},
optionalValueOne: 'ONE_OPTIONAL_VALUE',
optionalValueTwo: 'ANOTHER_OPTIONAL_VALUE'
});

expect(myConfig.get('collection.thePassword')).toEqual('secret');
expect(myConfig.get('optionalValueOne')).toEqual('abc');
expect(myConfig.get('optionalValueTwo')).toEqual('defghi');
});
});

describe('Basic Usage', function () {
Expand Down

0 comments on commit 73fed1e

Please sign in to comment.