Class: Dapp::Config::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/dapp/config/application.rb

Overview

Application

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) {|_self| ... } ⇒ Application

Returns a new instance of Application.

Yields:

  • (_self)

Yield Parameters:



17
18
19
20
21
22
23
24
25
# File 'lib/dapp/config/application.rb', line 17

def initialize(parent)
  @_apps   = []
  @_parent = parent

  @_app_install_dependencies = []
  @_app_setup_dependencies   = []

  yield self if block_given?
end

Instance Attribute Details

#_app_install_dependenciesObject (readonly)

Returns the value of attribute _app_install_dependencies.



13
14
15
# File 'lib/dapp/config/application.rb', line 13

def _app_install_dependencies
  @_app_install_dependencies
end

#_app_setup_dependenciesObject (readonly)

Returns the value of attribute _app_setup_dependencies.



14
15
16
# File 'lib/dapp/config/application.rb', line 14

def _app_setup_dependencies
  @_app_setup_dependencies
end

#_builderObject (readonly)

Returns the value of attribute _builder.



6
7
8
# File 'lib/dapp/config/application.rb', line 6

def _builder
  @_builder
end

#_chefObject (readonly)

Returns the value of attribute _chef.



10
11
12
# File 'lib/dapp/config/application.rb', line 10

def _chef
  @_chef
end

#_dockerObject (readonly)

Returns the value of attribute _docker.



8
9
10
# File 'lib/dapp/config/application.rb', line 8

def _docker
  @_docker
end

#_git_artifactObject (readonly)

Returns the value of attribute _git_artifact.



9
10
11
# File 'lib/dapp/config/application.rb', line 9

def _git_artifact
  @_git_artifact
end

#_home_pathObject (readonly)

Returns the value of attribute _home_path.



7
8
9
# File 'lib/dapp/config/application.rb', line 7

def _home_path
  @_home_path
end

#_nameObject (readonly)

Returns the value of attribute _name.



5
6
7
# File 'lib/dapp/config/application.rb', line 5

def _name
  @_name
end

#_parentObject (readonly)

Returns the value of attribute _parent.



12
13
14
# File 'lib/dapp/config/application.rb', line 12

def _parent
  @_parent
end

#_shellObject (readonly)

Returns the value of attribute _shell.



11
12
13
# File 'lib/dapp/config/application.rb', line 11

def _shell
  @_shell
end

Instance Method Details

#_app_chainObject



64
65
66
# File 'lib/dapp/config/application.rb', line 64

def _app_chain
  @_app_chain ||= (_parent ? _parent._app_chain : []) + [self]
end

#_app_runlistObject



68
69
70
71
72
73
74
75
# File 'lib/dapp/config/application.rb', line 68

def _app_runlist
  _app_chain.map(&:_name).map do |name|
    if subname = name.split("#{_root_app._name}-", 2)[1]
      subname_parts = subname.split('-')
      subname_parts.join('_') if subname_parts.any?
    end
  end.compact
end

#_appsObject



60
61
62
# File 'lib/dapp/config/application.rb', line 60

def _apps
  @_apps.empty? ? [self] : @_apps.flatten
end

#_root_appObject



77
78
79
# File 'lib/dapp/config/application.rb', line 77

def _root_app
  _app_chain.first
end

#app_install_depends_on(*args) ⇒ Object



27
28
29
# File 'lib/dapp/config/application.rb', line 27

def app_install_depends_on(*args)
  @_app_install_dependencies.concat(args)
end

#app_setup_depends_on(*args) ⇒ Object



31
32
33
# File 'lib/dapp/config/application.rb', line 31

def app_setup_depends_on(*args)
  @_app_setup_dependencies.concat(args)
end

#builder(type) ⇒ Object

Raises:



53
54
55
56
57
58
# File 'lib/dapp/config/application.rb', line 53

def builder(type)
  raise Error::Config, code: :builder_type_unsupported, data: { type: type } unless [:chef, :shell].include?((type = type.to_sym))
  another_builder = [:chef, :shell].find { |t| t != type }
  instance_variable_set(:"@_#{another_builder}", Config.const_get(another_builder.capitalize).new)
  @_builder = type
end

#chefObject

Raises:



35
36
37
38
# File 'lib/dapp/config/application.rb', line 35

def chef
  raise Error::Config, code: :builder_type_conflict unless _builder == :chef
  @_chef ||= Chef.new
end

#dockerObject



49
50
51
# File 'lib/dapp/config/application.rb', line 49

def docker
  @_docker ||= Docker.new
end

#git_artifactObject



45
46
47
# File 'lib/dapp/config/application.rb', line 45

def git_artifact
  @_git_artifact ||= GitArtifact.new
end

#shellObject

Raises:



40
41
42
43
# File 'lib/dapp/config/application.rb', line 40

def shell
  raise Error::Config, code: :builder_type_conflict unless _builder == :shell
  @_shell ||= Shell.new
end