Class: Dapp::Project

Inherits:
Object
  • Object
show all
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, SystemShellout
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/system_shellout.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, SystemShellout

Constant Summary

Constants included from SystemShellout

SystemShellout::SYSTEM_SHELLOUT_IMAGE

Constants included from Deps::Base

Deps::Base::BASE_VERSION

Constants included from Deps::Gitartifact

Deps::Gitartifact::GITARTIFACT_VERSION

Constants included from Logging::Paint

Logging::Paint::FORMAT

Constants included from Logging::Process

Logging::Process::DEFAULT_STYLE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SystemShellout

default_env_keys, #system_shellout, #system_shellout!, #system_shellout_extra

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

initialize, #t

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

#stage_image

Methods included from Command::Mrproper

#mrproper

Methods included from Command::Cleanup

#cleanup

Methods included from Command::Stages::Pull

#pull_all_stages?, #stages_pull

Methods included from Command::Stages::Push

#stages_push

Methods included from Command::Stages::FlushRepo

#stages_flush_repo

Methods included from Command::Stages::FlushLocal

#stages_flush_local

Methods included from Command::Stages::CleanupRepo

#stages_cleanup_repo

Methods included from Command::Stages::CleanupLocal

#stages_cleanup_local

Methods included from Command::List

#list

Methods included from Command::Tag

#tag

Methods included from Command::Spush

#spush

Methods included from Command::Push

#push

Methods included from Command::Bp

#bp, #bp_step

Methods included from Command::Build

#build

Methods included from Command::Run

#run

Methods included from Dappfile

#build_configs, #dappfile_path, #dimgs, #expand_path, #work_dir

Methods included from Lock

#_lock, #lock, #lock_path

Constructor Details

#initialize(cli_options: {}, dimgs_patterns: nil) ⇒ Project

Returns a new instance of Project.



43
44
45
46
47
48
49
50
# File 'lib/dapp/project.rb', line 43

def initialize(cli_options: {}, dimgs_patterns: nil)
  @cli_options = cli_options
  @dimgs_patterns = dimgs_patterns || []
  @dimgs_patterns << '*' unless @dimgs_patterns.any?

  Logging::Paint.initialize(cli_options[:log_color])
  Logging::I18n.initialize
end

Instance Attribute Details

#cli_optionsObject (readonly)

Returns the value of attribute cli_options.



40
41
42
# File 'lib/dapp/project.rb', line 40

def cli_options
  @cli_options
end

#dimgs_patternsObject (readonly)

Returns the value of attribute dimgs_patterns.



41
42
43
# File 'lib/dapp/project.rb', line 41

def dimgs_patterns
  @dimgs_patterns
end

Instance Method Details

#build_pathObject



91
92
93
94
95
96
97
98
99
# File 'lib/dapp/project.rb', line 91

def build_path
  @build_path ||= begin
    if cli_options[:build_dir]
      Pathname.new(cli_options[:build_dir])
    else
      Pathname.new(path).join('.dapp_build')
    end.expand_path.tap(&:mkpath)
  end
end

#cookbook_pathObject



87
88
89
# File 'lib/dapp/project.rb', line 87

def cookbook_path
  File.join(path, '.dapp_chef')
end

#dev_mode?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/dapp/project.rb', line 113

def dev_mode?
  !!cli_options[:dev]
end

#git_configObject



71
72
73
74
75
# File 'lib/dapp/project.rb', line 71

def git_config
  @git_config ||= begin
    IniFile.load(File.join(git_path, 'config')) if git_path
  end
end

#git_pathObject



77
78
79
80
81
# File 'lib/dapp/project.rb', line 77

def git_path
  defined?(@git_path) ? @git_path : begin
    @git_path = search_file_upward('.git')
  end
end

#git_urlObject



66
67
68
69
# File 'lib/dapp/project.rb', line 66

def git_url
  return unless git_config
  (git_config['remote "origin"'] || {})['url']
end

#nameObject



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/dapp/project.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))
    else
      File.basename(path)
    end
  end
end

#pathObject



83
84
85
# File 'lib/dapp/project.rb', line 83

def path
  @path ||= expand_path(dappfile_path)
end

#stage_cacheObject



105
106
107
# File 'lib/dapp/project.rb', line 105

def stage_cache
  "dimgstage-#{name}"
end

#stage_dapp_labelObject



109
110
111
# File 'lib/dapp/project.rb', line 109

def stage_dapp_label
  name
end

#system_filesObject



101
102
103
# File 'lib/dapp/project.rb', line 101

def system_files
  [dappfile_path, cookbook_path, build_path].map { |p| File.basename(p) }
end