chicken_soup 0.2.0 → 0.3.0
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/chicken_soup.gemspec
CHANGED
File without changes
|
@@ -2,37 +2,51 @@
|
|
2
2
|
# UNIX TASKS #
|
3
3
|
######################################################################
|
4
4
|
Capistrano::Configuration.instance(:must_exist).load do
|
5
|
-
before "deploy:
|
5
|
+
before "deploy:shared_files:symlink", "deploy:shared_files:setup"
|
6
6
|
|
7
7
|
namespace :deploy do
|
8
|
-
namespace :
|
8
|
+
namespace :shared_files do
|
9
9
|
desc <<-DESC
|
10
10
|
Creates the directory where the `symlink` task will look for its configuration files.
|
11
11
|
|
12
12
|
It will first look in the local Rails directory to see if there is
|
13
|
-
a file of the same name as one of the shared files with the deployment
|
14
|
-
appended on the end.
|
13
|
+
a file or directory of the same name as one of the shared files with the deployment
|
14
|
+
environment appended on the end.
|
15
15
|
|
16
|
-
For example, if you had `config/database.yml` as one of your
|
17
|
-
you were deploying to the `staging` environment, this
|
16
|
+
For example, if you had `config/database.yml` as one of your
|
17
|
+
global_shared_elements and you were deploying to the `staging` environment, this
|
18
|
+
task will look for:
|
18
19
|
|
19
20
|
\#{Rails.root}/config/database.yml.staging
|
20
21
|
|
21
|
-
If it finds it, it will upload the file to the shared directory on
|
22
|
+
If it finds it, it will upload the file or directory to the shared directory on
|
23
|
+
the server and rename it to the proper file name.
|
22
24
|
|
23
|
-
If it doesn't find it, it will check to see if the remote file exists
|
24
|
-
|
25
|
-
DESC
|
26
|
-
task :create do
|
27
|
-
run "if [ ! -d #{shared_path}/config ]; then mkdir -p #{shared_path}/config; fi"
|
25
|
+
If it doesn't find it, it will check to see if the remote file exists, if not,
|
26
|
+
it will use whatever local file is available with that name.
|
28
27
|
|
29
|
-
|
30
|
-
|
28
|
+
As a last resort, it will error out because the symlink task which follows will
|
29
|
+
fail due to the missing file.
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
Note: This task will also work for setting up shared directories for user uploads, etc.
|
32
|
+
DESC
|
33
|
+
task :setup do
|
34
|
+
global_shared_elements.each do |shared_file|
|
35
|
+
base_dir_of_shared_file = shared_file.match(%r{/?((?:.*)/)})[1]
|
36
|
+
run "mkdir -p '#{shared_path}/#{base_dir_of_shared_file}'"
|
37
|
+
|
38
|
+
remote_shared_file = "#{shared_path}/#{shared_file}"
|
39
|
+
local_shared_file = "#{Dir.pwd}/#{shared_file}"
|
40
|
+
local_environment_specific_file = "#{local_shared_file}.#{rails_env}"
|
41
|
+
|
42
|
+
if File.exists?(local_environment_specific_file)
|
43
|
+
top.upload(local_environment_specific_file, remote_shared_file, :mode => "600")
|
44
|
+
elsif !remote_file_exists?(remote_shared_file)
|
45
|
+
if File.exists?(local_shared_file)
|
46
|
+
top.upload(local_shared_file, remote_shared_file, :mode => "600")
|
47
|
+
else
|
48
|
+
abort "I'm sorry Dave, but I couldn't find a local file or directory at '#{local_shared_file}' or '#{local_environment_specific_file}'"
|
49
|
+
end
|
36
50
|
end
|
37
51
|
end
|
38
52
|
end
|
@@ -43,7 +57,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
43
57
|
By default, these live in the shared directory that Capistrano sets up.
|
44
58
|
DESC
|
45
59
|
task :symlink do
|
46
|
-
|
60
|
+
global_shared_elements.each do |shared_file|
|
47
61
|
run "ln -nfs #{shared_path}/#{shared_file} #{latest_release}/#{shared_file}"
|
48
62
|
end
|
49
63
|
end
|
data/lib/chicken_soup/deploy.rb
CHANGED
@@ -44,7 +44,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
44
44
|
|
45
45
|
_cset :keep_releases, 15
|
46
46
|
|
47
|
-
_cset :
|
47
|
+
_cset :global_shared_elements, ["config/database.yml"]
|
48
48
|
|
49
49
|
_cset(:application_short) {application}
|
50
50
|
_cset(:application_underscored) {application.gsub(/-/, "_")}
|
data/lib/chicken_soup/global.rb
CHANGED
@@ -99,18 +99,22 @@ end
|
|
99
99
|
###
|
100
100
|
# Runs a command on the remote server to see if the file currently exists.
|
101
101
|
#
|
102
|
-
# @param [String] file The filename (optionally including path)
|
103
|
-
# or may not exist.
|
102
|
+
# @param [String] file The filename (optionally including path), directory,
|
103
|
+
# or symlink that is may or may not exist.
|
104
104
|
#
|
105
|
-
# @return [Boolean] Whether or not the file exists.
|
105
|
+
# @return [Boolean] Whether or not the file, directory or symlink exists.
|
106
106
|
#
|
107
107
|
# @example File without path:
|
108
108
|
# remote_file_exists? 'server.log'
|
109
109
|
# @example File with path:
|
110
110
|
# remote_file_exists? '/var/www/myappdir/log/production.log'
|
111
|
+
# @example Directory:
|
112
|
+
# remote_file_exists? '/var/www/myappdir/log'
|
113
|
+
# @example Symbolic Link:
|
114
|
+
# remote_file_exists? '/var/www/myappdir/current'
|
111
115
|
#
|
112
116
|
def remote_file_exists?(file)
|
113
|
-
capture("if [ -f #{file} ]; then echo 'exists'; fi;")
|
117
|
+
capture("if [[ -d #{file} ]] || [[ -h #{file} ]] || [[ -f #{file} ]]; then echo -n 'exists'; fi;") == "exists"
|
114
118
|
end
|
115
119
|
|
116
120
|
def require_if_exists(file)
|
data/lib/chicken_soup/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: chicken_soup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.3.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- thekompanee
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-06-
|
14
|
+
date: 2011-06-15 00:00:00 -05:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -169,6 +169,6 @@ rubyforge_project: chicken_soup
|
|
169
169
|
rubygems_version: 1.6.2
|
170
170
|
signing_key:
|
171
171
|
specification_version: 3
|
172
|
-
summary: chicken_soup-0.
|
172
|
+
summary: chicken_soup-0.3.0
|
173
173
|
test_files:
|
174
174
|
- spec/support/focused.rb
|