Skip to content

Commit

Permalink
Init commit; Wayde
Browse files Browse the repository at this point in the history
  • Loading branch information
sunwei committed Jul 26, 2019
1 parent b46afa8 commit 31cc631
Show file tree
Hide file tree
Showing 21 changed files with 256 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,5 @@ venv.bak/

# mypy
.mypy_cache/

.idea
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
language: python
sudo: false
python:
- '2.7'
- '3.4'
- '3.5'
- '3.6'
install:
- pip install python-coveralls tox tox-travis
script: tox --recreate
after_success:
- pip install -r requirements.txt -e .
- py.test --cov=ddd_api_gateway --cov-report=term-missing tests
- coveralls
deploy:
provider: pypi
user: sunzhongmou
password:
secure: pai3O4/T/nDleRjtR6RxJP0IrxMaCALjHirm1PairjYYS03/HE0o1W39mYv+HMdK7Dy6YUpetUukxQ3TncNR77RvE32dloZSu7ivqSdHZc7/KvKV3u2prOSSsdARSuZem5/wf5FSx4pVr1Vn6VzRfTX0MwiRSz5CkgukCxgjYzt56iqMC11tlztkZ/5vyea0YHSjss6PCk63OzYreWYaY5t4CUocdhYJXflJRAB/jXLpXik0KZIyvlW75hDaSRwUBdSfkPLcKJD04ScsSaVnuHSrrJzM2mAB6oF9l8AxDVTDnwb6yQbO2g8s3vlSNIMdYUlUu81togDUBzADZ1kc0Ic4g7fAL1M0AUY1P8gTunwlITOCZD2QRmgC5NsvSuB1O2Kuuj3hN5ani6dwfZXnV6kzxwEIlNK7QqUHla7VwRslPgtMGHbJNcZCWmldlMnwGSixg9MTVy98xCWgK2WAq0eSa1si7mO8VCrULj5R/re6GmwrO7hPlPeB9qSVALLvc2Ox8QSzSvl/gaoDlWGLlah6vOd2JyPlonglpL6IeNDFb/IUUCpG/Vd3fYgYMTnJScQvyY8iU84ZCM/XS73KFJwfOEl4vzHfM3orQJT6hqchZanAsf1kH02Ar5XyWqBJtdpZNgvAw4onGDFzvoYX0nfz1SsstKwJEthxIojiiOo=
on:
python: 2.7
skip_existing: true
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Changelog
=========

0.0.1
-----

- Initial public release
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include *.rst
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
venv:
virtualenv -p `which python3` venv && \
source venv/bin/activate

activate:
source venv/bin/activate

develop: venv
venv/bin/pip install -e . -r requirements/test.txt

clean:
-rm -rf venv

test:
tox

require:
pip freeze > requirements.txt
2 changes: 0 additions & 2 deletions README.md

This file was deleted.

63 changes: 63 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
DDD Base Framework
==================

|Build Status| |Pypi Status| |Coveralls Status|

Installation
------------

From source code:

::

python setup.py install

From pypi:

::

pip install ddd-base

Usage
-----

::

from ddd_base.value_object import ValueObject


class TheValueObject(ValueObject):

def __init__(self, name):
super(TheValueObject, self).__init__()
self.name = name

def __eq__(self, other):
if not isinstance(other, ValueObject):
return NotImplemented

return self.name == other.name


def test_value_object_compare():
a_value_object = TheValueObject("name")
b_value_object = TheValueObject("name")

assert a_value_object.same_as(b_value_object)



License
-------

This software is licensed under the `MIT license <http://en.wikipedia.org/wiki/MIT_License>`_

See `License file <https://github.com/sunwei/ddd-base/blob/master/LICENSE>`_

.. |Build Status| image:: https://travis-ci.com/sunwei/ddd-base.svg?branch=master
:target: https://travis-ci.com/sunwei/ddd-base
.. |Pypi Status| image:: https://badge.fury.io/py/ddd-base.svg
:target: https://badge.fury.io/py/ddd-base
.. |Coveralls Status| image:: https://coveralls.io/repos/github/sunwei/ddd-base/badge.svg?branch=master
:target: https://coveralls.io/github/sunwei/ddd-base?branch=master

