-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_wrong.rb
111 lines (74 loc) · 1.79 KB
/
test_wrong.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#http://slideshow.rubyforge.org/ruby19.html#27
#require 'ruby-debug'; debugger;
#puts $:
=begin
mod = ProxyMachine
mod
.constants
.collect{|c| mod.const_get(c)}
.each{|c|
puts c.to_s; c.instance_methods(false).each{|m|
puts ' ' + c.instance_method(m).to_s
}
}
puts mod.methods
=end
###############################################################################
# DSL
###############################################################################
# A rule defined by the user. Or, simply, an arquitecture constraint
class Rule
end
=begin
class ModuleRule < Rule
attr_acessor :name, :modules
@name = ""
@modules = []
def initialize(name, modules)
@name = name
if modules.type != Array
modules = [modules]
end
@modules = modules
end
end
class TheRule < Rule
end
class OnlyRule < Rule
end
class ModuleList < List
def get_mod(name)
reject { |b| !match(b.name, 0, name) }
end
end
# Methods used by the DCL language
class DCL
attr_acessor :mods
@mods = ModuleList([])
@can_create = :can_create
@can_access = :can_access
@can_extend = :can_extend
@cannot_create = :cannot_create
@cannot_access = :cannot_access
@cannot_extend = :cannot_extend
# Create a module
def mod(mod_name, *mods_path)
@mods.push ModuleRule.new(mod_name, *mods_path)
end
def only(mods_name, action, mods_name_target)
end
def the(mods_name)
end
def extend()
end
def throw()
end
end
class Architecture < DCL
mod :A, "A.*"
mod :BC, "B.*", "C.*"
end
=end
puts Module.constants()
require "ruby18_parse"
puts Module.constants()