Class: Dapp::Dapp
- Inherits:
-
Object
- Object
- Dapp::Dapp
- Extended by:
- Helper::Trivia
- Includes:
- Chef, DappConfig, Dappfile, Deps::Base, Deps::Gitartifact, GitArtifact, Lock, Logging::Base, Logging::I18n, Logging::Paint, Logging::Process, Sentry, Shellout::Base, SshAgent, Helper::Sha256, Helper::Tar, Helper::Trivia, Helper::Url
- Defined in:
- lib/dapp/dapp.rb,
lib/dapp/dapp/chef.rb,
lib/dapp/dapp/lock.rb,
lib/dapp/dapp/sentry.rb,
lib/dapp/dapp/dappfile.rb,
lib/dapp/dapp/deps/base.rb,
lib/dapp/dapp/ssh_agent.rb,
lib/dapp/dapp/dapp_config.rb,
lib/dapp/dapp/git_artifact.rb,
lib/dapp/dapp/logging/base.rb,
lib/dapp/dapp/logging/i18n.rb,
lib/dapp/dapp/logging/paint.rb,
lib/dapp/dapp/shellout/base.rb,
lib/dapp/dapp/logging/process.rb,
lib/dapp/dapp/deps/gitartifact.rb,
lib/dapp/dapp/shellout/streaming.rb
Defined Under Namespace
Modules: Chef, DappConfig, Dappfile, Deps, GitArtifact, Lock, Logging, Sentry, Shellout, SshAgent
Constant Summary
Constants included from Deps::Base
Constants included from Deps::Gitartifact
Deps::Gitartifact::GITARTIFACT_VERSION
Constants included from Logging::Paint
Constants included from Logging::Process
Logging::Process::DEFAULT_STYLE, Logging::Process::DEFAULT_TERMINAL_WIDTH
Constants included from DappConfig
DappConfig::SUPPORTED_CONFIG_OPTIONS
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #build_dir ⇒ Object
- #build_path(*path) ⇒ Object
- #git_config ⇒ Object
- #git_path ⇒ Object
- #git_url ⇒ Object
- #host_docker_bin ⇒ Object
-
#initialize(options: {}) ⇒ Dapp
constructor
A new instance of Dapp.
- #local_git_artifact_exclude_paths(&blk) ⇒ Object
- #name ⇒ Object
- #path(*path) ⇒ Object
- #settings ⇒ Object
- #stage_cache ⇒ Object
- #stage_dapp_label ⇒ Object
- #tmp_base_dir ⇒ Object
Methods included from Helper::Trivia
class_to_lowercase, class_to_lowercase, delete_file, kwargs, make_path, search_file_upward
Methods included from Shellout::Base
default_env_keys, included, #shellout, #shellout!, #shellout_pack
Methods included from Deps::Base
#base_container, #base_container_name, #sudo_command, #sudo_format_user
Methods included from Deps::Gitartifact
#git_bin, #gitartifact_container, #gitartifact_container_name
Methods included from Helper::Url
#get_host_from_git_url, #git_url_to_name
Methods included from Helper::Tar
#tar_gz_read, #tar_read, #tar_write
Methods included from Helper::Sha256
#hashsum, #paths_content_hashsum, #sha256
Methods included from Sentry
#_make_sentry_params, #_sentry_extra_context, #_sentry_tags_context, #_sentry_user_context, #ensure_sentry_configured, #sentry_exception, #sentry_message
Methods included from SshAgent
#add_ssh_key, included, #run_ssh_agent, #setup_ssh_agent, #ssh_auth_sock
Methods included from Logging::Paint
included, initialize, #paint_string, #paint_style, #unpaint
Methods included from Logging::I18n
Methods included from Logging::Process
#log_process, #log_secondary_process, #log_state
Methods included from Logging::Base
#dev_mode?, #dry_run?, #ignore_config_warning?, included, #introspect_before_error?, #introspect_error?, #log, #log_config_warning, #log_dimg_name_with_indent, #log_format_string, #log_indent, #log_indent_next, #log_indent_prev, #log_info, #log_quiet?, #log_secondary, #log_step, #log_step_with_indent, #log_time, #log_time?, #log_verbose?, #log_warning, #with_log_indent
Methods included from DappConfig
#config_options, #option_color, #option_dev, #validate_config_options!
Methods included from Chef
Methods included from Dappfile
#config, #dappfile_exists?, #dappfile_path, #expand_path, #work_dir
Methods included from Lock
Constructor Details
#initialize(options: {}) ⇒ Dapp
Returns a new instance of Dapp.
30 31 32 33 34 35 36 37 38 |
# File 'lib/dapp/dapp.rb', line 30 def initialize(options: {}) @options = Logging::I18n.initialize Logging::Paint.initialize(option_color) ::Dapp::CLI.dapp_object = self ("Manual usage: `#{[:dapp_command]}` command") unless ENV['CI'] end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
28 29 30 |
# File 'lib/dapp/dapp.rb', line 28 def @options end |
Class Method Details
.home_dir ⇒ Object
127 128 129 |
# File 'lib/dapp/dapp.rb', line 127 def self.home_dir File.join(Dir.home, ".dapp") end |
.host_docker_bin ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/dapp/dapp.rb', line 131 def self.host_docker_bin @host_docker_bin ||= begin raise Error::Dapp, code: :docker_not_found if (res = shellout('which docker')).exitstatus.nonzero? res.stdout.strip.tap do |docker_bin| current_docker_version = shellout!("#{docker_bin} --version").stdout.strip required_docker_version = '1.10.0' if Gem::Version.new(required_docker_version) >= Gem::Version.new(current_docker_version[/(\d+\.)+\d+/]) raise Error::Dapp, code: :docker_version, data: { version: required_docker_version } end end end end |
Instance Method Details
#build_dir ⇒ Object
92 93 94 95 96 97 98 99 100 |
# File 'lib/dapp/dapp.rb', line 92 def build_dir @build_dir ||= begin if option_build_dir Pathname.new(option_build_dir) else path('.dapp_build') end..tap(&:mkpath) end end |
#build_path(*path) ⇒ Object
102 103 104 |
# File 'lib/dapp/dapp.rb', line 102 def build_path(*path) make_path(build_dir, *path) end |
#git_config ⇒ Object
71 72 73 74 75 |
# File 'lib/dapp/dapp.rb', line 71 def git_config @git_config ||= begin IniFile.load(File.join(git_path, 'config')) if git_path end end |
#git_path ⇒ Object
77 78 79 80 81 |
# File 'lib/dapp/dapp.rb', line 77 def git_path defined?(@git_path) ? @git_path : begin @git_path = search_file_upward('.git') end end |
#git_url ⇒ Object
66 67 68 69 |
# File 'lib/dapp/dapp.rb', line 66 def git_url return unless git_config (git_config['remote "origin"'] || {})['url'] end |
#host_docker_bin ⇒ Object
123 124 125 |
# File 'lib/dapp/dapp.rb', line 123 def host_docker_bin self.class.host_docker_bin end |
#local_git_artifact_exclude_paths(&blk) ⇒ Object
106 107 108 109 110 111 112 113 |
# File 'lib/dapp/dapp.rb', line 106 def local_git_artifact_exclude_paths(&blk) super do |exclude_paths| build_path_relpath = Pathname.new(build_path).subpath_of(File.dirname(git_path)) exclude_paths << build_path_relpath.to_s if build_path_relpath yield exclude_paths if block_given? end end |
#name ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/dapp/dapp.rb', line 52 def name @name ||= begin if git_url repo_name = git_url.split('/').last repo_name = repo_name[/.*(?=\.git)/] if repo_name.end_with? '.git' repo_name elsif git_path File.basename(File.dirname(git_path)).to_s else path.basename.to_s end end end |
#path(*path) ⇒ Object
83 84 85 86 |
# File 'lib/dapp/dapp.rb', line 83 def path(*path) @path ||= (dappfile_path) make_path(@path, *path) end |
#settings ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/dapp/dapp.rb', line 40 def settings @settings ||= begin settings_path = File.join(self.class.home_dir, "settings.toml") if File.exists? settings_path TomlRB.load_file(settings_path) else {} end end end |
#stage_cache ⇒ Object
115 116 117 |
# File 'lib/dapp/dapp.rb', line 115 def stage_cache "dimgstage-#{name}" end |
#stage_dapp_label ⇒ Object
119 120 121 |
# File 'lib/dapp/dapp.rb', line 119 def stage_dapp_label name end |
#tmp_base_dir ⇒ Object
88 89 90 |
# File 'lib/dapp/dapp.rb', line 88 def tmp_base_dir File.([:tmp_dir_prefix] || '/tmp') end |