confidence
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -118,3 +118,3 @@ // Load modules | ||
if (!filter.match(/^\w+$/)) { | ||
if (!filter.match(/^\w+(?:\.\w+)*$/)) { | ||
return error('Invalid filter value ' + node[key]); | ||
@@ -252,3 +252,3 @@ } | ||
var filter = node.$filter; | ||
var criterion = criteria[filter]; | ||
var criterion = Hoek.reach(criteria, filter); | ||
@@ -255,0 +255,0 @@ if (criterion) { |
{ | ||
"name": "confidence", | ||
"description": "Configuration API", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"author": "Eran Hammer <eran@hueniverse.com> (http://hueniverse.com)", | ||
@@ -6,0 +6,0 @@ "repository": "git://github.com/spumko/confidence", |
<a href="https://github.com/spumko"><img src="https://raw.github.com/spumko/spumko/master/images/from.png" align="right" /></a> | ||
![confidence Logo](https://raw.github.com/spumko/con/master/images/confidence.png) | ||
Configuration format, API, and A/B testing | ||
**Confidence** is a configuration document format, an API, and a foundation for A/B testing. The configuration format is designed to | ||
work with any existing JSON-based configuration, serving values based on object path ('/a/b/c' translates to `a.b.c`). In addition, | ||
**confidence** defines special $-prefixed keys used to filter values for a given criteria. | ||
## Example | ||
```json | ||
{ | ||
"key1": "abc", | ||
"key2": { | ||
"$filter": "env", | ||
"production": { | ||
"deeper": "value" | ||
}, | ||
"$default": { | ||
"$filter": "platform", | ||
"android": 0, | ||
"ios": 1, | ||
"$default": 2 | ||
} | ||
}, | ||
"key3": { | ||
"sub1": 123, | ||
"sub2": { | ||
"$filter": "xfactor", | ||
"yes": 6 | ||
} | ||
}, | ||
"ab": { | ||
"$filter": "random.1", | ||
"$range": [ | ||
{ "limit": 10, "value": 4 }, | ||
{ "limit": 20, "value": 5 } | ||
], | ||
"$default": 6 | ||
} | ||
} | ||
``` | ||
Without any criteria applied, the above configuration document will result in the following: | ||
```json | ||
{ | ||
"key1": "abc", | ||
"key2": 2 | ||
"key3": { | ||
"sub1": 123 | ||
}, | ||
"ab": 6 | ||
} | ||
``` | ||
With the following criteria applied: | ||
```json | ||
{ | ||
"env": "production", | ||
"platform": "ios", | ||
"xfactor": "yes", | ||
"random": { | ||
"1": 15 | ||
} | ||
} | ||
``` | ||
The result is: | ||
```json | ||
{ | ||
"key1": "abc", | ||
"key2": { | ||
"deeper": "value" | ||
}, | ||
"key3": { | ||
"sub1": 123, | ||
"sub2": 6 | ||
}, | ||
"ab": 5 | ||
} | ||
``` | ||
[![Build Status](https://secure.travis-ci.org/spumko/confidence.png)](http://travis-ci.org/spumko/confidence) | ||
@@ -53,3 +53,3 @@ // Load modules | ||
// Range | ||
$filter: 'group1', | ||
$filter: 'random.1', | ||
$range: [ | ||
@@ -91,7 +91,7 @@ { limit: 10, value: 4 }, | ||
get('/', { key1: 'abc', key2: 2, key3: { sub1: 123 }, ab: 6 }, null, 2); | ||
get('/ab', 4, { group1: 9 }); | ||
get('/ab', 4, { group1: 10 }); | ||
get('/ab', 5, { group1: 11 }); | ||
get('/ab', 5, { group1: 19 }); | ||
get('/ab', 6, { group1: 29 }); | ||
get('/ab', 4, { random: { 1: 9 } }); | ||
get('/ab', 4, { random: { 1: 10 } }); | ||
get('/ab', 5, { random: { 1: 11 } }); | ||
get('/ab', 5, { random: { 1: 19 } }); | ||
get('/ab', 6, { random: { 1: 29 } }); | ||
}); | ||
@@ -98,0 +98,0 @@ |
66659
89