Class: Dapp::Config::Application
- Inherits:
-
Object
- Object
- Dapp::Config::Application
- Defined in:
- lib/dapp/config/application.rb
Overview
Application
Instance Attribute Summary collapse
-
#_app_install_dependencies ⇒ Object
readonly
Returns the value of attribute _app_install_dependencies.
-
#_app_setup_dependencies ⇒ Object
readonly
Returns the value of attribute _app_setup_dependencies.
-
#_artifact ⇒ Object
readonly
Returns the value of attribute _artifact.
-
#_basename ⇒ Object
readonly
Returns the value of attribute _basename.
-
#_builder ⇒ Object
readonly
Returns the value of attribute _builder.
-
#_chef ⇒ Object
readonly
Returns the value of attribute _chef.
-
#_docker ⇒ Object
readonly
Returns the value of attribute _docker.
-
#_git_artifact ⇒ Object
readonly
Returns the value of attribute _git_artifact.
-
#_home_path ⇒ Object
readonly
Returns the value of attribute _home_path.
-
#_parent ⇒ Object
readonly
Returns the value of attribute _parent.
-
#_shell ⇒ Object
readonly
Returns the value of attribute _shell.
Instance Method Summary collapse
- #_app_chain ⇒ Object
- #_app_runlist ⇒ Object
- #_apps ⇒ Object
- #_name ⇒ Object
- #_root_app ⇒ Object
- #app_install_depends_on(*args) ⇒ Object
- #app_setup_depends_on(*args) ⇒ Object
- #artifact(where_to_add, **options, &blk) ⇒ Object
- #builder(type) ⇒ Object
- #chef ⇒ Object
- #docker ⇒ Object
- #git_artifact ⇒ Object
-
#initialize(parent) {|_self| ... } ⇒ Application
constructor
A new instance of Application.
- #shell ⇒ Object
Constructor Details
#initialize(parent) {|_self| ... } ⇒ Application
Returns a new instance of Application.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dapp/config/application.rb', line 18 def initialize(parent) @_apps = [] @_parent = parent @_artifact = [] @_app_install_dependencies = [] @_app_setup_dependencies = [] yield self if block_given? end |
Instance Attribute Details
#_app_install_dependencies ⇒ Object (readonly)
Returns the value of attribute _app_install_dependencies.
14 15 16 |
# File 'lib/dapp/config/application.rb', line 14 def _app_install_dependencies @_app_install_dependencies end |
#_app_setup_dependencies ⇒ Object (readonly)
Returns the value of attribute _app_setup_dependencies.
15 16 17 |
# File 'lib/dapp/config/application.rb', line 15 def _app_setup_dependencies @_app_setup_dependencies end |
#_artifact ⇒ Object (readonly)
Returns the value of attribute _artifact.
10 11 12 |
# File 'lib/dapp/config/application.rb', line 10 def _artifact @_artifact end |
#_basename ⇒ Object (readonly)
Returns the value of attribute _basename.
7 8 9 |
# File 'lib/dapp/config/application.rb', line 7 def _basename @_basename end |
#_builder ⇒ Object (readonly)
Returns the value of attribute _builder.
5 6 7 |
# File 'lib/dapp/config/application.rb', line 5 def _builder @_builder end |
#_chef ⇒ Object (readonly)
Returns the value of attribute _chef.
11 12 13 |
# File 'lib/dapp/config/application.rb', line 11 def _chef @_chef end |
#_docker ⇒ Object (readonly)
Returns the value of attribute _docker.
8 9 10 |
# File 'lib/dapp/config/application.rb', line 8 def _docker @_docker end |
#_git_artifact ⇒ Object (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_path ⇒ Object (readonly)
Returns the value of attribute _home_path.
6 7 8 |
# File 'lib/dapp/config/application.rb', line 6 def _home_path @_home_path end |
#_parent ⇒ Object (readonly)
Returns the value of attribute _parent.
13 14 15 |
# File 'lib/dapp/config/application.rb', line 13 def _parent @_parent end |
#_shell ⇒ Object (readonly)
Returns the value of attribute _shell.
12 13 14 |
# File 'lib/dapp/config/application.rb', line 12 def _shell @_shell end |
Instance Method Details
#_app_chain ⇒ Object
81 82 83 |
# File 'lib/dapp/config/application.rb', line 81 def _app_chain @_app_chain ||= (_parent ? _parent._app_chain : []) + [self] end |
#_app_runlist ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/dapp/config/application.rb', line 85 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 |
#_apps ⇒ Object
77 78 79 |
# File 'lib/dapp/config/application.rb', line 77 def _apps @_apps.empty? ? [self] : @_apps.flatten end |
#_name ⇒ Object
73 74 75 |
# File 'lib/dapp/config/application.rb', line 73 def _name @_name || @_basename end |
#_root_app ⇒ Object
94 95 96 |
# File 'lib/dapp/config/application.rb', line 94 def _root_app _app_chain.first end |
#app_install_depends_on(*args) ⇒ Object
29 30 31 |
# File 'lib/dapp/config/application.rb', line 29 def app_install_depends_on(*args) @_app_install_dependencies.concat(args) end |
#app_setup_depends_on(*args) ⇒ Object
33 34 35 |
# File 'lib/dapp/config/application.rb', line 33 def app_setup_depends_on(*args) @_app_setup_dependencies.concat(args) end |
#artifact(where_to_add, **options, &blk) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/dapp/config/application.rb', line 47 def artifact(where_to_add, **, &blk) @_artifact << begin config = clone.tap do |app| app.instance_variable_set(:'@_artifact', []) app.instance_variable_set(:'@_name', app_name("artifact-#{SecureRandom.hex(2)}")) app.instance_eval(&blk) if block_given? end Artifact::Stage.new(where_to_add, config: config, **) end end |
#builder(type) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/dapp/config/application.rb', line 66 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 |
#chef ⇒ Object
37 38 39 40 |
# File 'lib/dapp/config/application.rb', line 37 def chef raise Error::Config, code: :builder_type_conflict unless _builder == :chef @_chef ||= Chef.new end |
#docker ⇒ Object
62 63 64 |
# File 'lib/dapp/config/application.rb', line 62 def docker @_docker ||= Docker.new end |
#git_artifact ⇒ Object
58 59 60 |
# File 'lib/dapp/config/application.rb', line 58 def git_artifact @_git_artifact ||= GitArtifact.new end |
#shell ⇒ Object
42 43 44 45 |
# File 'lib/dapp/config/application.rb', line 42 def shell raise Error::Config, code: :builder_type_conflict unless _builder == :shell @_shell ||= Shell.new end |