vlad-push 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.autotest ADDED
@@ -0,0 +1,23 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'autotest/restart'
4
+
5
+ # Autotest.add_hook :initialize do |at|
6
+ # at.extra_files << "../some/external/dependency.rb"
7
+ #
8
+ # at.libs << ":../some/external"
9
+ #
10
+ # at.add_exception 'vendor'
11
+ #
12
+ # at.add_mapping(/dependency.rb/) do |f, _|
13
+ # at.files_matching(/test_.*rb$/)
14
+ # end
15
+ #
16
+ # %w(TestA TestB).each do |klass|
17
+ # at.extra_class_map[klass] = "test/test_misc.rb"
18
+ # end
19
+ # end
20
+
21
+ # Autotest.add_hook :run_command do |at|
22
+ # system "rake build"
23
+ # end
data/.gemtest ADDED
File without changes
data/Manifest.txt ADDED
@@ -0,0 +1,6 @@
1
+ .autotest
2
+ lib/vlad/push.rb
3
+ Manifest.txt
4
+ Rakefile
5
+ README.txt
6
+ test/test_vlad_push.rb
data/README.txt ADDED
@@ -0,0 +1,65 @@
1
+ = vlad-push
2
+
3
+ * http://github.com/jmervine/vlad-push
4
+
5
+ == DESCRIPTION:
6
+
7
+ Adds support to Vlad for pushing files to a remote server without SCM.
8
+
9
+
10
+ == FEATURES/PROBLEMS:
11
+
12
+ * Requires vlad-git gem
13
+
14
+ == SYNOPSIS:
15
+
16
+ $ rake <env> vlad:push
17
+ $ rake <env> vlad:update
18
+
19
+ or
20
+
21
+ $ rake <env> vlad:deploy
22
+
23
+
24
+ == REQUIREMENTS:
25
+
26
+ * Vlad[http://rubyhitsquad.com/Vlad_the_Deployer.html]
27
+ * Vlad-git[https://github.com/jbarnette/vlad-git.git]
28
+
29
+ == INSTALL:
30
+
31
+ $ sudo gem install vlad-push
32
+
33
+ == VARIABLES:
34
+
35
+ repository:: Vlad config param, should be set to a directory location
36
+ to use as repo on remote server(s)
37
+ <tt>:repository => "/tmp/repo"</tt>
38
+ domain:: See Vlad :domain variable
39
+ scp_cmd:: Defaults to <tt>scp</tt>
40
+ ssh_flags:: See Vlad :ssh_flags variable
41
+
42
+ == LICENSE:
43
+
44
+ (The MIT License)
45
+
46
+ Copyright (c) 2011 Joshua Mervine
47
+
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of this software and associated documentation files (the
50
+ 'Software'), to deal in the Software without restriction, including
51
+ without limitation the rights to use, copy, modify, merge, publish,
52
+ distribute, sublicense, and/or sell copies of the Software, and to
53
+ permit persons to whom the Software is furnished to do so, subject to
54
+ the following conditions:
55
+
56
+ The above copyright notice and this permission notice shall be
57
+ included in all copies or substantial portions of the Software.
58
+
59
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
60
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
61
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
62
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
63
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
64
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
65
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+
6
+ Hoe.plugin :hg
7
+
8
+ Hoe.spec 'vlad-push' do
9
+ developer('Joshua P. Mervine', 'joshua@mervine.net')
10
+ extra_deps << ['vlad', '~> 2.0']
11
+ extra_deps << ['vlad-git']
12
+ clean_globs << '.yardoc'
13
+ end
14
+
15
+ # vim: syntax=ruby
data/lib/vlad/push.rb ADDED
@@ -0,0 +1,112 @@
1
+ require 'vlad'
2
+ class Vlad::Push
3
+ VERSION = "1.0.0"
4
+
5
+ set :source, Vlad::Push.new
6
+
7
+ # default to be overwritten by deploy.rb as needed
8
+ set :repository, "/tmp/repo"
9
+ set :scm, :push
10
+ set :push_scp, "scp"
11
+ set :ssh_flags, ""
12
+ set :release_name, ENV['RELEASE']||release_name
13
+
14
+ #@paired = false
15
+
16
+ # telling vlad not to bother running checkout
17
+ # but this doesn't seem to work, I'll probably
18
+ # moving it to the Rakefile
19
+ #set :skip_scm, true
20
+
21
+ def checkout(revision, destination)
22
+ "echo 'skipping checkout per vlad-push'"
23
+ end
24
+
25
+ def export(source, destination)
26
+ # ignoring source
27
+ "cp -r #{repository} #{destination}"
28
+ #[ "mkdir -p #{repository}",
29
+ #"cd #{repository}",
30
+ #"tar -xzf /tmp/#{application}-#{release_name}.tgz",
31
+ #"cp -r #{repository} #{destination}"
32
+ #].join(" && ")
33
+ end
34
+
35
+ def revision(revision)
36
+ # telling vlad to use "repository" as "revision" as we have no scm
37
+ repository
38
+ end
39
+
40
+ def push(host)
41
+ [ "#{push_scp} #{ssh_flags}",
42
+ "/tmp/#{application}-#{release_name}.tgz",
43
+ "#{host}:/tmp/#{application}-#{release_name}.tgz"
44
+ ].join(" ")
45
+ end
46
+
47
+ def push_extract
48
+ [ "if [ -e #{repository} ]; then rm -rf #{repository}; fi",
49
+ "mkdir -p #{repository}",
50
+ "cd #{repository}",
51
+ "tar -xzf /tmp/#{application}-#{release_name}.tgz"
52
+ ].join(" && ")
53
+ end
54
+
55
+ def push_cleanup
56
+ [ "rm -vrf /tmp/#{application}-*.tgz",
57
+ [ "if [ -e #{repository} ]",
58
+ "then rm -rf #{repository}",
59
+ "fi"
60
+ ].join("; ")
61
+ ].join(" && ")
62
+ end
63
+
64
+ def compress
65
+ [ "tar -czf /tmp/#{application}-#{release_name}.tgz",
66
+ '--exclude "\.git*"',
67
+ '--exclude "\.svn*"',
68
+ "."
69
+ ].join(" ")
70
+ end
71
+
72
+ namespace :vlad do
73
+
74
+ desc "Push current working directory to remote servers."
75
+ remote_task :push do
76
+ sh source.compress
77
+ domain.each do |host|
78
+ sh source.push(host)
79
+ end
80
+ run source.push_extract
81
+ #if !@paired
82
+ #puts " "
83
+ #puts "To update successfully, execute the following command:"
84
+ #puts " "
85
+ #puts " $ rake <environment> vlad:update RELEASE=#{release_name}"
86
+ #puts " "
87
+ #end
88
+ end
89
+
90
+ # Updating 'vlad:cleanup' to include post-task
91
+ remote_task :cleanup do
92
+ Rake::Task['vlad:push_cleanup'].invoke
93
+ end
94
+
95
+ desc "Clean up archive files created by push. This will also be run by vlad:cleanup."
96
+ remote_task :push_cleanup do
97
+ sh source.push_cleanup
98
+ run source.push_cleanup
99
+ end
100
+
101
+ desc "Runs push and update"
102
+ task :deploy do
103
+ #@paired = true
104
+ Rake::Task["vlad:push"].invoke
105
+ Rake::Task["vlad:update"].invoke
106
+ end
107
+
108
+ end
109
+
110
+ end # class def
111
+
112
+
@@ -0,0 +1,55 @@
1
+ require "test/unit"
2
+ require "vlad/push"
3
+
4
+ class TestVladPush < Test::Unit::TestCase
5
+ def setup
6
+ super
7
+ @source = Vlad::Push.new
8
+ set :repository, "/tmp/repo"
9
+ set :push_scp, "scp"
10
+ set :ssh_flags, [ "-i", "~/.ssh/id_rsa_example" ].join(" ")
11
+ set :application, "testapp"
12
+ set :release_name, "12345678910"
13
+ end
14
+
15
+ def test_rake
16
+ assert system("rake -T vlad:push")
17
+ assert system("rake -T vlad:push | grep push")
18
+ end
19
+
20
+ def test_checkout
21
+ cmd = @source.checkout 'foo', 'bar'
22
+ assert_equal "echo 'skipping checkout per vlad-push'", cmd
23
+ end
24
+
25
+ def test_export
26
+ cmd = @source.export 'foo', '/tmp'
27
+ assert_equal 'cp -r /tmp/repo /tmp', cmd
28
+ end
29
+
30
+ def test_revision
31
+ out = @source.revision 'foo'
32
+ assert_equal '/tmp/repo', out
33
+ end
34
+
35
+ def test_push
36
+ cmd = @source.push 'example.com'
37
+ assert_equal 'scp -i ~/.ssh/id_rsa_example /tmp/testapp-12345678910.tgz example.com:/tmp/testapp-12345678910.tgz', cmd
38
+ end
39
+
40
+ def test_push_extract
41
+ cmd = @source.push_extract
42
+ assert_equal 'if [ -e /tmp/repo ]; then rm -rf /tmp/repo; fi && mkdir -p /tmp/repo && cd /tmp/repo && tar -xzf /tmp/testapp-12345678910.tgz', cmd
43
+ end
44
+
45
+ def test_push_cleanup
46
+ cmd = @source.push_cleanup
47
+ assert_equal 'rm -vrf /tmp/testapp-*.tgz && if [ -e /tmp/repo ]; then rm -rf /tmp/repo; fi', cmd
48
+ end
49
+
50
+ def test_compress
51
+ cmd = @source.compress
52
+ assert_equal 'tar -czf /tmp/testapp-12345678910.tgz --exclude "\.git*" --exclude "\.svn*" .', cmd
53
+ end
54
+
55
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vlad-push
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Joshua P. Mervine
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-07-20 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: vlad
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 2
32
+ - 0
33
+ version: "2.0"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: vlad-git
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: hoe
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 23
59
+ segments:
60
+ - 2
61
+ - 10
62
+ version: "2.10"
63
+ type: :development
64
+ version_requirements: *id003
65
+ description: Adds support to Vlad for pushing files to a remote server without SCM.
66
+ email:
67
+ - joshua@mervine.net
68
+ executables: []
69
+
70
+ extensions: []
71
+
72
+ extra_rdoc_files:
73
+ - Manifest.txt
74
+ - README.txt
75
+ files:
76
+ - .autotest
77
+ - lib/vlad/push.rb
78
+ - Manifest.txt
79
+ - Rakefile
80
+ - README.txt
81
+ - test/test_vlad_push.rb
82
+ - .gemtest
83
+ has_rdoc: true
84
+ homepage: http://github.com/jmervine/vlad-push
85
+ licenses: []
86
+
87
+ post_install_message:
88
+ rdoc_options:
89
+ - --main
90
+ - README.txt
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 0
101
+ version: "0"
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ hash: 3
108
+ segments:
109
+ - 0
110
+ version: "0"
111
+ requirements: []
112
+
113
+ rubyforge_project: vlad-push
114
+ rubygems_version: 1.6.2
115
+ signing_key:
116
+ specification_version: 3
117
+ summary: Adds support to Vlad for pushing files to a remote server without SCM.
118
+ test_files:
119
+ - test/test_vlad_push.rb