# -*- coding: utf-8 -*-
from setuptools import setup

modules = \
['sutoppu']
setup_kwargs = {
    'name': 'sutoppu',
    'version': '0.1.2',
    'description': 'A simple python implementation of Specification pattern.',
    'long_description': "# Sutoppu\n\n[![Pypi Version](https://img.shields.io/pypi/v/sutoppu.svg)](https://pypi.org/project/sutoppu/)\n[![Python Version](https://img.shields.io/pypi/pyversions/sutoppu)](https://pypi.org/project/sutoppu/)\n[![CI](https://github.com/u8slvn/sutoppu/actions/workflows/ci.yml/badge.svg)](https://github.com/u8slvn/sutoppu/actions/workflows/ci.yml)\n[![Coverage Status](https://coveralls.io/repos/github/u8slvn/sutoppu/badge.svg?branch=master)](https://coveralls.io/github/u8slvn/sutoppu?branch=master)\n[![Project license](https://img.shields.io/pypi/l/sutoppu)](https://pypi.org/project/sutoppu/)\n[![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n**Sutoppu** (ストップ - Japanese from English *Stop*) is a simple python implementation of Specification pattern.\n\n## What is Specification Pattern?\n\nSee [Wikipedia](https://en.wikipedia.org/wiki/Specification_pattern).\n\n> In computer programming, the specification pattern is a particular software design pattern, whereby business rules can be recombined by chaining the business rules together using boolean logic. The pattern is frequently used in the context of domain-driven design.\n\nMore information: [Eric Evans and Martin Fowler article about Specifications](https://www.martinfowler.com/apsupp/spec.pdf)\n\n## Basic usage\n\n### Installation\n\n```sh\n$ pip install sutoppu\n```\n\n### Usage\n\n```python\nfrom sutoppu import Specification\n\n\nclass Fruit:\n    def __init__(self, color: str, sweet: bool, bitter: bool):\n        self.color = color\n        self.sweet = sweet\n        self.bitter = bitter\n\n\nclass FruitIsBitter(Specification):\n    description = 'The given fruit must be bitter.'\n\n    def is_satisfied_by(self, fruit: Fruit):\n        return fruit.bitter is True\n\n\nclass FruitIsSweet(Specification):\n    description = 'The given fruit must be sweet.'\n    \n    def is_satisfied_by(self, fruit: Fruit):\n        return fruit.sweet is True\n\n\nclass FruitIsYellow(Specification):\n    description = 'The given fruit must be yellow.'\n\n    def is_satisfied_by(self, fruit: Fruit):\n        return self.color == 'yellow'\n```\n\n```python\n>>> lemon = Fruit(color='yellow', sweet=False, bitter=True)\n>>> is_a_lemon = FruitIsYellow() & FruitIsBitter() & ~FruitIsSweet()\n>>> is_a_lemon.is_satisfied_by(lemon)\nTrue\n```\n\n### Operators\n\nBitwise operators are overload to provide simple syntax.\n\nAnd:\nyellow\n```python\n>>> my_spec = SpecificationA() & SpecificationB()\n```\n\nOr:\n\n```python\n>>> my_spec = SpecificationA() | SpecificationB()\n```\n\nNot:\n\n```python\n>>> my_spec = ~SpecificationA()\n```\n\n### Lighter syntax\n\nIf you do not find the `is_satisfied_by` method very convenient you can also directly call the specification as below.\n\n```python\n>>> lemon = Fruit(color='yellow', sweet=False, bitter=True)\n>>> is_a_lime = FruitIsGreen() & FruitIsBitter() & ~FruitIsSweet()\n>>> is_a_lime(lemon)\nFalse\n```\n\n### Error reporting\n\nIt can be difficult to know which specification failed in a complex rule. Sutoppu allows to list all the failed specifications by getting the `errors` attribute after use.\nThe `errors` attribute is reset each time the specification is used. For each failed specification, it returns a dict with the name of the specification class for key and the description provide in the class for value. In the case where the specification failed with a `not` condition, the description is prefixed with `Not ~`.\n\n```python\n>>> apple = Fruit(color='red', sweet=True, bitter=False)\n>>> is_a_lemon = FruitIsYellow() & FruitIsBitter() & ~ FruitIsSweet()\n>>> is_a_lemon.is_satisfied_by(apple)\nFalse\n>>> is_a_lemon.errors\n{\n    'FruitIsColored': 'The given fruit must be yellow.',\n    'FruitIsBitter': 'The given fruit must be bitter.',\n    'FruitIsSweet': 'Not ~ The given fruit must be sweet.'\n}\n```\n",
    'author': 'u8slvn',
    'author_email': 'u8slvn@gmail.com',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/u8slvn/sutoppu',
    'py_modules': modules,
    'python_requires': '>=3.6.2,<4.0.0',
}


setup(**setup_kwargs)
