joekhoobyar-capistrano-extensions 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -2
- data/VERSION.yml +2 -2
- data/lib/capistrano_extensions/files.rb +1 -5
- data/lib/capistrano_extensions/files/local.rb +3 -4
- data/lib/capistrano_extensions/files/remote.rb +7 -7
- data/lib/capistrano_extensions/invocation.rb +24 -0
- data/lib/jk_capistrano_extensions.rb +1 -1
- metadata +15 -5
data/Rakefile
CHANGED
@@ -10,10 +10,12 @@ begin
|
|
10
10
|
s.name = "capistrano-extensions"
|
11
11
|
s.homepage = "http://github.com/joekhoobyar/capistrano-extensions"
|
12
12
|
s.summary = "Joe Khoobyar's Capistrano Extensions"
|
13
|
-
s.description = %Q{
|
13
|
+
s.description = %Q{Various capistrano extensions}
|
14
14
|
|
15
15
|
s.authors = ["Joe Khoobyar"]
|
16
16
|
s.email = "joe@ankhcraft.com"
|
17
|
+
|
18
|
+
s.add_dependency 'capistrano'
|
17
19
|
end
|
18
20
|
rescue LoadError
|
19
21
|
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
@@ -36,5 +38,5 @@ Rake::TestTask.new do |t|
|
|
36
38
|
t.libs << "lib"
|
37
39
|
end
|
38
40
|
|
39
|
-
task :default => :
|
41
|
+
task :default => :build
|
40
42
|
|
data/VERSION.yml
CHANGED
@@ -7,11 +7,7 @@ module CapistranoExtensions::Files
|
|
7
7
|
end.join("\n"))
|
8
8
|
|
9
9
|
def _via
|
10
|
-
|
11
|
-
:remote
|
12
|
-
else
|
13
|
-
:local
|
14
|
-
end
|
10
|
+
@config.fetch(:files_via, :remote).to_sym != :local ? :remote : :local
|
15
11
|
end
|
16
12
|
end
|
17
13
|
|
@@ -5,11 +5,10 @@ module CapistranoExtensions
|
|
5
5
|
module Local
|
6
6
|
|
7
7
|
def tail_f(file, n=10)
|
8
|
-
unless defined? File::Tail::Logfile
|
9
|
-
gem 'file-tail'
|
10
|
-
require 'file/tail'
|
11
|
-
end
|
8
|
+
unless defined? File::Tail::Logfile then gem 'file-tail'; require 'file/tail' end
|
12
9
|
File::Tail::Logfile.tail(file, :backward=>n) do |line| puts line end
|
10
|
+
rescue Interrupt
|
11
|
+
logger.trace "interrupted (Ctrl-C)" if logger
|
13
12
|
end
|
14
13
|
|
15
14
|
def upload(from, to)
|
@@ -6,15 +6,17 @@ module CapistranoExtensions
|
|
6
6
|
|
7
7
|
def tail_f(file, n=10)
|
8
8
|
cmd = "tail -n #{n} -f #{_q file}"
|
9
|
-
_via == :system ? system(cmd) : stream(cmd)
|
9
|
+
_via == :system ? system(cmd) : stream(cmd, :via => _via)
|
10
|
+
rescue Interrupt
|
11
|
+
logger.trace "interrupted (Ctrl-C)" if logger
|
10
12
|
end
|
11
13
|
|
12
14
|
def upload(*args)
|
13
|
-
_via == :system ? cp(*args) : upload(*args)
|
15
|
+
_via == :system ? cp(*args) : @config.upload(*args.push(:via => _via))
|
14
16
|
end
|
15
17
|
|
16
18
|
def download(*args)
|
17
|
-
_via == :system ? cp(*args) : download(*args)
|
19
|
+
_via == :system ? cp(*args) : @config.download(*args.push(:via => _via))
|
18
20
|
end
|
19
21
|
|
20
22
|
def cd(dir, options={})
|
@@ -160,8 +162,6 @@ module CapistranoExtensions
|
|
160
162
|
when :system
|
161
163
|
@quiet or $stderr.puts cmd
|
162
164
|
system cmd
|
163
|
-
when :sudo
|
164
|
-
sudo cmd, :as => @config.fetch(:runner, 'app')
|
165
165
|
else
|
166
166
|
invoke_command cmd, :via => v
|
167
167
|
end
|
@@ -172,11 +172,11 @@ module CapistranoExtensions
|
|
172
172
|
end
|
173
173
|
|
174
174
|
def _via
|
175
|
-
case (v = files_via)
|
175
|
+
case (v = @config.fetch(:files_via, nil))
|
176
176
|
when :local
|
177
177
|
:system
|
178
178
|
when :remote, NilClass
|
179
|
-
:
|
179
|
+
@config.fetch(:run_method, nil)
|
180
180
|
else
|
181
181
|
v
|
182
182
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module CapistranoExtension
|
2
|
+
module Invocation
|
3
|
+
def sudo_as(*args, &block)
|
4
|
+
options = Hash===args.last ? args.pop.dup : {}
|
5
|
+
options[:as] = fetch(:runner, nil)
|
6
|
+
sudo *args.push(options), &block
|
7
|
+
end
|
8
|
+
|
9
|
+
def sudo_su(*args, &block)
|
10
|
+
options = Hash===args.last ? args.pop.dup : {}
|
11
|
+
args[0] = "su #{fetch(:runner, nil)} -c '#{args[0]}'"
|
12
|
+
sudo *args.push(options), &block
|
13
|
+
end
|
14
|
+
|
15
|
+
def sudo_su_to(*args, &block)
|
16
|
+
options = Hash===args.last ? args.pop.dup : {}
|
17
|
+
options[:shell] = false
|
18
|
+
args[0] = "echo \"#{args[0].gsub('"', '\\"')}\" | #{sudo} su - #{fetch(:runner, nil)}"
|
19
|
+
run *args.push(options), &block
|
20
|
+
end
|
21
|
+
end
|
22
|
+
Capistrano::Configuration.send :include, Invocation
|
23
|
+
end
|
24
|
+
|
@@ -3,6 +3,6 @@ unless Capistrano::Configuration.respond_to?(:instance)
|
|
3
3
|
end
|
4
4
|
require 'capistrano'
|
5
5
|
|
6
|
-
require "#{File.dirname(__FILE__)}/capistrano_extensions/
|
6
|
+
require "#{File.dirname(__FILE__)}/capistrano_extensions/invocation.rb"
|
7
7
|
require "#{File.dirname(__FILE__)}/capistrano_extensions/files.rb"
|
8
8
|
require "#{File.dirname(__FILE__)}/capistrano_extensions/service.rb"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: joekhoobyar-capistrano-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Khoobyar
|
@@ -9,11 +9,20 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-24 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: capistrano
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description: Various capistrano extensions
|
17
26
|
email: joe@ankhcraft.com
|
18
27
|
executables: []
|
19
28
|
|
@@ -27,6 +36,7 @@ files:
|
|
27
36
|
- lib/capistrano_extensions/files.rb
|
28
37
|
- lib/capistrano_extensions/files/local.rb
|
29
38
|
- lib/capistrano_extensions/files/remote.rb
|
39
|
+
- lib/capistrano_extensions/invocation.rb
|
30
40
|
- lib/capistrano_extensions/service.rb
|
31
41
|
- lib/jk_capistrano_extensions.rb
|
32
42
|
- README
|