capistrano-copy-subdir 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -18,9 +18,11 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- Write following snipet in your `config/deploy.rb`.
21
+ Configure strategy as `:copy_subidr` and specify your application path in `:deploy_subdir`.
22
22
 
23
+ # in "config/deploy.rb"
23
24
  set(:deploy_via, :copy_subdir)
25
+ set(:deploy_subdir, '/where/your/app/is/in')
24
26
 
25
27
  ## Contributing
26
28
 
@@ -1,7 +1,11 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/capistrano-copy-subdir/version', __FILE__)
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano/recipes/deploy/strategy/copy_subdir/version'
3
5
 
4
6
  Gem::Specification.new do |gem|
7
+ gem.name = "capistrano-copy-subdir"
8
+ gem.version = Capistrano::Deploy::Strategy::COPY_SUBDIR_VERSION
5
9
  gem.authors = ["Yamashita Yuu"]
6
10
  gem.email = ["yamashita@geishatokyo.com"]
7
11
  gem.description = %q{a capistrano strategy to deploy subdir with copy strategy.}
@@ -11,9 +15,10 @@ Gem::Specification.new do |gem|
11
15
  gem.files = `git ls-files`.split($\)
12
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
- gem.name = "capistrano-copy-subdir"
15
18
  gem.require_paths = ["lib"]
16
- gem.version = Capistrano::CopySubdir::VERSION
17
19
 
18
20
  gem.add_dependency("capistrano")
21
+ gem.add_development_dependency("net-scp", "~> 1.0.4")
22
+ gem.add_development_dependency("net-ssh", "~> 2.2.2")
23
+ gem.add_development_dependency("vagrant", "~> 1.0.6")
19
24
  end
@@ -7,15 +7,16 @@
7
7
  # http://stackoverflow.com/questions/29168/deploying-a-git-subdirectory-in-capistrano
8
8
  #
9
9
 
10
- require 'capistrano'
11
- require 'capistrano/recipes/deploy/strategy/copy'
12
- require 'capistrano-copy-subdir'
13
- require 'tmpdir'
10
+ require "capistrano"
11
+ require "capistrano/recipes/deploy/strategy/copy"
12
+ require "capistrano/recipes/deploy/strategy/copy_subdir/version"
13
+ require "tmpdir"
14
14
 
15
15
  module Capistrano
16
16
  module Deploy
17
17
  module Strategy
18
18
  class CopySubdir < Copy
19
+ VERSION = ::Capistrano::Deploy::Strategy::COPY_SUBDIR_VERSION
19
20
 
20
21
  def deploy!
21
22
  update_repository_cache