3 changes: 3 additions & 0 deletions ddd_nginx/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .aggregate import Aggregate
from .entity import Entity
from .value_object import ValueObject
1 change: 1 addition & 0 deletions ddd_nginx/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.0.1'
6 changes: 6 additions & 0 deletions ddd_nginx/aggregate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
"""Domain Driven Design framework - Aggregate Root."""


class Aggregate(object):
pass
17 changes: 17 additions & 0 deletions ddd_nginx/entity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
"""Domain Driven Design base framework - Entity."""

import uuid


class Entity(object):

def __init__(self, id_=uuid.uuid1()):
super(Entity, self).__init__()
self.id = id_

def __eq__(self, other):
if not isinstance(other, Entity):
return NotImplemented

return self.id == other.id
7 changes: 7 additions & 0 deletions ddd_nginx/value_object.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
"""Domain Driven Design base framework - Value Object."""


class ValueObject(object):
def same_as(self, other):
return self == other
5 changes: 5 additions & 0 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# requirements for the CI test runner
tox-travis>=0.10
codecov>=2.0.9

-r tox.txt
6 changes: 6 additions & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# requirements for running the tests via pytest
pytest==4.5.0
pytest-cov==2.7.1
pytest-pep8==1.0.6

-r tox.txt
2 changes: 2 additions & 0 deletions requirements/tox.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# requirements for building and running tox
tox==3.9.0
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[bdist_wheel]
universal = 1
48 changes: 48 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""Setuptools entry point."""
import codecs
import os
from setuptools import find_packages

try:
from setuptools import setup
except ImportError:
from distutils.core import setup


HERE = os.path.abspath(os.path.dirname(__file__))
ABOUT = {}
with open(os.path.join(HERE, 'ddd_nginx', '__version__.py')) as f:
exec(f.read(), ABOUT)

CLASSIFIERS = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Software Development :: Libraries :: Python Modules'
]

dirname = os.path.dirname(__file__)

long_description = (
codecs.open(os.path.join(dirname, 'README.rst'), encoding='utf-8').read() + '\n' +
codecs.open(os.path.join(dirname, 'CHANGES.rst'), encoding='utf-8').read()
)

setup(
name='ddd-nginx',
version=ABOUT['__version__'],
description='DDD base framework for python',
long_description=long_description,
author='Sun Wei',
author_email='wayde.sun@gmail.com',
url='https://github.com/sunwei/ddd-nginx',
packages=find_packages(exclude=['tests*']),
install_requires=[],
classifiers=CLASSIFIERS)
Empty file added tests/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions tests/test_entity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from ddd_nginx.entity import Entity


def test_entity_sets_ids():
an_entity = Entity()

assert an_entity.id is not None
21 changes: 21 additions & 0 deletions tests/test_value_object.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from ddd_nginx.value_object import ValueObject


class TheValueObject(ValueObject):

def __init__(self, name):
super(TheValueObject, self).__init__()
self.name = name

def __eq__(self, other):
if not isinstance(other, ValueObject):
return NotImplemented

return self.name == other.name


def test_value_object_compare():
a_value_object = TheValueObject("name")
b_value_object = TheValueObject("name")

assert a_value_object.same_as(b_value_object)
18 changes: 18 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[tox]
distshare={homedir}/.tox/distshare
envlist=py{27,34,35,36}
skip_missing_interpreters=true
indexserver=
pypi = https://pypi.python.org/simple

[testenv]
commands=
py.test ddd_nginx tests --pep8
deps =
py32: pytest<3.0
py{27,34,35,36}: pytest>=3.0
pytest-pep8==1.0.6

[pytest]
addopts = -vvl
pep8maxlinelength=120

0 comments on commit 31cc631

Please sign in to comment.