Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajustes no CI #6

Merged
merged 1 commit into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .github/fluxos de trabalho/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Upload Python Package

on:
push:

jobs:
executa_black:
runs-on: ubuntu-latest
steps:

- name: Realiza o checkout
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Instala Poetry
- uses: Gr1N/setup-poetry@v7

- name: Instala dependências
run: poetry install

- name: Executa black
run: poetry run black --check flunt

jobs:
executa_isort:
runs-on: ubuntu-latest
steps:

- name: Realiza o checkout
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Instala Poetry
- uses: Gr1N/setup-poetry@v7

- name: Instala dependências
run: poetry install

- name: Executa isort
run: poetry run isort --check flunt

jobs:
executa_pydocstyle:
runs-on: ubuntu-latest
steps:

- name: Realiza o checkout
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Instala Poetry
- uses: Gr1N/setup-poetry@v7

- name: Instala dependências
run: poetry install

- name: Executa pydocstyle
run: poetry run pydocstyle flunt

jobs:
executa_pytest:
runs-on: ubuntu-latest
steps:

- name: Realiza o checkout
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Instala Poetry
- uses: Gr1N/setup-poetry@v7

- name: Instala dependências
run: poetry install

- name: Executa test
run: poetry run pytest
34 changes: 0 additions & 34 deletions .github/fluxos de trabalho/python-publish.yml

This file was deleted.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ Python implementation of Domain Notification Pattern based in [Flunt](https://gi
[![PyPI Latest Release](https://img.shields.io/pypi/v/flunt.svg)](https://pypi.org/project/flunt/)
[![Downloads](https://pepy.tech/badge/flunt)](https://pepy.tech/project/flunt)

Flunt é uma forma de implementar um padrão de notificações em sua aplicação para concentrar erros e mudança em determinadas ações e entidades.

O Flunt nasceu de duas necessidades, a implementação do Domain Notification Pattern para substituir Exceptions a nível de domínio na aplicação e para reduzir a quantidade de IFs (Complexidade) utilizando uma abordagem por contratos.

Desta forma, basicamente o que Flunt faz é adicionar uma lista de Notification (Notificações) a sua classe e diversos métodos para interagir com ela.

## Python Version

- [Python 3.10](https://www.python.org/)
Expand Down
3 changes: 2 additions & 1 deletion flunt/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__version__ = '0.1.0'
"""Version Software."""
__version__ = "0.1.1"
22 changes: 8 additions & 14 deletions flunt/contract.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Module Contract."""
from flunt.notification import Notification
from flunt.notifiable import Notifiable
import re

from flunt.notifiable import Notifiable
from flunt.notification import Notification


class Contract(Notifiable):
"""Class Contract."""
Expand All @@ -18,9 +19,7 @@ def has_min_len(self, value, minimum, field, message):
:return: self
"""
if not value or len(value) < minimum:
self.add_notification(
Notification(field, message)
)
self.add_notification(Notification(field, message))

return self

Expand All @@ -34,18 +33,13 @@ def is_email(self, value, field, message):
:return: self
"""
if not self._valid_email(value):
self.add_notification(
Notification(field, message)
)
self.add_notification(Notification(field, message))

return self

def _valid_email(self, value):
return re.match(
r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)",
value,
re.IGNORECASE
)
regex = r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)"
return re.match(regex, value, re.IGNORECASE)

def requires(self, value, field):
"""Require.
Expand All @@ -57,7 +51,7 @@ def requires(self, value, field):
"""
if not value:
self.add_notification(
Notification(field, 'Campo preenchimento obrigatório')
Notification(field, "Campo preenchimento obrigatório")
)

return self
3 changes: 2 additions & 1 deletion flunt/notifiable.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def add_notification(self, notification: Notification):
self._notifications.append(notification)

def add_notifications_of_contract(self, *notifications):
"""Add notification of contract object."""
self._notifications += self._filter_and_map_notifiables(notifications)
# self._notifications += self._filter_notifications(notifications)

def _filter_and_map_notifiables(self, notifications):
return [
Expand Down Expand Up @@ -56,4 +56,5 @@ def is_valid(self) -> bool:
return False

def __str__(self):
"""Print object string."""
return self._notifications.__str__()
4 changes: 3 additions & 1 deletion flunt/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ def __init__(self, field: str, message: str) -> None:
self.message: str = message

def __str__(self):
return '{}field: {}, message: {}{}'.format('{', self.field, self.message, '}')
"""Print object string."""
string = "{}field: {}, message: {}{}"
return string.format("{", self.field, self.message, "}")
Loading