Module: Zashoku::Module

Included in:
Conf
Defined in:
lib/core/module.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.load(modules) ⇒ Object



20
21
22
23
24
# File 'lib/core/module.rb', line 20

def self.load(modules)
  require_all(modules).map do |mod|
    [mod.name.split(':').last.downcase, mod]
  end.to_h
end

.require_all(modules) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/core/module.rb', line 26

def self.require_all(modules)
  modules.map do |mod|
    if require_module(mod)
      Zashoku.logger.info("loaded module #{mod}")
      Zashoku.const_get(mod)
    else
      Zashoku.logger.error("failed to load module #{mod}")
      nil
    end
  end.compact
end

.require_module(mod) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/core/module.rb', line 7

def self.require_module(mod)
  mod = mod.downcase
  Zashoku::LoadPaths.map do |path|
    mod_path = File.join(path, "#{mod}/lib/#{mod}.rb")
    next unless File.exist?(mod_path)
    begin
      require mod_path
    rescue LoadError
      false
    end
  end.any?
end

Instance Method Details

#controllerObject



42
# File 'lib/core/module.rb', line 42

def controller; end

#daemon_configObject



48
49
50
# File 'lib/core/module.rb', line 48

def daemon_config
  Util.get_yaml(File.join(self::Root, 'config/daemon.yml'))
end

#viewObject



40
# File 'lib/core/module.rb', line 40

def view; end

#view_configObject



44
45
46
# File 'lib/core/module.rb', line 44

def view_config
  Util.get_yaml(File.join(self::Root, 'config/view.yml'))
end