mushin 0.0.0.pre6 → 0.0.0.pre7
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 +4 -4
- data/lib/mushin/base.rb +76 -9
- 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: 772621afa533c2966ba9f755bff39cb61d70e673
|
4
|
+
data.tar.gz: 4cab1bb635e2c1855b3bb15abf4a88f43ccb7585
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff7f05f96308b7f05944cc53d6e071ac870de52160cda8cb42f84177886b5d8b7e4f0c7f558b3d471c512f01d5cefa3964c4a97b0bd244e262ff5caa79b2c624
|
7
|
+
data.tar.gz: b3ea9d45afb09336522389146912b1940e323aa7890b11a357deb0b0ea2c29fef94750098c3ed7563231ea9242df724cc7e0306aeed3588ef7c9d8f38df0edd2
|
data/lib/mushin/base.rb
CHANGED
@@ -2,30 +2,98 @@ require_relative './middleware/builder'
|
|
2
2
|
require_relative './middleware/runner'
|
3
3
|
|
4
4
|
module Mushin
|
5
|
+
module Errors
|
6
|
+
exceptions = %w[ UnkownDSLConstruct UnkownActivation UnknownOption ]
|
7
|
+
exceptions.each { |e| const_set(e, Class.new(StandardError)) }
|
8
|
+
end
|
9
|
+
|
5
10
|
module DSL
|
11
|
+
class Context
|
12
|
+
attr_accessor :title, :statments
|
13
|
+
def initialize title
|
14
|
+
@title = title
|
15
|
+
@statments = []
|
16
|
+
end
|
17
|
+
end
|
18
|
+
class Statment
|
19
|
+
attr_accessor :title, :activations
|
20
|
+
def initialize title
|
21
|
+
@title = title
|
22
|
+
@activations = []
|
23
|
+
end
|
24
|
+
end
|
25
|
+
class Activation
|
26
|
+
attr_accessor :name, :opts, :params
|
27
|
+
def initialize name, opts={}, params={}
|
28
|
+
@name = name
|
29
|
+
@opts = opts
|
30
|
+
@params = params
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
6
34
|
module Notebook
|
7
35
|
def self.extended(mod)
|
8
36
|
puts "#{self} extended in #{mod}"
|
9
|
-
self.send(:include, mod)
|
37
|
+
#self.send(:include, mod)
|
38
|
+
mod.send(:include, self)
|
39
|
+
def mod.method_added(method_name)
|
40
|
+
puts "Adding #{method_name.inspect}"
|
41
|
+
end
|
10
42
|
end
|
11
43
|
|
12
|
-
def self.find
|
44
|
+
def self.find activity_context, activity_statment
|
13
45
|
@@middlewares = []
|
14
|
-
@@
|
15
|
-
if
|
16
|
-
|
17
|
-
if
|
18
|
-
|
46
|
+
@@contexts.each do |current_context|
|
47
|
+
if activity_context == current_context.title
|
48
|
+
current_context.statments.each do |statment|
|
49
|
+
if activity_statment == statment.title
|
50
|
+
statment.activations.each do |middleware|
|
19
51
|
@@middlewares << middleware
|
20
52
|
end
|
21
53
|
end
|
22
54
|
end
|
23
55
|
end
|
24
56
|
end
|
57
|
+
|
58
|
+
@@middlewares.each do |middleware|
|
59
|
+
p "use #{middleware.name}, #{middleware.opts}, #{middleware.params}"
|
60
|
+
#use middleware.name, middleware.opts, middleware.params
|
61
|
+
end
|
25
62
|
@@middlewares
|
26
63
|
end
|
64
|
+
|
65
|
+
def self.build context_construct, statment_construct, activation_construct
|
66
|
+
@@statment_construct = statment_construct
|
67
|
+
@@activation_construct = activation_construct
|
68
|
+
@@contexts = []
|
69
|
+
def context title, &block
|
70
|
+
@context = Mushin::DSL::Context.new title
|
71
|
+
def statment statment=[], &block
|
72
|
+
@statment = Mushin::DSL::Statment.new statment
|
73
|
+
|
74
|
+
def activation name, opts={}, params={}
|
75
|
+
@activation = Mushin::DSL::Activation.new name, opts, params
|
76
|
+
@statment.activations << @activation
|
77
|
+
end
|
78
|
+
Mushin::Notebook.class_eval do
|
79
|
+
alias_method @@activation_construct, :activation
|
80
|
+
end
|
81
|
+
yield
|
82
|
+
@context.statments << @statment
|
83
|
+
@statment = nil
|
84
|
+
end
|
85
|
+
Mushin::Notebook.class_eval do
|
86
|
+
alias_method @@statment_construct, :statment
|
87
|
+
end
|
88
|
+
yield
|
89
|
+
@@contexts << @context
|
90
|
+
@context = nil
|
91
|
+
end
|
92
|
+
alias_method context_construct, :context
|
93
|
+
end
|
27
94
|
end
|
28
95
|
|
96
|
+
|
29
97
|
class Activities
|
30
98
|
def self.on domain_context, &block
|
31
99
|
|
@@ -82,9 +150,8 @@ module Mushin
|
|
82
150
|
p 'Mushin::Engine is running'
|
83
151
|
@@domain_context = domain_context
|
84
152
|
@@activity = activity
|
85
|
-
|
153
|
+
|
86
154
|
@@middlewares = Mushin::DSL::Notebook.find @@domain_context, @@activity
|
87
|
-
#p @@middlewares
|
88
155
|
@@stack = Middleware::Builder.new do
|
89
156
|
#use GameOn::Persistence::DS
|
90
157
|
@@middlewares.each do |middleware|
|