capistrano-utils 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,8 +13,8 @@ Gem::Specification.new do |gem|
13
13
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
14
  gem.name = 'capistrano-utils'
15
15
  gem.require_paths = ['lib']
16
- gem.version = '0.0.4'
16
+ gem.version = '0.0.5'
17
17
 
18
18
  gem.add_dependency 'rake'
19
- gem.add_dependency 'capistrano'
19
+ gem.add_dependency 'capistrano', '>= 2.12.0'
20
20
  end
@@ -1,9 +1,3 @@
1
- require 'capistrano/ext/helpers'
2
-
3
- unless Capistrano::Configuration.respond_to?(:instance)
4
- abort 'capistrano/ext/contao requires capistrano 2'
5
- end
6
-
7
1
  Capistrano::Configuration.instance(:must_exist).load do
8
2
  set :repository,
9
3
  fetch(:project_repository, `git remote show -n origin | grep 'URL' | awk '{print $3}' | head -n 1`.strip)
@@ -1,10 +1,6 @@
1
1
  require 'digest/sha1'
2
2
  require 'highline'
3
3
 
4
- unless Capistrano::Configuration.respond_to?(:instance)
5
- abort 'capistrano/ext/helpers requires capistrano 2'
6
- end
7
-
8
4
  Capistrano::Configuration.instance(:must_exist).load do
9
5
  # Taken from the capistrano code.
10
6
  def _cset(name, *args, &block)
@@ -30,63 +26,50 @@ Capistrano::Configuration.instance(:must_exist).load do
30
26
  end
31
27
  end
32
28
 
33
- # Return an array of arrays of files to link
34
- #
35
- # @param [String] Absolute path to folder from which to link
36
- # @param [String] Absolute path to folder to which to link
37
- # @return [Array]
38
- def exhaustive_list_of_files_to_link(from, to)
29
+ # Deeply link files from a folder to another
30
+ def deep_link(from, to)
39
31
  script = <<-END
40
- exhaustive_list_of_files_to_link() {
41
- files="";
42
-
43
- for f in `ls -A1 ${1}`; do
44
- file="${2}/${f}";
45
- f="${1}/${f}";
46
- if [ -e "${file}" ]; then
47
- files="${files} `exhaustive_list_of_files_to_link ${f} ${file}`";
48
- else
49
- files="${files} ${f}:${file}";
50
- fi;
51
- done;
52
- echo "${files}";
53
- };
32
+ exhaustive_list_of_files_to_link() {
33
+ files="";
34
+
35
+ for file in `ls -A1 ${1}`; do
36
+ dest_file="${2}/${file}";
37
+ file="${1}/${file}";
38
+ if [ -e "${dest_file}" ]; then
39
+ files="${files} `exhaustive_list_of_files_to_link ${file} ${dest_file}`";
40
+ else
41
+ files="${files} ${file}:${dest_file}";
42
+ fi;
43
+ done;
44
+ echo "${files}";
45
+ };
46
+
47
+ files=`exhaustive_list_of_files_to_link '#{from}' '#{to}'`;
48
+ for file in ${files}; do
49
+ ln -s "`echo "${file}" | cut -d: -f1`" \
50
+ "`echo "${file}" | cut -d: -f2`";
51
+ done;
54
52
  END
55
53
 
56
- script << "exhaustive_list_of_files_to_link '#{from}' '#{to}';"
57
-
58
- begin
59
- files = capture(script).strip.split(' ')
60
- files.map {|f| f.split(':')}
61
- rescue Capistrano::CommandError
62
- abort "Unable to get files list"
63
- end
54
+ run script
64
55
  end
65
56
 
66
- def link_files(path, files = {})
67
- files.each do |f|
68
- file_name = f.dup.gsub(/\//, '_')
69
- unless remote_file_exists?("#{path}/#{file_name}")
70
- begin
71
- run <<-CMD
72
- #{try_sudo} cp -a #{latest_release}/#{f} #{path}/#{file_name}
73
- CMD
74
- rescue Capistrano::CommandError
75
- if remote_file_exists?("#{latest_release}/#{f}.default")
76
- run <<-CMD
77
- #{try_sudo} cp #{latest_release}/#{f}.default #{path}/#{file_name}
78
- CMD
79
- else
80
- run <<-CMD
81
- #{try_sudo} touch #{path}/#{file_name}
82
- CMD
83
- logger.info "WARNING: You should edit '#{path}/#{file_name}' or re-create it as a folder if that's your intention."
84
- end
85
- end
86
- end
57
+ # Link all items
58
+ def link_items(from, to)
59
+ script = <<-END
60
+ symlink_all_shared_items() {
61
+ for file in `ls -A1 ${1}`; do
62
+ dest_file="${2}/`echo "${file}" | tr ',' '/'`";
63
+ file="${1}/${file}";
64
+ mkdir -p "`dirname "${dest_file}"`";
65
+ ln -nsf "${file}" "${dest_file}";
66
+ done;
67
+ };
68
+
69
+ symlink_all_shared_items '#{from}' '#{to}';
70
+ END
87
71
 
88
- link_file File.join(path, file_name), File.join(fetch(:latest_release), f)
89
- end
72
+ run script
90
73
  end
91
74
 
92
75
  def gen_pass( len = 8 )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: '0'
37
+ version: 2.12.0
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: '0'
45
+ version: 2.12.0
46
46
  description: Capistrano small recipes and methods
47
47
  email:
48
48
  - wael.nasreddine@gmail.com
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  version: '0'
79
79
  segments:
80
80
  - 0
81
- hash: -2247547276093644561
81
+ hash: -3673788544776060832
82
82
  requirements: []
83
83
  rubyforge_project:
84
84
  rubygems_version: 1.8.23