Class: DevSystem::ControllerShell
- Inherits:
-
Shell
show all
- Defined in:
- lib/dev_system/subsystems/shell/shells/controller_shell.rb
Instance Attribute Summary
#menv
Class Method Summary
collapse
Methods inherited from Shell
all, cruby?, engine, jruby?, linux?, mac?, os, ruby_version, unix?, windows?
#`, `, attr_accessor, attr_reader, attr_writer, #attrs, box, #box, call, color, division, division!, division?, inherited, menv_accessor, menv_reader, menv_writer, on_connected, panel, #panel, plural, require, requirements, sh, #sh, singular, subsystem, subsystem!, subsystem?, subsystem_token, token
Methods inherited from Liza::Unit
_erbs_for, #add, add, cl, #cl, class_methods_defined, const_added, const_missing, constants_defined, define_error, descendants_select, division, erbs_available, erbs_defined, erbs_for, errors, #fetch, fetch, get, #get, instance_methods_defined, log, #log, log?, #log?, #log_array, log_array, log_hash, #log_hash, #log_level, log_level, #log_level?, log_level?, log_levels, #log_levels, #log_render_convert, #log_render_format, #log_render_in, #log_render_out, method_added, methods_defined, namespace, part, raise_error, #raise_error, reload!, #reload!, #render, #render!, #render_stack, renderable_formats_for, renderable_names, section, sections, #set, set, #settings, settings, singleton_method_added, sleep, #sleep, stick, #stick, sticks, #sticks, subclasses_select, subunits, system, #system, system?, test_class, time_diff, #time_diff
Class Method Details
.path_for(place, name) ⇒ Object
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/dev_system/subsystems/shell/shells/controller_shell.rb', line 32
def self.path_for(place, name)
system_name, subsystem_name = place.split("/")
if system_name == "app"
App.directory / "A"
elsif subsystem_name
App.systems_directory / "B"
else
App.systems_directory / "#{system_name}_system" / "subsystems" / name
end
end
|
.place_for(controller) ⇒ Object
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
|
# File 'lib/dev_system/subsystems/shell/shells/controller_shell.rb', line 43
def self.place_for(controller)
path = controller.source_location_path
system = controller.system
if path.include? App.directory.to_s
path = path.sub(App.directory.to_s, '')
segments = path.split('/')
token = segments[3].split("_").last.sub(".rb", "")
"app/#{segments[1]}/#{token}"
elsif path.include? system.source_location_radical
path = path.sub(system.source_location_radical, '')
segments = path.split('/')
case segments.count
when 3
"#{system.token}"
when 4, 5
token = segments[2]
"#{system.token}/#{token}"
else
raise "unexpected path: #{path} with #{segments.count} segments"
end
else
segments = path.split('/')
"other #{segments}"
end
end
|
.places_for(controller, directory_name: controller.plural) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/dev_system/subsystems/shell/shells/controller_shell.rb', line 5
def self.places_for(controller, directory_name: controller.plural)
ret = {
"app" => "#{App.relative_path}/#{controller.system.token}/#{directory_name}",
}
AppShell.writable_systems.each do |system_key, system|
path = system.source_location_radical.sub "#{App.root}/", ""
ret[system_key.to_s] = "#{path}/#{directory_name}"
system.subs.each do |sub|
ret["#{system_key}/#{sub}"] = "#{path}/subsystems/#{sub}/#{directory_name}"
end
end
ret
end
|
.places_for_systems(controller_name) ⇒ Object
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/dev_system/subsystems/shell/shells/controller_shell.rb', line 21
def self.places_for_systems(controller_name)
ret = {}
AppShell.writable_systems.each do |system_key, system|
path = system.source_location_radical.gsub "#{App.root}/", ""
ret[system_key.to_s] = "#{path}/subsystems/#{controller_name}"
end
ret
end
|
.unit_for(controller) ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/dev_system/subsystems/shell/shells/controller_shell.rb', line 74
def self.unit_for(controller)
place = place_for(controller)
segments = place.split('/')
case segments.count
when 1
Liza.const "#{segments[0]}_system"
when 2, 3
Liza.const segments.last
else
raise "unexpected place: #{place}"
end
end
|