-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdcl.rb
79 lines (50 loc) · 1.57 KB
/
dcl.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# ModuleDef
require_relative "moduledef"
# Logging
require_relative "factlogging"
# The base classes
require_relative "statemachine"
# System constraints
require_relative "rules"
# Debug
require_relative "modulecache"
# Re-opening the class to define the DSL syntax
module DCL
# Defining a module for DCL
def mod(name, *paths)
# example - mod :ModuleA, ['system/views']
moddef = ModuleDef.new(name, paths)
DCL.insert_mod(moddef)
puts ModuleCache.cache
moddef
end
# Constraint simple
def the(mod_name, type_interaction, mod_target)
mod = DCL.get_mod(mod_name)
mod_target = DCL.get_mod(mod_target)
rule = TheRule.new(mod, type_interaction, mod_target)
DCL.insert_rule(rule)
end
def only(mod_name, type_interaction, mod_target)
end
end
if __FILE__ == $0
$:.unshift File.join(File.dirname(__FILE__),'..')
$:.unshift File.join(File.dirname(__FILE__),'.')
class Architecture
include DCL
def run
mod :model, 'system/model'
mod :view, 'system/view'
mod :controller, 'system/controller'
mod :util, 'system/util'
the :controller, :cant_access, :model
the :view, :cant_access, :controller
the :model, :cant_access, :view
the :model, :cant_access, :controller
# calls the system
require_relative 'system/main'
end
end
Architecture.new.run
end