Skip to content

Commit

Permalink
[UPDATE] lib, tests, examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
kgryte committed Sep 18, 2014
1 parent de01387 commit 21c5f4c
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 34 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ doc-metrix-disk
===
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Dependencies][dependencies-image]][dependencies-url]

Provides an API for doc-metrix disk performance metrics.
Provides an API for doc-metrix [disk](https://github.com/doc-metrix/disk) performance metrics.


## Installation
Expand All @@ -16,10 +16,10 @@ For use in the browser, use [browserify](https://github.com/substack/node-browse

## Usage

To interface with the [specification](https://github.com/doc-metrix/INSERT_NAME),
To interface with the disk [specification](https://github.com/doc-metrix/disk),

``` javascript
var metrics = require( 'doc-metrix-NAME' );
var metrics = require( 'doc-metrix-disk' );
```

The interface has the following methods...
Expand All @@ -35,10 +35,10 @@ Metric centric methods...
Checks whether a metric having the provided `name` is included in the specification.

``` javascript
metrics.mexists( '' );
metrics.mexists( 'disk.ioInProgress' );
// returns true

metrics.mexists( '' );
metrics.mexists( 'cpu.utilization' );
// returns false
```

Expand All @@ -60,7 +60,7 @@ metrics.mlist();
Lists all metrics satisfying a regular expression filter.

``` javascript
metrics.mfilter( /.+/i );
metrics.mfilter( /Reads/i );
```

Note: filtering for metric names __is__ case sensitive. Ignore case `/i` for case insensitive filtering.
Expand All @@ -71,17 +71,17 @@ Note: filtering for metric names __is__ case sensitive. Ignore case `/i` for cas
Returns metric specifications. The provided `filter` may be a `string` or a regular expression. If a metric does not have a specification, returns `null`. To return a single specification,

``` javascript
metrics.mget( '' );
metrics.mget( 'disk.ioInProgress' );
// returns {...}

metrics.mget( '' );
metrics.mget( 'cpu.utilization' );
// returns null
```

To return metric specifications matching a filter,

``` javascript
metrics.mget( /.+/i );
metrics.mget( /Reads/i );
// returns {...}
```

Expand All @@ -107,10 +107,10 @@ Device centric methods...
Checks whether a device having the provided `name` is known to have associated metric specifications.

``` javascript
metrics.dexists( '' );
metrics.dexists( 'dm-0' );
// returns true

metrics.dexists( '' );
metrics.dexists( 'cpu0' );
// returns false
```

Expand All @@ -131,10 +131,10 @@ Note: the returned list __may__ contain regular expressions. Regular expressions
Returns specifications associated with devices. If a device does not have associated specifications, returns `null`. To return a single device's specifications,

``` javascript
metrics.dget( '' );
metrics.dget( 'dm-0' );
// returns {"metric0":{...},"metric1":{...},...}

metrics.dget( '' );
metrics.dget( 'cpu0' );
// returns null
```

Expand Down Expand Up @@ -166,7 +166,7 @@ $ npm install
$ npm update
```

this package, when used as a dependency, will attempt an HTTP request to retrieve the latest specification from [Github](https://github.com/doc-metrix/INSERT_NAME).
this package, when used as a dependency, will attempt an HTTP request to retrieve the latest specification from [Github](https://github.com/doc-metrix/disk).

During development, run the following command to retrieve the latest specification

Expand Down Expand Up @@ -211,7 +211,7 @@ $ open reports/coverage/lcov-report/index.html
---
## Copyright

Copyright © 2014. Athan Reines.
Copyright © 2014. NodePrime.


[npm-image]: http://img.shields.io/npm/v/doc-metrix-disk.svg
Expand Down
16 changes: 8 additions & 8 deletions examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
// SCRIPT //

// Check if a metric exists:
console.log( metrics.mexists( '' ) );
console.log( metrics.mexists( 'disk.ioInProgress' ) );

/**
* Returns:
* true
*/

console.log( metrics.mexists( '' ) );
console.log( metrics.mexists( 'cpu.utilization' ) );

/**
* Returns:
Expand All @@ -65,7 +65,7 @@
*/

// Filter the list of metrics:
console.log( metrics.mfilter( /.+/i ) );
console.log( metrics.mfilter( /Reads/i ) );

/**
* Returns:
Expand All @@ -78,7 +78,7 @@
*/

// Get a metric specification:
console.log( metrics.mget( '' ) );
console.log( metrics.mget( 'disk.ioInProgress' ) );

/**
* Returns:
Expand All @@ -90,7 +90,7 @@
*/

// Get metric specifications matching a filter:
console.log( metrics.mget( /.+/i ) );
console.log( metrics.mget( /Reads/i ) );

/**
* Returns:
Expand All @@ -110,14 +110,14 @@
*/

// Check if a device is known to have associated metrics:
console.log( metrics.dexists( '' ) );
console.log( metrics.dexists( 'dm-0' ) );

/**
* Returns:
* true
*/

console.log( metrics.dexists( '' ) );
console.log( metrics.dexists( 'cpu0' ) );

/**
* Returns:
Expand All @@ -138,7 +138,7 @@
*/

// Get a list of metric specifications arranged by device name:
console.log( metrics.dget( '' ) );
console.log( metrics.dget( 'dm-0' ) );

/**
* Returns:
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

// SPECIFICATIONS //

var METRICS = require( '' );
var METRICS = require( './../specs/disk.json' );


// VARIABLES //
Expand Down
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@
"url": "git://github.com/doc-metrix/disk-node.git"
},
"keywords": [
"doc-metrix"
"doc-metrix",
"performance metrics",
"metrics",
"documentation",
"specification",
"spec",
"disk",
"nodeprime"
],
"bugs": {
"url": "https://github.com/doc-metrix/disk-node/issues"
Expand Down
4 changes: 3 additions & 1 deletion scripts/specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@

// SPECIFICATIONS //

var resources = {};
var resources = {
'disk': 'https://raw.githubusercontent.com/doc-metrix/disk/master/spec/index.json'
};


// VARIABLES //
Expand Down
16 changes: 8 additions & 8 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var // Expectation library:
chai = require( 'chai' ),

// Metrics specification:
METRICS = require( '' ),
METRICS = require( './../specs/disk.json' ),

// Module to be tested:
metrics = require( './../lib' );
Expand Down Expand Up @@ -71,7 +71,7 @@ describe( 'doc-metrix-disk', function tests() {
});

it( 'should filter documented metric names', function test() {
assert.isArray( metrics.mfilter( /.+/i ) );
assert.isArray( metrics.mfilter( /Reads/i ) );
});

});
Expand Down Expand Up @@ -165,7 +165,7 @@ describe( 'doc-metrix-disk', function tests() {
});

it( 'should return a filtered list of metric specifications', function test() {
assert.isObject( metrics.mget( /.+/i ) );
assert.isObject( metrics.mget( /Reads/i ) );
});

it( 'should return null if no metrics match a provided filter', function test() {
Expand All @@ -187,7 +187,7 @@ describe( 'doc-metrix-disk', function tests() {
it( 'should list all devices associated with metrics', function test() {
var list = metrics.dlist();
assert.isArray( list );
assert.ok( list.indexOf( '' ) !== -1 );
assert.ok( list.indexOf( 'dm-\\d+' ) !== -1 );
});

});
Expand Down Expand Up @@ -226,11 +226,11 @@ describe( 'doc-metrix-disk', function tests() {
});

it( 'should return true for a device which has associated specifications', function test() {
assert.ok( metrics.dexists( '' ) );
assert.ok( metrics.dexists( 'dm-0' ) );
});

it( 'should return true for a device which has an associated specification regardless of input name case', function test() {
assert.ok( metrics.dexists( '' ) );
assert.ok( metrics.dexists( 'dM-0' ) );
});

});
Expand Down Expand Up @@ -269,7 +269,7 @@ describe( 'doc-metrix-disk', function tests() {
});

it( 'should return metric specification(s) associated with a device', function test() {
var obj = metrics.dget( '' );
var obj = metrics.dget( 'dm-0' );
assert.isObject( obj );
assert.ok( Object.keys( obj ).length );
});
Expand All @@ -281,7 +281,7 @@ describe( 'doc-metrix-disk', function tests() {
});

it( 'should return metric specification(s) associated with a device regardless of input device case', function test() {
var obj = metrics.dget( '' );
var obj = metrics.dget( 'dM-0' );
assert.isObject( obj );
assert.ok( Object.keys( obj ).length );
});
Expand Down

0 comments on commit 21c5f4c

Please sign in to comment.