ecko-plugins 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 883fbcf6ef0b1c7e0caf9fd5ba07beed59fa4af7a33b8fd3c137ac1a4421a984
4
- data.tar.gz: 0c8a25cee099f3ffc5a3bf692da8ffbaf0b7e51004b85ea4d51969fb772af538
3
+ metadata.gz: dce97dbb50221ff2e328c927ef9f40ed6109d982b249e6d55f1001037eb8e1a7
4
+ data.tar.gz: '0191d7f6fb03a1d7dff1f354b05de53ed8092951c5735fe8c8c60d02360e312d'
5
5
  SHA512:
6
- metadata.gz: 84dae5fac3fb58997cf336fb99abbb1013073468fd85692a7a9aaadd242e7db7d8880274e493bba6785797cea8b86e82afbc5fb2faa0617364cb3d8fc63b1581
7
- data.tar.gz: f2616cad5bee83e2dfbb6ea95849fac811154bbfe3933919244468ea48d785f49f1ee00284aab81022a7e12379b528c26518787f951be92e6e692d34e638fc6c
6
+ metadata.gz: 88f0dcde5f58e3a160763d6f384476db9e99f598149f4cf5ecc4190b0fb726af66d6286bd4f424498dcc0564fc60f9038d66fcf6c939fe0d4de817fdd908f467
7
+ data.tar.gz: c1268a19a779fe9da8feeafcd5cb1d0c5b0f252c95e464b4bb0a72aa2859d34fc45c930cc8af963dc6694f8c11dc5634195b41d9da36f83aa9ba5bf8f8ab5099
@@ -0,0 +1,5 @@
1
+ module Ecko
2
+ module Plugins
3
+ VERSION = '0.1.6'
4
+ end
5
+ end
@@ -0,0 +1,49 @@
1
+ require "ecko/plugins/version"
2
+
3
+ module Ecko
4
+ module Plugins
5
+ # Set a registry variable to help cache all the registries
6
+ @@registry = {}
7
+
8
+ class Error < StandardError; end
9
+
10
+ class PluginPresentError < StandardError; end
11
+
12
+ class Registry; end
13
+
14
+ class << self
15
+ def registry
16
+ @@registry
17
+ end
18
+
19
+ # Registers a new plugin, A plugin with the same name cannot be registered twice
20
+ # That will raise Ecko::Plugins::PluginPresentError if a plugin is already registered.
21
+ # name: Name of the plugin in snail case
22
+ # schema: hash/object or any data structure which defines the plugin
23
+ # engine: It is a class which exposes a configure class definition(method)
24
+ def register(name:, schema:, engine:)
25
+ raise Ecko::Plugins::PluginPresentError unless Ecko::Plugins.registry[name].nil?
26
+
27
+ # This helps set a new reference class which will be used as a pristine class. It doesnt have a big
28
+ # role currently but will serve a great deal of purpose in the future.
29
+ registered_plugin = Ecko::Plugins::Registry.const_set(name.capitalize, Class.new(engine))
30
+ Ecko::Plugins.registry[name] = { schema: schema, engine: engine, engine_stub: registered_plugin }
31
+ register_method(name, registered_plugin)
32
+ execute_pipeline(registered_plugin, schema)
33
+ end
34
+
35
+ # Pipeline just includes configuration currently, It will help us run a validation pipeline in the future.
36
+ # TODO: Update the comment on the method when upgraded.
37
+ def execute_pipeline(registered_plugin, schema)
38
+ registered_plugin.configure(schema)
39
+ end
40
+
41
+ # Creates a singleton class to help devs use the plugin engine and run methods accordingly.
42
+ def register_method(name, engine)
43
+ define_singleton_method name do
44
+ engine
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecko-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manish Sharma
@@ -44,7 +44,9 @@ email:
44
44
  executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
- files: []
47
+ files:
48
+ - lib/ecko/plugins.rb
49
+ - lib/ecko/plugins/version.rb
48
50
  homepage: https://github.com/magicstone-dev/ecko-plugins/tree/main/ecko-plugins
49
51
  licenses:
50
52
  - GPL-3.0+