scruby-plugin 0.7.2__py3-none-any.whl → 0.8.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
scruby_plugin/plugin.py CHANGED
@@ -8,6 +8,7 @@ from __future__ import annotations
8
8
  __all__ = ("ScrubyPlugin",)
9
9
 
10
10
  import weakref
11
+ from typing import ClassVar
11
12
 
12
13
  from scruby import Scruby
13
14
 
@@ -15,5 +16,8 @@ from scruby import Scruby
15
16
  class ScrubyPlugin:
16
17
  """Base class for creating Scruby plugins."""
17
18
 
19
+ # What version of Scruby is the plugin for?
20
+ scruby_version: ClassVar[int] = 0
21
+
18
22
  def __init__(self, scruby_self: Scruby) -> None: # noqa: D107
19
23
  self.scruby_self = weakref.ref(scruby_self)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scruby-plugin
3
- Version: 0.7.2
3
+ Version: 0.8.0
4
4
  Summary: Library for creating Scruby plugins.
5
5
  Project-URL: Bug Tracker, https://github.com/kebasyaty/scruby-plugin/issues
6
6
  Project-URL: Changelog, https://github.com/kebasyaty/scruby-plugin/blob/v0/CHANGELOG.md
@@ -79,7 +79,7 @@ class PluginName(ScrubyPlugin):
79
79
  import anyio
80
80
  from typing import Any
81
81
  from pydantic import Field
82
- from scruby import Scruby, ScrubyModel, ScrubyConfig
82
+ from scruby import Scruby, ScrubyModel
83
83
  from scruby_plugin import ScrubyPlugin
84
84
  from pprint import pprint as pp
85
85
 
@@ -94,15 +94,8 @@ class CollectionMeta(ScrubyPlugin):
94
94
  return await scruby_self.get_meta()
95
95
 
96
96
 
97
- # Plugins connection.
98
- ScrubyConfig.plugins = [
99
- CollectionMeta,
100
- ]
101
-
102
-
103
97
  class Car(ScrubyModel):
104
98
  """Car model."""
105
-
106
99
  brand: str = Field(strict=True, frozen=True)
107
100
  model: str = Field(strict=True, frozen=True)
108
101
  year: int = Field(strict=True)
@@ -116,6 +109,10 @@ class Car(ScrubyModel):
116
109
 
117
110
 
118
111
  async def main() -> None:
112
+ """Example."""
113
+ # Activate database.
114
+ Scruby.run(plugins=[CollectionMeta])
115
+
119
116
  # Get collection `Car`.
120
117
  car_coll = await Scruby.collection(Car)
121
118
  # Get metadata of collection
@@ -0,0 +1,7 @@
1
+ scruby_plugin/__init__.py,sha256=kWaqpz4RYNT9Kc9FF6jj0GX1Mppm1uhFfArPY6EYneI,241
2
+ scruby_plugin/plugin.py,sha256=9VsNylr4lLn4IX7WGQMdej56iuMdx9lnQS5kBtfbxQQ,599
3
+ scruby_plugin/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ scruby_plugin-0.8.0.dist-info/METADATA,sha256=aFsvvxB1twM3Y0wVelcyjp9nd8fJcZeWuxETSzVe37I,5315
5
+ scruby_plugin-0.8.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
6
+ scruby_plugin-0.8.0.dist-info/licenses/LICENSE,sha256=mvh5qv1YJGyuVCkRxonDDNOzxlwXszKvwxXfOeXKrqw,1074
7
+ scruby_plugin-0.8.0.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- scruby_plugin/__init__.py,sha256=kWaqpz4RYNT9Kc9FF6jj0GX1Mppm1uhFfArPY6EYneI,241
2
- scruby_plugin/plugin.py,sha256=oGhbFBPZ4LaPLsDJO316vV0zJCrUPZ7KTCPAUAV0Rj4,484
3
- scruby_plugin/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- scruby_plugin-0.7.2.dist-info/METADATA,sha256=R8mkWwb58RAhnLcialUsNb2xwQFC7PZAYbIsz796J5Q,5315
5
- scruby_plugin-0.7.2.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
6
- scruby_plugin-0.7.2.dist-info/licenses/LICENSE,sha256=mvh5qv1YJGyuVCkRxonDDNOzxlwXszKvwxXfOeXKrqw,1074
7
- scruby_plugin-0.7.2.dist-info/RECORD,,