capsaicin 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION.yml +1 -1
- data/capsaicin.gemspec +36 -43
- data/lib/capistrano/recipes/deploy/strategy/copy_package.rb +76 -0
- data/lib/capsaicin/pom.rb +28 -0
- data/test/capsaicin/files/local_test.rb +174 -174
- metadata +20 -15
- data/.gitignore +0 -5
- data/lib/capistrano/recipes/deploy/strategy/local_copy.rb +0 -64
data/Rakefile
CHANGED
data/VERSION.yml
CHANGED
data/capsaicin.gemspec
CHANGED
@@ -1,64 +1,57 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.1.
|
7
|
+
s.name = "capsaicin"
|
8
|
+
s.version = "0.1.11"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Joe Khoobyar"]
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
12
|
+
s.date = "2013-02-19"
|
13
|
+
s.description = "Spicy capistrano extensions for various needs"
|
14
|
+
s.email = "joe@ankhcraft.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.rdoc"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
|
-
"
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
"test/capsaicin/files/local_test.rb",
|
42
|
-
"test/capsaicin/invocation_test.rb",
|
43
|
-
"test/helper.rb"
|
44
|
-
]
|
45
|
-
s.homepage = %q{http://github.com/joekhoobyar/capsaicin}
|
46
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
47
|
-
s.require_paths = ["lib"]
|
48
|
-
s.rubyforge_project = %q{capsaicin}
|
49
|
-
s.rubygems_version = %q{1.3.6}
|
50
|
-
s.summary = %q{Joe Khoobyar's spicy capistrano extensions}
|
51
|
-
s.test_files = [
|
20
|
+
"LICENSE",
|
21
|
+
"README.rdoc",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION.yml",
|
24
|
+
"capsaicin.gemspec",
|
25
|
+
"lib/capistrano/recipes/deploy/strategy/copy_package.rb",
|
26
|
+
"lib/capsaicin.rb",
|
27
|
+
"lib/capsaicin/bundle.rb",
|
28
|
+
"lib/capsaicin/files.rb",
|
29
|
+
"lib/capsaicin/files/local.rb",
|
30
|
+
"lib/capsaicin/files/remote.rb",
|
31
|
+
"lib/capsaicin/invocation.rb",
|
32
|
+
"lib/capsaicin/namespace.rb",
|
33
|
+
"lib/capsaicin/pom.rb",
|
34
|
+
"lib/capsaicin/service.rb",
|
35
|
+
"lib/capsaicin/service/command.rb",
|
36
|
+
"lib/capsaicin/service/crm.rb",
|
37
|
+
"lib/capsaicin/service/lsb.rb",
|
38
|
+
"lib/capsaicin/service/windows.rb",
|
39
|
+
"lib/capsaicin/sys.rb",
|
40
|
+
"lib/capsaicin/ui.rb",
|
52
41
|
"test/capsaicin/files/local_test.rb",
|
53
|
-
|
54
|
-
|
42
|
+
"test/capsaicin/invocation_test.rb",
|
43
|
+
"test/helper.rb"
|
55
44
|
]
|
45
|
+
s.homepage = "http://github.com/joekhoobyar/capsaicin"
|
46
|
+
s.require_paths = ["lib"]
|
47
|
+
s.rubyforge_project = "capsaicin"
|
48
|
+
s.rubygems_version = "1.8.11"
|
49
|
+
s.summary = "Joe Khoobyar's spicy capistrano extensions"
|
56
50
|
|
57
51
|
if s.respond_to? :specification_version then
|
58
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
59
52
|
s.specification_version = 3
|
60
53
|
|
61
|
-
if Gem::Version.new(Gem::
|
54
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
62
55
|
s.add_runtime_dependency(%q<capistrano>, [">= 2.5"])
|
63
56
|
s.add_runtime_dependency(%q<archive-tar-minitar>, [">= 0.5"])
|
64
57
|
else
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'capistrano/recipes/deploy/strategy/copy'
|
2
|
+
|
3
|
+
module Capistrano # :nodoc:
|
4
|
+
module Deploy # :nodoc:
|
5
|
+
module Strategy # :nodoc:
|
6
|
+
|
7
|
+
# Specialized copy strategy that expects the compressed package to exist after the source is built.
|
8
|
+
class CopyPackage < Copy
|
9
|
+
|
10
|
+
# Returns the location of the local package file.
|
11
|
+
# Returns +nil+ unless :package_file has been set. If :package_file
|
12
|
+
# is +true+, a default file location will be returned.
|
13
|
+
def package_file
|
14
|
+
@package_file ||= begin
|
15
|
+
file = configuration[:package_file]
|
16
|
+
file = "#{package_name}.#{compression.extension}" if TrueClass === file
|
17
|
+
File.expand_path(configuration[:package_file], copy_dir) rescue nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns the package name. Used as a default basename for :package_file
|
22
|
+
def package_name
|
23
|
+
@package_name ||= configuration[:package_name] || "#{configuration[:application]}-#{File.basename(destination)}"
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def destination
|
29
|
+
@destination ||= copy_dir
|
30
|
+
end
|
31
|
+
|
32
|
+
def filename
|
33
|
+
@filename ||= File.expand_path(package_file, copy_dir)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns the value of the :copy_dir variable, defaulting to the current directory.
|
37
|
+
def copy_dir
|
38
|
+
@copy_dir ||= configuration[:copy_dir] || '.'
|
39
|
+
end
|
40
|
+
|
41
|
+
# Don't build an archive file.
|
42
|
+
def copy_repository_to_server ; end
|
43
|
+
def compress_repository ; end
|
44
|
+
def create_revision_file ; end
|
45
|
+
def copy_cache_to_staging_area ; end
|
46
|
+
def remove_excluded_files ; end
|
47
|
+
def rollback_changes ; end
|
48
|
+
|
49
|
+
# Distributes the file to the remote servers
|
50
|
+
def distribute!
|
51
|
+
files.upload(filename, remote_filename)
|
52
|
+
decompress_remote_file
|
53
|
+
end
|
54
|
+
|
55
|
+
def decompress_remote_file
|
56
|
+
run "mkdir -p #{configuration[:release_path]} && cd #{configuration[:release_path]} && #{decompress(remote_filename).join(" ")} && rm #{remote_filename}"
|
57
|
+
end
|
58
|
+
|
59
|
+
#
|
60
|
+
# def xx
|
61
|
+
# logger.debug "compressing local copy to #{filename}"
|
62
|
+
# local_files.tar_cz filename, '.', :verbose=>false do |item|
|
63
|
+
# if (item=item[2..-1]) and item.length > 0
|
64
|
+
# name = File.basename item
|
65
|
+
# name == "." || name == ".." || copy_prune.include?(name) ||
|
66
|
+
# copy_exclude.any?{|p| File.fnmatch(p, item, File::FNM_DOTMATCH)} ||
|
67
|
+
# (! File.directory?(item) && copy_directory_only.any?{|p| item[0,p.length+1]==p+'/'})
|
68
|
+
# end
|
69
|
+
# end
|
70
|
+
# end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Capistrano::Configuration.instance.load do
|
2
|
+
set :pom_file, 'pom.xml'
|
3
|
+
|
4
|
+
set(:pom_doc) do
|
5
|
+
require 'rexml/document'
|
6
|
+
File.open(pom_file, 'r') { |f| REXML::Document.new(f) } or abort "Cannot read XML: #{pom_xml}"
|
7
|
+
end
|
8
|
+
|
9
|
+
set(:pom_artifact_id) do
|
10
|
+
t = pom_doc.root.elements['/project/artifactId/text()'].to_s.strip rescue ''
|
11
|
+
t.length > 0 or abort "Cannot read /project/artifactId element from #{pom_xml}"
|
12
|
+
t
|
13
|
+
end
|
14
|
+
|
15
|
+
set(:pom_version) do
|
16
|
+
x = pom_doc
|
17
|
+
until 0 < (t = x.root.elements['/project/version/text()'].to_s.strip rescue '').length
|
18
|
+
p = x.root.elements['/project/parent/relativePath/text()'].to_s.strip rescue ''
|
19
|
+
break if p.length == 0
|
20
|
+
p = File.join p, pom_file
|
21
|
+
x = File.open(p, 'r') { |f| REXML::Document.new(f) } or abort "Cannot read parent XML: #{p}"
|
22
|
+
end
|
23
|
+
t.length > 0 or abort "Cannot read /project/version element from #{pom_xml} or parent(s)"
|
24
|
+
t
|
25
|
+
end
|
26
|
+
|
27
|
+
set(:pom_final_name) { [pom_artifact_id, pom_version].compact.join '-' }
|
28
|
+
end
|
@@ -1,174 +1,174 @@
|
|
1
|
-
require 'helper'
|
2
|
-
require 'tmpdir'
|
3
|
-
require 'capsaicin/files'
|
4
|
-
require 'capsaicin/files/local'
|
5
|
-
|
6
|
-
class Capsaicin::Files::LocalTest < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@local = CapistranoMock.new
|
10
|
-
@local.extend Capsaicin::Files::Local
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
@tmpdir and FileUtils.rm_rf(@tmpdir)
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_exists
|
18
|
-
assert @local.exists?(__FILE__)
|
19
|
-
assert_equal "test -e #{__FILE__}", @local.logbuf.string.strip
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_not_exists
|
23
|
-
assert ! @local.exists?(__FILE__+'/nope')
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_readable
|
27
|
-
assert @local.readable?(__FILE__)
|
28
|
-
assert_equal "test -r #{__FILE__}", @local.logbuf.string.strip
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_not_readable
|
32
|
-
assert ! @local.readable?(__FILE__+'/nope')
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_writable
|
36
|
-
assert @local.writable?(Dir.tmpdir)
|
37
|
-
assert_equal "test -w #{Dir.tmpdir}", @local.logbuf.string.strip
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_not_writable
|
41
|
-
assert ! @local.writable?(__FILE__+'/nope')
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_file
|
45
|
-
assert @local.file?(__FILE__)
|
46
|
-
assert_equal "test -f #{__FILE__}", @local.logbuf.string.strip
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_not_file
|
50
|
-
assert ! @local.file?(__FILE__+'/nope')
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_directory
|
54
|
-
assert @local.directory?(File.dirname(__FILE__))
|
55
|
-
assert_equal "test -d #{File.dirname __FILE__}", @local.logbuf.string.strip
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_not_directory
|
59
|
-
assert ! @local.directory?(__FILE__)
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_mkdir
|
63
|
-
assert @local.mkdir(d = tmpdir('test-mkdir'))
|
64
|
-
assert File.directory?(d)
|
65
|
-
assert_equal "mkdir #{d}", @local.logbuf.string.strip
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_mkdir_not_p
|
69
|
-
assert_raise Errno::ENOENT do
|
70
|
-
@local.mkdir(tmpdir('test-mkdir','p'))
|
71
|
-
end
|
72
|
-
assert ! File.directory?(d = tmpdir('test-mkdir','p'))
|
73
|
-
assert_equal "mkdir #{d}", @local.logbuf.string.strip
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_mkdir_p
|
77
|
-
assert @local.mkdir_p(d = tmpdir('test-mkdir','p'))
|
78
|
-
assert File.directory?(d)
|
79
|
-
assert_equal "mkdir -p #{d}", @local.logbuf.string.strip
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_mkdir_p_one
|
83
|
-
assert @local.mkdir_p(d = tmpdir('test-mkdir-p'))
|
84
|
-
assert File.directory?(d)
|
85
|
-
assert_equal "mkdir -p #{d}", @local.logbuf.string.strip
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_rmdir
|
89
|
-
FileUtils.mkdir(d = tmpdir('test-rmdir'))
|
90
|
-
assert @local.rmdir(d)
|
91
|
-
assert ! File.directory?(d)
|
92
|
-
assert ! File.exists?(d)
|
93
|
-
assert_equal "rmdir #{d}", @local.logbuf.string.strip
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_cp
|
97
|
-
assert_nil @local.cp(__FILE__, f = tmpdir('test-cp'))
|
98
|
-
assert_equal File.read(__FILE__), File.read(f)
|
99
|
-
assert_equal "cp #{__FILE__} #{f}", @local.logbuf.string.strip
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_cp_r
|
103
|
-
assert_nil @local.cp_r(File.dirname(__FILE__), d = tmpdir('test-cp-r'))
|
104
|
-
assert_equal File.read(__FILE__), File.read(File.join(d,File.basename(__FILE__)))
|
105
|
-
assert_equal "cp -r #{File.dirname __FILE__} #{d}", @local.logbuf.string.strip
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_rm
|
109
|
-
FileUtils.cp(__FILE__, f = tmpdir('test-cp'))
|
110
|
-
assert @local.rm(f)
|
111
|
-
assert ! File.exists?(f)
|
112
|
-
assert_equal "rm #{f}", @local.logbuf.string.strip
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_rm_missing
|
116
|
-
assert_raise Errno::ENOENT do
|
117
|
-
assert @local.rm(tmpdir('test-cp'))
|
118
|
-
end
|
119
|
-
assert_equal "rm #{tmpdir('test-cp')}", @local.logbuf.string.strip
|
120
|
-
end
|
121
|
-
|
122
|
-
def test_rm_f
|
123
|
-
FileUtils.cp(__FILE__, f = tmpdir('test-cp'))
|
124
|
-
assert @local.rm_f(f)
|
125
|
-
assert ! File.exists?(f)
|
126
|
-
assert_equal "rm -f #{f}", @local.logbuf.string.strip
|
127
|
-
end
|
128
|
-
|
129
|
-
def test_rm_f_missing
|
130
|
-
assert @local.rm_f(f = tmpdir('test-cp'))
|
131
|
-
assert ! File.exists?(f)
|
132
|
-
assert_equal "rm -f #{f}", @local.logbuf.string.strip
|
133
|
-
end
|
134
|
-
|
135
|
-
def test_rm_r
|
136
|
-
FileUtils.cp_r(File.dirname(__FILE__), d = tmpdir('test-cp-r'))
|
137
|
-
assert @local.rm_r(d)
|
138
|
-
assert ! File.directory?(d)
|
139
|
-
assert ! File.exists?(d)
|
140
|
-
assert_equal "rm -r #{d}", @local.logbuf.string.strip
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_rm_r_missing
|
144
|
-
assert_raise Errno::ENOENT do
|
145
|
-
assert @local.rm_r(tmpdir('test-cp-r'))
|
146
|
-
end
|
147
|
-
assert_equal "rm -r #{tmpdir('test-cp-r')}", @local.logbuf.string.strip
|
148
|
-
end
|
149
|
-
|
150
|
-
def test_rm_rf
|
151
|
-
FileUtils.cp_r(File.dirname(__FILE__), d = tmpdir('test-cp-r'))
|
152
|
-
assert @local.rm_rf(d)
|
153
|
-
assert ! File.directory?(d)
|
154
|
-
assert ! File.exists?(d)
|
155
|
-
assert_equal "rm -rf #{d}", @local.logbuf.string.strip
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_rm_rf_missing
|
159
|
-
assert @local.rm_rf(d = tmpdir('test-cp-r'))
|
160
|
-
assert ! File.directory?(d)
|
161
|
-
assert ! File.exists?(d)
|
162
|
-
assert_equal "rm -rf #{d}", @local.logbuf.string.strip
|
163
|
-
end
|
164
|
-
|
165
|
-
protected
|
166
|
-
|
167
|
-
def tmpdir(*args)
|
168
|
-
@tmpdir ||= "#{Dir.tmpdir}/capsaicin".tap do |d|
|
169
|
-
FileUtils.rm_rf d
|
170
|
-
FileUtils.mkdir_p d
|
171
|
-
end
|
172
|
-
File.join @tmpdir, *args
|
173
|
-
end
|
174
|
-
end
|
1
|
+
require 'helper'
|
2
|
+
require 'tmpdir'
|
3
|
+
require 'capsaicin/files'
|
4
|
+
require 'capsaicin/files/local'
|
5
|
+
|
6
|
+
class Capsaicin::Files::LocalTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@local = CapistranoMock.new
|
10
|
+
@local.extend Capsaicin::Files::Local
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
@tmpdir and FileUtils.rm_rf(@tmpdir)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_exists
|
18
|
+
assert @local.exists?(__FILE__)
|
19
|
+
assert_equal "test -e #{__FILE__}", @local.logbuf.string.strip
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_not_exists
|
23
|
+
assert ! @local.exists?(__FILE__+'/nope')
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_readable
|
27
|
+
assert @local.readable?(__FILE__)
|
28
|
+
assert_equal "test -r #{__FILE__}", @local.logbuf.string.strip
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_not_readable
|
32
|
+
assert ! @local.readable?(__FILE__+'/nope')
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_writable
|
36
|
+
assert @local.writable?(Dir.tmpdir)
|
37
|
+
assert_equal "test -w #{Dir.tmpdir}", @local.logbuf.string.strip
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_not_writable
|
41
|
+
assert ! @local.writable?(__FILE__+'/nope')
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_file
|
45
|
+
assert @local.file?(__FILE__)
|
46
|
+
assert_equal "test -f #{__FILE__}", @local.logbuf.string.strip
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_not_file
|
50
|
+
assert ! @local.file?(__FILE__+'/nope')
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_directory
|
54
|
+
assert @local.directory?(File.dirname(__FILE__))
|
55
|
+
assert_equal "test -d #{File.dirname __FILE__}", @local.logbuf.string.strip
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_not_directory
|
59
|
+
assert ! @local.directory?(__FILE__)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_mkdir
|
63
|
+
assert @local.mkdir(d = tmpdir('test-mkdir'))
|
64
|
+
assert File.directory?(d)
|
65
|
+
assert_equal "mkdir #{d}", @local.logbuf.string.strip
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_mkdir_not_p
|
69
|
+
assert_raise Errno::ENOENT do
|
70
|
+
@local.mkdir(tmpdir('test-mkdir','p'))
|
71
|
+
end
|
72
|
+
assert ! File.directory?(d = tmpdir('test-mkdir','p'))
|
73
|
+
assert_equal "mkdir #{d}", @local.logbuf.string.strip
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_mkdir_p
|
77
|
+
assert @local.mkdir_p(d = tmpdir('test-mkdir','p'))
|
78
|
+
assert File.directory?(d)
|
79
|
+
assert_equal "mkdir -p #{d}", @local.logbuf.string.strip
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_mkdir_p_one
|
83
|
+
assert @local.mkdir_p(d = tmpdir('test-mkdir-p'))
|
84
|
+
assert File.directory?(d)
|
85
|
+
assert_equal "mkdir -p #{d}", @local.logbuf.string.strip
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_rmdir
|
89
|
+
FileUtils.mkdir(d = tmpdir('test-rmdir'))
|
90
|
+
assert @local.rmdir(d)
|
91
|
+
assert ! File.directory?(d)
|
92
|
+
assert ! File.exists?(d)
|
93
|
+
assert_equal "rmdir #{d}", @local.logbuf.string.strip
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_cp
|
97
|
+
assert_nil @local.cp(__FILE__, f = tmpdir('test-cp'))
|
98
|
+
assert_equal File.read(__FILE__), File.read(f)
|
99
|
+
assert_equal "cp #{__FILE__} #{f}", @local.logbuf.string.strip
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_cp_r
|
103
|
+
assert_nil @local.cp_r(File.dirname(__FILE__), d = tmpdir('test-cp-r'))
|
104
|
+
assert_equal File.read(__FILE__), File.read(File.join(d,File.basename(__FILE__)))
|
105
|
+
assert_equal "cp -r #{File.dirname __FILE__} #{d}", @local.logbuf.string.strip
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_rm
|
109
|
+
FileUtils.cp(__FILE__, f = tmpdir('test-cp'))
|
110
|
+
assert @local.rm(f)
|
111
|
+
assert ! File.exists?(f)
|
112
|
+
assert_equal "rm #{f}", @local.logbuf.string.strip
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_rm_missing
|
116
|
+
assert_raise Errno::ENOENT do
|
117
|
+
assert @local.rm(tmpdir('test-cp'))
|
118
|
+
end
|
119
|
+
assert_equal "rm #{tmpdir('test-cp')}", @local.logbuf.string.strip
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_rm_f
|
123
|
+
FileUtils.cp(__FILE__, f = tmpdir('test-cp'))
|
124
|
+
assert @local.rm_f(f)
|
125
|
+
assert ! File.exists?(f)
|
126
|
+
assert_equal "rm -f #{f}", @local.logbuf.string.strip
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_rm_f_missing
|
130
|
+
assert @local.rm_f(f = tmpdir('test-cp'))
|
131
|
+
assert ! File.exists?(f)
|
132
|
+
assert_equal "rm -f #{f}", @local.logbuf.string.strip
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_rm_r
|
136
|
+
FileUtils.cp_r(File.dirname(__FILE__), d = tmpdir('test-cp-r'))
|
137
|
+
assert @local.rm_r(d)
|
138
|
+
assert ! File.directory?(d)
|
139
|
+
assert ! File.exists?(d)
|
140
|
+
assert_equal "rm -r #{d}", @local.logbuf.string.strip
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_rm_r_missing
|
144
|
+
assert_raise Errno::ENOENT do
|
145
|
+
assert @local.rm_r(tmpdir('test-cp-r'))
|
146
|
+
end
|
147
|
+
assert_equal "rm -r #{tmpdir('test-cp-r')}", @local.logbuf.string.strip
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_rm_rf
|
151
|
+
FileUtils.cp_r(File.dirname(__FILE__), d = tmpdir('test-cp-r'))
|
152
|
+
assert @local.rm_rf(d)
|
153
|
+
assert ! File.directory?(d)
|
154
|
+
assert ! File.exists?(d)
|
155
|
+
assert_equal "rm -rf #{d}", @local.logbuf.string.strip
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_rm_rf_missing
|
159
|
+
assert @local.rm_rf(d = tmpdir('test-cp-r'))
|
160
|
+
assert ! File.directory?(d)
|
161
|
+
assert ! File.exists?(d)
|
162
|
+
assert_equal "rm -rf #{d}", @local.logbuf.string.strip
|
163
|
+
end
|
164
|
+
|
165
|
+
protected
|
166
|
+
|
167
|
+
def tmpdir(*args)
|
168
|
+
@tmpdir ||= "#{Dir.tmpdir}/capsaicin".tap do |d|
|
169
|
+
FileUtils.rm_rf d
|
170
|
+
FileUtils.mkdir_p d
|
171
|
+
end
|
172
|
+
File.join @tmpdir, *args
|
173
|
+
end
|
174
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capsaicin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 13
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
9
|
+
- 11
|
10
|
+
version: 0.1.11
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Joe Khoobyar
|
@@ -14,16 +15,17 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date:
|
18
|
-
default_executable:
|
18
|
+
date: 2013-02-19 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: capistrano
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
24
25
|
requirements:
|
25
26
|
- - ">="
|
26
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 9
|
27
29
|
segments:
|
28
30
|
- 2
|
29
31
|
- 5
|
@@ -34,9 +36,11 @@ dependencies:
|
|
34
36
|
name: archive-tar-minitar
|
35
37
|
prerelease: false
|
36
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
37
40
|
requirements:
|
38
41
|
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 1
|
40
44
|
segments:
|
41
45
|
- 0
|
42
46
|
- 5
|
@@ -53,13 +57,12 @@ extra_rdoc_files:
|
|
53
57
|
- LICENSE
|
54
58
|
- README.rdoc
|
55
59
|
files:
|
56
|
-
- .gitignore
|
57
60
|
- LICENSE
|
58
61
|
- README.rdoc
|
59
62
|
- Rakefile
|
60
63
|
- VERSION.yml
|
61
64
|
- capsaicin.gemspec
|
62
|
-
- lib/capistrano/recipes/deploy/strategy/
|
65
|
+
- lib/capistrano/recipes/deploy/strategy/copy_package.rb
|
63
66
|
- lib/capsaicin.rb
|
64
67
|
- lib/capsaicin/bundle.rb
|
65
68
|
- lib/capsaicin/files.rb
|
@@ -67,6 +70,7 @@ files:
|
|
67
70
|
- lib/capsaicin/files/remote.rb
|
68
71
|
- lib/capsaicin/invocation.rb
|
69
72
|
- lib/capsaicin/namespace.rb
|
73
|
+
- lib/capsaicin/pom.rb
|
70
74
|
- lib/capsaicin/service.rb
|
71
75
|
- lib/capsaicin/service/command.rb
|
72
76
|
- lib/capsaicin/service/crm.rb
|
@@ -77,37 +81,38 @@ files:
|
|
77
81
|
- test/capsaicin/files/local_test.rb
|
78
82
|
- test/capsaicin/invocation_test.rb
|
79
83
|
- test/helper.rb
|
80
|
-
has_rdoc: true
|
81
84
|
homepage: http://github.com/joekhoobyar/capsaicin
|
82
85
|
licenses: []
|
83
86
|
|
84
87
|
post_install_message:
|
85
|
-
rdoc_options:
|
86
|
-
|
88
|
+
rdoc_options: []
|
89
|
+
|
87
90
|
require_paths:
|
88
91
|
- lib
|
89
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
90
94
|
requirements:
|
91
95
|
- - ">="
|
92
96
|
- !ruby/object:Gem::Version
|
97
|
+
hash: 3
|
93
98
|
segments:
|
94
99
|
- 0
|
95
100
|
version: "0"
|
96
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
97
103
|
requirements:
|
98
104
|
- - ">="
|
99
105
|
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
100
107
|
segments:
|
101
108
|
- 0
|
102
109
|
version: "0"
|
103
110
|
requirements: []
|
104
111
|
|
105
112
|
rubyforge_project: capsaicin
|
106
|
-
rubygems_version: 1.
|
113
|
+
rubygems_version: 1.8.11
|
107
114
|
signing_key:
|
108
115
|
specification_version: 3
|
109
116
|
summary: Joe Khoobyar's spicy capistrano extensions
|
110
|
-
test_files:
|
111
|
-
|
112
|
-
- test/capsaicin/invocation_test.rb
|
113
|
-
- test/helper.rb
|
117
|
+
test_files: []
|
118
|
+
|
data/.gitignore
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'capistrano/recipes/deploy/strategy/base'
|
2
|
-
require 'tempfile'
|
3
|
-
|
4
|
-
module Capistrano # :nodoc:
|
5
|
-
module Deploy # :nodoc:
|
6
|
-
module Strategy # :nodoc:
|
7
|
-
class LocalCopy < Base # :nodoc:
|
8
|
-
|
9
|
-
def deploy! # :nodoc:
|
10
|
-
logger.debug "compressing local copy to #{filename}"
|
11
|
-
local_files.tar_cz filename, '.', :verbose=>false do |item|
|
12
|
-
if (item=item[2..-1]) and item.length > 0
|
13
|
-
name = File.basename item
|
14
|
-
name == "." || name == ".." || copy_prune.include?(name) ||
|
15
|
-
copy_exclude.any?{|p| File.fnmatch(p, item, File::FNM_DOTMATCH)} ||
|
16
|
-
(! File.directory?(item) && copy_directory_only.any?{|p| item[0,p.length+1]==p+'/'})
|
17
|
-
end
|
18
|
-
end
|
19
|
-
files.upload filename, remote_filename
|
20
|
-
begin
|
21
|
-
files.mkdir_p configuration[:release_path]
|
22
|
-
files.tar_xz remote_filename, :chdir=>configuration[:release_path], :verbose=>true
|
23
|
-
ensure
|
24
|
-
files.rm_f remote_filename rescue nil
|
25
|
-
end
|
26
|
-
ensure
|
27
|
-
FileUtils.rm filename rescue nil
|
28
|
-
FileUtils.rm_rf destination rescue nil
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def local_copy_dir # :nodoc:
|
34
|
-
@local_copy_dir ||= configuration.fetch(:local_copy_dir, '.')
|
35
|
-
end
|
36
|
-
|
37
|
-
def copy_exclude # :nodoc:
|
38
|
-
@copy_exclude ||= Array(configuration.fetch(:copy_exclude, %w(.*)))
|
39
|
-
end
|
40
|
-
|
41
|
-
def copy_prune # :nodoc:
|
42
|
-
@copy_prune ||= Array(configuration.fetch(:copy_exclude, %w(.svn .git)))
|
43
|
-
end
|
44
|
-
|
45
|
-
def copy_directory_only # :nodoc:
|
46
|
-
@copy_directory_only ||= Array(configuration.fetch(:copy_directory_only, %w(log tmp)))
|
47
|
-
end
|
48
|
-
|
49
|
-
def filename # :nodoc:
|
50
|
-
@filename ||= File.join(Dir.tmpdir, "#{configuration.fetch(:application, 'local_copy')}.tgz")
|
51
|
-
end
|
52
|
-
|
53
|
-
def remote_dir # :nodoc:
|
54
|
-
@remote_dir ||= configuration[:copy_remote_dir] || "/tmp"
|
55
|
-
end
|
56
|
-
|
57
|
-
def remote_filename # :nodoc:
|
58
|
-
@remote_filename ||= File.join(remote_dir, File.basename(filename))
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|