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

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

Constant Summary

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 inherited from Worker

#package_bin_path, #package_path, #package_version, #packages, #release_path, #service_entry, #shell_setup_commands

Methods included from Service::Worker::Base

#compose_command, #control_file_name, #control_file_path, #log_file_name, #log_file_path, #log_path, #logrotate_file_name, #logrotate_file_path, #pid_file_name, #pid_file_path, #pids_path, #profile_path, #service_entry, #shell_setup_commands

Methods included from Worker::Paths::Remote

#app_bin_path, #app_path, #app_tmp_path, #current_app_path, #downloads_path, #env_path, #envrc_file, #etc_path, #logrotate_path, #luban_install_path, #project_path, #shared_path, #tmp_path, #unset_envrc_file

Methods inherited from Worker::Base

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

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

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::Helpers::Utils

Instance Method Details

#after_publishObject



91
92
93
94
# File 'lib/luban/deployment/cli/application/publisher.rb', line 91

def after_publish
  create_symlinks
  bundle_gems unless gems.empty?
end

#bundle_cmdObject



34
35
36
# File 'lib/luban/deployment/cli/application/publisher.rb', line 34

def bundle_cmd
  @bundle_cmd ||= app_bin_path.join('bundle')
end

#bundle_config_pathObject



38
39
40
# File 'lib/luban/deployment/cli/application/publisher.rb', line 38

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

#bundle_flagsObject



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

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

#bundle_linked_dirsObject



58
59
60
# File 'lib/luban/deployment/cli/application/publisher.rb', line 58

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

#bundle_pathObject



42
43
44
# File 'lib/luban/deployment/cli/application/publisher.rb', line 42

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

#bundle_withoutObject



50
51
52
# File 'lib/luban/deployment/cli/application/publisher.rb', line 50

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

#bundled_gemsObject



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

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

#deprecateObject



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

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

#gemfileObject



30
31
32
# File 'lib/luban/deployment/cli/application/publisher.rb', line 30

def gemfile
  @gemfile ||= release_path.join('Gemfile')
end

#gemsObject



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

def gems; bundled_gems[:gems]; end

#gems_cache_pathObject



46
47
48
# File 'lib/luban/deployment/cli/application/publisher.rb', line 46

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

#gems_sourceObject



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

def gems_source; bundled_gems[:gems_cache]; end

#locked_gemfileObject



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

def locked_gemfile; bundled_gems[:locked_gemfile]; end

#publishObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/luban/deployment/cli/application/publisher.rb', line 64

def publish
  assure_dirs(releases_path)
  if published?
    if force?
      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)


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

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

#publish_profile?Boolean

Returns:

  • (Boolean)


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

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

#published?Boolean

Returns:

  • (Boolean)


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

def published?; directory?(release_path); end

#release_md5Object



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

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

#release_nameObject



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

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

#release_package_pathObject



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

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

#release_tagObject



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

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

#release_typeObject



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

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

#release_versionObject



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

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

#releases_log_pathObject



26
27
28
# File 'lib/luban/deployment/cli/application/publisher.rb', line 26

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

#releases_pathObject



22
23
24
# File 'lib/luban/deployment/cli/application/publisher.rb', line 22

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