<commit_before>[![Build Status](https://secure.travis-ci.org/Afmrak/stubby4node.png?branch=master)](http://travis-ci.org/Afmrak/stubby4node)

# Installation

## via npm

    npm install -g stubby

This will install `stubby` as a command in your `PATH`. Leave off the `-g` flag if you'd like to use stubby as an embedded module in your project.

## via source

You need to have `coffee-script` installed on your system.

    git clone git://github.com/Afmrak/stubby4node.git
    cd stubby4node
    coffee -o lib -c src
    export PATH=$PATH:<pwd>/bin/stubby

# Requirements

* [node.js](http://nodejs.org/) (tested with v0.8.x)

Development is on Mac OS X Mountain Lion.

## Packaged

* [JS-YAML](https://github.com/nodeca/js-yaml) for loading yaml files
* [cloneextend](https://github.com/shimondoodkin/nodejs-clone-extend)

## Optional (for development)

* [coffee-script](http://coffeescript.org)
* [node-inspector](https://github.com/dannycoates/node-inspector)
* [jasmine-node](https://github.com/mhevery/jasmine-node)

# Starting the Server(s)

Some systems require you to `sudo` before running services on port certain ports (like 80)

    [sudo] stubby

# Command-line switches

```
stubby [-a <port>] [-c <file>] [-d <file>] [-h] [-k <file>] [-l <hostname>] [-m] [-p <file>]
       [-s <port>] [-t <port>] [-v] [-w]

-a, --admin <port>          Port for admin portal. Defaults to 8889.
-c, --cert <file>           Certificate file. Use with --key.
-d, --data <file>           Data file to pre-load endoints. YAML or JSON format.
-h, --help                  This help text.
-k, --key <file>            Private key file. Use with --cert.
-l, --location <hostname>   Hostname at which to bind stubby.
-m, --mute                  Prevent stubby from printing to the console.
-p, --pfx <file>            PFX file. Ignored if used with --key/--cert
-s, --stubs <port>          Port for stubs portal. Defaults to 8882.
-t, --tls <port>            Port for https stubs portal. Defaults to 7443.
-v, --version               Prints stubby's version number.
-w, --watch                 Auto-reload data file when edits are made.
```<commit_msg>added TOC to readme<commit_after>[![Build Status](https://secure.travis-ci.org/Afmrak/stubby4node.png?branch=master)](http://travis-ci.org/Afmrak/stubby4node)

* [Installation](#installation)
    * [via npm](#via-npm)
    * [via source](#via-source)
* [Requirements](#requirements)
    * [Packaged](#packaged)
    * [Optional (for development)](#optional-for-development)
* [Starting the Server(s)](#starting-the-servers)
* [Command-line Switches](#command-line-switches)
* [The Admin Portal](#the-admin-portal)
    * [Supplying Endpoints to Stubby](#supplying-endpoints-to-stubby)
        * [YAML (file only)](#yaml-file-only)
        * [JSON (file or POST/PUT)](#json-file-or-postput)
    * [Getting the Current List of Stubbed Endpoints](#getting-the-current-list-of-stubbed-endpoints)
    * [Changing Existing Endpoints](#changing-existing-endpoints)
    * [Deleting Endpoints](#deleting-endpoints)
* [The Stubs Portal](#the-stubs-portal)
    * [How Endpoints Are Matched](#how-endpoints-are-matched)
* [Programmatic API](#programmatic-api)
    * [The Stubby Module](#the-stubby-module)
        * [start(options, [callback])](#startoptions-callback)
        * [stop([callback])](#stopcallback)
        * [get(id, callback)](#getid-callback)
        * [get(callback)](#getcallback)
        * [post(data, [callback])](#postdata-callback)
        * [put(id, data, [callback])](#putid-data-callback)
        * [delete([id], callback)](#deleteid-callback)
        * [Example (coffeescript)](#example-coffeescript)
* [Running Tests](#running-tests)
* [See Also](#see-also)
* [TODO](#todo)
* [Wishful Thinkings](#wishful-thinkings)
* [NOTES](#notes)

# Installation

## via npm

    npm install -g stubby

This will install `stubby` as a command in your `PATH`. Leave off the `-g` flag if you'd like to use stubby as an embedded module in your project.

## via source

You need to have `coffee-script` installed on your system.

    git clone git://github.com/Afmrak/stubby4node.git
    cd stubby4node
    coffee -o lib -c src
    export PATH=$PATH:<pwd>/bin/stubby

# Requirements

* [node.js](http://nodejs.org/) (tested with v0.8.x)

Development is on Mac OS X Mountain Lion.

## Packaged

* [JS-YAML](https://github.com/nodeca/js-yaml) for loading yaml files
* [cloneextend](https://github.com/shimondoodkin/nodejs-clone-extend)

## Optional (for development)

* [coffee-script](http://coffeescript.org)
* [node-inspector](https://github.com/dannycoates/node-inspector)
* [jasmine-node](https://github.com/mhevery/jasmine-node)

# Starting the Server(s)

Some systems require you to `sudo` before running services on port certain ports (like 80)

    [sudo] stubby

# Command-line Switches

```
stubby [-a <port>] [-c <file>] [-d <file>] [-h] [-k <file>] [-l <hostname>] [-m] [-p <file>]
       [-s <port>] [-t <port>] [-v] [-w]

-a, --admin <port>          Port for admin portal. Defaults to 8889.
-c, --cert <file>           Certificate file. Use with --key.
-d, --data <file>           Data file to pre-load endoints. YAML or JSON format.
-h, --help                  This help text.
-k, --key <file>            Private key file. Use with --cert.
-l, --location <hostname>   Hostname at which to bind stubby.
-m, --mute                  Prevent stubby from printing to the console.
-p, --pfx <file>            PFX file. Ignored if used with --key/--cert
-s, --stubs <port>          Port for stubs portal. Defaults to 8882.
-t, --tls <port>            Port for https stubs portal. Defaults to 7443.
-v, --version               Prints stubby's version number.
-w, --watch                 Auto-reload data file when edits are made.
```
{'fraction_non_alphanumeric': 0.1570290858725762, 'fraction_numerical': 0.006925207756232687, 'mean_word_length': 2.96771978021978, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7498603', 'n_tokens_mistral': 2040, 'n_tokens_neox': 1915, 'n_words': 553}