Class: Dapp::Project
- Inherits:
-
Object
- Object
- Dapp::Project
- Includes:
- Helper::Sha256, Helper::Trivia, Command::Bp, Command::Build, Command::Cleanup, Command::Common, Command::List, Command::Mrproper, Command::Push, Command::Run, Command::Spush, Command::StageImage, Command::Stages::CleanupLocal, Command::Stages::CleanupRepo, Command::Stages::Common, Command::Stages::FlushLocal, Command::Stages::FlushRepo, Command::Stages::Pull, Command::Stages::Push, Command::Tag, Dappfile, Deps::Base, Deps::Gitartifact, Lock, Logging::Base, Logging::I18n, Logging::Paint, Logging::Process, Shellout::Base, SshAgent
- Defined in:
- lib/dapp/project.rb,
lib/dapp/project/lock.rb,
lib/dapp/project/dappfile.rb,
lib/dapp/project/deps/base.rb,
lib/dapp/project/ssh_agent.rb,
lib/dapp/project/command/bp.rb,
lib/dapp/project/command/run.rb,
lib/dapp/project/command/tag.rb,
lib/dapp/project/command/list.rb,
lib/dapp/project/command/push.rb,
lib/dapp/project/logging/base.rb,
lib/dapp/project/logging/i18n.rb,
lib/dapp/project/command/build.rb,
lib/dapp/project/command/spush.rb,
lib/dapp/project/logging/paint.rb,
lib/dapp/project/shellout/base.rb,
lib/dapp/project/command/common.rb,
lib/dapp/project/command/cleanup.rb,
lib/dapp/project/logging/process.rb,
lib/dapp/project/command/mrproper.rb,
lib/dapp/project/deps/gitartifact.rb,
lib/dapp/project/shellout/streaming.rb,
lib/dapp/project/command/stage_image.rb,
lib/dapp/project/command/stages/pull.rb,
lib/dapp/project/command/stages/push.rb,
lib/dapp/project/command/stages/common.rb,
lib/dapp/project/command/stages/flush_repo.rb,
lib/dapp/project/command/stages/flush_local.rb,
lib/dapp/project/command/stages/cleanup_repo.rb,
lib/dapp/project/command/stages/cleanup_local.rb
Overview
Project
Defined Under Namespace
Modules: Command, Dappfile, Deps, Lock, Logging, 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
Instance Attribute Summary collapse
-
#cli_options ⇒ Object
readonly
Returns the value of attribute cli_options.
-
#dimgs_patterns ⇒ Object
readonly
Returns the value of attribute dimgs_patterns.
Instance Method Summary collapse
- #build_path ⇒ Object
- #cookbook_path ⇒ Object
- #dev_mode? ⇒ Boolean
- #git_config ⇒ Object
- #git_path ⇒ Object
- #git_url ⇒ Object
-
#initialize(cli_options: {}, dimgs_patterns: nil) ⇒ Project
constructor
A new instance of Project.
- #name ⇒ Object
- #path ⇒ Object
- #stage_cache ⇒ Object
- #stage_dapp_label ⇒ Object
- #system_files ⇒ Object
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::Trivia
class_to_lowercase, #class_to_lowercase, #delete_file, #kwargs, #search_file_upward
Methods included from Helper::Sha256
#hashsum, #paths_content_hashsum, #sha256
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
#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, #log_with_indent, #with_log_indent
Methods included from Command::StageImage
Methods included from Command::Mrproper
Methods included from Command::Cleanup
Methods included from Command::Stages::Pull
#pull_all_stages?, #stages_pull
Methods included from Command::Stages::Push
Methods included from Command::Stages::FlushRepo
Methods included from Command::Stages::FlushLocal
Methods included from Command::Stages::CleanupRepo
Methods included from Command::Stages::CleanupLocal
Methods included from Command::List
Methods included from Command::Tag
Methods included from Command::Spush
Methods included from Command::Push
Methods included from Command::Bp
Methods included from Command::Build
Methods included from Command::Run
Methods included from Dappfile
#build_configs, #dappfile_path, #dimgs, #expand_path, #work_dir
Methods included from Lock
Constructor Details
#initialize(cli_options: {}, dimgs_patterns: nil) ⇒ Project
Returns a new instance of Project.
42 43 44 45 46 47 48 49 |
# File 'lib/dapp/project.rb', line 42 def initialize(cli_options: {}, dimgs_patterns: nil) @cli_options = @dimgs_patterns = dimgs_patterns || [] @dimgs_patterns << '*' unless @dimgs_patterns.any? Logging::Paint.initialize([:log_color]) Logging::I18n.initialize end |
Instance Attribute Details
#cli_options ⇒ Object (readonly)
Returns the value of attribute cli_options.
39 40 41 |
# File 'lib/dapp/project.rb', line 39 def @cli_options end |
#dimgs_patterns ⇒ Object (readonly)
Returns the value of attribute dimgs_patterns.
40 41 42 |
# File 'lib/dapp/project.rb', line 40 def dimgs_patterns @dimgs_patterns end |
Instance Method Details
#build_path ⇒ Object
90 91 92 93 94 95 96 97 98 |
# File 'lib/dapp/project.rb', line 90 def build_path @build_path ||= begin if [:build_dir] Pathname.new([:build_dir]) else Pathname.new(path).join('.dapp_build') end..tap(&:mkpath) end end |
#cookbook_path ⇒ Object
86 87 88 |
# File 'lib/dapp/project.rb', line 86 def cookbook_path File.join(path, '.dapp_chef') end |
#dev_mode? ⇒ Boolean
112 113 114 |
# File 'lib/dapp/project.rb', line 112 def dev_mode? !![:dev] end |
#git_config ⇒ Object
70 71 72 73 74 |
# File 'lib/dapp/project.rb', line 70 def git_config @git_config ||= begin IniFile.load(File.join(git_path, 'config')) if git_path end end |
#git_path ⇒ Object
76 77 78 79 80 |
# File 'lib/dapp/project.rb', line 76 def git_path defined?(@git_path) ? @git_path : begin @git_path = search_file_upward('.git') end end |
#git_url ⇒ Object
65 66 67 68 |
# File 'lib/dapp/project.rb', line 65 def git_url return unless git_config (git_config['remote "origin"'] || {})['url'] end |
#name ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dapp/project.rb', line 51 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)) else File.basename(path) end end end |
#path ⇒ Object
82 83 84 |
# File 'lib/dapp/project.rb', line 82 def path @path ||= (dappfile_path) end |
#stage_cache ⇒ Object
104 105 106 |
# File 'lib/dapp/project.rb', line 104 def stage_cache "dimgstage-#{name}" end |
#stage_dapp_label ⇒ Object
108 109 110 |
# File 'lib/dapp/project.rb', line 108 def stage_dapp_label name end |
#system_files ⇒ Object
100 101 102 |
# File 'lib/dapp/project.rb', line 100 def system_files [dappfile_path, cookbook_path, build_path].map { |p| File.basename(p) } end |