Class: DevSystem::AppShell

Inherits:
Shell show all
Defined in:
lib/dev_system/sub/shell/shells/app_shell.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Shell

all, cruby?, engine, jruby?, linux?, mac?, os, ruby_version, unix?, windows?

Methods inherited from Liza::Controller

color, inherited, on_connected

Methods inherited from Liza::Unit

const_missing, division, part, system, #system, test_class

Constructor Details

#initializeAppShell

Returns a new instance of AppShell.



19
20
21
22
23
24
25
26
27
# File 'lib/dev_system/sub/shell/shells/app_shell.rb', line 19

def initialize
  liza_classes = self.class.liza_classes
  liza_categories = self.class.liza_categories
  h = @consts = {}
  h[:top_level]  = [Lizarb, App, Liza]
  h[:liza]       = self.class.liza_classes_structured
  h[:systems]    = self.class.system_classes_structured
  h[:app]        = self.class.object_classes_structured
end

Instance Attribute Details

#constsObject (readonly)

Returns the value of attribute consts.



17
18
19
# File 'lib/dev_system/sub/shell/shells/app_shell.rb', line 17

def consts
  @consts
end

Class Method Details

.classesObject



31
32
33
# File 'lib/dev_system/sub/shell/shells/app_shell.rb', line 31

def self.classes
  liza_classes + implementation_classes
end

.constsObject



12
13
14
15
# File 'lib/dev_system/sub/shell/shells/app_shell.rb', line 12

def self.consts
  @instance ||= new
  @instance.consts
end

.implementation_classesObject



39
40
41
# File 'lib/dev_system/sub/shell/shells/app_shell.rb', line 39

def self.implementation_classes
  Lizarb.loaders[1].__to_unload.keys.map { Object.const_get _1 }
end

.liza_categoriesObject



55
56
57
# File 'lib/dev_system/sub/shell/shells/app_shell.rb', line 55

def self.liza_categories
  ["unit", "base", "safety", "meta", "ruby_tests"]
end

.liza_classesObject



35
36
37
# File 'lib/dev_system/sub/shell/shells/app_shell.rb', line 35

def self.liza_classes
  Lizarb.loaders[0].__to_unload.keys.map { Object.const_get _1 }
end

.liza_classes_structuredObject



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
# File 'lib/dev_system/sub/shell/shells/app_shell.rb', line 61

def self.liza_classes_structured
  ret = {}
  liza_classes = self.liza_classes

  ret["unit"] =
    liza_classes
      .select { _1.source_location_radical.include? "/liza/unit" }
      .sort_by { _1.to_s }

  ret["base"] =
    liza_classes
      .select { _1.source_location_radical.include? "/liza/base" }
      .sort_by { _1.to_s }

  ret["safety"] =
    liza_classes
      .select { _1.source_location_radical.include? "/liza/safety" }
      .sort_by { _1.to_s }

  ret["meta"] =
    liza_classes
      .select { _1.source_location_radical.include? "/liza/meta" }
      .sort_by { _1.to_s }

  ret["ruby_tests"] =
    liza_classes
      .select { _1.source_location_radical.include? "/liza/ruby_tests" }
      .sort_by { _1.to_s }

  raise "not all categories are filled" if liza_categories != ret.select { _2.any? }.keys

  ret
end

.object_classesObject



49
50
51
# File 'lib/dev_system/sub/shell/shells/app_shell.rb', line 49

def self.object_classes
  implementation_classes.select { _1.namespace == Object }
end

.object_classes_structuredObject



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/dev_system/sub/shell/shells/app_shell.rb', line 155

def self.object_classes_structured
  ret = {}
  object_classes = self.object_classes.sort_by { _1.source_location_radical }

  App.systems.each do |system_name, system|
    tree = ret[system_name.to_s] = {}

    a = object_classes.select { _1.system == system }
    
    tree["box"] = []
    box = Liza.const "#{system_name}_box"
    if box.namespace == Object
      tree["box"] << box
      a.delete box
    end

    tree["controllers"] = {}

    a.each do |klass|
      tree["controllers"][klass.subsystem] ||= {}
      tree["controllers"][klass.subsystem][klass.division] ||= []
      tree["controllers"][klass.subsystem][klass.division] << klass
    end

    system.subsystems.each do |subsystem|
      tree["controllers"][subsystem]&.each do |division, klasses|
        klasses.sort_by! &:to_s
      end
    end
  end

  ret
end

.system_classesObject



45
46
47
# File 'lib/dev_system/sub/shell/shells/app_shell.rb', line 45

def self.system_classes
  implementation_classes.reject { _1.namespace == Object }
end

.system_classes_structuredObject



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/dev_system/sub/shell/shells/app_shell.rb', line 95

def self.system_classes_structured
  ret = {}
  system_classes = self.system_classes

  App.systems.each do |system_name, system|
    tree = ret[system_name.to_s] = {}

    array = system_classes.select { _1.system == system }

    tree["system"]      = [system]
    tree["box"]         = [system.box, system.box.test_class]
    tree["controllers"] = {}
    tree["subsystems"]  = {}

    array.delete system
    array.delete system.box
    array.delete system.box.test_class
    
    system.subsystems.each do |subsystem|
      tree["subsystems"][subsystem] = {}
      tree["subsystems"][subsystem]["panel"] = [subsystem.panel.class, subsystem.panel.class.test_class]
      tree["subsystems"][subsystem]["controller"] = [subsystem, subsystem.test_class]
      tree["subsystems"][subsystem]["controllers"] = {}

      array.delete subsystem.panel.class
      array.delete subsystem.panel.class.test_class
      array.delete subsystem
      array.delete subsystem.test_class
    end

    array.each do |klass|
      radical = klass.source_location_radical

      if radical.include? "/#{system_name}_system/sub"
        name = radical.split("_system/sub/").last.split("/").first
        subsystem = system.const name
        klasses = tree["subsystems"][subsystem]["controllers"][klass.division] ||= []
      else
        klasses = tree["controllers"][klass.division] ||= []
      end

      klasses << klass
    end

  end

  ret.each do |system_name, tree|
    tree["subsystems"].each do |subsystem_name, subsystem_tree|
      subsystem_tree["controllers"].each do |division, controllers|
        controllers.sort_by! &:to_s
      end
    end
    tree["controllers"].each do |division, controllers|
      controllers.sort_by! &:to_s
    end
  end

  ret
end

.writable_systemsObject



5
6
7
8
# File 'lib/dev_system/sub/shell/shells/app_shell.rb', line 5

def self.writable_systems
  root = App.root.to_s
  App.systems.select { _2.source_location_radical.start_with? root }
end