Refactor: better abstractions needed for GetGist internals
Opened this issue · 0 comments
This package has a poor design.
Both getgist.github
and getgist.local
(the core modules of the package) abstracts two things, making then coupled: they act as an adapter to systems (GitHub and local file system, respectively) and as a manager output information (formating, asking for confirmation, etc.). We need to decouple these responsibilities.
I suggest a huge refactor in which we end up with:
-
GitHub
class with methods to handle GitHub related actions:.read(name: str)
returns the contents of the gist.write(name: str, contents: str, private: bool)
writes the Gist and returns its URLlist()
return a list of all the Gist files for a given user- plus “private” methods needed for the internals
-
Local
class with methods to handle local file system actions, but… to be honest, we might just inherit from Python's nativepathlib.Path
adding one or other method or wrapper to better fit our use case (and, yes, we can drop support for Python 2.7):pathlib.Path.read_text()
to read the contents of a local filepathlib.Path.write_text(…)
to write contents to a local file- plus “private” methods needed for the internals
-
A logger/output object to replace existing
GetGistCommons
that would be able to:- write to
stdout
orstderr
without raising errors when running as CLI - raise custom GetGist errors when using in a script (as in #14)
- write to