@@ -0,0 +1,7 @@
1
+ module Capistrano
2
+ module Deploy
3
+ module Strategy
4
+ COPY_SUBDIR_VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ /.bundle
2
+ /.vagrant
3
+ /known_hosts
4
+ /tmp
5
+ /vendor
@@ -0,0 +1,2 @@
1
+ load "deploy"
2
+ load "../config/deploy"
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec(:path => "../..")
@@ -0,0 +1,99 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant::Config.run do |config|
5
+ # All Vagrant configuration is done here. The most common configuration
6
+ # options are documented and commented below. For a complete reference,
7
+ # please see the online documentation at vagrantup.com.
8
+
9
+ # Every Vagrant virtual environment requires a box to build off of.
10
+ config.vm.box = "centos6-64"
11
+
12
+ # The url from where the 'config.vm.box' box will be fetched if it
13
+ # doesn't already exist on the user's system.
14
+ config.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.3-x86_64-v20130101.box"
15
+
16
+ # Boot with a GUI so you can see the screen. (Default is headless)
17
+ # config.vm.boot_mode = :gui
18
+
19
+ # Assign this VM to a host-only network IP, allowing you to access it
20
+ # via the IP. Host-only networks can talk to the host machine as well as
21
+ # any other machines on the same network, but cannot be accessed (through this
22
+ # network interface) by any external networks.
23
+ config.vm.network :hostonly, "192.168.33.10"
24
+
25
+ # Assign this VM to a bridged network, allowing you to connect directly to a
26
+ # network using the host's network device. This makes the VM appear as another
27
+ # physical device on your network.
28
+ # config.vm.network :bridged
29
+
30
+ # Forward a port from the guest to the host, which allows for outside
31
+ # computers to access the VM, whereas host only networking does not.
32
+ # config.vm.forward_port 80, 8080
33
+
34
+ # Share an additional folder to the guest VM. The first argument is
35
+ # an identifier, the second is the path on the guest to mount the
36
+ # folder, and the third is the path on the host to the actual folder.
37
+ # config.vm.share_folder "v-data", "/vagrant_data", "../data"
38
+
39
+ # Enable provisioning with Puppet stand alone. Puppet manifests
40
+ # are contained in a directory path relative to this Vagrantfile.
41
+ # You will need to create the manifests directory and a manifest in
42
+ # the file precise-amd64.pp in the manifests_path directory.
43
+ #
44
+ # An example Puppet manifest to provision the message of the day:
45
+ #
46
+ # # group { "puppet":
47
+ # # ensure => "present",
48
+ # # }
49
+ # #
50
+ # # File { owner => 0, group => 0, mode => 0644 }
51
+ # #
52
+ # # file { '/etc/motd':
53
+ # # content => "Welcome to your Vagrant-built virtual machine!
54
+ # # Managed by Puppet.\n"
55
+ # # }
56
+ #
57
+ # config.vm.provision :puppet do |puppet|
58
+ # puppet.manifests_path = "manifests"
59
+ # puppet.manifest_file = "precise-amd64.pp"
60
+ # end
61
+
62
+ # Enable provisioning with chef solo, specifying a cookbooks path, roles
63
+ # path, and data_bags path (all relative to this Vagrantfile), and adding
64
+ # some recipes and/or roles.
65
+ #
66
+ # config.vm.provision :chef_solo do |chef|
67
+ # chef.cookbooks_path = "../my-recipes/cookbooks"
68
+ # chef.roles_path = "../my-recipes/roles"
69
+ # chef.data_bags_path = "../my-recipes/data_bags"
70
+ # chef.add_recipe "mysql"
71
+ # chef.add_role "web"
72
+ #
73
+ # # You may also specify custom JSON attributes:
74
+ # chef.json = { :mysql_password => "foo" }
75
+ # end
76
+
77
+ # Enable provisioning with chef server, specifying the chef server URL,
78
+ # and the path to the validation key (relative to this Vagrantfile).
79
+ #
80
+ # The Opscode Platform uses HTTPS. Substitute your organization for
81
+ # ORGNAME in the URL and validation key.
82
+ #
83
+ # If you have your own Chef Server, use the appropriate URL, which may be
84
+ # HTTP instead of HTTPS depending on your configuration. Also change the
85
+ # validation key to validation.pem.
86
+ #
87
+ # config.vm.provision :chef_client do |chef|
88
+ # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
89
+ # chef.validation_key_path = "ORGNAME-validator.pem"
90
+ # end
91
+ #
92
+ # If you're using the Opscode platform, your validator client is
93
+ # ORGNAME-validator, replacing ORGNAME with your organization name.
94
+ #
95
+ # IF you have your own Chef Server, the default validation client name is
96
+ # chef-validator, unless you changed the configuration.
97
+ #
98
+ # chef.validation_client_name = "ORGNAME-validator"
99
+ end
@@ -0,0 +1,7 @@
1
+ #!/bin/sh -e
2
+
3
+ bundle exec vagrant up
4
+ bundle exec cap test_all
5
+ bundle exec vagrant halt
6
+
7
+ # vim:set ft=sh :
@@ -0,0 +1,122 @@
1
+ set :application, "capistrano-copy-subdir"
2
+ set :repository, "."
3
+ set :deploy_to do
4
+ File.join("/home", user, application)
5
+ end
6
+ set :deploy_via, :copy
7
+ set :scm, :none
8
+ set :use_sudo, false
9
+ set :user, "vagrant"
10
+ set :password, "vagrant"
11
+ set :ssh_options, {:user_known_hosts_file => "/dev/null"}
12
+
13
+ role :web, "192.168.33.10"
14
+ role :app, "192.168.33.10"
15
+ role :db, "192.168.33.10", :primary => true
16
+
17
+ $LOAD_PATH.push(File.expand_path("../../lib", File.dirname(__FILE__)))
18
+ require "tempfile"
19
+
20
+ def assert_file_exists(file, options={})
21
+ begin
22
+ invoke_command("test -f #{file.dump}", options)
23
+ rescue
24
+ logger.debug("assert_file_exists(#{file}) failed.")
25
+ invoke_command("ls #{File.dirname(file).dump}", options)
26
+ raise
27
+ end
28
+ end
29
+
30
+ def assert_file_content(file, content, options={})
31
+ begin
32
+ tempfile = Tempfile.new("tmp")
33
+ download(file, tempfile.path)
34
+ remote_content = tempfile.read
35
+ abort if content != remote_content
36
+ rescue
37
+ logger.info("assert_file_content(#{file}, #{content.dump}) failed.")
38
+ raise
39
+ end
40
+ end
41
+
42
+ task(:test_all) {
43
+ find_and_execute_task("test_default")
44
+ find_and_execute_task("test_with_subdir")
45
+ }
46
+
47
+ namespace(:test_default) {
48
+ task(:default) {
49
+ methods.grep(/^test_/).each do |m|
50
+ send(m)
51
+ end
52
+ }
53
+ before "test_default", "test_default:setup"
54
+ after "test_default", "test_default:teardown"
55
+
56
+ task(:setup) {
57
+ set(:deploy_via, :copy_subdir)
58
+ set(:deploy_subdir, nil)
59
+ reset!(:strategy)
60
+ find_and_execute_task("deploy:setup")
61
+ }
62
+
63
+ task(:teardown) {
64
+ run("rm -rf #{deploy_to.dump}")
65
+ }
66
+
67
+ task(:test_deploy) {
68
+ find_and_execute_task("deploy")
69
+ # check if files in current directory has been deployed?
70
+ assert_file_exists(File.join(current_path, "Capfile"))
71
+ assert_file_exists(File.join(current_path, "Vagrantfile"))
72
+ assert_file_content(File.join(current_path, "Capfile"), File.read("Capfile"))
73
+ assert_file_content(File.join(current_path, "Vagrantfile"), File.read("Vagrantfile"))
74
+ }
75
+ }
76
+
77
+ namespace(:test_with_subdir) {
78
+ task(:default) {
79
+ methods.grep(/^test_/).each do |m|
80
+ send(m)
81
+ end
82
+ }
83
+ before "test_with_subdir", "test_with_subdir:setup"
84
+ after "test_with_subdir", "test_with_subdir:teardown"
85
+
86
+ task(:setup) {
87
+ run_locally("mkdir -p tmp/copy_subdir")
88
+ set(:deploy_via, :copy_subdir)
89
+ set(:deploy_subdir, "tmp/copy_subdir")
90
+ reset!(:strategy)
91
+ find_and_execute_task("deploy:setup")
92
+ }
93
+
94
+ task(:teardown) {
95
+ run_locally("rm -rf tmp/copy_subdir")
96
+ run("rm -rf #{deploy_to.dump}")
97
+ }
98
+
99
+ task(:test_deploy) {
100
+ run_locally("echo foo > tmp/copy_subdir/foo")
101
+ run_locally("echo bar > tmp/copy_subdir/bar")
102
+ find_and_execute_task("deploy")
103
+ # check if files in sub directory has been deployed?
104
+ assert_file_exists(File.join(current_path, "foo"))
105
+ assert_file_exists(File.join(current_path, "bar"))
106
+ assert_file_content(File.join(current_path, "foo"), File.read("tmp/copy_subdir/foo"))
107
+ assert_file_content(File.join(current_path, "bar"), File.read("tmp/copy_subdir/bar"))
108
+ }
109
+
110
+ task(:test_redeploy) {
111
+ run_locally("echo bar > tmp/copy_subdir/foo")
112
+ run_locally("echo foo > tmp/copy_subdir/bar")
113
+ find_and_execute_task("deploy")
114
+ # check again if files in sub directory has been deployed?
115
+ assert_file_exists(File.join(current_path, "foo"))
116
+ assert_file_exists(File.join(current_path, "bar"))
117
+ assert_file_content(File.join(current_path, "foo"), File.read("tmp/copy_subdir/foo"))
118
+ assert_file_content(File.join(current_path, "bar"), File.read("tmp/copy_subdir/bar"))
119
+ }
120
+ }
121
+
122
+ # vim:set ft=ruby sw=2 ts=2 :
@@ -0,0 +1,5 @@
1
+ /.bundle
2
+ /.vagrant
3
+ /known_hosts
4
+ /tmp
5
+ /vendor
@@ -0,0 +1,2 @@
1
+ load "deploy"
2
+ load "../config/deploy"
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec(:path => "../..")
@@ -0,0 +1,99 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant::Config.run do |config|
5
+ # All Vagrant configuration is done here. The most common configuration
6
+ # options are documented and commented below. For a complete reference,
7
+ # please see the online documentation at vagrantup.com.
8
+
9
+ # Every Vagrant virtual environment requires a box to build off of.
10
+ config.vm.box = "precise64"
11
+
12
+ # The url from where the 'config.vm.box' box will be fetched if it
13
+ # doesn't already exist on the user's system.
14
+ config.vm.box_url = "http://files.vagrantup.com/precise64.box"
15
+
16
+ # Boot with a GUI so you can see the screen. (Default is headless)
17
+ # config.vm.boot_mode = :gui
18
+
19
+ # Assign this VM to a host-only network IP, allowing you to access it
20
+ # via the IP. Host-only networks can talk to the host machine as well as
21
+ # any other machines on the same network, but cannot be accessed (through this
22
+ # network interface) by any external networks.
23
+ config.vm.network :hostonly, "192.168.33.10"
24
+
25
+ # Assign this VM to a bridged network, allowing you to connect directly to a
26
+ # network using the host's network device. This makes the VM appear as another
27
+ # physical device on your network.
28
+ # config.vm.network :bridged
29
+
30
+ # Forward a port from the guest to the host, which allows for outside
31
+ # computers to access the VM, whereas host only networking does not.
32
+ # config.vm.forward_port 80, 8080
33
+
34
+ # Share an additional folder to the guest VM. The first argument is
35
+ # an identifier, the second is the path on the guest to mount the
36
+ # folder, and the third is the path on the host to the actual folder.
37
+ # config.vm.share_folder "v-data", "/vagrant_data", "../data"
38
+
39
+ # Enable provisioning with Puppet stand alone. Puppet manifests
40
+ # are contained in a directory path relative to this Vagrantfile.
41
+ # You will need to create the manifests directory and a manifest in
42
+ # the file precise-amd64.pp in the manifests_path directory.
43
+ #
44
+ # An example Puppet manifest to provision the message of the day:
45
+ #
46
+ # # group { "puppet":
47
+ # # ensure => "present",
48
+ # # }
49
+ # #
50
+ # # File { owner => 0, group => 0, mode => 0644 }
51
+ # #
52
+ # # file { '/etc/motd':
53
+ # # content => "Welcome to your Vagrant-built virtual machine!
54
+ # # Managed by Puppet.\n"
55
+ # # }
56
+ #
57
+ # config.vm.provision :puppet do |puppet|
58
+ # puppet.manifests_path = "manifests"
59
+ # puppet.manifest_file = "precise-amd64.pp"
60
+ # end
61
+
62
+ # Enable provisioning with chef solo, specifying a cookbooks path, roles
63
+ # path, and data_bags path (all relative to this Vagrantfile), and adding
64
+ # some recipes and/or roles.
65
+ #
66
+ # config.vm.provision :chef_solo do |chef|
67
+ # chef.cookbooks_path = "../my-recipes/cookbooks"
68
+ # chef.roles_path = "../my-recipes/roles"
69
+ # chef.data_bags_path = "../my-recipes/data_bags"
70
+ # chef.add_recipe "mysql"
71
+ # chef.add_role "web"
72
+ #
73
+ # # You may also specify custom JSON attributes:
74
+ # chef.json = { :mysql_password => "foo" }
75
+ # end
76
+
77
+ # Enable provisioning with chef server, specifying the chef server URL,
78
+ # and the path to the validation key (relative to this Vagrantfile).
79
+ #
80
+ # The Opscode Platform uses HTTPS. Substitute your organization for
81
+ # ORGNAME in the URL and validation key.
82
+ #
83
+ # If you have your own Chef Server, use the appropriate URL, which may be
84
+ # HTTP instead of HTTPS depending on your configuration. Also change the
85
+ # validation key to validation.pem.
86
+ #
87
+ # config.vm.provision :chef_client do |chef|
88
+ # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
89
+ # chef.validation_key_path = "ORGNAME-validator.pem"
90
+ # end
91
+ #
92
+ # If you're using the Opscode platform, your validator client is
93
+ # ORGNAME-validator, replacing ORGNAME with your organization name.
94
+ #
95
+ # IF you have your own Chef Server, the default validation client name is
96
+ # chef-validator, unless you changed the configuration.
97
+ #
98
+ # chef.validation_client_name = "ORGNAME-validator"
99
+ end
@@ -0,0 +1,7 @@
1
+ #!/bin/sh -e
2
+
3
+ bundle exec vagrant up
4
+ bundle exec cap test_all
5
+ bundle exec vagrant halt
6
+
7
+ # vim:set ft=sh :
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-copy-subdir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-10 00:00:00.000000000 Z
12
+ date: 2013-03-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
@@ -27,6 +27,54 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: net-scp
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.0.4
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.0.4
46
+ - !ruby/object:Gem::Dependency
47
+ name: net-ssh
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 2.2.2
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.2.2
62
+ - !ruby/object:Gem::Dependency
63
+ name: vagrant
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.0.6
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.0.6
30
78
  description: a capistrano strategy to deploy subdir with copy strategy.
