capistrano-config 0.0.2 → 0.0.3
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.
- data/README.md +2 -0
- data/lib/capistrano-config.rb +9 -5
- data/lib/capistrano-config/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -31,6 +31,8 @@ Following options are available to manage your configuration files.
|
|
31
31
|
|
32
32
|
* `:config_update_remotely` - specify whether update config files on remote machines or not. `true` by default.
|
33
33
|
* `:config_update_locally` - specify whether update config files on local machines or not. `false` by default.
|
34
|
+
* `:config_use_sudo_locally` - specify whether use `sudo` or not on local execution. `false` by default.
|
35
|
+
* `:config_use_sudo_remotely` - specify whether use `sudo` or not on remote execution. `true` by default.
|
34
36
|
* `:config_path` - specify configuration base directory on remote machines. use `release_path` by default.
|
35
37
|
* `:config_path_local` - specify configuration base directory on local machine. use `.` by default.
|
36
38
|
* `:config_template_path` - specify configuration template directory on local machine. use `./config/templates` by default.
|
data/lib/capistrano-config.rb
CHANGED
@@ -52,17 +52,19 @@ module Capistrano
|
|
52
52
|
options = {
|
53
53
|
:readable_files => [], :writable_files => [], :executable_files => [],
|
54
54
|
:remove_files => [],
|
55
|
+
:use_sudo => true,
|
55
56
|
}.merge(options)
|
56
57
|
dirs = src_tmp_tgt.map { |src, tmp, tgt| File.dirname(tgt) }.uniq
|
58
|
+
try_sudo = options[:use_sudo] ? sudo : ""
|
57
59
|
execute = []
|
58
60
|
execute << "mkdir -p #{dirs.join(' ')}" unless dirs.empty?
|
59
61
|
src_tmp_tgt.map { |src, tmp, tgt|
|
60
|
-
execute << "( diff -u #{tgt} #{tmp} || #{
|
62
|
+
execute << "( diff -u #{tgt} #{tmp} || #{try_sudo} mv -f #{tmp} #{tgt} )"
|
61
63
|
}
|
62
|
-
execute << "#{
|
63
|
-
execute << "#{
|
64
|
-
execute << "#{
|
65
|
-
execute << "#{
|
64
|
+
execute << "#{try_sudo} chmod #{config_readable_mode} #{options[:readable_files].join(' ')}" unless options[:readable_files].empty?
|
65
|
+
execute << "#{try_sudo} chmod #{config_writable_mode} #{options[:writable_files].join(' ')}" unless options[:writable_files].empty?
|
66
|
+
execute << "#{try_sudo} chmod #{config_executable_mode} #{options[:executable_files].join(' ')}" unless options[:executable_files].empty?
|
67
|
+
execute << "#{try_sudo} rm -f #{options[:remove_files].join(' ')}" unless options[:remove_files].empty?
|
66
68
|
|
67
69
|
execute.join(' && ')
|
68
70
|
end
|
@@ -75,6 +77,7 @@ module Capistrano
|
|
75
77
|
File.open(tmp, 'wb') { |fp| fp.write(_read_config(src)) } unless dry_run
|
76
78
|
}
|
77
79
|
run_locally(_do_update(src_tmp_tgt,
|
80
|
+
:use_sudo => fetch(:config_use_sudo_locally, false),
|
78
81
|
:readable_files => config_readable_files.map { |f| File.join(config_path_local, f) },
|
79
82
|
:writable_files => config_writable_files.map { |f| File.join(config_path_local, f) },
|
80
83
|
:executable_files => config_executable_files.map { |f| File.join(config_path_local, f) },
|
@@ -92,6 +95,7 @@ module Capistrano
|
|
92
95
|
put(_read_config(src), tmp)
|
93
96
|
}
|
94
97
|
run(_do_update(src_tmp_tgt,
|
98
|
+
:use_sudo => fetch(:config_use_sudo_remotely, true),
|
95
99
|
:readable_files => config_readable_files.map { |f| File.join(config_path, f) },
|
96
100
|
:writable_files => config_writable_files.map { |f| File.join(config_path, f) },
|
97
101
|
:executable_files => config_executable_files.map { |f| File.join(config_path, f) },
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|