vlad-push 1.0.2 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.txt +10 -7
  2. data/lib/vlad/push.rb +68 -40
  3. data/test/test_vlad_push.rb +2 -6
  4. metadata +22 -8
data/README.txt CHANGED
@@ -13,14 +13,14 @@ Adds support to Vlad for pushing files to a remote server without SCM. (Really,
13
13
 
14
14
  == SYNOPSIS:
15
15
 
16
- $ rake <env> vlad:push
17
- $ rake <env> vlad:update
16
+ $ rake [env] vlad:push
17
+ $ rake [env] vlad:update
18
18
 
19
19
  ^-- if using environment tasks in deploy.rb
20
20
 
21
21
  or
22
22
 
23
- $ rake <env> vlad:deploy
23
+ $ rake [env] vlad:deploy
24
24
 
25
25
  ^-- if using environment tasks in deploy.rb
26
26
 
@@ -33,6 +33,7 @@ Adds support to Vlad for pushing files to a remote server without SCM. (Really,
33
33
 
34
34
  set :deploy_to, "/web/root"
35
35
  set :repository, "/push/root"
36
+ set :extract_file, "#{application}-#{release_name}.tgz"
36
37
 
37
38
  == REQUIREMENTS:
38
39
 
@@ -40,16 +41,18 @@ Adds support to Vlad for pushing files to a remote server without SCM. (Really,
40
41
 
41
42
  == INSTALL:
42
43
 
43
- $ sudo gem install vlad-push
44
+ $ sudo gem install vlad-push
44
45
 
45
46
  == VARIABLES:
46
47
 
47
48
  repository:: Vlad config param, should be set to a directory location
48
49
  to use as repo on remote server(s)
49
50
  <tt>:repository => "/tmp/repo"</tt>
50
- domain:: See Vlad :domain variable
51
- scp_cmd:: Defaults to <tt>scp</tt>
52
- ssh_flags:: See Vlad :ssh_flags variable
51
+ extract_file:: Name of tarball that vlad-push will generate, we suggest changing this
52
+ extract_dir:: Path to a directory that we will create the extract in, defaults to "/tmp"
53
+ domain:: See remote_task :domain variable
54
+ ssh_flags:: See remote_task :ssh_flags variable
55
+ rsync_flags:: See remote_task :rsync_flags variable
53
56
 
54
57
  == ACKKNOWLEDGEMENTS
55
58
 
data/lib/vlad/push.rb CHANGED
@@ -1,60 +1,77 @@
1
1
  require 'vlad'
2
2
 
3
+ # @author Joshua P. Mervine <jmervine@mervine.net>
4
+ #
5
+ # Please see {file:lib/vlad/push.rb Vlad::Push Source} for Rake task documentation.
3
6
  class Vlad::Push
4
- VERSION = "1.0.2"
7
+ VERSION = "1.1.1"
5
8
 
9
+ # @attribute[rw]
10
+ # init Vlad::Push
6
11
  set :source, Vlad::Push.new
7
12
 
8
- # default to be overwritten by deploy.rb as needed
9
- set :repository, "/tmp/repo"
10
- set :scm, :push
11
- set :push_scp, "scp"
12
- set :ssh_flags, ""
13
+ # @attribute[rw]
14
+ # set default repository
15
+ set :repository, "/tmp/repo"
16
+
17
+ # @attribute[rw]
18
+ # set default scm
19
+ set :scm, :push
20
+
21
+ # @attribute[rw]
22
+ # allow for overwriting release_name via command line
13
23
  set :release_name, ENV['RELEASE']||release_name
14
24
 
15
- # telling vlad not to bother running checkout
16
- # but this doesn't seem to work, I'll probably
17
- # moving it to the Rakefile
25
+ # @attribute[rw]
26
+ # set default directory to build tarballs in
27
+ set :extract_dir, "/tmp"
28
+
29
+ # @attribute[rw]
30
+ # set default name of tarball generates, you should override this in your rakefile
31
+ set :extract_file, "vlad-push-extract-#{release_name}.tgz"
32
+
33
+ # Overwriting Vlad.checkout, to do nothing.
34
+ #
35
+ # @return [String] echo bash command
36
+ #
37
+ # @param revision [String] ignored
38
+ # @param destination [String] ignored
18
39
  def checkout(revision, destination)
19
40
  "echo '[vlad-push] skipping checkout, not needed without scm'"
20
41
  end
21
42
 
22
- # overwrite vlad export to simply copied what was
23
- # pushed from the 'repository' location to the
43
+ # Overwrite Vlad.export to simply copied what was
44
+ # pushed from the 'repository' location to the
24
45
  # 'destination'
25
- # * 'source' is for vlad support, but ignored
46
+ #
47
+ # @param source [String] ignored
48
+ # @param destination [String] target export folder
26
49
  def export(source, destination)
27
- # ignoring source
28
50
  "cp -r #{repository} #{destination}"
29
51
  end
30
52
 
31
- # telling vlad to use "repository" as "revision" just
32
- # in case this method is needed
53
+ # Overwriting Vlad.revision
54
+ #
55
+ # @param revision [String] ignored
56
+ # @return [String] returning 'repository'
33
57
  def revision(revision)
34
58
  repository
35
59
  end
36
60
 
37
- # push extracted and compressed files to 'host'
38
- # this should be run once for each host by
39
- # the rake task :push
40
- def push(host)
41
- [ "#{push_scp} #{ssh_flags.join(' ')}",
42
- "/tmp/#{application}-#{release_name}.tgz",
43
- "#{host}:/tmp/#{application}-#{release_name}.tgz"
44
- ].join(" ")
45
- end
46
-
47
- # extract the remote compressed file on each host
61
+ # Extract the remote compressed file on each host
62
+ #
63
+ # @return [String] bash command to extract compressed archive on remote server
48
64
  def push_extract
49
65
  [ "if [ -e #{repository} ]; then rm -rf #{repository}; fi",
50
66
  "mkdir -p #{repository}",
51
67
  "cd #{repository}",
52
- "tar -xzf /tmp/#{application}-#{release_name}.tgz"
68
+ "tar -xzf #{extract_dir}/#{extract_file}"
53
69
  ].join(" && ")
54
70
  end
55
71
 
56
- # clean up old compressed archives both locally and
57
- # remotely
72
+ # Clean up old compressed archives both locally and remotely
73
+ #
74
+ # @return [String] bash command to remove compressed archives
58
75
  def push_cleanup
59
76
  [ "rm -vrf /tmp/#{application}-*.tgz",
60
77
  [ "if [ -e #{repository} ]",
@@ -64,27 +81,34 @@ class Vlad::Push
64
81
  ].join(" && ")
65
82
  end
66
83
 
67
- # compress the files in the current working directory
84
+ # Compress the files in the current working directory
68
85
  # to be pushed to the remote server
86
+ #
87
+ # @return [String] bash command to compress current directory
69
88
  def compress
70
- [ "tar -czf /tmp/#{application}-#{release_name}.tgz",
89
+ [ "tar -czf #{extract_dir}/#{extract_file}",
71
90
  '--exclude "\.git*"',
72
91
  '--exclude "\.svn*"',
73
92
  "."
74
- ].join(" ")
93
+ ].join(" ")
75
94
  end
76
95
 
77
- # using :vlad namespace to make this part
96
+ # Using :vlad namespace to make this part
78
97
  # of vlad in rake
79
98
  namespace :vlad do
80
99
 
81
- desc "Push current working directory to remote servers."
82
- remote_task :push do
100
+ desc "Built the extracted tarball to be pushed from the CWD"
101
+ task :create_extract do
83
102
  sh source.compress
84
- # TODO: find a better way to ensure array for each
85
- [domain].flatten.each do |host|
86
- sh source.push(host)
87
- end
103
+ end
104
+
105
+ # Run the following on specified environment:
106
+ # * Vlad::Push.compress
107
+ # * Vlad::Push.push
108
+ # * Vlad::Push.push_extract
109
+ desc "Push current working directory to remote servers."
110
+ remote_task :push => :create_extract do
111
+ rsync "#{extract_dir}/#{extract_file}", "#{target_host}:#{extract_dir}/#{extract_file}"
88
112
  run source.push_extract
89
113
  end
90
114
 
@@ -93,12 +117,16 @@ class Vlad::Push
93
117
  Rake::Task['vlad:push_cleanup'].invoke
94
118
  end
95
119
 
120
+ # Run the following on specified environment:
121
+ # * Vlad::Push.push_cleanup on local machine
122
+ # * Vlad::Push.push_cleanup on remote machines
96
123
  desc "Clean up archive files created by push. This will also be run by vlad:cleanup."
97
124
  remote_task :push_cleanup do
98
125
  sh source.push_cleanup
99
126
  run source.push_cleanup
100
127
  end
101
128
 
129
+ # Adding task to do both 'vlad:push' and 'vlad:update' rake tasks
102
130
  desc "Runs push and update"
103
131
  task :deploy do
104
132
  Rake::Task["vlad:push"].invoke
@@ -107,6 +135,6 @@ class Vlad::Push
107
135
 
108
136
  end
109
137
 
110
- end
138
+ end
111
139
 
112
140
 
@@ -5,11 +5,12 @@ class TestVladPush < Test::Unit::TestCase
5
5
  def setup
6
6
  super
7
7
  @source = Vlad::Push.new
8
+ set :application, "testapp"
8
9
  set :repository, "/tmp/repo"
9
- set :push_scp, "scp"
10
10
  set :ssh_flags, [ "-i", "~/.ssh/id_rsa_example" ]
11
11
  set :application, "testapp"
12
12
  set :release_name, "12345678910"
13
+ set :extract_file, "#{application}-#{release_name}.tgz"
13
14
  end
14
15
 
15
16
  def test_checkout
@@ -27,11 +28,6 @@ class TestVladPush < Test::Unit::TestCase
27
28
  assert_equal '/tmp/repo', out
28
29
  end
29
30
 
30
- def test_push
31
- cmd = @source.push 'example.com'
32
- assert_equal 'scp -i ~/.ssh/id_rsa_example /tmp/testapp-12345678910.tgz example.com:/tmp/testapp-12345678910.tgz', cmd
33
- end
34
-
35
31
  def test_push_extract
36
32
  cmd = @source.push_extract
37
33
  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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vlad-push
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-03 00:00:00.000000000Z
12
+ date: 2012-02-02 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: vlad
16
- requirement: &2151899840 !ruby/object:Gem::Requirement
16
+ requirement: &70325218998820 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,18 +21,29 @@ dependencies:
21
21
  version: '2.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2151899840
24
+ version_requirements: *70325218998820
25
+ - !ruby/object:Gem::Dependency
26
+ name: rdoc
27
+ requirement: &70325218998280 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '3.10'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70325218998280
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: hoe
27
- requirement: &2151898680 !ruby/object:Gem::Requirement
38
+ requirement: &70325218997760 !ruby/object:Gem::Requirement
28
39
  none: false
29
40
  requirements:
30
41
  - - ~>
31
42
  - !ruby/object:Gem::Version
32
- version: '2.10'
43
+ version: '2.13'
33
44
  type: :development
34
45
  prerelease: false
35
- version_requirements: *2151898680
46
+ version_requirements: *70325218997760
36
47
  description: Adds support to Vlad for pushing files to a remote server without SCM.
37
48
  (Really, pre 1.x didn't work as expected.)
38
49
  email:
@@ -64,6 +75,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
64
75
  - - ! '>='
65
76
  - !ruby/object:Gem::Version
66
77
  version: '0'
78
+ segments:
79
+ - 0
80
+ hash: 2321986802396206083
67
81
  required_rubygems_version: !ruby/object:Gem::Requirement
68
82
  none: false
69
83
  requirements:
@@ -72,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
86
  version: '0'
73
87
  requirements: []
74
88
  rubyforge_project: vlad-push
75
- rubygems_version: 1.8.5
89
+ rubygems_version: 1.8.10
76
90
  signing_key:
77
91
  specification_version: 3
78
92
  summary: Adds support to Vlad for pushing files to a remote server without SCM