31
79
  email:
32
80
  - yamashita@geishatokyo.com
@@ -40,9 +88,19 @@ files:
40
88
  - README.md
41
89
  - Rakefile
42
90
  - capistrano-copy-subdir.gemspec
43
- - lib/capistrano-copy-subdir.rb
44
- - lib/capistrano-copy-subdir/version.rb
45
91
  - lib/capistrano/recipes/deploy/strategy/copy_subdir.rb
92
+ - lib/capistrano/recipes/deploy/strategy/copy_subdir/version.rb
93
+ - test/centos6-64/.gitignore
94
+ - test/centos6-64/Capfile
95
+ - test/centos6-64/Gemfile
96
+ - test/centos6-64/Vagrantfile
97
+ - test/centos6-64/run.sh
98
+ - test/config/deploy.rb
99
+ - test/precise64/.gitignore
100
+ - test/precise64/Capfile
101
+ - test/precise64/Gemfile
102
+ - test/precise64/Vagrantfile
103
+ - test/precise64/run.sh
46
104
  homepage: https://github.com/yyuu/capistrano-copy-subdir
47
105
  licenses: []
48
106
  post_install_message:
@@ -67,5 +125,15 @@ rubygems_version: 1.8.23
67
125
  signing_key:
68
126
  specification_version: 3
69
127
  summary: a capistrano strategy to deploy subdir with copy strategy.
70
- test_files: []
71
- has_rdoc:
128
+ test_files:
129
+ - test/centos6-64/.gitignore
130
+ - test/centos6-64/Capfile
131
+ - test/centos6-64/Gemfile
132
+ - test/centos6-64/Vagrantfile
133
+ - test/centos6-64/run.sh
134
+ - test/config/deploy.rb
135
+ - test/precise64/.gitignore
136
+ - test/precise64/Capfile
137
+ - test/precise64/Gemfile
138
+ - test/precise64/Vagrantfile
139
+ - test/precise64/run.sh
@@ -1,7 +0,0 @@
1
- require "capistrano-copy-subdir/version"
2
-
3
- module Capistrano
4
- module CopySubdir
5
- # Your code goes here...
6
- end
7
- end
@@ -1,5 +0,0 @@
1
- module Capistrano
2
- module CopySubdir
3
- VERSION = "0.0.1"
4
- end
5
- end