capistrano-scm-local 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "capistrano-scm-local"
7
- gem.version = '0.1.6'
7
+ gem.version = '0.1.7'
8
8
  gem.authors = ["Boris Gorbylev"]
9
9
  gem.email = ["ekho@ekho.name"]
10
10
  gem.description = %q{Capistrano extension for deploying form local directory}
@@ -9,55 +9,56 @@ require 'tmpdir'
9
9
  require 'fileutils'
10
10
 
11
11
  class Capistrano::Local < Capistrano::SCM
12
- module DefaultStrategy
12
+ module PlainStrategy
13
13
  def check
14
14
  puts repo_url
15
15
  test! " [ -e #{repo_url} ] "
16
16
  end
17
17
 
18
18
  def release
19
+ file_list = Dir.glob(File.join(repo_url, '*')).concat(Dir.glob(File.join(repo_url, '.[^.]*')))
20
+
19
21
  on release_roles :all, in: :parallel do |host|
20
- file_list = Dir.glob(repo_url + '/*').concat(Dir.glob(repo_url + '/.[^.]*'))
21
- file_list.each { |r| upload! r, release_path, recursive: true }
22
+ file_list.each { |r| upload! r, release_path, recursive: true }
23
+ end
22
24
  end
23
25
  end
24
- end
25
26
 
26
- module ArchiveStrategy
27
- def check
28
- test! " [ -e #{repo_url} ] "
29
- end
27
+ module ArchiveStrategy
28
+ def check
29
+ test! " [ -e #{repo_url} ] "
30
+ end
30
31
 
31
- def release
32
- archive = ''
33
- # preparing archive
34
- run_locally do
35
- archive = fetch(:tmp_dir, Dir::tmpdir()) + '/' + fetch(:application, 'distr') + "-#{release_timestamp}.tar.gz"
36
- unless File.exists?(archive)
37
- if File.directory?(repo_url) || !File.fnmatch('*.tar.gz', repo_url)
38
- Dir.chdir(repo_url) do
39
- Minitar.pack('.', Zlib::GzipWriter.new(File.open(archive, 'wb')))
32
+ def release
33
+ archive = ''
34
+ # preparing archive
35
+ run_locally do
36
+ archive = fetch(:tmp_dir, Dir::tmpdir()) + '/' + fetch(:application, 'distr') + "-#{release_timestamp}.tar.gz"
37
+ unless File.exists?(archive)
38
+ if File.directory?(repo_url) || !File.fnmatch('*.tar.gz', repo_url)
39
+ Dir.chdir(repo_url) do
40
+ Minitar.pack('.', Zlib::GzipWriter.new(File.open(archive, 'wb')))
41
+ end
42
+ else
43
+ FileUtils.cp(repo_url, archive)
40
44
  end
41
- else
42
- FileUtils.cp(repo_url, archive)
43
45
  end
44
46
  end
45
- end
46
47
 
47
- # uploading and unpacking
48
- on release_roles :all, in: :parallel do |host|
49
- upload! archive, releases_path, verbose: false
50
- remote_archive = File.join(releases_path, File.basename(archive))
51
- execute :tar, 'xzf', remote_archive, '-C', release_path
52
- execute :rm, '-f', remote_archive
53
- end
48
+ # uploading and unpacking
49
+ on release_roles :all, in: :parallel do |host|
50
+ upload! archive, releases_path, verbose: false
51
+ remote_archive = File.join(releases_path, File.basename(archive))
52
+ execute :tar, 'xzf', remote_archive, '-C', release_path
53
+ execute :rm, '-f', remote_archive
54
+ end
54
55
 
55
- # removing archive
56
- run_locally do
57
- execute :rm, '-f', archive
56
+ # removing archive
57
+ run_locally do
58
+ execute :rm, '-f', archive
59
+ end
60
+ end
58
61
  end
59
62
  end
60
- end
61
- end
62
63
 
63
64
  set :capistrano_local_archive, Capistrano::Local::ArchiveStrategy
@@ -1,9 +1,9 @@
1
1
  namespace :local do
2
2
 
3
3
  def local_strategy
4
- strategies = {:default=>Capistrano::Local::DefaultStrategy, :archive=>Capistrano::Local::ArchiveStrategy}
4
+ strategies = {:plain=>Capistrano::Local::PlainStrategy, :archive=>Capistrano::Local::ArchiveStrategy}
5
5
 
6
- m = fetch(:local_strategy ? :local_strategy : :default)
6
+ m = fetch(:local_strategy ? :local_strategy : :archive)
7
7
  unless m.is_a?(Module)
8
8
  abort "Invalid local_strategy: " + m.to_s unless strategies.include?(m)
9
9
  m = strategies[m]
@@ -28,4 +28,10 @@ namespace :local do
28
28
  end
29
29
  local_strategy.release
30
30
  end
31
+
32
+ desc 'Read revision from REVISION file if exists'
33
+ task :set_current_revision do
34
+ revision_file = File.join(repo_url, 'REVISION')
35
+ set :current_revision, File.exist?(revision_file) ? File.read(revision_file).strip : 'UNKNOWN'
36
+ end
31
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-scm-local
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: