Module: Pult::Panel::App

Defined in:
lib/init/struct.rb,
lib/pult/panel/app.rb

Defined Under Namespace

Modules: DotAccessible, Injector

Class Method Summary collapse

Class Method Details

.config_dir!(app_hash, path) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/pult/panel/app.rb', line 3

def self.config_dir! app_hash, path
  app_name = app_hash.keys.first

  dir = Pathname.new(path).dirname.to_s

  app_hash[app_name] = {} if ! app_hash[app_name]
  config = (app_hash[app_name]['config'] ||= {})

  config['dir'] ||= dir
end

.make_apps!(panel) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pult/panel/app.rb', line 14

def self.make_apps! panel
  panel.instance_variable_set(:@_apps, [])

  for app_name in panel.keys
    hash = panel[app_name]

    panel._apps << app_name

    to_app! hash, panel, app_name
  end
end

.multi_action!(app_hash) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/pult/panel/app.rb', line 40

def self.multi_action! app_hash
  app_hash.keys.each do |key|
    value = app_hash[key]

    case value.class.name

    when "Hash"
      multi_action! value

    when "Array"
      case Pult::MULTIACT

      when 'clone'
        clone app_hash
        complex = {}
        value.each{ |elm| complex[elm] = app_hash[elm] }
        app_hash[key] = complex

      when 'join'
        app_hash[key] = '$(' + value.join(') && $(') + ')'
      end
    end
  end
end

.to_app!(app_hash, panel, app_name) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pult/panel/app.rb', line 26

def self.to_app! app_hash, panel, app_name
  multi_action! app_hash

  app_hash.class_eval { include DotAccessible }

  Injector.inject! app_hash, panel, app_name

  app_hash.values.each do |target|
    to_app!(target, panel, app_name) if target.is_a?(Hash)
  end

  app_hash
end