<commit_before>****************
NoSQL Versioning
****************

A Python library for NoSQL record versioning.

Installation
============

To install the latest release on `PyPi <https://pypi.python.org/pypi/nosql_versioning>`_,
simply run:

::

  pip install nosql_versioning

Or to install the latest development version, run:

::

  git clone https://github.com/xinhuang/nosql_versioning.git
  cd nosql_versioning
  python setup.py install

Quick Tutorial
==============

.. code:: pycon

  >>> from nosql_versioning import database
  >>> import json
  >>>
  >>> version, Record = database(decode=json.loads)
  >>>
  >>> @version()
  >>> class Recordv0(object):
  >>>     def __init__(self, data):
  >>>         self.old_name = data['old_name']
  >>>
  >>> @version(1)
  >>> class Recordv1(object):
  >>>     def __init__(self, data=None, value=None):
  >>>         if data:
  >>>             self.new_name = data['new_name']
  >>>         else:
  >>>             self.new_name = value
  >>>
  >>>     @staticmethod
  >>>     def migrate(data):
  >>>         data['new_name'] = data['old_name']
  >>>         del data['old_name']
  >>>
  >>> rec = Record('{"_ver": 0, "old_name": 1}')
  >>> print(rec.new_name)
  1
  >>> rec = Record(value=42)         # custom constructor can also be used
  >>> print(rec.new_name)
  42


API Reference
=============

``database(decode=None, version=None)``

  :Args:
    * ``decode``: Deserialize objects retrieved from database. By default no decoding will be applied.
    * ``version``: Get version from record. By default it's ``data.get('_ver')``

  :Returns:
    * ``version``: A class descriptor to specify record version.
    * ``Record``: A initializer that to construct defined Record class. Migrate if data is not the latest version.
<commit_msg>[doc] update API reference<commit_after>****************
NoSQL Versioning
****************

A Python library for NoSQL record versioning.

Installation
============

To install the latest release on `PyPi <https://pypi.python.org/pypi/nosql_versioning>`_,
simply run:

::

  pip install nosql_versioning

Or to install the latest development version, run:

::

  git clone https://github.com/xinhuang/nosql_versioning.git
  cd nosql_versioning
  python setup.py install

Quick Tutorial
==============

.. code:: pycon

  >>> from nosql_versioning import database
  >>> import json
  >>>
  >>> version, Record = database(decode=json.loads)
  >>>
  >>> @version()
  >>> class Recordv0(object):
  >>>     def __init__(self, data):
  >>>         self.old_name = data['old_name']
  >>>
  >>> @version(1)
  >>> class Recordv1(object):
  >>>     def __init__(self, data=None, value=None):
  >>>         if data:
  >>>             self.new_name = data['new_name']
  >>>         else:
  >>>             self.new_name = value
  >>>
  >>>     @staticmethod
  >>>     def migrate(data):
  >>>         data['new_name'] = data['old_name']
  >>>         del data['old_name']
  >>>
  >>> rec = Record('{"_ver": 0, "old_name": 1}')
  >>> print(rec.new_name)
  1
  >>> rec = Record(value=42)         # custom constructor can also be used
  >>> print(rec.new_name)
  42


API Reference
=============

``database(decode=None, version=None)``
  Create a class descriptor to specify record classes of different version, and a Record initializer to instantiate the latest record from data, or migrate data to the latest version.

  :Args:
    * ``decode``: Deserialize objects retrieved from database. By default no decoding will be applied.
    * ``version``: Get version from record. By default it's ``data.get('_ver')``

  :Returns:
    * ``version``: A class descriptor to specify record version.
    * ``Record``: A initializer that to construct defined Record class. Migrate if data is not the latest version.

{'fraction_non_alphanumeric': 0.1739245183425706, 'fraction_numerical': 0.005278437582475587, 'mean_word_length': 3.3563218390804597, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 167, 'https://': 4, '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': '2160741', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1134, 'n_words': 336}