capistrano-shared-file 1.0.1 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae6818f152a7cd866f7f83a61c1bcab73e34146f
4
- data.tar.gz: 101df52331a4d973b2ca6f251f349a74c9413df2
3
+ metadata.gz: 0e1eee643c665843a165fec2114bd677d8f0c024
4
+ data.tar.gz: 01d534b9072cef9a0f6a653ae38a6c435c56e0a2
5
5
  SHA512:
6
- metadata.gz: e29bee61fabc330137611a53da11e4ca15e532fc0fe67dcb563c0fa37a00de9dba6fa6ccb3f58837c4fc9f1758e36e0dc0a5823640712bc80aad48cf6a04aacc
7
- data.tar.gz: 254d231b4f3dbf6376deace92eb0971ee802cf1c33eafb1521b7e18d78e7c5206ff1ee3993ba0f1596f9678689bdf4d3c8b42d223846a05dc6fb1afcc58880fc
6
+ metadata.gz: 09696afa985ae72b31d5522eda84551f174da87d5fff8193e1a264d92e225c3519431ab9eeef5b9a9bc1825c22daeb79e955f79ffc694174bbb859e705a185bf
7
+ data.tar.gz: 5839efabdc0a3605a6cf2d65cad54679a4edf00d4f74436b456d9dee00dd17664909fa512d4af23885cce07b03c3f584dabad9b5fe100ec56bc4eb1fef5df048
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # capistrano-shared-file
2
- A Capistrano recipe to upload, download and symlink configuration files like `config/database.yml` or `config/application.yml` to or from your remote servers. Heavily inspired by teohm's [capistrano-shared_file](https://github.com/teohm/capistrano-shared_file) gem.
2
+ A Capistrano recipe to upload, download and symlink configuration files like `config/database.yml` to or from your remote servers.
3
+
4
+ One of the most common use cases for this gem is when used together with [Figaro](https://github.com/laserlemon/figaro), where the `config/application.yml` file is *git-ignored* but you still want to have a convenient way to push it to your servers on every deploy.
5
+
6
+ Heavily inspired by teohm's [capistrano-shared_file](https://github.com/teohm/capistrano-shared_file) gem.
3
7
 
4
8
  ## Install
5
9
 
@@ -11,11 +15,50 @@ For Bundler, add this to your `Gemfile`:
11
15
 
12
16
  ## Usage
13
17
 
14
- Add the following lines to `config/deploy.rb`:
18
+ You can start using it by simply adding the line below at the bottom of your `deploy.rb`:
15
19
 
16
- set :shared_files, %w(config/database.yml)
17
20
  require 'capistrano-shared-file'
18
21
 
22
+ Generally you won't need to modify any of the default variables defined in the gem. For a more customized setup, please refer to the next section.
23
+
24
+ ## Variables
25
+
26
+ The following is the list of capistrano variables that are defined in this gem and that can be customized to fit your specific needs.
27
+
28
+ ### shared_files
29
+
30
+ Specifies the list of files that you want to symlink to the `current_release` directory. By default:
31
+
32
+ set :shared_files, %w(config/database.yml)
33
+
34
+ For example, when using [Figaro](https://github.com/laserlemon/figaro) you will probably want to add the `application.yml` file to this list.
35
+
36
+ set :shared_files, %w(config/database.yml config/application.yml)
37
+
38
+ ### shared_file_dir
39
+
40
+ Specify the directory in which you want to upload all shared files. By default:
41
+
42
+ set :shared_file_dir, 'files'
43
+
44
+ For example, given the following variables are set in your `deploy.rb`:
45
+
46
+ set :deploy_to, '/home/damselem/my_amazing_project
47
+ set :shared_file_dir, 'files'
48
+ set :shared_files, %w(config/application.yml)
49
+
50
+ The shared file in the remote will be at:
51
+
52
+ /home/damselem/my_amazing_project/shared/files/config/application.yml
53
+
54
+ ### shared_file_backup
55
+
56
+ Enbales backups of your shared files when uploading and downloading shared files. By default:
57
+
58
+ set :shared_file_backup, false
59
+
60
+ For more details on the implications of setting this variable to `true`, refer to the next **Upload** and **Download** sections.
61
+
19
62
  ## Tasks
20
63
 
21
64
  ### Upload
@@ -24,21 +67,30 @@ To upload all the files defined in the `shared_files` capistrano variable to a r
24
67
 
25
68
  bundle exec cap shared_file:upload
26
69
 
70
+ With backup (it creates a backup of the remote shared files on your machine before uploading the new versions to the remote machine):
71
+
72
+ bundle exec cap shared_file:upload -S shared_file_backup=true
73
+
27
74
  ### Download
28
75
 
29
76
  To download all the files defined in the `shared_files` capistrano variable from a remote server, you can execute:
30
77
 
31
78
  bundle exec cap shared_file:download
32
-
79
+
80
+ With backup (it creates a backup of the local shared files on your machine before downloading the new versions from the remote machine):
81
+
82
+ bundle exec cap shared_file:download -S shared_file_backup=true
83
+
33
84
  ### Symlink
34
85
 
35
86
  To symlink the uploaded configuration files to the current release path, you can execute:
36
87
 
37
88
  bundle exec cap shared_file:symlink
38
-
39
- This task will be executed on every deploy. If you happen to make any changes in the files specified in the `shared_files` capistrano variable, make sure you upload them.
40
89
 
41
- **Note**: You can use it together with `capistrano/ext/multistage` like:
90
+ You normally shouldn't have to execute it manually since it's already executed automatically on every deploy.
91
+
92
+ ## capistrano/ext/multistage
93
+ This gem has been tested to work with `capistrano/ext/multistage`. For example:
42
94
 
43
95
  bundle exec cap <STAGE> shared_file:upload
44
96
  bundle exec cap <STAGE> shared_file:download
@@ -6,13 +6,18 @@ end
6
6
 
7
7
  Capistrano::Configuration.instance.load do
8
8
 
9
- _cset :shared_files, %w(config/database.yml)
10
- _cset :shared_file_dir, 'files'
9
+ _cset :shared_files, %w(config/database.yml)
10
+ _cset :shared_file_dir, 'files'
11
+ _cset :shared_file_backup, false
11
12
 
12
13
  def remote_path_to(file)
13
14
  File.join(shared_path, shared_file_dir, file)
14
15
  end
15
16
 
17
+ def backup_path_to(file)
18
+ File.join(File.dirname(file), "#{Time.now.strftime('%Y%m%dT%H%M%S')}_#{File.basename(file)}")
19
+ end
20
+
16
21
  namespace :shared_file do
17
22
 
18
23
  desc 'Generate remote directories for shared files.'
@@ -27,6 +32,9 @@ Capistrano::Configuration.instance.load do
27
32
  desc 'Upload shared files to server'
28
33
  task :upload, :except => { :no_release => true } do
29
34
  shared_files.each do |file|
35
+ if shared_file_backup
36
+ top.download(remote_path_to(file), backup_path_to(file), :via => :scp)
37
+ end
30
38
  top.upload(file, remote_path_to(file), :via => :scp)
31
39
  end
32
40
  end
@@ -34,6 +42,9 @@ Capistrano::Configuration.instance.load do
34
42
  desc 'Download shared files from server.'
35
43
  task :download, :except => { :no_release => true } do
36
44
  shared_files.each do |file|
45
+ if shared_file_backup
46
+ run_locally "cp #{file} #{backup_path_to(file)}"
47
+ end
37
48
  top.download(remote_path_to(file), file, :via => :scp)
38
49
  end
39
50
  end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module SharedFile
3
- VERSION = '1.0.1'
3
+ VERSION = '1.1.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-shared-file
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Salmeron Amselem
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-04 00:00:00.000000000 Z
11
+ date: 2013-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano