fedux_org-stdlib 0.6.53 → 0.6.54
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/fedux_org_stdlib/plugins/plugin_manager.rb +31 -3
- data/lib/fedux_org_stdlib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab784af842eb076d1daf729f886e73eaacb42553
|
4
|
+
data.tar.gz: 9aa883cd9e21d5250198d77ab77cfae52dac709e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80579d9e5ad8076e62cd8868d29ab8abd3fcef84ba14f4da31188739130093140bf273959e8f931f7b552df1175461262cb6587da9793c510ea615764a21dc6f
|
7
|
+
data.tar.gz: 6f1423f64e8c31b4252ab5d2eb96eac6064491955bbd938905496e07089ae194ee06e6c7e54cbac864cb53ad293ac05e3806336a55ca7fada2c03021f0122291
|
data/Gemfile.lock
CHANGED
@@ -11,15 +11,33 @@ module FeduxOrgStdlib
|
|
11
11
|
# Make sure you've got a class method `.plugin_prefix` on your main module
|
12
12
|
#
|
13
13
|
# @example
|
14
|
+
# # -- main.rb --
|
14
15
|
# # main module
|
15
|
-
# module
|
16
|
+
# module YourApplication
|
17
|
+
# # The manager
|
16
18
|
# @plugin_manager = PluginManager.new
|
17
|
-
#
|
19
|
+
#
|
20
|
+
# # This regex depends on your application's plugins file system structure
|
21
|
+
# @plugin_prefix = Regexp.new("^#{self.name.underscore.gsub(/\//, '-')}-")
|
18
22
|
#
|
19
23
|
# class << self
|
20
24
|
# attr_reader :plugin_prefix, :plugin_manager
|
25
|
+
#
|
26
|
+
# def load_plugins
|
27
|
+
# self.plugin_manager.locate_plugins
|
28
|
+
# self.plugin_manager.load_plugins
|
29
|
+
# end
|
21
30
|
# end
|
22
31
|
# end
|
32
|
+
#
|
33
|
+
# At some place you need to load your plugins.
|
34
|
+
#
|
35
|
+
# @example
|
36
|
+
#
|
37
|
+
# # -- runner.rb --
|
38
|
+
#
|
39
|
+
# YourApplication.load_plugins
|
40
|
+
#
|
23
41
|
class PluginManager
|
24
42
|
private
|
25
43
|
|
@@ -36,7 +54,7 @@ module FeduxOrgStdlib
|
|
36
54
|
Gem.refresh
|
37
55
|
|
38
56
|
(Gem::Specification.respond_to?(:each) ? Gem::Specification : Gem.source_index.find_name('')).each do |gem|
|
39
|
-
next if gem.name !~
|
57
|
+
next if gem.name !~ plugin_prefix
|
40
58
|
|
41
59
|
plugin_name = gem.name.split('-', 2).last
|
42
60
|
@plugins << Plugin.new(plugin_name, gem.name, gem, true) if !gem_located?(gem.name)
|
@@ -69,6 +87,16 @@ module FeduxOrgStdlib
|
|
69
87
|
def gem_located?(gem_name)
|
70
88
|
@plugins.any? { |plugin| plugin.gem_name == gem_name }
|
71
89
|
end
|
90
|
+
|
91
|
+
def plugin_prefix
|
92
|
+
module_name = if self.class.name.deconstantize.blank?
|
93
|
+
self.class.name
|
94
|
+
else
|
95
|
+
self.class.name.deconstantize
|
96
|
+
end
|
97
|
+
|
98
|
+
module_name.constantize.plugin_prefix
|
99
|
+
end
|
72
100
|
end
|
73
101
|
end
|
74
102
|
end
|