frazzle 0.1.3 → 0.1.4
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.
- checksums.yaml +7 -0
- data/README.md +42 -0
- data/example/pizza/lib/pizza/run.rb +2 -2
- data/frazzle.gemspec +1 -1
- data/lib/frazzle/core/registry.rb +19 -0
- data/lib/frazzle/version.rb +1 -1
- data/{Rakefile.rb → rakefile.rb} +0 -0
- metadata +12 -18
- data/Gemfile +0 -2
- data/Gemfile.lock +0 -10
- data/README +0 -1
- data/example/Gemfile +0 -2
- data/example/Gemfile.lock +0 -10
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 352eda37ebf020ca7924f653b5ddcd7974b8b11c
|
4
|
+
data.tar.gz: 088c02ec046f2333d43c16790836d1cd550a16d3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a4f4d8d7f5b9f17f64ad3ce2c5693b9dda04dfa36fe4a9255c2bbeaea9dd2cabe4d6b01cbfc0a0f507913913e9ba7a62969f90391332e5f388bb99f119ff8ddf
|
7
|
+
data.tar.gz: 8eae245d72fe68fdb4d9105431f3e3c911214ee8327a90dad704dbaaf602fa34741cb7bda26790f18e1e7e08dcdf1ed9caccad0bac604b532eaf1410a6ddb30d
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
frazzle
|
2
|
+
=========
|
3
|
+
|
4
|
+
Simple plugin-manager facilitating ruby gems.
|
5
|
+
|
6
|
+
## Introduction
|
7
|
+
Lets say we want to implement a pizzaria without hardcoding recipes or
|
8
|
+
ovens. New recipes or ovens should be picked out automatically as soon
|
9
|
+
as a fitting gem is installed.
|
10
|
+
|
11
|
+
For this we would have to create the following "plugin" gems for the
|
12
|
+
recipes:
|
13
|
+
|
14
|
+
- pizzaria_margerita_recipe
|
15
|
+
- pizzaria_tonno_recipe
|
16
|
+
- pizzaria_diavola_recipe
|
17
|
+
|
18
|
+
and for the ovens:
|
19
|
+
|
20
|
+
- pizzaria_wood_oven
|
21
|
+
- pizzaria_electric_oven
|
22
|
+
|
23
|
+
The pizzaria application could then find all recipes and call them with:
|
24
|
+
|
25
|
+
registry = Frazzle::Registry.new('pizzaria', '_', '_')
|
26
|
+
plugins = registry.get_plugins('recipe')
|
27
|
+
plugins.each do |plugin|
|
28
|
+
registry.load_plugin(plugin, Context.new)
|
29
|
+
end
|
30
|
+
|
31
|
+
The interesting part is the second argument to load_plugin.
|
32
|
+
Frazzle executes the file lib/gemname/plugin.rb with instance oval on
|
33
|
+
this object. You are free to come up with a plugin mechanism you like.
|
34
|
+
|
35
|
+
## Conventions
|
36
|
+
As seens in the intrductionary example, the plugin system has some
|
37
|
+
conventions hardcoded.
|
38
|
+
|
39
|
+
1. The gems that can be used as plugin must follow a nameing scheme:
|
40
|
+
`application_plugin_type`. The seapator between application,
|
41
|
+
plugin and type can be configured.
|
42
|
+
2. Frazzle always instance-evals the file lib/gemname/plugin.rb.
|
@@ -9,9 +9,9 @@ class PizzaFactory
|
|
9
9
|
|
10
10
|
def run()
|
11
11
|
pizzas = [ "Margerita", "Fungi", "Scampi" ]
|
12
|
-
plugins = @registry.
|
12
|
+
plugins = @registry.plugins("oven")
|
13
13
|
plugins.each do |plugin|
|
14
|
-
oven =
|
14
|
+
oven = plugin.load.create({ :pizza_type => pizzas.pop })
|
15
15
|
oven.make_pizza()
|
16
16
|
end
|
17
17
|
end
|
data/frazzle.gemspec
CHANGED
@@ -18,6 +18,17 @@ module Frazzle
|
|
18
18
|
# ******************************************************************************************************
|
19
19
|
class Registry
|
20
20
|
|
21
|
+
class Plugin
|
22
|
+
attr_reader :name
|
23
|
+
def initialize(registry, name)
|
24
|
+
@registry = registry
|
25
|
+
@name = name
|
26
|
+
end
|
27
|
+
def load(context=Object.new)
|
28
|
+
@registry.load_plugin(@name, context)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
21
32
|
def initialize(base_name, base_separator='-', plugin_separator='-')
|
22
33
|
@base_name = base_name
|
23
34
|
@base_separator = base_separator
|
@@ -25,11 +36,19 @@ class Registry
|
|
25
36
|
end
|
26
37
|
attr_accessor :base_name
|
27
38
|
|
39
|
+
def plugins(plugin_type)
|
40
|
+
get_plugins(plugin_type).map{|name|Plugin.new(self, name)}
|
41
|
+
end
|
42
|
+
|
28
43
|
def get_plugins(plugin_type)
|
29
44
|
get_names(get_plugin_gems(plugin_type))
|
30
45
|
end
|
31
46
|
|
32
47
|
|
48
|
+
def all_plugin
|
49
|
+
get_all_plugins.map{|name|Plugin.new(self, name)}
|
50
|
+
end
|
51
|
+
|
33
52
|
def get_all_plugins
|
34
53
|
get_names(find_gems do |spec|
|
35
54
|
spec.name =~ /#{@base_name}#{@base_separator}.*/
|
data/lib/frazzle/version.rb
CHANGED
data/{Rakefile.rb → rakefile.rb}
RENAMED
File without changes
|
metadata
CHANGED
@@ -1,33 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frazzle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Kevin russ
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-02-07 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: plugin registry based on gems
|
15
14
|
email: kevin.russ@esrlabs.com
|
16
15
|
executables: []
|
17
16
|
extensions: []
|
18
17
|
extra_rdoc_files:
|
19
|
-
- README
|
18
|
+
- README.md
|
20
19
|
files:
|
21
|
-
- .gitignore
|
22
|
-
- .rvmrc
|
23
|
-
- Gemfile
|
24
|
-
- Gemfile.lock
|
20
|
+
- ".gitignore"
|
21
|
+
- ".rvmrc"
|
25
22
|
- LICENCE
|
26
|
-
- README
|
27
|
-
- Rakefile.rb
|
23
|
+
- README.md
|
28
24
|
- example/.rvmrc
|
29
|
-
- example/Gemfile
|
30
|
-
- example/Gemfile.lock
|
31
25
|
- example/Rakefile.rb
|
32
26
|
- example/pizza-electric-oven/Rakefile.rb
|
33
27
|
- example/pizza-electric-oven/gemspec
|
@@ -43,28 +37,28 @@ files:
|
|
43
37
|
- lib/frazzle/core/registry.rb
|
44
38
|
- lib/frazzle/frazzle.rb
|
45
39
|
- lib/frazzle/version.rb
|
40
|
+
- rakefile.rb
|
46
41
|
homepage:
|
47
42
|
licenses: []
|
43
|
+
metadata: {}
|
48
44
|
post_install_message:
|
49
45
|
rdoc_options: []
|
50
46
|
require_paths:
|
51
47
|
- lib
|
52
48
|
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
-
none: false
|
54
49
|
requirements:
|
55
|
-
- -
|
50
|
+
- - ">="
|
56
51
|
- !ruby/object:Gem::Version
|
57
52
|
version: '0'
|
58
53
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
-
none: false
|
60
54
|
requirements:
|
61
|
-
- -
|
55
|
+
- - ">="
|
62
56
|
- !ruby/object:Gem::Version
|
63
57
|
version: '0'
|
64
58
|
requirements: []
|
65
59
|
rubyforge_project:
|
66
|
-
rubygems_version:
|
60
|
+
rubygems_version: 2.5.1
|
67
61
|
signing_key:
|
68
|
-
specification_version:
|
62
|
+
specification_version: 4
|
69
63
|
summary: gem plugin-manager using extention-points
|
70
64
|
test_files: []
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
data/README
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
gem plugin-manager using extention-points
|
data/example/Gemfile
DELETED