<commit_before># Cozy-fixtures
Manage easily the data fixtures for your Cozy developments!

[![Build Status](https://travis-ci.org/mycozycloud/cozy-fixtures.png?branch=master)](https://travis-ci.org/mycozycloud/cozy-fixtures)

# Usage
Please note that the "load" process do the following:

* removing all the data for the concerned doctypes
* adding the fixtures for the concerned doctypes

The "concerned doctypes" are the ones found in the fixture files or the ones you gaves through parameters.

## CLI
When you develop an application you might want to feed the Data System with data.

```bash
npm install -g cozy-fixtures
cozy-fixtures load # will load all the fixtures inside ./tests/fixtures/
cozy-fixtures load ./fixtures/ # you can specify a folder
cozy-fixtures load ./fixtures/my-super-fixtures.json # or a file
cozy-fixtures load -d contact # only load the documents for a specified doctype
cozy-fixtures load -s # run the script quietly
cozy-fixutres -l load # doesn't remove documents before loading
```

## Automatic Tests
You can use cozy-fixtures programatically to ease automatic testing:

* First, add it to your dev dependencies:
```bash
npm install cozy-fixtures --save-dev
```
* Then use it where you need it

```coffeescript
fixtures = require 'cozy-fixtures'
fixtures.load
    dirPath: 'path/to/fixtures' # default is './tests/fixtures/'
    doctypeTarget: 'doctypeName' # default is null
    silent: true # default is false
    removeBeforeLoad: false # default is true. Remove docs for concerned doctypes before loading the data
    callback: yourCallback # default is null
```

You can also do more precise action like:

* deleting all the documents for a specified doctype

```coffeescript
fixtures = require 'cozy-fixtures'
fixtures.removeDocs "doctypeName", (err) ->
    console.log err if err?
```

* deleting all the documents from the database

```coffeescript
fixtures = require 'cozy-fixtures'
    fixtures.resetDatabase
        callback: (err) -> console.log err if err?
        designsToRemove: true # default is false, removes all the design docs in the database (and related) views
```

If you want to have the same configuration for every call, use the setDefaultValues method:

```coffeescript
fixtures = require 'cozy-fixtures'
fixtures.setDefautValues
            target: './a/custom/target.json'
            silent: true
            removeBeforeLoad: false
fixtures.load callback: (err) -> console.log "fixtures loaded !"
```

You can still override the defautl values by passing the arguments to the load function.


# How to format the fixtures
* You must put the fixtures into files
* Fixtures must be described in valid JSON
* Don't forget the "docType" field in the fixtures

A simple example:
```json
[
    {
        "docType": "Alarm",
        "action": "DISPLAY",
        "trigg": "Tue Jul 02 2013 16:00:00",
        "description": "Réunion review scopyleft",
        "related": null
    },
    {
        "docType": "Contact",
        "fn": "<NAME>",
        "datapoints": [
            {
                "name": "about",
                "type": "birthday",
                "value": "02/02/1980",
                "id": 1
            },
            {
                "name": "tel",
                "type": "main",
                "value": "+33 12 34 56 78",
                "id": 2
            }
        ],
        "note": "Données complémentaires sur le contact."
    },
    {
        "_id": "2",
        "docType": "File",
        "_attachments": "tests/fixtures/files/fixtures.json",
        "class": "document",
        "lastModification": "Thu Oct 17 2013 08:29:21 GMT+0200 (CEST)",
        "name": "fixtures.json",
        "path": "",
        "size": 2413
    }
}
]
```
Note that you can add files as attachments. In order to achieve this, add a "_attachments" field to your fixture and put the path relatively to where you run the command.

<commit_msg>add Cozy infos to README<commit_after># Cozy-fixtures
Manage easily the data fixtures for your Cozy developments!

[![Build Status](https://travis-ci.org/mycozycloud/cozy-fixtures.png?branch=master)](https://travis-ci.org/mycozycloud/cozy-fixtures)

# Usage
Please note that the "load" process do the following:

* removing all the data for the concerned doctypes
* adding the fixtures for the concerned doctypes

The "concerned doctypes" are the ones found in the fixture files or the ones you gaves through parameters.

## CLI
When you develop an application you might want to feed the Data System with data.

```bash
npm install -g cozy-fixtures
cozy-fixtures load # will load all the fixtures inside ./tests/fixtures/
cozy-fixtures load ./fixtures/ # you can specify a folder
cozy-fixtures load ./fixtures/my-super-fixtures.json # or a file
cozy-fixtures load -d contact # only load the documents for a specified doctype
cozy-fixtures load -s # run the script quietly
cozy-fixutres -l load # doesn't remove documents before loading
```

## Automatic Tests
You can use cozy-fixtures programatically to ease automatic testing:

* First, add it to your dev dependencies:
```bash
npm install cozy-fixtures --save-dev
```
* Then use it where you need it

```coffeescript
fixtures = require 'cozy-fixtures'
fixtures.load
    dirPath: 'path/to/fixtures' # default is './tests/fixtures/'
    doctypeTarget: 'doctypeName' # default is null
    silent: true # default is false
    removeBeforeLoad: false # default is true. Remove docs for concerned doctypes before loading the data
    callback: yourCallback # default is null
```

You can also do more precise action like:

* deleting all the documents for a specified doctype

```coffeescript
fixtures = require 'cozy-fixtures'
fixtures.removeDocs "doctypeName", (err) ->
    console.log err if err?
```

* deleting all the documents from the database

```coffeescript
fixtures = require 'cozy-fixtures'
    fixtures.resetDatabase
        callback: (err) -> console.log err if err?
        designsToRemove: true # default is false, removes all the design docs in the database (and related) views
```

If you want to have the same configuration for every call, use the setDefaultValues method:

```coffeescript
fixtures = require 'cozy-fixtures'
fixtures.setDefautValues
            target: './a/custom/target.json'
            silent: true
            removeBeforeLoad: false
fixtures.load callback: (err) -> console.log "fixtures loaded !"
```

You can still override the defautl values by passing the arguments to the load function.


# How to format the fixtures
* You must put the fixtures into files
* Fixtures must be described in valid JSON
* Don't forget the "docType" field in the fixtures

A simple example:
```json
[
    {
        "docType": "Alarm",
        "action": "DISPLAY",
        "trigg": "Tue Jul 02 2013 16:00:00",
        "description": "Réunion review scopyleft",
        "related": null
    },
    {
        "docType": "Contact",
        "fn": "<NAME>",
        "datapoints": [
            {
                "name": "about",
                "type": "birthday",
                "value": "02/02/1980",
                "id": 1
            },
            {
                "name": "tel",
                "type": "main",
                "value": "+33 12 34 56 78",
                "id": 2
            }
        ],
        "note": "Données complémentaires sur le contact."
    },
    {
        "_id": "2",
        "docType": "File",
        "_attachments": "tests/fixtures/files/fixtures.json",
        "class": "document",
        "lastModification": "Thu Oct 17 2013 08:29:21 GMT+0200 (CEST)",
        "name": "fixtures.json",
        "path": "",
        "size": 2413
    }
}
]
```
Note that you can add files as attachments. In order to achieve this, add a "_attachments" field to your fixture and put the path relatively to where you run the command.


## What is Cozy?

![Cozy Logo](https://raw.github.com/mycozycloud/cozy-setup/gh-pages/assets/images/happycloud.png)

[Cozy](http://cozy.io) is a platform that brings all your web services in the
same private space.  With it, your web apps and your devices can share data
easily, providing you with a new experience. You can install Cozy on your own
hardware where no one profiles you. 

## Community 

You can reach the Cozy Community by:

* Chatting with us on IRC #cozycloud on irc.freenode.net
* Posting on our [Forum](https://groups.google.com/forum/?fromgroups#!forum/cozy-cloud)
* Posting issues on the [Github repos](https://github.com/mycozycloud/)
* Mentioning us on [Twitter](http://twitter.com/mycozycloud)

{'fraction_non_alphanumeric': 0.10409356725146199, 'fraction_numerical': 0.01239766081871345, 'mean_word_length': 2.924277191372189, 'pattern_counts': {'":': 50, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 7, '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': '430984', 'n_tokens_mistral': 2667, 'n_tokens_neox': 2462, 'n_words': 953}