Class: Luban::Deployment::Application::Publisher

Inherits:
Worker show all
Includes:
Helpers::LinkedPaths
Defined in:
lib/luban/deployment/cli/application/publisher.rb

Constant Summary

Constants included from Parameters::Application

Parameters::Application::DefaultLogrotateInterval, Parameters::Application::DefaultLogrotateMaxAge

Constants included from Parameters::General

Parameters::General::DefaultLubanRootPath

Constants included from Helpers::Utils

Helpers::Utils::LogLevels

Instance Attribute Summary

Attributes inherited from Worker::Base

#task

Attributes included from Helpers::Utils

#backend

Attributes included from Helpers::Configuration

#config

Instance Method Summary collapse

Methods included from Helpers::LinkedPaths

#linked_dirs, #linked_files, #linked_files_dir, #linked_files_from, #linked_files_root

Methods inherited from Worker

#bundle_command, #bundle_executable, #gemfile, #has_gemfile?, #profile_name, #release_path, #ruby_bin_path, #shell_setup

Methods included from Service::Worker::Base

#control_file_name, #control_file_path, #log_file_name, #log_file_path, #log_path, #output_redirection, #pid_file_name, #pid_file_path, #pids_path, #profile_name, #profile_path, #service_entry, #shell_command, #shell_delimiter, #shell_output, #shell_prefix, #shell_setup

Methods included from Worker::Paths::Remote

#app_archives_path, #app_bin_path, #app_path, #app_tmp_path, #archived_logs_path, #archives_path, #current_app_path, #downloads_path, #env_path, #envrc_file, #luban_install_path, #package_bin_path, #package_install_path, #project_path, #shared_path, #tmp_path, #unset_envrc_file

Methods inherited from Worker::Base

#dry_run?, #force?, #initialize, #linux?, #method_missing, #osx?, #packages, #run, #target_full_name, #target_major_version, #target_name, #target_patch_level, #target_version

Methods included from Parameters::Application

#env_name, #logrotate_count, #monitor_itself?, #monitorable?

Methods included from Parameters::Base

#parameter

Methods included from Parameters::Project

#monitor_defined?, #process_monitor_via

Methods included from Parameters::General

included

Methods included from Helpers::Utils

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

Methods included from Helpers::Configuration

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

Constructor Details

This class inherits a constructor from Luban::Deployment::Worker::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Luban::Deployment::Worker::Base

Instance Method Details

#after_publishObject



86
87
88
89
# File 'lib/luban/deployment/cli/application/publisher.rb', line 86

def after_publish
  create_symlinks
  bundle_gems if has_gemfile?
end

#bundle_config_pathObject



32
33
34
# File 'lib/luban/deployment/cli/application/publisher.rb', line 32

def bundle_config_path
  @bundle_config_path ||= shared_path.join('.bundle')
end

#bundle_flagsObject



48
49
50
# File 'lib/luban/deployment/cli/application/publisher.rb', line 48

def bundle_flags
  @bundle_flags ||= %w(--deployment --quiet)
end

#bundle_linked_dirsObject



52
53
54
# File 'lib/luban/deployment/cli/application/publisher.rb', line 52

def bundle_linked_dirs
  @bundle_linked_dirs ||= %w(.bundle vendor/cache vendor/bundle)
end

#bundle_pathObject



36
37
38
# File 'lib/luban/deployment/cli/application/publisher.rb', line 36

def bundle_path
  @bundle_path ||= shared_path.join('vendor', 'bundle')
end

#bundle_withoutObject



44
45
46
# File 'lib/luban/deployment/cli/application/publisher.rb', line 44

def bundle_without
  @bundle_without ||= %w(development test)
end

#bundled_gemsObject



12
# File 'lib/luban/deployment/cli/application/publisher.rb', line 12

def bundled_gems; task.opts.release_pack[:bundled_gems]; end

#deprecateObject



79
80
81
82
83
84
# File 'lib/luban/deployment/cli/application/publisher.rb', line 79

def deprecate
  if directory?(release_path)
    rmdir(release_path)
    update_result "Successfully deprecated published release #{release_name}."
  end
end

#gemsObject



15
# File 'lib/luban/deployment/cli/application/publisher.rb', line 15

def gems; bundled_gems[:gems]; end

#gems_cache_pathObject



40
41
42
# File 'lib/luban/deployment/cli/application/publisher.rb', line 40

def gems_cache_path
  @gems_cache_path ||= shared_path.join('vendor', 'cache')
end

#gems_sourceObject



14
# File 'lib/luban/deployment/cli/application/publisher.rb', line 14

def gems_source; bundled_gems[:gems_cache]; end

#locked_gemfileObject



13
# File 'lib/luban/deployment/cli/application/publisher.rb', line 13

def locked_gemfile; bundled_gems[:locked_gemfile]; end

#publishObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/luban/deployment/cli/application/publisher.rb', line 58

def publish
  assure_dirs(releases_path)
  if published?
    if force?
      rmdir(release_path)
      publish!
    else
      update_result "Skipped! ALREADY published #{release_name}.", status: :skipped
      return
    end
  else
    publish!
  end

  if published?
    update_result "Successfully published #{release_name}."
  else
    update_result "FAILED to publish #{release_name}.", status: :failed, level: :error
  end
end

#publish_app?Boolean

Returns:

  • (Boolean)


17
# File 'lib/luban/deployment/cli/application/publisher.rb', line 17

def publish_app?; release_type == 'app'; end

#publish_profile?Boolean

Returns:

  • (Boolean)


18
# File 'lib/luban/deployment/cli/application/publisher.rb', line 18

def publish_profile?; release_type == 'profile'; end

#published?Boolean

Returns:

  • (Boolean)


56
# File 'lib/luban/deployment/cli/application/publisher.rb', line 56

def published?; directory?(release_path); end

#release_md5Object



11
# File 'lib/luban/deployment/cli/application/publisher.rb', line 11

def release_md5; task.opts.release_pack[:md5]; end

#release_nameObject



20
21
22
# File 'lib/luban/deployment/cli/application/publisher.rb', line 20

def release_name
  @release_name ||= "#{application}:#{release_type}:#{release_tag}"
end

#release_package_pathObject



10
# File 'lib/luban/deployment/cli/application/publisher.rb', line 10

def release_package_path; task.opts.release_pack[:path]; end

#release_tagObject



9
# File 'lib/luban/deployment/cli/application/publisher.rb', line 9

def release_tag; task.opts.release_pack[:tag]; end

#release_typeObject



7
# File 'lib/luban/deployment/cli/application/publisher.rb', line 7

def release_type; task.opts.release_pack[:type]; end

#release_versionObject



8
# File 'lib/luban/deployment/cli/application/publisher.rb', line 8

def release_version; task.opts.release_pack[:version]; end

#releases_log_pathObject



28
29
30
# File 'lib/luban/deployment/cli/application/publisher.rb', line 28

def releases_log_path
  @releases_log_path ||= app_path.join('releases.log')
end

#releases_pathObject



24
25
26
# File 'lib/luban/deployment/cli/application/publisher.rb', line 24

def releases_path
  @releases_path ||= super.dirname.join(release_type)
end