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, Dappfile, Deps::Base, Deps::Gitartifact, Lock, Logging::Base, Logging::I18n, Logging::Paint, Logging::Process, Shellout::Base, Shellout::System, 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/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/shellout/system.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 Shellout::System

Shellout::System::SYSTEM_SHELLOUT_IMAGE, Shellout::System::SYSTEM_SHELLOUT_VERSION

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 Shellout::System

default_env_keys, #system_shellout, #system_shellout!, #system_shellout_container, #system_shellout_container_name

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_path, #gitartifact_container, #gitartifact_container_name

Methods included from Helper::Trivia

class_to_lowercase, #class_to_lowercase, #delete_file, #kwargs

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?, included, #introspect_before_error?, #introspect_error?, #log, #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::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

#apps, #build_configs, #dappfile_path, #dappfiles, #dapps_dappfiles_pathes, #expand_path, #search_up, #work_dir

Methods included from Lock

#_lock, #lock, #lock_path

Constructor Details

#initialize(cli_options: {}, apps_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: {}, apps_patterns: nil)
  @cli_options = cli_options
  @apps_patterns = apps_patterns || []
  @apps_patterns << '*' unless @apps_patterns.any?

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

Instance Attribute Details

#apps_patternsObject (readonly)

Returns the value of attribute apps_patterns.



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

def apps_patterns
  @apps_patterns
end

#cli_optionsObject (readonly)

Returns the value of attribute cli_options.



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

def cli_options
  @cli_options
end

Instance Method Details

#build_pathObject



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

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

#cache_formatObject



80
81
82
# File 'lib/dapp/project.rb', line 80

def cache_format
  "dappstage-#{name}-%{application_name}"
end

#nameObject



51
52
53
54
55
56
57
# File 'lib/dapp/project.rb', line 51

def name
  @name ||= begin
    system_shellout!("#{git_path} -C #{path} config --get remote.origin.url").stdout.strip.split('/').last[/.*(?=.git)/]
  rescue Error::Shellout
    File.basename(path)
  end
end

#pathObject



59
60
61
62
63
64
65
66
67
68
# File 'lib/dapp/project.rb', line 59

def path
  @path ||= begin
    dappfile_path = dappfiles.first
    if File.basename(expand_path(dappfile_path, 2)) == '.dapps'
      expand_path(dappfile_path, 3)
    else
      expand_path(dappfile_path)
    end
  end
end

#stage_dapp_label_formatObject



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

def stage_dapp_label_format
  '%{application_name}'
end