Class: Dapp::Application
- Inherits:
-
Object
- Object
- Dapp::Application
- Includes:
- GitArtifact, Logging, Path, Tags, Filelock, Helper::I18n, Helper::Log, Helper::Sha256, Helper::Shellout
- Defined in:
- lib/dapp/application.rb,
lib/dapp/application/path.rb,
lib/dapp/application/tags.rb,
lib/dapp/application/logging.rb,
lib/dapp/application/git_artifact.rb
Overview
Application
Direct Known Subclasses
Defined Under Namespace
Modules: GitArtifact, Logging, Path, Tags
Constant Summary
Constants included from Logging
Instance Attribute Summary collapse
-
#cli_options ⇒ Object
readonly
Returns the value of attribute cli_options.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#ignore_git_fetch ⇒ Object
readonly
Returns the value of attribute ignore_git_fetch.
-
#is_artifact ⇒ Object
readonly
Returns the value of attribute is_artifact.
Instance Method Summary collapse
- #build! ⇒ Object
- #builder ⇒ Object
- #export!(repo) ⇒ Object
-
#initialize(config:, cli_options:, ignore_git_fetch: false, is_artifact: false) ⇒ Application
constructor
A new instance of Application.
- #run(docker_options, command) ⇒ Object
- #signature ⇒ Object
Methods included from Filelock
Methods included from Path
#build_path, #container_dapp_path, #container_tmp_path, #home_path, #tmp_path
Methods included from GitArtifact
#git_artifacts, #local_git_artifacts, #remote_git_artifacts
Methods included from Logging
#dry_run?, #free_space, #log?, #log_process, #log_process_default, #log_process_short, #log_process_verbose, #log_quiet?, #log_secondary_process, #log_state, #log_time?, #log_verbose?, #rjust, #slice, #terminal_width
Methods included from Helper::Sha256
#hashsum, #paths_content_hashsum, #sha256
Methods included from Helper::I18n
Methods included from Helper::Shellout
included, #shellout, #shellout!, #shellout_pack
Methods included from Helper::Log
included, #log, #log_format_string, #log_indent, #log_indent_next, #log_indent_prev, #log_info, #log_secondary, #log_step, #log_time, #log_with_indent, #with_log_indent
Constructor Details
#initialize(config:, cli_options:, ignore_git_fetch: false, is_artifact: false) ⇒ Application
Returns a new instance of Application.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dapp/application.rb', line 19 def initialize(config:, cli_options:, ignore_git_fetch: false, is_artifact: false) @config = config = @tmp_path = Dir.mktmpdir([:tmp_dir_prefix] || 'dapp-') @build_path = [:build_dir] || home_path('.dapps-build') @last_stage = Build::Stage::DockerInstructions.new(self) @ignore_git_fetch = ignore_git_fetch @is_artifact = is_artifact end |
Instance Attribute Details
#cli_options ⇒ Object (readonly)
Returns the value of attribute cli_options.
15 16 17 |
# File 'lib/dapp/application.rb', line 15 def end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
14 15 16 |
# File 'lib/dapp/application.rb', line 14 def config @config end |
#ignore_git_fetch ⇒ Object (readonly)
Returns the value of attribute ignore_git_fetch.
16 17 18 |
# File 'lib/dapp/application.rb', line 16 def ignore_git_fetch @ignore_git_fetch end |
#is_artifact ⇒ Object (readonly)
Returns the value of attribute is_artifact.
17 18 19 |
# File 'lib/dapp/application.rb', line 17 def is_artifact @is_artifact end |
Instance Method Details
#build! ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/dapp/application.rb', line 31 def build! with_introspection do last_stage.build! last_stage.save_in_cache! end ensure FileUtils.rm_rf(tmp_path) end |
#builder ⇒ Object
69 70 71 |
# File 'lib/dapp/application.rb', line 69 def builder @builder ||= Builder.const_get(config._builder.capitalize).new(self) end |
#export!(repo) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/dapp/application.rb', line 40 def export!(repo) raise Error::Application, code: :application_not_built unless last_stage.image.tagged? || dry_run? .each do |tag| image_name = [repo, tag].join(':') if dry_run? log_state(image_name, state: t(code: 'state.push'), styles: { status: :success }) else log_process(image_name, process: t(code: 'status.process.pushing')) do last_stage.image.export!(image_name, log_verbose: log_verbose?, log_time: log_time?, force: [:force]) end end end end |
#run(docker_options, command) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/dapp/application.rb', line 55 def run(, command) raise Error::Application, code: :application_not_built unless last_stage.image.tagged? cmd = "docker run #{[docker_options, last_stage.image.name, command].flatten.compact.join(' ')}" if dry_run? log_info(cmd) else system(cmd) || raise(Error::Application, code: :application_not_run) end end |
#signature ⇒ Object
65 66 67 |
# File 'lib/dapp/application.rb', line 65 def signature last_stage.send(:signature) end |