{ "info": { "author": "Ramon Hagenaars", "author_email": "ramon.hagenaars@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8" ], "description": "[![Build Status](https://travis-ci.org/ramonhagenaars/jacked.svg?branch=master)](https://travis-ci.org/ramonhagenaars/jacked)\n[![Pypi version](https://badge.fury.io/py/jacked.svg)](https://badge.fury.io/py/jsons)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ramonhagenaars/jacked/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ramonhagenaars/jacked/?branch=master)\n[![codecov](https://codecov.io/gh/ramonhagenaars/jacked/branch/master/graph/badge.svg)](https://codecov.io/gh/ramonhagenaars/jacked)\n\n\n_NOTE: This project is in ALPHA state_\n# jacked ~ *python on roids*\n\n* A light and easy to use dependency injection framework.\n* Inject _objects_, _functions_, _classes_ or _lists_ containing any of these.\n* Let **jacked** automatically discover your injectables in a package.\n* Loose coupling _on the juice_!\n* Excellent for making your code testable!\n\n## Install\n```\npip install jacked\n```\n\n## Usage\n\n### Inject instances\nTo inject instances, mark a class with the ``injectable`` decorator:\n```python\nfrom jacked import injectable\n\n@injectable\nclass Cat:\n def sound(self):\n return 'meow'\n```\nYou can now inject it in a function anywhere. Place the ``inject`` decorator on \ntop of the function or method. Let **jacked** know what type to inject by type \nhinting your parameters:\n```python\n@inject\ndef what_sound_does_it_make(cat: Cat):\n print(cat.sound())\n\nwhat_sound_does_it_make()\n```\n\n### Inject functions\nInjecting functions works similarly. Just make sure that your function has the\nproper type hints:\n\n```python\n@injectable\ndef some_func(x: int, y: int) -> str:\n return f'The sum of {x} and {y} is {x + y}'\n```\nAnd like with instances, inject as follows:\n```python\n@inject\ndef do_something(func: Callable[[int, int], str]):\n print(func(21, 21))\n\ndo_something()\n```\n### Inject classes\nAssuming that we have the same ``Cat`` injectable like before, we can inject\nthat class as follows:\n\n```python\nfrom typing import Type\n\n@inject\ndef do_something(cat_type: Type[Cat]):\n print(cat_type.__name__)\n\ndo_something()\n```\n\n\n### Inject lists\nLet's suppose that we have the following two injectables of the same parent:\n```python\nclass Animal(ABC):\n @abstractmethod\n def sound(self):\n raise NotImplementedError\n\n@injectable\nclass Cat(Animal):\n def sound(self):\n return 'meow'\n\n@injectable\nclass Dog(Animal):\n def sound(self):\n return 'bark'\n```\nYou can now inject them in a list:\n```python\n@inject\ndef what_sound_does_it_make(animals: List[Animal]):\n for animal in animals:\n print(f'The {animal.__class__.__name__} does {animal.sound()}')\n\nwhat_sound_does_it_make()\n```\nYou could have also injected a ``list`` of classes or functions by hinting\n``List[Type[...]]`` or ``List[Callable[...]]`` (the ``...`` replaced by your\ninjection target).\n\n### Singletons\nYou can annotate an injectable as singleton, meaning that if the injectable is \na class, only one instance is ever injected:\n\n```python\n@injectable(singleton=True)\nclass Dog(Animal):\n def sound(self):\n return 'bark'\n```\n\n### Auto discovery\nYou can let **jacked** discover injectables in some package using the \n``discover`` function:\n```python\nfrom jacked import discover\n\ndiscover('path/to/your/package')\n```\nAll python modules in that package are imported and the injectables are \nregistered.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ramonhagenaars/jacked", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "jacked", "package_url": "https://pypi.org/project/jacked/", "platform": "", "project_url": "https://pypi.org/project/jacked/", "project_urls": { "Homepage": "https://github.com/ramonhagenaars/jacked" }, "release_url": "https://pypi.org/project/jacked/1.0.0a3/", "requires_dist": null, "requires_python": "", "summary": "Dependency injection for Python", "version": "1.0.0a3" }, "last_serial": 5430654, "releases": { "1.0.0a0": [ { "comment_text": "", "digests": { "md5": "15b57779b6d4de6848b238265f932956", "sha256": "ffc9d844472959f27ab283d4ea1eb1550137001d06512e87e385103dde2e7459" }, "downloads": -1, "filename": "jacked-1.0.0a0-py3-none-any.whl", "has_sig": false, "md5_digest": "15b57779b6d4de6848b238265f932956", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13277, "upload_time": "2019-05-19T15:52:00", "url": "https://files.pythonhosted.org/packages/e7/de/a614bfe74e385db2fd23e2b6f1294bb2a65a37486bf400a31f3202cee097/jacked-1.0.0a0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5ac32f811e4b857526829da48fa787aa", "sha256": "be5e654f4a306470085c0e0bd6982672a8239758544502635056c47cbf913a6b" }, "downloads": -1, "filename": "jacked-1.0.0a0.tar.gz", "has_sig": false, "md5_digest": "5ac32f811e4b857526829da48fa787aa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9410, "upload_time": "2019-05-19T15:52:02", "url": "https://files.pythonhosted.org/packages/e2/22/f78c8fac4db3c355126baab8a65c486378ef0afb9fca3788ec49536db601/jacked-1.0.0a0.tar.gz" } ], "1.0.0a2": [ { "comment_text": "", "digests": { "md5": "5f556a1e357cc226f9af50adfdc2ee1e", "sha256": "40f71091194f8b01cff8ad45d558d36704db2f58cc3716e5883aca2534b5df92" }, "downloads": -1, "filename": "jacked-1.0.0a2-py3-none-any.whl", "has_sig": false, "md5_digest": "5f556a1e357cc226f9af50adfdc2ee1e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14244, "upload_time": "2019-05-23T19:42:10", "url": "https://files.pythonhosted.org/packages/6d/81/147a0e3a1924d6e206fb9cd89fc815d6d2870b9e989d97cc8e82e89fc776/jacked-1.0.0a2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "17cc89dceef54104f4f8da701d2c1752", "sha256": "e33f42d71619b49dbc35584a99a1f7b3c89e993559502b5cb340d75540d2f6a0" }, "downloads": -1, "filename": "jacked-1.0.0a2.tar.gz", "has_sig": false, "md5_digest": "17cc89dceef54104f4f8da701d2c1752", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10268, "upload_time": "2019-05-23T19:42:11", "url": "https://files.pythonhosted.org/packages/1d/81/e40fb493a52fa3490049dcfe55905e07c3b8a742337c985b24f55f18b8db/jacked-1.0.0a2.tar.gz" } ], "1.0.0a3": [ { "comment_text": "", "digests": { "md5": "6f9ec6d703ea67f5739b91adee5eda7a", "sha256": "c60b5db33039ebf40af3b86b9bbf8126801afb3f858a21cb5122cfa5322414fd" }, "downloads": -1, "filename": "jacked-1.0.0a3-py3-none-any.whl", "has_sig": false, "md5_digest": "6f9ec6d703ea67f5739b91adee5eda7a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 15671, "upload_time": "2019-06-21T12:50:26", "url": "https://files.pythonhosted.org/packages/11/de/d82585bac9e53970486110738c5057f0a7823f40b18d87871018ed0da361/jacked-1.0.0a3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2c32d7e279612b098bd58cbeab592efe", "sha256": "2d13491f05e126df19e18be7406a43cb89464bc28b22544a913f4107493da47e" }, "downloads": -1, "filename": "jacked-1.0.0a3.tar.gz", "has_sig": false, "md5_digest": "2c32d7e279612b098bd58cbeab592efe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11600, "upload_time": "2019-06-21T12:50:27", "url": "https://files.pythonhosted.org/packages/40/fd/cba9492f76fb4ef0b11d61fa9244174fea57131081fff3cd324411d58d84/jacked-1.0.0a3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6f9ec6d703ea67f5739b91adee5eda7a", "sha256": "c60b5db33039ebf40af3b86b9bbf8126801afb3f858a21cb5122cfa5322414fd" }, "downloads": -1, "filename": "jacked-1.0.0a3-py3-none-any.whl", "has_sig": false, "md5_digest": "6f9ec6d703ea67f5739b91adee5eda7a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 15671, "upload_time": "2019-06-21T12:50:26", "url": "https://files.pythonhosted.org/packages/11/de/d82585bac9e53970486110738c5057f0a7823f40b18d87871018ed0da361/jacked-1.0.0a3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2c32d7e279612b098bd58cbeab592efe", "sha256": "2d13491f05e126df19e18be7406a43cb89464bc28b22544a913f4107493da47e" }, "downloads": -1, "filename": "jacked-1.0.0a3.tar.gz", "has_sig": false, "md5_digest": "2c32d7e279612b098bd58cbeab592efe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11600, "upload_time": "2019-06-21T12:50:27", "url": "https://files.pythonhosted.org/packages/40/fd/cba9492f76fb4ef0b11d61fa9244174fea57131081fff3cd324411d58d84/jacked-1.0.0a3.tar.gz" } ] }