Metadata-Version: 2.4
Name: pl-dpl
Version: 0.1.2
Summary: Peach's Lightweight Design Pattern Library
Author-email: Peach <james@christhall.us>
License: MIT
Project-URL: Homepage, https://gitlab.com/Peach32/pl-dpl
Keywords: design pattern
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: black>=23.0; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Dynamic: license-file

# PL-DPL
Peach's Lightweight Design Pattern Library

Low code, low dependency, simple implementation of commonly used design patterns.

# Quick Start
Install library
```bash
pip install pl-dpl
```

# Factory
Lazy Loading Self-Registering Factory Design Pattern.

Create a subclass of BaseFactory, specify the directory where concrete implementations exist, define abstract functions.

**NOTE: Only include one implementation per file in the plugin directory, registration is done by module name, not class name. This makes it more readable for developers so when they look at the config and see "s3" they can immediately see the file "s3.py" and know where the implementation is.

## Usage
Create packages for implementations:
```
src/
|-- storage/
|  |-- s3.py
|-- storage_factory.py
|-- main.py
```

./main.py
```python
from storage_factory import StorageFactory

data = b'123'

StorageFactory("s3").save(data)

```

./storage_factory
```python
from patterns import BaseFactory

# Create Factory
class StorageFactory(BaseFactory):
    plugin_dir = "storage"
    _registry = {}

    # Define Abstract Functions
    def save(self, data: bytes):
        raise NotImplementedError
```

./storage/s3.py
```python
from storage_factory import StorageFactory

# Create implementation
class S3(StorageFactory):
    def save(self, data: bytes):
        ...
```

# Chain
## TODO:

# Entity
## TODO:

# Command
## TODO:
