Skip to content

Commit

Permalink
Merge pull request #4 from ffekirnew/docs
Browse files Browse the repository at this point in the history
Docs
  • Loading branch information
ffekirnew authored Jun 6, 2024
2 parents 3bd9b41 + ce02cf0 commit 9f19e87
Show file tree
Hide file tree
Showing 15 changed files with 381 additions and 38 deletions.
94 changes: 94 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Contributing to RmediatoR
Thank you for your interest in contributing to RmediatoR! We welcome contributions from the community and are excited to see what you can bring to the project. Below are some guidelines to help you get started.

## How Can You Contribute?
1. Reporting Bugs: If you find a bug, please report it by opening an issue on GitHub. Provide as much detail as possible to help us understand and reproduce the issue.

2. Feature Requests: Have an idea for a new feature? Open an issue on GitHub to discuss it. We welcome new ideas and improvements.

3. Code Contributions: We accept pull requests for bug fixes, new features, and documentation improvements. See the guidelines below for more details.

4. Documentation: Help us improve our documentation. This includes everything from fixing typos to adding new sections and improving existing content.

## Getting Started
1. Fork the Repository
Start by forking the repository to your own GitHub account.

2. Clone the Repository
Clone the forked repository to your local machine:

```sh
git clone https://github.com/your-username/rmediator.git
cd rmediator
```
3. Install Dependencies
Install the necessary dependencies using pip or poetry:

```sh
pip install -r requirements.txt
```

or

```sh
poetry install
```
4. Create a Branch
Create a new branch for your work. Use a descriptive name for the branch:

```sh
git checkout -b feature/your-feature-name
```
## Making Changes
### Coding Guidelines
Follow PEP 8 style guidelines for Python code.
Write clear, concise commit messages.
Include docstrings for all public methods and classes.
Add or update tests as needed to cover your changes.

We are using `isort` and `black` to format our code. Please run them before making your commits.

### Running Tests
Ensure all tests pass before submitting your pull request. Run the tests with:

```sh
make test
```

or

```sh
make test-coverage
```
Which will also display the test coverage statistics achieved by the code at that point.

### Commit Your Changes
Commit your changes to your branch:

```sh
git add .
git commit -m "Description of your changes"
```
### Push to GitHub
Push your changes to your forked repository:

```sh
git push origin feature/your-feature-name
```

### Submitting a Pull Request
1. Navigate to the original repository on GitHub.
2. Click the "New Pull Request" button.
3. Select the branch you created and compare it with the main branch.
4. Fill out the pull request template, providing as much detail as possible.
5. Submit your pull request.

### Code Review Process
Your pull request will be reviewed by the maintainers. They may request changes or ask for additional information. Please be responsive to feedback and make the requested changes promptly.

### Community Guidelines
- Be respectful and considerate in your interactions with others.
- Provide constructive feedback and be open to receiving it.

### Thank You!
Thank you for contributing to RmediatoR! Your efforts help make this project better for everyone. If you have any questions, feel free to reach out by opening an issue on GitHub or contacting us at [email protected].
19 changes: 14 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
.phony: test build upload
.phony: format lint test test-coverage build upload

format:
@echo "Make: Running formatters..."
@isort src
@black src

lint:
@echo "Make: Running linters..."
@ruff check src

test:
@echo "Running tests..."
@echo "Make: Running tests..."
@pytest

test-coverage:
@echo "Running tests with coverage..."
@echo "Make: Running tests with coverage..."
@coverage run -m pytest -q
@coverage report -m

build:
@echo "Building package..."
@echo "Make: Building package..."
@python setup.py sdist

upload:
@echo "Uploading package..."
@echo "Make: Uploading package..."
@twine upload dist/*
@rm -rf dist
@rm -rf build
Expand Down
78 changes: 72 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,88 @@
# RmediatoR: Request Mediator
# RmediatoR

<div style="text-align: center;">
<img src="./docs/images/RmediatoR.png" width="200" height="200">
<div style="text-align: left; padding: 1rem 0;">
<img src="./docs/assets/images/logo-dark.png" width="500" aspect-ration="1/1" style="padding: 0.8rem 0;">
<p align="left">
<a href="#introduction">Introduction</a> •
<a href="#demonstration">Demonstration</a> •
<a href="#how-to-use">How to Use</a> •
<a href="#how-to-use">Contributing</a> •
<a href="#how-to-use">License</a>
</p>
</div>

## [Introduction](#introduction)

RmediatoR is a request mediator that allows you to make requests to multiple APIs at once. It is a simple and easy-to-use tool that allows you to make requests to multiple APIs at once, and then process the responses in a single place. It is a simple and easy-to-use tool that allows you to make requests to multiple APIs at once, and then process the responses in a single place.
RmediatoR is a Python package inspired by the MediatR library available on NuGet. It allows developers to implement the mediator design pattern in their applications, promoting a clean separation of concerns by centralizing request/response logic and eliminating direct dependencies between components. This package simplifies the communication between different parts of your application, making your code more maintainable and scalable.

## [Demonstration](#demonstration)

--- Under construction ---
Here's a quick example to demonstrate how RmediatoR works:

1. Define a Request and Handler: Create a request class and a handler class that processes the request.
```py
from rmediator.decorators import request, request_handler

# Define a response
class SomeResponse:
def __init__(self, message):
self.message = message

# Define a request
@request(SomeResponse)
class SomeRequest:
pass

# Define a handler for the request
@request_handler(SomeRequest, SomeResponse)
class SomeRequestHandler:
def handle(self, request: SomeRequest) -> SomeResponse:
return SomeResponse("Handled!")
```
2. Initialize the mediator and register the handlers
```py
from rmediator import Mediator

mediator = Mediator()

mediator.register_handler(SomeRequest, SomeRequestHandler())
```
3. Send a Request: Use the mediator to send a request and get a response.
```py
# Create a request instance
request = SomeRequest()

# Send the request through the mediator
response = mediator.send(request)

# Output the response
print(response.message) # Output: Handled!
```
## [How to Use](#how-to-use)

--- Under construction ---
To start using RmediatoR, follow these steps:
1. Installation: First, install the package using pip (or use other options like poetry).
```bash
pip install rmediator
```
2. Creating Requests and Handlers: Define your request and handler classes as shown in the demonstration above. Each request should inherit from the Request class, and each handler should inherit from the Handler class.

3. Registering Handlers: Register your handlers with the mediator. This tells the mediator which handler to use for each request type.

```py
mediator.register_handler(YourRequestClass, YourHandlerClass)
```
4. Sending Requests: Use the mediator to send requests. The mediator will find the appropriate handler and return the response.

```py
response = mediator.send(your_request_instance)
```

## [License](#license)
RmediatoR is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.

## [Contributing](#contributing)
Contributions are welcome! Please read the [CONTRIBUTING](CONTRIBUTING.md) guidelines for more information on how to get started.

## [Contact](#contact)
For questions or issues, please open an issue on GitHub or contact me on my channels.
Binary file added docs/.DS_Store
Binary file not shown.
Binary file added docs/assets/.DS_Store
Binary file not shown.
Binary file added docs/assets/images/.DS_Store
Binary file not shown.
Binary file added docs/assets/images/logo-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/images/logo-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 96 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ pytest = "^8.2.1"
pytest-cov = "^5.0.0"
tox = "^4.15.0"


[tool.poetry.group.dev.dependencies]
isort = "^5.13.2"
black = "^24.4.2"
ruff = "^0.4.8"

[build-system]
requires = ["setuptools>=46.4.0", "wheel"]
build-backend = "setuptools.build_meta"
Loading

0 comments on commit 9f19e87

Please sign in to comment.