1- # This trick lets us access the copy plugin within `on` blocks.
2- copy_plugin = self
3-
41namespace :copy do
52 desc 'Check if all configuration variables and copy sources exist'
63 task :check do
@@ -24,11 +21,11 @@ namespace :copy do
2421
2522 # generate an exclude.txt file with the patterns to be excluded
2623 exclude_content = copy_exclude . join ( "\n " )
27- File . write ( copy_plugin . local_exclude_path , exclude_content )
24+ File . write ( local_exclude_path , exclude_content )
2825
2926 # build the tar archive excluding the patterns from exclude.txt
3027 within copy_source do
31- execute :tar , '-X ' + copy_plugin . local_exclude_path , '-cpzf' , copy_plugin . local_archive_path , '.'
28+ execute :tar , '-X ' + local_exclude_path , '-cpzf' , local_archive_path , '.'
3229 end
3330 end
3431 end
@@ -38,17 +35,17 @@ namespace :copy do
3835 #
3936 task :copy_archive_to_server do
4037 on release_roles :all do
41- info I18n . t ( 'file.upload' , file : 'archive' , target : copy_plugin . remote_tmp_dir , scope : :dkdeploy )
42- execute :mkdir , '-p' , copy_plugin . remote_tmp_dir
38+ info I18n . t ( 'file.upload' , file : 'archive' , target : remote_tmp_dir , scope : :dkdeploy )
39+ execute :mkdir , '-p' , remote_tmp_dir
4340
44- upload! copy_plugin . local_archive_path , copy_plugin . remote_tmp_dir
41+ upload! local_archive_path , remote_tmp_dir
4542
4643 info I18n . t ( 'directory.create' , directory : release_path , scope : :dkdeploy )
4744 execute :mkdir , '-p' , release_path
4845
4946 within release_path do
5047 info I18n . t ( 'tasks.copy.archive.extract' , target : release_path , scope : :dkdeploy )
51- execute :tar , '-xpzf' , copy_plugin . remote_archive_path
48+ execute :tar , '-xpzf' , remote_archive_path
5249 end
5350 end
5451 end
@@ -58,19 +55,47 @@ namespace :copy do
5855 task :clean_up_temporary_sources do
5956 # remove the local temporary directory
6057 run_locally do
61- info I18n . t ( 'file.remove' , path : copy_plugin . local_tmp_dir , scope : :dkdeploy )
62- execute :rm , '-rf' , copy_plugin . local_tmp_dir
58+ info I18n . t ( 'file.remove' , path : fetch ( :copy_local_tmp_dir ) , scope : :dkdeploy )
59+ execute :rm , '-rf' , fetch ( :copy_local_tmp_dir )
6360 end
6461
6562 # removes the remote temp path including the uploaded archive
6663 on release_roles :all do
67- info I18n . t ( 'file.remove' , path : copy_plugin . remote_archive_path , scope : :dkdeploy )
68- execute :rm , '-rf' , copy_plugin . remote_tmp_dir
64+ info I18n . t ( 'file.remove' , path : remote_archive_path , scope : :dkdeploy )
65+ execute :rm , '-rf' , remote_tmp_dir
6966 end
7067 end
7168
7269 desc 'Determine the revision that will be deployed'
7370 task :set_current_revision do
7471 set :current_revision , I18n . t ( 'log.revision_log_message' , copy_source : fetch ( :copy_source ) , time : Time . now , scope : :dkdeploy )
7572 end
73+
74+ # Archive path in a local temporary directory
75+ #
76+ # @return [String]
77+ def local_exclude_path
78+ File . join fetch ( :copy_local_tmp_dir ) , 'exclude.txt'
79+ end
80+
81+ # Archive path in a local temporary directory
82+ #
83+ # @return [String]
84+ def local_archive_path
85+ File . join fetch ( :copy_local_tmp_dir ) , fetch ( :copy_archive_filename )
86+ end
87+
88+ # Remote temporary directory path
89+ #
90+ # @return [String]
91+ def remote_tmp_dir
92+ File . join fetch ( :tmp_dir ) , application
93+ end
94+
95+ # Archive path in a remote temporary directory
96+ #
97+ # @return [String]
98+ def remote_archive_path
99+ File . join remote_tmp_dir , fetch ( :copy_archive_filename )
100+ end
76101end
0 commit comments