ecko-plugins 0.1.2 → 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: 6ea907c7cdf100f9d8604d626f005995e94e53ccd3eff8201a844196df13413a
4
- data.tar.gz: 0724d24e0897f4f2d9757fddcf338e7e9c2bd286d9d83de8a7baf6ab62c027b3
3
+ metadata.gz: dce97dbb50221ff2e328c927ef9f40ed6109d982b249e6d55f1001037eb8e1a7
4
+ data.tar.gz: '0191d7f6fb03a1d7dff1f354b05de53ed8092951c5735fe8c8c60d02360e312d'
5
5
  SHA512:
6
- metadata.gz: b6e3385c059320a0c41af91acae210312650c0d66b92bf3c7fd3244fb0b0cb175b87e1730c8c58d5a337ac99ce90ed92f21086ae3dc586d2c8d992223348a3a9
7
- data.tar.gz: a3e167e2fcf72764083c6ee94131ffe6595dd9ed85fe1193a15a9e897ed3fed3550ce87c4beefc2583709cc232f79af25738d8be757336e7415aea327035a03d
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.2
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manish Sharma
@@ -44,10 +44,12 @@ 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
- - GPL/AGPL
52
+ - GPL-3.0+
51
53
  metadata:
52
54
  allowed_push_host: https://rubygems.org
53
55
  homepage_uri: https://github.com/magicstone-dev/ecko-plugins/tree/main/ecko-plugins