mushin 0.0.0.pre45 → 0.0.0.pre46

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mushin/base.rb +51 -101
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 959da7c4d30dc339ba3cf0f83d5d68ce2c7f7421
4
- data.tar.gz: 1b32f29c40158a46adcb3705ee88f3382eabc0b7
3
+ metadata.gz: 64031cf8b44aef12e01d9f26736db1e4d994f411
4
+ data.tar.gz: 51fbcc7fd495144bd40f44dbd1d24a40d31e334c
5
5
  SHA512:
6
- metadata.gz: 36aa96d41d3f6e7ad4c65f93a3c26c40cc6240b4267480c2cbbfd50f36b9172a7cc63a4d9da4a542711a274c15e36dcb48b3b223dfa5c0e57154210a7b850ae6
7
- data.tar.gz: 96563ee189baba19c9110d6827d4475b2ffc369be950a77223de658e48a55ae1984f34605cac9918ed66e24de426fd2e582b60b99dca23f8adf095e78af66a7f
6
+ metadata.gz: 2b0d38f41cef39e429c193287e94f6cbbb407bfc395fd6fa701a6049102334c10e4ad0a60462cecbfe39b2ded302f9ba0c96bcfa19447941f3811da35a7c5157
7
+ data.tar.gz: 1a5a14de10aa5ff5e118aeffd92b3256fec7cb31e6be6f83c439953f51702c60ed9e05651c5d9d0c0c02093a0a5bdfeaf9910b214dea58eaa13e56d0daea61c0
data/lib/mushin/base.rb CHANGED
@@ -1,39 +1,49 @@
1
1
  require_relative './middleware/builder'
2
2
  require_relative './middleware/runner'
3
3
 
4
- module Mushin
4
+ module Mushin # Domain Frameworks Generator
5
5
  module Errors
6
6
  exceptions = %w[ UnkownDSLConstruct UnkownActivation UnknownOption ]
7
7
  exceptions.each { |e| const_set(e, Class.new(StandardError)) }
8
8
  end
9
9
 
10
- module Customization
10
+ module Env
11
+ def register &block
12
+ instance_eval &block
13
+ end
14
+
15
+ def set id, &block
16
+ raise "Domain Framework must impelment set"
17
+ end
18
+ def get id
19
+ raise "Domain Framework must impelment get"
20
+ end
21
+ end
22
+
23
+ module Mushin::Middleware
11
24
  class << self
25
+ attr_accessor :opts, :params
12
26
  def opts
13
- instance_eval do
14
- @opts ||= {}
15
- end
27
+ @opts ||= {}
16
28
  end
17
29
  def params
18
- instance_eval do
19
- @params ||= {}
20
- end
30
+ @params ||= {}
21
31
  end
22
32
  end
23
33
  module Opts
24
34
  def self.[] key
25
- Mushin::Customization.opts[key]
35
+ Mushin::Middleware.opts[key]
26
36
  end
27
37
  def self.[]= key, value
28
- Mushin::Customization.opts.merge! Hash[key, value]
38
+ Mushin::Middleware.opts.merge! Hash[key, value]
29
39
  end
30
40
  end
31
41
  module Params
32
42
  def self.[] key
33
- Mushin::Customization.params[key]
43
+ Mushin::Middleware.params[key]
34
44
  end
35
45
  def self.[]= key, value
36
- Mushin::Customization.params.merge! Hash[key, value]
46
+ Mushin::Middleware.params.merge! Hash[key, value]
37
47
  end
38
48
  end
39
49
  end
@@ -62,109 +72,49 @@ module Mushin
62
72
  end
63
73
  end
64
74
 
