<commit_before>CronJobManager
==============

A node-cron wrapper that manages many jobs at once. This is built using of [<NAME>'s node-cron fork](https://github.com/ncb000gt/node-cron).

Installation
=============
```bash
npm install cron-job-manager
```
Synopsis
============
```javascript
var CronJobManager = require('cron-job-manager'),
manager = new CronJobManager( // this creates a new manager and adds the arguments as a new job.
'a_key_string_to_call_this_job',
'0 30 * * * *', // the crontab schedule
function() { console.log("tick - what should be executed?") },
{
// extra options.. 
// see https://github.com/ncb000gt/node-cron/blob/master/README.md for all available
  start:true,
  timeZone:"America/Los_Angeles",
  completion: function() {console.log("a_key_string_to_call_this_job has stopped....")}
} 
);
manager.add('next_job', '0 40 * * * *', function() { console.log('tick...')});
manager.start('next_job');
manager.stop('a_key_string_to_call_this_job');
manager.exists('next_job') //true
manger.update('a_key_string_to_call_this_job', 
  "0 */2 * * * *", 
  function() {console.log("now running this job every two minutes, using this function..."});
console.log("current jobs are: " + manager);
```
Create a Manager
===
creating a manager object is easy, you can create one with arguments that become a new job, or just create one to add jobs to later:
```javascript
var manager1 = new CronJobManager('a key to identify the job', 
  '30 * * * * *', 
  taskFunction,
  {
    start: true, 
    completion: taskCompleteFunction, 
    timeZone:"Australia/Sydney"
  }),
manager2 = new CronJobManager();
```
the final options object is optional, these are options that are past to node-cron and they include the following:
  * start: true/false
  * completion: function - runs when the job is stopped
  * timeZone: MUST have time installed for this work - see [the node-cron readme](https://github.com/ncb000gt/node-cron/blob/master/README.md) for more details.

Adding jobs
===
jobs are added with arguments similar to the above with the *add* function:
```javascript
manager.add('key','* 30 * * * *', taskFunction)
```
in this case with the final options object left out of the arguments, the job will be created with the defaults as per node-cron, this means the job will not start until you tell it to, there will be no completion function and the time zone  will default to whatever you have your node.js process to use. 

If the key you are using already exits in the manager, that key will be overwriten, the original job will stop and this one will  take its place. A warning will be printed to the log when this happens.

Starting Jobs
===
To start a job you can use the *start* function
```javasctipt
manager.start('key')
```
Stopping Jobs
===
Stopping is the same as start with the *stop* function
```javascript<commit_msg>needed to change the onComplete key for cron options<commit_after>CronJobManager
==============

A node-cron wrapper that manages many jobs at once. This is built using of [Nick Campbell's node-cron fork](https://github.com/ncb000gt/node-cron).

Installation
=============
```bash
npm install cron-job-manager
```
Synopsis
============
```javascript
var CronJobManager = require('cron-job-manager'),
manager = new CronJobManager( // this creates a new manager and adds the arguments as a new job.
'a_key_string_to_call_this_job',
'0 30 * * * *', // the crontab schedule
function() { console.log("tick - what should be executed?") },
{
// extra options.. 
// see https://github.com/ncb000gt/node-cron/blob/master/README.md for all available
  start:true,
  timeZone:"America/Los_Angeles",
  completion: function() {console.log("a_key_string_to_call_this_job has stopped....")}
} 
);
manager.add('next_job', '0 40 * * * *', function() { console.log('tick...')});
manager.start('next_job');
manager.stop('a_key_string_to_call_this_job');
manager.exists('next_job') //true
manger.update('a_key_string_to_call_this_job', 
  "0 */2 * * * *", 
  function() {console.log("now running this job every two minutes, using this function..."});
console.log("current jobs are: " + manager);
```
Create a Manager
===
creating a manager object is easy, you can create one with arguments that become a new job, or just create one to add jobs to later:
```javascript
var manager1 = new CronJobManager('a key to identify the job', 
  '30 * * * * *', 
  taskFunction,
  {
    start: true, 
    onComplete: taskCompleteFunction, 
    timeZone:"Australia/Sydney"
  }),
manager2 = new CronJobManager();
```
the final options object is optional, these are options that are past to node-cron and they include the following:
  * start: true/false
  * onComplete: function - runs when the job is stopped
  * timeZone: MUST have time installed for this work - see [the node-cron readme](https://github.com/ncb000gt/node-cron/blob/master/README.md) for more details.

Adding jobs
===
jobs are added with arguments similar to the above with the *add* function:
```javascript
manager.add('key','* 30 * * * *', taskFunction)
```
in this case with the final options object left out of the arguments, the job will be created with the defaults as per node-cron, this means the job will not start until you tell it to, there will be no completion function and the time zone  will default to whatever you have your node.js process to use. 

If the key you are using already exits in the manager, that key will be overwriten, the original job will stop and this one will  take its place. A warning will be printed to the log when this happens.

Starting Jobs
===
To start a job you can use the *start* function
```javasctipt
manager.start('key')
```
Stopping Jobs
===
Stopping is the same as start with the *stop* function
```javascript
{'fraction_non_alphanumeric': 0.1266527487821851, 'fraction_numerical': 0.008002783576896311, 'mean_word_length': 4.433837429111531, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 6, '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': '4056116', 'n_tokens_mistral': 1775, 'n_tokens_neox': 1667, 'n_words': 672}