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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mushin/base.rb +76 -9
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7c56221d209cd7648ec3a78e1a0a09be5ec652b
4
- data.tar.gz: 0f7943316a34d57c0dfab9ca82af398e7a1cca6b
3
+ metadata.gz: 772621afa533c2966ba9f755bff39cb61d70e673
4
+ data.tar.gz: 4cab1bb635e2c1855b3bb15abf4a88f43ccb7585
5
5
  SHA512:
6
- metadata.gz: e0a69caa382476e9f07273c3585d12df85856bd7ef4b7a128567c38591a841c972328bcb2abcf2f27fc0e1627c6a8f3cfe0493463c32d308b1f6b59cb1fc6555
7
- data.tar.gz: ab727a9e7ef1119d7f6248f6ea61f8394a055b708098e6b672fea362c1125683229f6bc758b30bd02c6a70a12ebaeddf4cddf1c17bf8b347d0c74cf84c40d6b2
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 activity_construct, activity_rule
44
+ def self.find activity_context, activity_statment
13
45
  @@middlewares = []
14
- @@constructs.each do |construct|
15
- if activity_construct == construct.title
16
- construct.rules.each do |rule|
17
- if activity_rule == rule.title
18
- rule.all_dynamix.each do |middleware|
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
- #TODO write metaprog code in Mushin::DSL::Gamebooks to figure out the modules that included it via the included(self) and then trigger the find function on it to get its own domain
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|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mushin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.pre6
4
+ version: 0.0.0.pre7
5
5
  platform: ruby
6
6
  authors:
7
7
  - theotherstupidguy