Class: Dapp::Config::Application
- Inherits:
-
Object
- Object
- Dapp::Config::Application
- Defined in:
- lib/dapp/config/application.rb
Overview
Application
Instance Attribute Summary collapse
-
#_after_install_artifact ⇒ Object
readonly
Returns the value of attribute _after_install_artifact.
-
#_after_setup_artifact ⇒ Object
readonly
Returns the value of attribute _after_setup_artifact.
-
#_basename ⇒ Object
readonly
Returns the value of attribute _basename.
-
#_before_install_artifact ⇒ Object
readonly
Returns the value of attribute _before_install_artifact.
-
#_before_setup_artifact ⇒ Object
readonly
Returns the value of attribute _before_setup_artifact.
-
#_build_dir ⇒ Object
readonly
Returns the value of attribute _build_dir.
-
#_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.
-
#_import_artifact ⇒ Object
readonly
Returns the value of attribute _import_artifact.
-
#_install_dependencies ⇒ Object
readonly
Returns the value of attribute _install_dependencies.
-
#_parent ⇒ Object
readonly
Returns the value of attribute _parent.
-
#_setup_dependencies ⇒ Object
readonly
Returns the value of attribute _setup_dependencies.
-
#_shell ⇒ Object
readonly
Returns the value of attribute _shell.
-
#_tmp_dir ⇒ Object
readonly
Returns the value of attribute _tmp_dir.
Instance Method Summary collapse
- #_app_chain ⇒ Object
- #_app_runlist ⇒ Object
- #_apps ⇒ Object
- #_name ⇒ Object
- #_root_app ⇒ Object
- #artifact(where_to_add, before: nil, after: nil, **options, &blk) ⇒ Object
- #build_dir ⇒ Object
- #builder(type) ⇒ Object
- #chef ⇒ Object
- #docker ⇒ Object
- #git_artifact ⇒ Object
-
#initialize(parent) {|_self| ... } ⇒ Application
constructor
A new instance of Application.
- #install_depends_on(*args) ⇒ Object
- #setup_depends_on(*args) ⇒ Object
- #shell ⇒ Object
- #tmp_dir ⇒ Object
Constructor Details
#initialize(parent) {|_self| ... } ⇒ Application
Returns a new instance of Application.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dapp/config/application.rb', line 15 def initialize(parent) @_parent = parent @_docker = Directive::Docker::Base.new @_git_artifact = Directive::GitArtifact.new @_shell = Directive::Shell::Base.new @_chef = Directive::Chef.new @_tmp_dir = Directive::TmpDir.new @_build_dir = Directive::BuildDir.new @_apps = [] @_before_install_artifact = [] @_before_setup_artifact = [] @_after_install_artifact = [] @_after_setup_artifact = [] @_import_artifact = [] @_install_dependencies = [] @_setup_dependencies = [] yield self if block_given? end |
Instance Attribute Details
#_after_install_artifact ⇒ Object (readonly)
Returns the value of attribute _after_install_artifact.
12 13 14 |
# File 'lib/dapp/config/application.rb', line 12 def _after_install_artifact @_after_install_artifact end |
#_after_setup_artifact ⇒ Object (readonly)
Returns the value of attribute _after_setup_artifact.
12 13 14 |
# File 'lib/dapp/config/application.rb', line 12 def _after_setup_artifact @_after_setup_artifact end |
#_basename ⇒ Object (readonly)
Returns the value of attribute _basename.
6 7 8 |
# File 'lib/dapp/config/application.rb', line 6 def _basename @_basename end |
#_before_install_artifact ⇒ Object (readonly)
Returns the value of attribute _before_install_artifact.
12 13 14 |
# File 'lib/dapp/config/application.rb', line 12 def _before_install_artifact @_before_install_artifact end |
#_before_setup_artifact ⇒ Object (readonly)
Returns the value of attribute _before_setup_artifact.
12 13 14 |
# File 'lib/dapp/config/application.rb', line 12 def _before_setup_artifact @_before_setup_artifact end |
#_build_dir ⇒ Object (readonly)
Returns the value of attribute _build_dir.
13 14 15 |
# File 'lib/dapp/config/application.rb', line 13 def _build_dir @_build_dir end |
#_builder ⇒ Object (readonly)
Returns the value of attribute _builder.
8 9 10 |
# File 'lib/dapp/config/application.rb', line 8 def _builder @_builder end |
#_chef ⇒ Object (readonly)
Returns the value of attribute _chef.
8 9 10 |
# File 'lib/dapp/config/application.rb', line 8 def _chef @_chef end |
#_docker ⇒ Object (readonly)
Returns the value of attribute _docker.
10 11 12 |
# File 'lib/dapp/config/application.rb', line 10 def _docker @_docker end |
#_git_artifact ⇒ Object (readonly)
Returns the value of attribute _git_artifact.
11 12 13 |
# File 'lib/dapp/config/application.rb', line 11 def _git_artifact @_git_artifact end |
#_home_path ⇒ Object (readonly)
Returns the value of attribute _home_path.
5 6 7 |
# File 'lib/dapp/config/application.rb', line 5 def _home_path @_home_path end |
#_import_artifact ⇒ Object (readonly)
Returns the value of attribute _import_artifact.
12 13 14 |
# File 'lib/dapp/config/application.rb', line 12 def _import_artifact @_import_artifact end |
#_install_dependencies ⇒ Object (readonly)
Returns the value of attribute _install_dependencies.
9 10 11 |
# File 'lib/dapp/config/application.rb', line 9 def _install_dependencies @_install_dependencies end |
#_parent ⇒ Object (readonly)
Returns the value of attribute _parent.
7 8 9 |
# File 'lib/dapp/config/application.rb', line 7 def _parent @_parent end |
#_setup_dependencies ⇒ Object (readonly)
Returns the value of attribute _setup_dependencies.
9 10 11 |
# File 'lib/dapp/config/application.rb', line 9 def _setup_dependencies @_setup_dependencies end |
#_shell ⇒ Object (readonly)
Returns the value of attribute _shell.
8 9 10 |
# File 'lib/dapp/config/application.rb', line 8 def _shell @_shell end |
#_tmp_dir ⇒ Object (readonly)
Returns the value of attribute _tmp_dir.
13 14 15 |
# File 'lib/dapp/config/application.rb', line 13 def _tmp_dir @_tmp_dir end |
Instance Method Details
#_app_chain ⇒ Object
95 96 97 |
# File 'lib/dapp/config/application.rb', line 95 def _app_chain @_app_chain ||= (_parent ? _parent._app_chain : []) + [self] end |
#_app_runlist ⇒ Object
99 100 101 102 103 104 105 106 |
# File 'lib/dapp/config/application.rb', line 99 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
91 92 93 |
# File 'lib/dapp/config/application.rb', line 91 def _apps @_apps.empty? ? [self] : @_apps.flatten end |
#_name ⇒ Object
84 85 86 87 88 89 |
# File 'lib/dapp/config/application.rb', line 84 def _name (@_name || @_basename).tap do |name| reg = '^[[[:alnum:]]_.-]*$' raise Error::Config, code: :app_name_incorrect, data: { name: name, reg: reg } unless name =~ /#{reg}/ end end |
#_root_app ⇒ Object
108 109 110 |
# File 'lib/dapp/config/application.rb', line 108 def _root_app _app_chain.first end |
#artifact(where_to_add, before: nil, after: nil, **options, &blk) ⇒ Object
67 68 69 70 |
# File 'lib/dapp/config/application.rb', line 67 def artifact(where_to_add, before: nil, after: nil, **, &blk) raise Error::Config, code: :stage_artifact_double_associate unless before.nil? || after.nil? artifact_base(instance_variable_get(:"@_#{artifact_variable_name(before, after)}"), where_to_add, **, &blk) end |
#build_dir ⇒ Object
80 81 82 |
# File 'lib/dapp/config/application.rb', line 80 def build_dir @_build_dir end |
#builder(type) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/dapp/config/application.rb', line 47 def builder(type) project.log_warning(desc: { code: 'excess_builder_instruction', context: 'warning' }) if @_chef.send(:empty?) && @_shell.send(:empty?) 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}", instance_variable_get(:"@_#{another_builder}").class.new) @_builder = type end |
#chef ⇒ Object
55 56 57 |
# File 'lib/dapp/config/application.rb', line 55 def chef @_chef.tap { raise Error::Config, code: :builder_type_conflict unless _builder == :chef } end |
#docker ⇒ Object
63 64 65 |
# File 'lib/dapp/config/application.rb', line 63 def docker @_docker end |
#git_artifact ⇒ Object
72 73 74 |
# File 'lib/dapp/config/application.rb', line 72 def git_artifact @_git_artifact ||= Directive::GitArtifact.new end |
#install_depends_on(*args) ⇒ Object
39 40 41 |
# File 'lib/dapp/config/application.rb', line 39 def install_depends_on(*args) @_install_dependencies.concat(args) end |
#setup_depends_on(*args) ⇒ Object
43 44 45 |
# File 'lib/dapp/config/application.rb', line 43 def setup_depends_on(*args) @_setup_dependencies.concat(args) end |
#shell ⇒ Object
59 60 61 |
# File 'lib/dapp/config/application.rb', line 59 def shell @_shell.tap { raise Error::Config, code: :builder_type_conflict unless _builder == :shell } end |
#tmp_dir ⇒ Object
76 77 78 |
# File 'lib/dapp/config/application.rb', line 76 def tmp_dir @_tmp_dir end |