From e26bbe25f275b844122dfd3f783387ec484f9aab Mon Sep 17 00:00:00 2001 From: indexzero Date: Thu, 19 May 2011 23:12:56 -0400 Subject: [PATCH] [doc] Updated code samples for GitHub flavored markdown with Javascript --- README.md | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 1d1491f..bb32029 100644 --- a/README.md +++ b/README.md @@ -5,19 +5,19 @@ A hybrid local / remote configuration storage library for node.js. ## Installation ### Installing npm (node package manager) -
+```
   curl http://npmjs.org/install.sh | sh
-
+``` ### Installing nconf -
+```
   [sudo] npm install nconf
-
+``` ## Usage Using nconf is easy; it is designed to be a simple key-value store with support for both local and remote storage. Keys are namespaced and delimited by `:`. Lets dive right into sample usage: -
+``` js
   var fs    = require('fs'),
       nconf = require('nconf');
   
@@ -41,44 +41,47 @@ Using nconf is easy; it is designed to be a simple key-value store with support
       console.dir(JSON.parse(data.toString()))
     });
   });
-
+``` ## Storage Engines ### Memory A simple in-memory storage engine that stores a nested JSON representation of the configuration. To use this engine, just call `.use()` with the appropriate arguments. All calls to `.get()`, `.set()`, `.clear()`, `.reset()` methods are synchronous since we are only dealing with an in-memory object. -
+
+``` js 
   nconf.use('memory');
-
+``` ### File Based on the Memory engine, but provides additional methods `.save()` and `.load()` which allow you to read your configuration to and from file. As with the Memory store, all method calls are synchronous with the exception of `.save()` and `.load()` which take callback functions. It is important to note that setting keys in the File engine will not be persisted to disk until a call to `.save()` is made. -
+``` js
   nconf.use('file', { file: 'path/to/your/config.json' });
-
+``` The file store is also extensible for multiple file formats, defaulting to `JSON`. To use a custom format, simply pass a format object to the `.use()` method. This object must have `.parse()` and `.stringify()` methods just like the native `JSON` object. ### Redis The Redis engine will persist all of your configuration settings to a Redis server. All calls to `.get()`, `.set()`, `.clear()`, `.reset()` are asynchronous taking an additional callback parameter. -
+``` js
   nconf.use('redis', { host: 'localhost', port: 6379, ttl: 60 * 60 * 1000 });
-
+``` The Redis engine also has an in-memory cache with a default TTL of one hour. To change this, just pass the `ttl` option to `.use()`. ## More Documentation There is more documentation available through docco. I haven't gotten around to making a gh-pages branch so in the meantime if you clone the repository you can view the docs: -
+
+```
   open docs/nconf.html
-
+``` ## Run Tests Tests are written in vows and give complete coverage of all APIs and storage engines. -
+
+```
   vows test/*-test.js --spec
-
+``` #### Author: [Charlie Robbins](http://nodejitsu.com) \ No newline at end of file