Class: SCM::CopyStrategy
- Inherits:
-
Capistrano::SCM::Plugin
- Object
- Capistrano::SCM::Plugin
- SCM::CopyStrategy
- Defined in:
- lib/capistrano/scm/copy-strategy.rb
Instance Method Summary collapse
- #archive_to_release_path ⇒ Object
- #check_repo_dir ⇒ Object
- #check_server ⇒ Object
- #create_archive ⇒ Object
- #define_tasks ⇒ Object
- #register_hooks ⇒ Object
- #set_defaults ⇒ Object
Instance Method Details
#archive_to_release_path ⇒ Object
64 65 66 67 68 |
# File 'lib/capistrano/scm/copy-strategy.rb', line 64 def archive_to_release_path backend.execute :mkdir, "-p", release_path backend.execute :tar, "-xf", "#{repo_path}/#{fetch(:archive_name)}", "-C", release_path backend.execute :rm, "#{repo_path}/#{fetch(:archive_name)}" end |
#check_repo_dir ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/capistrano/scm/copy-strategy.rb', line 30 def check_repo_dir if !backend.test " [ -d #{repo_path} ] " backend.execute :mkdir, "-p", repo_path else backend.test :rm, "#{repo_path}/*" end end |
#check_server ⇒ Object
26 27 28 |
# File 'lib/capistrano/scm/copy-strategy.rb', line 26 def check_server backend.test :tar, "--version" end |
#create_archive ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/capistrano/scm/copy-strategy.rb', line 38 def create_archive archive_name = fetch(:archive_name) include_dir = fetch(:include_dir) exclude_dirs = Array(fetch(:exclude_dirs)) exclude_dirs.push(archive_name) temp_folder = fetch(:temp_folder) FileUtils.copy_entry include_dir, "#{temp_folder}/#{env.}" # sh "ls -al #{temp_folder}/#{env.release_timestamp}" exclude_dirs.map { |dir| FileUtils.rm_rf "#{temp_folder}/#{env.}/#{dir}" FileUtils.rm_rf Dir.glob("#{temp_folder}/#{env.}/#{dir}") } sh "ls -al #{temp_folder}/#{env.}" tar_verbose = fetch(:tar_verbose, true) ? "v" : "" cmd = ["tar", "-c#{tar_verbose}zf", archive_name, "-C #{temp_folder}/#{env.}", '.'] sh cmd.join(' ') return archive_name end |
#define_tasks ⇒ Object
22 23 24 |
# File 'lib/capistrano/scm/copy-strategy.rb', line 22 def define_tasks eval_rakefile File.("../tasks/copy-strategy.rake", __FILE__) end |
#register_hooks ⇒ Object
17 18 19 20 |
# File 'lib/capistrano/scm/copy-strategy.rb', line 17 def register_hooks after "deploy:new_release_path", "copy_strategy:create_release" before "deploy:check", "copy_strategy:check" end |
#set_defaults ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/capistrano/scm/copy-strategy.rb', line 9 def set_defaults # Define any variables needed to configure the plugin. set_if_empty :include_dir, "." set_if_empty :archive_name, "#{env.}.tar.gz" set_if_empty :temp_folder, "#{Dir.tmpdir}" end |