<commit_before>![Graceland](https://github.com/qtpeters/graceland/blob/master/wiki/images/GracelandGuitar_vectorized.png)

Welcome to Graceland, a dependency injection framework with soul for node.js.  Here we have a simple, pleasent syntax to make your code testable and truly modular! No more faking out require() 
to inject mock code into your tests, Graceland takes the funk out of your testing and puts the soul in! <commit_msg>Updating the README to include examples<commit_after>## Graceland Dependency Injection Framework
![Graceland](https://github.com/qtpeters/graceland/blob/master/wiki/images/GracelandGuitar_vectorized.png)
### Installing the library

In order to install this library you need to install dependencies with:

    npm install graceland --save-dev

### Adding Graceland to your project 

Require Graceland register a library and a factory, start Graceland and use your api:
```
var graceland = require( 'graceland' );

graceland.register({
   id: 'fs',
   lib: require( 'fs' );
});

graceland.register({
   id: 'myFactory',
   factory: function( fs ) {

      // Do something with fs 
      function _doImportantFileSystemThing() {
         ...
      }

      return {
         doFsThing: _doImportantFileSystemThing
      }
   }
});

// Start Graceland
graceland.start();

// Get your factory
var myFactory = graceland.get( 'myFactory' );

// Do important file system thing
myFactory.doFsThing();

```

### Why this is better

#### Unit Testing

Unit tests are hard enough to write, injecting libraries into your code makes mocking a lot easier.

```
var graceland = require( 'graceland' );

graceland.register({
   id: 'fs',
   lib: jasmine.createSpyObj( "mockFs", [ "readdir" ] );
});

graceland.register({
   id: 'myFactory',
   factory: require( "myFactory" )
});

describe( "Testing myFactory", function() {

   it( "Will use the injected file system library", function() {
      graceland.get( 'myFactory' ).doFsThing();
      expect( graceland.get( 'fs' ).readdir ).toHaveBeenCalled();
   });

});
```
Using Graceland, one can avoid re-defining require or doing other shifty things to test their code.  


### Running tests

To run a test suite execute:

    grunt

{'fraction_non_alphanumeric': 0.11136363636363636, 'fraction_numerical': 0.0, 'mean_word_length': 3.8267543859649122, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3763886', 'n_tokens_mistral': 696, 'n_tokens_neox': 660, 'n_words': 228}