joekhoobyar-capistrano-extensions 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.
data/VERSION.yml
CHANGED
@@ -28,9 +28,20 @@ module CapistranoExtensions
|
|
28
28
|
compare_file compare_stream
|
29
29
|
uptodate?)
|
30
30
|
|
31
|
-
|
32
|
-
"
|
33
|
-
|
31
|
+
def exists?(a, options={})
|
32
|
+
$stdout.puts "[ -f #{_q a} ] ]"
|
33
|
+
File.exists? a
|
34
|
+
end
|
35
|
+
|
36
|
+
def directory?(a, options={})
|
37
|
+
$stdout.puts "[ -d #{_q a} ]"
|
38
|
+
File.directory? a
|
39
|
+
end
|
40
|
+
|
41
|
+
def executable?(a, options={})
|
42
|
+
$stdout.puts "[ -x #{_q a} ]"
|
43
|
+
File.executable? a
|
44
|
+
end
|
34
45
|
|
35
46
|
end
|
36
47
|
end
|
@@ -12,11 +12,11 @@ module CapistranoExtensions
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def upload(*args)
|
15
|
-
_via == :system ? cp(*args) : @config.upload(*args
|
15
|
+
_via == :system ? cp(*args) : @config.upload(*args)
|
16
16
|
end
|
17
17
|
|
18
18
|
def download(*args)
|
19
|
-
_via == :system ? cp(*args) : @config.download(*args
|
19
|
+
_via == :system ? cp(*args) : @config.download(*args)
|
20
20
|
end
|
21
21
|
|
22
22
|
def cd(dir, options={})
|
@@ -122,30 +122,41 @@ module CapistranoExtensions
|
|
122
122
|
_r 'touch', args
|
123
123
|
end
|
124
124
|
|
125
|
-
def exists?(a
|
126
|
-
|
125
|
+
def exists?(a)
|
126
|
+
_t "test -f", a
|
127
127
|
end
|
128
128
|
|
129
129
|
def directory?(a, options={:verbose=>false})
|
130
|
-
|
130
|
+
_t "test -d", a
|
131
131
|
end
|
132
132
|
|
133
133
|
def executable?(a, options={:verbose=>false})
|
134
|
-
|
134
|
+
_t "test -x", a
|
135
135
|
end
|
136
136
|
|
137
137
|
|
138
138
|
private
|
139
139
|
|
140
|
-
def
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
140
|
+
def _t(cmd, args=nil, min=nil)
|
141
|
+
cmd = _a cmd, args, min
|
142
|
+
if _via == :system then
|
143
|
+
system(cmd)
|
144
|
+
else
|
145
|
+
capture("#{cmd}; echo $?", :via => _via).strip == '0'
|
146
|
+
end
|
146
147
|
end
|
147
148
|
|
148
149
|
def _r(cmd, args=nil, min=nil)
|
150
|
+
cmd = _a cmd, args, min
|
151
|
+
if _via != :system then
|
152
|
+
invoke_command(cmd, :via => _via)
|
153
|
+
else
|
154
|
+
$stdout.puts cmd
|
155
|
+
system cmd
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def _a(cmd, args=nil, min=nil)
|
149
160
|
case args
|
150
161
|
when NilClass
|
151
162
|
raise ArgumentError unless min.nil? or min.zero?
|
@@ -154,17 +165,9 @@ module CapistranoExtensions
|
|
154
165
|
raise ArgumentError if (min || 1) > args.length
|
155
166
|
cmd = "#{cmd} #{_q(*args)}" if args.any?
|
156
167
|
else
|
157
|
-
raise ArgumentError if min
|
168
|
+
raise ArgumentError if min and min < 1
|
158
169
|
cmd = "#{cmd} #{_q args}"
|
159
170
|
end
|
160
|
-
|
161
|
-
case (v = _via)
|
162
|
-
when :system
|
163
|
-
@quiet or $stderr.puts cmd
|
164
|
-
system cmd
|
165
|
-
else
|
166
|
-
invoke_command cmd, :via => v
|
167
|
-
end
|
168
171
|
end
|
169
172
|
|
170
173
|
def _q(*list)
|
@@ -15,7 +15,9 @@ module CapistranoExtension
|
|
15
15
|
def sudo_su_to(*args, &block)
|
16
16
|
options = Hash===args.last ? args.pop.dup : {}
|
17
17
|
options[:shell] = false
|
18
|
-
|
18
|
+
cmd = args[0].gsub(/[$\\`"]/) { |m| "\\#{m}" }
|
19
|
+
args[0] = "echo \"#{cmd}\" | #{sudo} su - #{fetch(:runner, nil)}"
|
20
|
+
#args[0] = "echo \"#{.gsub('"', '\\"')}\" | #{sudo} su - #{fetch(:runner, nil)}"
|
19
21
|
run *args.push(options), &block
|
20
22
|
end
|
21
23
|
end
|