Module: Liza

Defined in:
lib/liza.rb

Defined Under Namespace

Classes: AppTest, Box, BoxTest, ClassTest, ConstNotFound, Controller, ControllerSubsystemPart, ControllerTest, Error, ModuleTest, ObjectTest, Panel, PanelRescuerPart, PanelTest, Part, PartTest, StringTest, System, SystemTest, Test, TestAssertionsAdvancedPart, TestAssertionsPart, TestDslPart, TestLogPart, TestSubjectPart, TestTest, TestTreePart, TimeTest, Unit, UnitClassesPart, UnitClassesPartTest, UnitLoggingPart, UnitLoggingPartTest, UnitMethodsPart, UnitMethodsPartTest, UnitProcedurePart, UnitProcedurePartTest, UnitRendererPart, UnitRendererPartTest, UnitSettingsPart, UnitSettingsPartTest, UnitTest

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object



17
18
19
# File 'lib/liza.rb', line 17

def [] name
  const name
end

.const(name) ⇒ Object

Checks Object, each system, then Liza for Liza::Unit classes



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/liza.rb', line 22

def const name
  name = name.to_s.camelize.to_sym

  k = const_check_object name
  return k if k

  k = const_check_systems name
  return k if k

  k = const_get name
  return k if k

  nil
rescue NameError
  log "Liza const #{name} not found!" if $VERBOSE
  if Lizarb.ruby_supports_raise_cause?
    raise ConstNotFound, name, cause: nil
  else
    raise ConstNotFound, name, []
  end
end

.const_check_object(name) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/liza.rb', line 52

def const_check_object name
  return if not Object.const_defined? name
  kk = Object.const_get name
  return kk if is_unit? kk

  nil
end

.const_check_systems(name) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/liza.rb', line 60

def const_check_systems name
  App.systems.frozen? or return nil

  for k in App.systems.values.reverse
    next if not k.const_defined? name.to_sym
    kk = k.const(name) if k.constants.include? name
    return kk if is_unit? kk
  end

  nil
end

.const_missing(name) ⇒ Object

Checks each system, then Liza for Liza::Unit classes



45
46
47
48
49
50
# File 'lib/liza.rb', line 45

def const_missing name
  k = const_check_systems name
  return k if k

  super
end

.is_unit?(kk) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/liza.rb', line 72

def is_unit? kk
  kk && kk < Liza::Unit
end

.log(s) ⇒ Object



11
12
13
# File 'lib/liza.rb', line 11

def log s
  puts s
end