Skip to content

Commit

Permalink
update readme, rename events
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonixRIT committed Jun 13, 2022
1 parent 3d06956 commit ab8ade8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,31 @@
# versionmanager.py
A GitHub Project Version Manager that polls latest version data from GitHub repo release tag.

# Installation
### PIP
[PyPI](https://pypi.org/project/versionmanagerpy/)

`> pip install versionmanagerpy`

# Usage
versionmanager checks the version passed to its constructor against the tag attached to the latest release on a GitHub repo. Comparing the given version string against the `tag_name` value at [https://api.github.com/repos/{author}/{projectName}/releases/latest](). This means release tag names need to be formatted specifically for this. Versionmanager doesnt support letters in version categories* and assumes a separator of a period unless told otherwise.

*A version category is a set of numbers separated by a uniform character (e.g. 2.0.3 has categories 2, 0, and 3). Using Semantic Versioning there are usually 3 version categories (major, minor, and patch) but versionmanager supports more categories as well.
```
from versionmanagerpy import VersionManager
def main():
vm = VersionManager("Aquatic-Labs", "Umbra-Mod-Menu", "2.0.4")
vm.on_outdated += lambda: print("Outdated.")
vm.on_current += lambda: print("Current.")
vm.on_dev += lambda: print("Dev.")
vm.check_status()
if __name__ == "__main__":
main()
```
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
setup(
# the name must match the folder name 'verysimplemodule'
name="versionmanagerpy",
version='1.0.1',
version='1.0.2',
author="Kamron Cole",
author_email="[email protected]",
description='A GitHub Project Version Manager.',
Expand Down
14 changes: 7 additions & 7 deletions versionmanagerpy/versionmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class VersionManager:
'''
The main class to compare a local project to the latest Github release and perform actions based on the result
'''
__slots__ = ['__local', '__remote', '__author', '__projectName', '__separator', 'outdated_event', 'current_event', 'dev_event']
__slots__ = ['__local', '__remote', '__author', '__projectName', '__separator', 'on_outdated', 'on_current', 'on_dev']


def __init__(self, author: str, projectName: str, version: str, separator='.'):
Expand All @@ -36,9 +36,9 @@ def __init__(self, author: str, projectName: str, version: str, separator='.'):
self.__local = Local(author, projectName, version, separator)
self.__remote = None

self.outdated_event = Event()
self.current_event = Event()
self.dev_event = Event()
self.on_outdated = Event()
self.on_current = Event()
self.on_dev = Event()


def check_status(self) -> Status:
Expand All @@ -52,13 +52,13 @@ def check_status(self) -> Status:
self.__remote.refresh()

if self.__local.verison() == self.__remote.verison():
self.current_event()
self.on_current()
return Status.CURRENT
elif self.__local.verison() < self.__remote.verison():
self.outdated_event()
self.on_outdated()
return Status.OUTDATED
else:
self.dev_event()
self.on_dev()
return Status.DEV


Expand Down

0 comments on commit ab8ade8

Please sign in to comment.