capistrano-scm-local 0.1.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/.gitignore ADDED
@@ -0,0 +1,38 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
35
+
36
+
37
+ /.idea
38
+ /atlassian-ide-plugin.xml
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Boris Gorbylev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ capistrano-scm-local
2
+ ====================
3
+
4
+ allow deploy from local directory
5
+
6
+ Capfile
7
+ ```ruby
8
+ require 'capistrano/scm-local'
9
+ ```
10
+
11
+ Gemfile
12
+ ```ruby
13
+ gem 'capistrano-scm-local', '~> 0.1', :github => 'i-ekho/capistrano-scm-local'
14
+ ```
15
+
16
+ deploy.rb
17
+ ```ruby
18
+ set :scm, :local
19
+ set :local_strategy, :archive
20
+ set :repo_url, 'path/to/source'
21
+ ```
22
+
23
+ local_strategy can be :default or :archive
24
+ :default - directly uploads folder
25
+ :archive - makes tar.gz, uploads it and unpack
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "capistrano-scm-local"
7
+ gem.version = '0.1.0'
8
+ gem.authors = ["Boris Gorbylev"]
9
+ gem.email = ["ekho@ekho.name"]
10
+ gem.description = %q{Capistrano extension for deploying form local directory}
11
+ gem.summary = %q{Capistrano SCM Local - Deploy from local copy}
12
+ gem.homepage = "http://github.com/i-ekho/capistrano-scm-local"
13
+
14
+ gem.files = `git ls-files`.split($/)
15
+ # no tests as of yet
16
+ # gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.require_paths = ["lib"]
18
+
19
+ gem.licenses = ['MIT']
20
+
21
+ gem.add_dependency 'capistrano', '~> 3.1'
22
+ gem.add_dependency 'minitar', '~> 0.5.4'
23
+ end
@@ -0,0 +1,57 @@
1
+ load File.expand_path("../tasks/local.rake", __FILE__)
2
+
3
+ require 'capistrano/scm'
4
+
5
+ require 'zlib'
6
+ require 'archive/tar/minitar'
7
+ include Archive::Tar
8
+ require 'tmpdir'
9
+
10
+ class Capistrano::Local < Capistrano::SCM
11
+ module DefaultStrategy
12
+ def check
13
+ test! " [ -d #{repo_url} ] "
14
+ end
15
+
16
+ def release
17
+ on release_roles :all do |host|
18
+ file_list = Dir.glob(repo_url + '/*').concat(Dir.glob(repo_url + '/.[^.]*'))
19
+ file_list.each { |r| upload! r, release_path, recursive: true }
20
+ end
21
+ end
22
+ end
23
+
24
+ module ArchiveStrategy
25
+ def check
26
+ test! " [ -d #{repo_url} ] "
27
+ end
28
+
29
+ def release
30
+ archive = ''
31
+ # preparing archive
32
+ run_locally do
33
+ archive = fetch(:tmp_dir, Dir::tmpdir()) + '/' + fetch(:application, 'distr') + "-#{release_timestamp}.tar.gz"
34
+ unless File.exists?(archive)
35
+ Dir.chdir(repo_url) do
36
+ Minitar.pack('.', Zlib::GzipWriter.new(File.open(archive, 'wb')))
37
+ end
38
+ end
39
+ end
40
+
41
+ # uploading and unpacking
42
+ on release_roles :all do |host|
43
+ upload! archive, repo_path
44
+ remote_archive = File.join(repo_path, File.basename(archive))
45
+ execute :tar, 'xzf', remote_archive, '-C', release_path
46
+ execute :rm, '-f', remote_archive
47
+ end
48
+
49
+ # removing archive
50
+ run_locally do
51
+ execute :rm, '-f', archive
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ set :capistrano_local_archive, Capistrano::Local::ArchiveStrategy
@@ -0,0 +1,2 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -0,0 +1,32 @@
1
+ namespace :local do
2
+
3
+ def strategy
4
+ strategies = {:default=>Capistrano::Local::DefaultStrategy, :archive=>Capistrano::Local::ArchiveStrategy}
5
+
6
+ m = fetch(:local_strategy ? :local_strategy : :default)
7
+ unless m.is_a?(Module)
8
+ abort "Invalid local_strategy: " + m.to_s unless strategies.include?(m)
9
+ m = strategies[m]
10
+ end
11
+
12
+ @strategy ||= Capistrano::Local.new(self, m)
13
+ end
14
+
15
+ desc 'Check that the source is reachable'
16
+ task :check do
17
+ run_locally do
18
+ exit 1 unless strategy.check
19
+ end
20
+ end
21
+
22
+ desc 'Copy repo to releases'
23
+ task :create_release do
24
+ on release_roles :all do
25
+ within repo_path do
26
+ execute :mkdir, '-p', release_path
27
+ strategy.release
28
+ end
29
+ end
30
+ strategy.release
31
+ end
32
+ end
File without changes
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-scm-local
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Boris Gorbylev
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-04-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.1'
30
+ - !ruby/object:Gem::Dependency
31
+ name: minitar
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.5.4
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.5.4
46
+ description: Capistrano extension for deploying form local directory
47
+ email:
48
+ - ekho@ekho.name
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - LICENSE
55
+ - README.md
56
+ - capistrano-scm-local.gemspec
57
+ - lib/capistrano-scm-local.rb
58
+ - lib/capistrano/local.rb
59
+ - lib/capistrano/scm-local.rb
60
+ - lib/capistrano/tasks/local.rake
61
+ homepage: http://github.com/i-ekho/capistrano-scm-local
62
+ licenses:
63
+ - MIT
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 1.8.23
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: Capistrano SCM Local - Deploy from local copy
86
+ test_files: []