Class: Luban::Deployment::Application::Repository
- Inherits:
-
Worker::Base
- Object
- Worker::Base
- Luban::Deployment::Application::Repository
show all
- Includes:
- Worker::Paths::Local
- Defined in:
- lib/luban/deployment/cli/application/scm/git.rb,
lib/luban/deployment/cli/application/scm/rsync.rb,
lib/luban/deployment/cli/application/repository.rb
Defined Under Namespace
Modules: SCM
Constant Summary
collapse
- DefaultRevisionSize =
12
Parameters::Application::DefaultLogrotateInterval, Parameters::Application::DefaultLogrotateMaxAge
Parameters::General::DefaultLubanRootPath
Helpers::Utils::LogLevels
Instance Attribute Summary collapse
Attributes inherited from Worker::Base
#task
#backend
#config
Instance Method Summary
collapse
#app_path, #apps_path, #project_path
#dry_run?, #force?, #initialize, #linux?, #method_missing, #osx?, #packages, #run, #target_full_name, #target_major_version, #target_name, #target_patch_level, #target_version
#env_name, #logrotate_count, #monitor_itself?, #monitorable?
#parameter
#monitor_defined?, #process_monitor_via
included
#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
#ask, #fetch, #find_template_file, #load_configuration_file, #primary, #release_roles, #role, #roles, #server, #set, #set_default, #syntax_error?
Instance Attribute Details
#from ⇒ Object
Returns the value of attribute from.
11
12
13
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 11
def from
@from
end
|
#rev_size ⇒ Object
Returns the value of attribute rev_size.
14
15
16
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 14
def rev_size
@rev_size
end
|
#revision ⇒ Object
Returns the value of attribute revision.
13
14
15
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 13
def revision
@revision
end
|
#scm ⇒ Object
Returns the value of attribute scm.
12
13
14
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 12
def scm
@scm
end
|
#type ⇒ Object
Returns the value of attribute type.
10
11
12
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 10
def type
@type
end
|
#version ⇒ Object
Returns the value of attribute version.
15
16
17
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 15
def version
@version
end
|
Instance Method Details
#build ⇒ Object
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 92
def build
assure_dirs(clone_path, releases_path)
if cloned? and !force?
update_result "Skipped! Local #{type} repository has been built ALREADY.", status: :skipped
else
abort "Aborted! Remote #{type} repository is NOT available." unless available?
if build!
update_result "Successfully built local #{type} repository."
else
abort "FAILED to build local #{type} repository!"
end
end
end
|
#bundle_cmd ⇒ Object
66
67
68
69
70
71
72
73
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 66
def bundle_cmd
return @bundle_cmd unless @bundle_cmd.nil?
@bundle_cmd = fetch(:bundle_via, :bundle).tap do |cmd|
if cmd.is_a?(Pathname) and !file?(cmd)
abort "Aborted! Bundler command is NOT found: #{cmd}"
end
end
end
|
#bundle_without ⇒ Object
75
76
77
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 75
def bundle_without
@bundle_without ||= %w(development test)
end
|
#clone_path ⇒ Object
30
31
32
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 30
def clone_path
@clone_path ||= workspace_path.join('repositories', type)
end
|
#deprecate ⇒ Object
137
138
139
140
141
142
143
144
145
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 137
def deprecate
abort "Aborted! Local #{type} repository is NOT built yet!" unless cloned?
abort "Aborted! Version to deprecate is MISSING!" if version.nil?
if file?(release_package_path)
rm(release_package_path)
update_result "Successfully deprecated packaged release #{release_name}."
end
update_result release_pack: { type: type, version: version, tag: release_tag }
end
|
#gems_path ⇒ Object
26
27
28
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 26
def gems_path
@gems_path ||= workspace_path.join('gems')
end
|
#package ⇒ Object
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 108
def package
abort "Aborted! Local #{type} repository is NOT built yet!" unless cloned?
abort "Aborted! FAILED to update local #{type} repository!" unless update
update_revision
abort "Aborted! Version to package is MISSING!" if version.nil?
release_package = ->{ { type: type, version: version, tag: release_tag,
path: release_package_path,
md5: md5_for_file(release_package_path),
bundled_gems: bundle_gems } }
if packaged?
if force?
release
else
update_result "Skipped! ALREADY packaged #{release_name}.", status: :skipped,
release_pack: release_package.call
end
else
release
cleanup_releases
end
if packaged?
update_result "Successfully packaged #{release_name} to #{release_package_path}."
else
abort "Aborted! FAILED to package #{release_name}!"
end
update_result release_pack: release_package.call
end
|
#packaged? ⇒ Boolean
106
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 106
def packaged?; file?(release_package_path); end
|
#release_name ⇒ Object
62
63
64
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 62
def release_name
@release_name ||= "#{application}:#{type}:#{release_tag}"
end
|
#release_package_extname ⇒ Object
50
51
52
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 50
def release_package_extname
@release_package_extname ||= 'tgz'
end
|
#release_package_file_name ⇒ Object
42
43
44
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 42
def release_package_file_name
@release_package_file_name ||= "#{release_package_name}.#{release_package_extname}"
end
|
#release_package_name ⇒ Object
46
47
48
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 46
def release_package_name
@release_package_name ||= "#{release_prefix}-#{release_tag}"
end
|
#release_package_path ⇒ Object
38
39
40
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 38
def release_package_path
@release_package_path ||= releases_path.join(release_package_file_name)
end
|
#release_prefix ⇒ Object
54
55
56
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 54
def release_prefix
@release_prefix ||= "#{stage}-#{project}-#{application}-#{type}"
end
|
#release_tag ⇒ Object
58
59
60
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 58
def release_tag
@release_tag ||= "#{version}-#{revision}"
end
|
#releases_path ⇒ Object
34
35
36
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 34
def releases_path
@releases_path ||= workspace_path.join('releases', type)
end
|
#scm_module ⇒ Object
17
18
19
20
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 17
def scm_module
require_relative "scm/#{scm}"
@scm_module ||= SCM.const_get(scm.camelcase)
end
|
#workspace_path ⇒ Object
22
23
24
|
# File 'lib/luban/deployment/cli/application/repository.rb', line 22
def workspace_path
@workspace_path ||= app_path.join('.luban')
end
|