Class: DevSystem::BaseCommand

Inherits:
Command show all
Defined in:
lib/dev_system/subsystems/command/commands/base_command.rb

Direct Known Subclasses

SimpleCommand

Instance Attribute Summary

Attributes inherited from Liza::Controller

#menv

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Liza::Controller

#`, `, attr_accessor, attr_reader, attr_writer, #attrs, box, #box, 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

.call(menv) ⇒ Object



5
6
7
8
9
# File 'lib/dev_system/subsystems/command/commands/base_command.rb', line 5

def self.call(menv)
  super
  command = menv[:command] = new
  command.call menv
end

.get_command_signaturesObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/dev_system/subsystems/command/commands/base_command.rb', line 51

def self.get_command_signatures
  signatures = []
  ancestors_until(BaseCommand).each do |c|
    signatures +=
      c.instance_methods_defined.select do |name|
        name.start_with? "call_"
      end.map do |name|
        {
          name: ( name.to_s.sub("call_", "").sub("default", "") ),
          description: "# no description",
        }
      end
  end
  signatures.uniq { _1[:name] }
end

.typoObject



75
# File 'lib/dev_system/subsystems/command/commands/base_command.rb', line 75

def self.typo() = TypographyShell

Instance Method Details

#action_method_nameObject



73
# File 'lib/dev_system/subsystems/command/commands/base_command.rb', line 73

def action_method_name() = "call_#{action_name}"

#action_nameObject



71
# File 'lib/dev_system/subsystems/command/commands/base_command.rb', line 71

def action_name() = menv[:command_action]

#afterObject



41
42
43
# File 'lib/dev_system/subsystems/command/commands/base_command.rb', line 41

def after
  # placebolder
end

#aroundObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/dev_system/subsystems/command/commands/base_command.rb', line 26

def around
  log :high, "."
  before
  public_send action_method_name
  after
  log :high, "."
rescue Exception => e
  raise unless defined? rescue_from
  rescue_from e
end

#beforeObject



37
38
39
# File 'lib/dev_system/subsystems/command/commands/base_command.rb', line 37

def before
  # placebolder
end

#call(menv) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/dev_system/subsystems/command/commands/base_command.rb', line 15

def call(menv)
  log :higher, "menv.count is #{menv.count}"
  self.menv = menv

  if respond_to? action_method_name
    around
  else
    not_found
  end
end

#envObject



13
# File 'lib/dev_system/subsystems/command/commands/base_command.rb', line 13

def env() = menv

#not_foundObject



45
46
47
# File 'lib/dev_system/subsystems/command/commands/base_command.rb', line 45

def not_found
  log stick :red, "Not found: #{action_name}, please define method '#{action_method_name}'"
end

#typoObject



77
# File 'lib/dev_system/subsystems/command/commands/base_command.rb', line 77

def typo() = TypographyShell