65
- module Notebook
66
- def self.extended(mod)
67
- puts "#{self} extended in #{mod}"
68
- #self.send(:include, mod)
69
- mod.send(:include, self)
70
- end
71
-
72
- @@contexts = []
73
- def context title, &block
74
- @context = Mushin::DSL::Context.new title
75
- def statment statment=[], &block
76
- @statment = Mushin::DSL::Statment.new statment
77
- def activation name, opts={}, params={}
78
- @activation = Mushin::DSL::Activation.new name, opts, params
79
- @statment.activations << @activation
80
- end
81
- yield
82
- @context.statments << @statment
83
- end
84
- yield
85
- @@contexts << @context
86
- end
87
-
88
- def self.find activity_context, activity_statment
89
- @@middlewares = []
90
- @@contexts.each do |current_context|
91
- if activity_context == current_context.title
92
- current_context.statments.each do |statment|
93
- if activity_statment == statment.title
94
- statment.activations.each do |middleware|
95
- @@middlewares << middleware
96
- end
97
- end
98
- end
99
- end
100
- end
101
- @@middlewares
102
- end
103
- end
104
- end
105
-
106
- class Env
107
- @@ds = ''
108
-
109
- def Env.register &block
110
- class_eval &block
111
- #instance_eval &block
75
+ class << self
76
+ attr_accessor :contexts, :middlewares
112
77
  end
113
-
114
- #def Env.params &block
115
- #attr_accessor :opts, :params
116
- #instance_eval &block
117
- #end
118
-
119
- #def Env.set id, &block
120
- # raise "Framework didn't implement Env.set"
121
- #end
122
- @@domain_folder = ""
123
- def Env.set id, &block
124
- @id = id
125
- def self.on domain_context, &block
126
- @@domain_context = domain_context
127
- @@activities = []
128
- def self.activity statment
129
- @@activities += [statment]
78
+ Mushin::DSL.contexts = []
79
+ def context title, &block
80
+ @context = Mushin::DSL::Context.new title
81
+ def statment statment=[], &block
82
+ @statment = Mushin::DSL::Statment.new statment
83
+ def activation name, opts={}, params={}
84
+ @activation = Mushin::DSL::Activation.new name, opts, params
85
+ @statment.activations << @activation
130
86
  end
131
- class_eval(&block)
132
- end
133
- class_eval(&block)
134
-
135
- Dir["./#{@@domain_folder}/*"].each {|file| load file }
136
-
137
- Mushin::Engine.setup [Object.const_get(@@ds)]
138
- @@activities.each do |activity|
139
- Mushin::Engine.run @@domain_context, activity
87
+ yield
88
+ @context.statments << @statment
140
89
  end
141
- end
142
-
143
- def Env.get id
144
- raise "Framework didn't implement Env.get"
90
+ yield
91
+ Mushin::DSL.contexts << @context
145
92
  end
146
93
  end
147
94
 
148
95
  module Engine
149
- def Engine.setup before_stack = []
150
- @@setup_middlewares = before_stack
96
+ attr_accessor :setup_middlewares
97
+ def setup before_stack = []
98
+ @setup_middlewares = before_stack
151
99
  end
152
100
 
153
- def Engine.run domain_context, activity
154
- @@domain_context = domain_context
155
- @@activity = activity
101
+ attr_accessor :domain_context, :activity
102
+ attr_accessor :middlewares, :stack
103
+ def run domain_context, activity
104
+ @domain_context = domain_context
105
+ @activity = activity
156
106
 
157
- @@middlewares = Mushin::DSL::Notebook.find @@domain_context, @@activity
158
- @@stack = Middleware::Builder.new do
159
- @@middlewares.each do |middleware|
160
- #p "use #{middleware.name}, #{middleware.opts}, #{middleware.params}"
107
+ @middlewares = Mushin::DSL::Notebook.find @domain_context, @activity
108
+ @stack = Middleware::Builder.new do
109
+ @middlewares.each do |middleware|
110
+ p "Mushin Logging: use #{middleware.name}, #{middleware.opts}, #{middleware.params}"
161
111
  use middleware.name, middleware.opts, middleware.params
162
112
  end
163
113
  end
164
- @@setup_middlewares.each do |setup_middleware|
165
- @@stack.insert_before 0, setup_middleware
114
+ @setup_middlewares.each do |setup_middleware|
115
+ @stack.insert_before 0, setup_middleware
166
116
  end
167
- @@stack.call
117
+ @stack.call
168
118
  end
169
119
  end
170
120
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mushin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.pre45
4
+ version: 0.0.0.pre46
5
5
  platform: ruby
6
6
  authors:
7
7
  - theotherstupidguy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-25 00:00:00.000000000 Z
11
+ date: 2014-05-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: In the beginner’s mind there are many possibilities, in the expert’s
14
14
  mind there are few!