Skip to content

Commit

Permalink
Merge ecbb579 into ea1efa6
Browse files Browse the repository at this point in the history
  • Loading branch information
BrainBacon committed Nov 11, 2015
2 parents ea1efa6 + ecbb579 commit b21fc55
Show file tree
Hide file tree
Showing 9 changed files with 328 additions and 56 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<a name="0.2.0"></a>
# [0.2.0](https://github.com/BrainBacon/Nodep/compare/0.1.0...v0.2.0) (2015-11-11)


### Features

* **nodep.js:** add dependency tree analysis ([fcba22a](https://github.com/BrainBacon/Nodep/commit/fcba22a)), closes [#1](https://github.com/BrainBacon/Nodep/issues/1)
* **nodep.js:** glob support for pattern matching ([762a22b](https://github.com/BrainBacon/Nodep/commit/762a22b)), closes [#2](https://github.com/BrainBacon/Nodep/issues/2)


### BREAKING CHANGES

* $p.load has now moved to $p.init



<a name="0.1.0"></a>
# [0.1.0](https://github.com/BrainBacon/Nodep/compare/0.1.0...v0.1.0) (2015-09-23)

Expand Down
76 changes: 68 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ $ npm install --save nodep
```js
var $p = require('nodep')();

$p.load({
$p.init({
myVar: localVariable
}).load([
}).init([
'anNpmPackage',
'./a/nested/local.dependency',
'./a.local.dependency'
Expand All @@ -59,6 +59,24 @@ module.exports = function(localDependency, myVar, anNpmPackage) {
- `./a.local.dependency` becomes `aLocalDependency` is executed and injectable


## Glob pattern matching for directories
### $p.init also supports glob syntax for loading multiple files from a directory or directory tree
- Any file without a `.js` extension will be ignored
- [glob docs and patterns](https://github.com/isaacs/node-glob)

### Example
**index.js**
```js
var $p = require('nodep')();

$p.init('src/*').init([
'anNpmPackage',
'./a/nested/local.dependency',
'glob/patterns/*'
]);
```


## Existing providers
Register other instances of nodep into your project.

Expand Down Expand Up @@ -155,13 +173,17 @@ var $p = require('nodep')();
* [.PATH_REPLACE_RESULT](#module_nodep..$p.PATH_REPLACE_RESULT) : <code>String</code>
* [.REMOVE_COMMENTS_REGEXP](#module_nodep..$p.REMOVE_COMMENTS_REGEXP) : <code>RegExp</code>
* [.REGISTER_TYPE_ERROR_MESSAGE](#module_nodep..$p.REGISTER_TYPE_ERROR_MESSAGE) : <code>String</code>
* [.CIRCULAR_DEPENDENCY_ERROR_MESSAGE](#module_nodep..$p.CIRCULAR_DEPENDENCY_ERROR_MESSAGE) : <code>String</code>
* [.PROVIDER_TYPE_ERROR_MESSAGE](#module_nodep..$p.PROVIDER_TYPE_ERROR_MESSAGE) : <code>String</code>
* [.camelCase(match, $1, offset)](#module_nodep..$p.camelCase) ⇒ <code>String</code>
* [.name(path)](#module_nodep..$p.name) ⇒ <code>String</code>
* [.args(fn)](#module_nodep..$p.args)
* [.applyArgs(name, args)](#module_nodep..$p.applyArgs)
* [.decorator(name, dependency, [skipInject])](#module_nodep..$p.decorator) ⇒ <code>Object</code>
* [.register(path)](#module_nodep..$p.register)
* [.load(paths)](#module_nodep..$p.load) ⇒ <code>Object</code>
* [.easyRegister(path)](#module_nodep..$p.easyRegister) ⇒ <code>Boolean</code>
* [.register(paths)](#module_nodep..$p.register)
* [.resolveFiles(paths)](#module_nodep..$p.resolveFiles) ⇒ <code>Array.&lt;String&gt;</code>
* [.init(paths)](#module_nodep..$p.init) ⇒ <code>Object</code>
* [.provider(instances)](#module_nodep..$p.provider) ⇒ <code>Object</code>
* [.inject(name)](#module_nodep..$p.inject) ⇒ <code>?</code>

Expand Down Expand Up @@ -214,6 +236,11 @@ Expression to remove comments when parsing arguments for a dependency
### $p.REGISTER_TYPE_ERROR_MESSAGE : <code>String</code>
Error message to send when trying to register a non-string type

**Kind**: static constant of <code>[$p](#module_nodep..$p)</code>
<a name="module_nodep..$p.CIRCULAR_DEPENDENCY_ERROR_MESSAGE"></a>
### $p.CIRCULAR_DEPENDENCY_ERROR_MESSAGE : <code>String</code>
Error message to send when a circular reference is detected in the dependency tree

**Kind**: static constant of <code>[$p](#module_nodep..$p)</code>
<a name="module_nodep..$p.PROVIDER_TYPE_ERROR_MESSAGE"></a>
### $p.PROVIDER_TYPE_ERROR_MESSAGE : <code>String</code>
Expand Down Expand Up @@ -254,6 +281,17 @@ Will extract the order and name of injectable arguments in a given function
| --- | --- | --- |
| fn | <code>function</code> | the function to extract injection arguments from |

<a name="module_nodep..$p.applyArgs"></a>
### $p.applyArgs(name, args)
Function to apply args to a new dependency and register it

**Kind**: static method of <code>[$p](#module_nodep..$p)</code>

| Param | Type | Description |
| --- | --- | --- |
| name | <code>String</code> | the name of the new dependency to register |
| args | <code>Array.&lt;String&gt;</code> | the names of args to apply to the new dependeency |

<a name="module_nodep..$p.decorator"></a>
### $p.decorator(name, dependency, [skipInject]) ⇒ <code>Object</code>
Main dependency injection function
Expand Down Expand Up @@ -282,18 +320,40 @@ Dependency Handling:
| dependency | <code>?</code> | a value to assign to this dependency |
| [skipInject] | <code>Boolean</code> | inject into a provided dependency of type function unless true |

<a name="module_nodep..$p.easyRegister"></a>
### $p.easyRegister(path) ⇒ <code>Boolean</code>
Easy dependency test, will register simple dependencies

**Kind**: static method of <code>[$p](#module_nodep..$p)</code>
**Returns**: <code>Boolean</code> - true if register was successful

| Param | Type | Description |
| --- | --- | --- |
| path | <code>String</code> | the name or filepath of a dependency to register to the provider |

<a name="module_nodep..$p.register"></a>
### $p.register(path)
### $p.register(paths)
Default registration function in front of `$p.decorator`

**Kind**: static method of <code>[$p](#module_nodep..$p)</code>

| Param | Type | Description |
| --- | --- | --- |
| path | <code>String</code> | the name or filepath of a dependency to register to the provider |
| paths | <code>String</code> &#124; <code>Array.&lt;String&gt;</code> | the name or filepath of a dependency to register to the provider or an array of the former |

<a name="module_nodep..$p.resolveFiles"></a>
### $p.resolveFiles(paths) ⇒ <code>Array.&lt;String&gt;</code>
Function to normalize glob type paths into file paths omitting any non-js files

**Kind**: static method of <code>[$p](#module_nodep..$p)</code>
**Returns**: <code>Array.&lt;String&gt;</code> - an array with globbed paths normalized and merged with regular paths

| Param | Type | Description |
| --- | --- | --- |
| paths | <code>Array.&lt;String&gt;</code> | file paths and globbed paths |

<a name="module_nodep..$p.load"></a>
### $p.load(paths) ⇒ <code>Object</code>
<a name="module_nodep..$p.init"></a>
### $p.init(paths) ⇒ <code>Object</code>
Load one or more dependencies into the provider
Loading Mechanism:
- All strings in an array loaded into $p will be initialized according to `$p.register`
Expand Down
3 changes: 2 additions & 1 deletion docs.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{#module name="header"~}}{{>body~}}{{/module}}
{{#module name="load"~}}{{>body~}}{{/module}}
{{#module name="init"~}}{{>body~}}{{/module}}
{{#module name="glob"~}}{{>body~}}{{/module}}
{{#module name="provider"~}}{{>body~}}{{/module}}
{{#module name="inject"~}}{{>body~}}{{/module}}
{{#module name="decorator"~}}{{>body~}}{{/module}}
Expand Down

0 comments on commit b21fc55

Please sign in to comment.