Class: Luban::Deployment::Worker::Base

Inherits:
Object
  • Object
show all
Includes:
Helpers::Configuration, Helpers::Utils, Parameters::Application, Parameters::General, Parameters::Project
Defined in:
lib/luban/deployment/worker/base.rb

Constant Summary

Constants included from Parameters::General

Parameters::General::DefaultLubanRootPath

Constants included from Helpers::Utils

Helpers::Utils::LogLevels

Instance Attribute Summary collapse

Attributes included from Helpers::Utils

#backend

Attributes included from Helpers::Configuration

#config

Instance Method Summary collapse

Methods included from Parameters::Base

#parameter

Methods included from Parameters::General

included

Methods included from Helpers::Utils

#assure, #assure_dirs, #assure_symlink, #capture, #check_pass?, #chmod, #cp, #directory?, #file?, #hardware_name, #host, #hostname, #ln, #match?, #md5_for_file, #md5_matched?, #method_missing, #mkdir, #mv, #now, #os_name, #os_release, #readlink, #render_template, #revision_match?, #rm, #rmdir, #sudo, #symlink?, #upload_by_template, #url_exists?, #user_home

Methods included from Helpers::Configuration

#ask, #default_templates_paths, #fetch, #find_template_file, #load_configuration_file, #primary, #release_roles, #role, #roles, #server, #set, #set_default, #syntax_error?

Constructor Details

#initialize(config:, backend:, **task, &blk) ⇒ Base

Returns a new instance of Base.



13
14
15
16
17
18
19
20
# File 'lib/luban/deployment/worker/base.rb', line 13

def initialize(config:, backend:, **task, &blk)
  @config = config
  @backend = backend
  @run_blk = blk
  @task = create_task(task)
  init
  validate
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Luban::Deployment::Helpers::Utils

Instance Attribute Details

#taskObject (readonly)

Returns the value of attribute task.



11
12
13
# File 'lib/luban/deployment/worker/base.rb', line 11

def task
  @task
end

Instance Method Details

#dry_run?Boolean

Returns:

  • (Boolean)


23
# File 'lib/luban/deployment/worker/base.rb', line 23

def dry_run?; task.opts.dry_run; end

#env_nameObject



28
29
30
# File 'lib/luban/deployment/worker/base.rb', line 28

def env_name
  @env_name ||= "#{stage}.#{project}/#{application}"
end

#force?Boolean

Returns:

  • (Boolean)


22
# File 'lib/luban/deployment/worker/base.rb', line 22

def force?; task.opts.force; end

#linux?Boolean

Returns:

  • (Boolean)


26
# File 'lib/luban/deployment/worker/base.rb', line 26

def linux?; os_name == 'Linux'; end

#osx?Boolean

Returns:

  • (Boolean)


25
# File 'lib/luban/deployment/worker/base.rb', line 25

def osx?; os_name == 'Darwin'; end

#runObject



39
40
41
# File 'lib/luban/deployment/worker/base.rb', line 39

def run
  update_result(__return__: @run_blk ? run_with_block : run_with_command).to_h
end

#target_full_nameObject



33
# File 'lib/luban/deployment/worker/base.rb', line 33

def target_full_name; "#{target_name}-#{target_version}"; end

#target_major_versionObject



36
# File 'lib/luban/deployment/worker/base.rb', line 36

def target_major_version; task.opts.major_version || target_version; end

#target_nameObject



32
# File 'lib/luban/deployment/worker/base.rb', line 32

def target_name; task.opts.name; end

#target_patch_levelObject



37
# File 'lib/luban/deployment/worker/base.rb', line 37

def target_patch_level; task.opts.patch_level || ''; end

#target_versionObject



35
# File 'lib/luban/deployment/worker/base.rb', line 35

def target_version; task.opts.version; end