capistrano-lazy-templates 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5c8ed65fd53f620ff4fd653b9bfdb2648cf920b
|
4
|
+
data.tar.gz: e4293e601d4d7a2e74b99f981bb79dc177a32cb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 325c49e46e923f1e2a3792491ef8e4b5eb13aa2f6fd2662e823e6a32102b78f0bf1213153eaf4db805e74b065a52b7c791293bac3335ad2f461709c69996aba2
|
7
|
+
data.tar.gz: 5132e9dba7cf5562ffd0488ce4d7d983d40c88ab53ca623e42b9687c306afc4d798bf7de51a0874a054c603f21f5f08a475e0ce73ece77bdaa2e7cb689e63cb2
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Capistrano Lazy Templates
|
2
2
|
|
3
|
+
[](http://badge.fury.io/rb/capistrano-lazy-templates)
|
4
|
+
|
3
5
|
Helping tasks to download and upload server files or ERB templates in capistrano v3
|
4
6
|
|
5
7
|
This gem gives capistrano tasks to mantain a set of files to upload and download to the servers, separated by role and stage.
|
@@ -21,7 +23,6 @@ Once installed uning bundler an after creating a deploy recipe with capistrano,
|
|
21
23
|
|
22
24
|
## Configuration
|
23
25
|
|
24
|
-
|
25
26
|
There are two variables to set and configure the behavior if this gem
|
26
27
|
|
27
28
|
set :template_dir, 'config/templates'
|
@@ -42,7 +43,7 @@ Once the gem is properly loaded it share three tasks on the capistrano_lazy_temp
|
|
42
43
|
|
43
44
|
### Downloading Files
|
44
45
|
|
45
|
-
There are
|
46
|
+
There are three task for downloading files. The `get` task lets you to specify a file (or directory) you want to take from the servers.
|
46
47
|
|
47
48
|
cap production lazy_templates:get FILE=/etc/nginx/nginx.conf ROLE=web
|
48
49
|
|
@@ -56,15 +57,19 @@ the path config/templates/production/web must exists before download, but from t
|
|
56
57
|
|
57
58
|
#### Directories
|
58
59
|
|
59
|
-
If the file specified in `FILE` environment variable is a directory in the target server, the task will recursively download all the regular files it finds from that path.
|
60
|
+
If the file specified in `FILE` environment variable is a directory in the target server, the task will recursively download all the regular files it finds from that path.
|
60
61
|
|
61
62
|
#### File Lists
|
62
63
|
|
63
64
|
Instead of specify manually each file you want to download you can use the task `:lazy_templates:get_file_list` using that instead, the value you specify in `FILE` environment variable will be interpreted as a local file for read the files or directories to download, just like the `lazy_templates:get` task.
|
64
65
|
|
66
|
+
#### Update Existing Files
|
67
|
+
|
68
|
+
You can update the existing files in the template dir using `:lazy_templates:update_files` capistrano will download the files which match the existing ones in the local repository.
|
69
|
+
|
65
70
|
#### Limitations
|
66
71
|
|
67
|
-
- `get` and `
|
72
|
+
- `get`, `get_file_list` and `update_files` tasks cannot read nothing that the deploy user cannot read, so if it finds a file that won't be readed it will skip it and continue downloading the next one.
|
68
73
|
|
69
74
|
- These task will not download empty directories or directories without enough permissions to be traversed.
|
70
75
|
|
@@ -62,11 +62,9 @@ namespace :lazy_templates do
|
|
62
62
|
roles_array.each do |role|
|
63
63
|
on roles(role) do
|
64
64
|
local_base = fetch(:template_dir) + "/" + fetch(:stage).to_s + '/' + role
|
65
|
-
info "role #{role} #{local_base}"
|
66
65
|
Dir["#{local_base}/**/*"].each do |file|
|
67
66
|
if File.file?(file)
|
68
67
|
if File.extname(file) == '.erb'
|
69
|
-
binding.pry
|
70
68
|
erb = File.read(file)
|
71
69
|
random_foo = (1000000000 * rand).round.to_s
|
72
70
|
res = ERB.new(erb).result(binding)
|
@@ -84,4 +82,21 @@ namespace :lazy_templates do
|
|
84
82
|
end
|
85
83
|
end
|
86
84
|
end
|
85
|
+
|
86
|
+
desc "Updates only existing files"
|
87
|
+
task :update_files do
|
88
|
+
roles_array = fetch(:role_templates)
|
89
|
+
roles_array = [ENV['ROLE']] if ENV['ROLE']
|
90
|
+
roles_array.each do |role|
|
91
|
+
on roles(role) do
|
92
|
+
local_base = fetch(:template_dir) + "/" + fetch(:stage).to_s + '/' + role
|
93
|
+
Dir["#{local_base}/**/*"].each do |file|
|
94
|
+
if File.file?(file)
|
95
|
+
get_remote_file(file.gsub(/^#{local_base}/,''),local_base)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
87
102
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-lazy-templates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Peñas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|