sbfaulkner-astrovan 0.5.4 → 0.5.6

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/README.rdoc CHANGED
@@ -28,7 +28,15 @@ This is my attempt.
28
28
 
29
29
  == CHANGES
30
30
 
31
- === 0.5.3
31
+ === 0.5.6
32
+
33
+ - support for specification of git and rake command paths
34
+
35
+ === 0.5.5
36
+
37
+ - change working directory for rake tasks
38
+
39
+ === 0.5.4
32
40
 
33
41
  - handle github private repository urls
34
42
 
@@ -39,6 +47,8 @@ This is my attempt.
39
47
  - other commands (all using exec)
40
48
  - cp ?
41
49
  - mv ?
50
+ - move magic vars into separate context to avoid collision with method names
51
+ - e.g. rake method and rake var collision forces access of environment[:rake] instead of self.rake
42
52
 
43
53
  == Legal
44
54
 
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 5
4
- :patch: 4
4
+ :patch: 6
@@ -20,18 +20,17 @@ module Astrovan
20
20
  def deploy(repository, options = {})
21
21
  original_environment = self.environment.dup
22
22
 
23
- self.repository = repository
24
- self.application = application = options[:application] || self.application || File.basename(parse_repository_uri(repository).path.split('/').last,".git")
23
+ self.environment.merge!(options)
25
24
 
26
- self.deploy_to = deploy_to = options[:deploy_to] || self.deploy_to || "/u/apps/#{application}"
27
- self.shared_path = shared_path = File.join(deploy_to, 'shared')
28
- self.shared_repository = shared_repository = File.join(shared_path, "#{application}.git")
29
- self.release_name = release_name = Time.now.utc.strftime("%Y%m%d%H%M%S")
30
- self.releases_path = releases_path = File.join(deploy_to, 'releases')
31
- self.release_path = release_path = File.join(releases_path, release_name)
32
- self.env = options[:env] || self.env
33
- self.rakefile = options[:rakefile] || self.rakefile
34
- self.current_path = current_path = File.join(deploy_to, 'current')
25
+ self.repository = repository
26
+ self.application ||= File.basename(parse_repository_uri(repository).path.split('/').last,".git")
27
+ self.deploy_to ||= "/u/apps/#{application}"
28
+ self.shared_path = File.join(deploy_to, 'shared')
29
+ self.shared_repository = File.join(shared_path, "#{application}.git")
30
+ self.release_name = Time.now.utc.strftime("%Y%m%d%H%M%S")
31
+ self.releases_path = File.join(deploy_to, 'releases')
32
+ self.release_path = File.join(releases_path, release_name)
33
+ self.current_path = File.join(deploy_to, 'current')
35
34
 
36
35
  if block_given?
37
36
  yield
@@ -48,7 +47,13 @@ module Astrovan
48
47
  end
49
48
 
50
49
  # Create a symlink from a file or directory in the shared folder into the current release.
50
+ #
51
+ # Options:
52
+ # * +shared_path+ - specify the parent directory of the file or directory to be shared
53
+ # * +release_path+ - specify the parent directory to contain the shared file or directory
51
54
  def share(path, options = {})
55
+ shared_path = options[:shared_path] || self.shared_path
56
+ release_path = options[:release_path] || self.release_path
52
57
  symlink "#{shared_path}/#{path}", options.merge(:to => "#{release_path}/#{path}")
53
58
  end
54
59
 
data/lib/astrovan/exec.rb CHANGED
@@ -6,6 +6,7 @@ module Astrovan
6
6
  #
7
7
  # Options:
8
8
  # * +on+ - specifies a subset of servers to run the command on.
9
+ # * +env+ - the initial environment for the remote server.
9
10
  def exec(command, options = {})
10
11
  session = session_for(options.delete(:on))
11
12
  begin
data/lib/astrovan/rake.rb CHANGED
@@ -3,13 +3,14 @@ module Astrovan
3
3
  # Execute a rake task on the remote servers.
4
4
  #
5
5
  # Options:
6
+ # * +rake+ - path to rake tool. Default is 'rake'
6
7
  # * +rakefile+ - specify the path to a rakefile (if not in the default location)
7
8
  def rake(*tasks)
8
9
  options = tasks.last.is_a?(Hash) ? tasks.pop : {}
9
- rake = 'rake'
10
- rakefile = options.delete(:rakefile) || self.rakefile
10
+ rake = options[:rake] || self.environment[:rake]
11
+ rakefile = options[:rakefile] || self.rakefile
11
12
  rake << ' -f ' << rakefile if rakefile
12
- exec "#{rake} #{tasks.join(' ')}", options
13
+ exec "cd #{current_path} && #{rake} #{tasks.join(' ')}", options
13
14
  end
14
15
 
15
16
  # Map one or more rake tasks to deployment methods.
@@ -16,10 +16,15 @@ module Astrovan
16
16
  #:stopdoc:
17
17
  DEFAULTS = {
18
18
  :application => nil,
19
+ :current_path => nil,
19
20
  :deploy_to => nil,
20
21
  :env => nil,
22
+ :git => 'git',
21
23
  :password => nil,
24
+ :rake => 'rake',
22
25
  :rakefile => nil,
26
+ :release_path => nil,
27
+ :shared_path => nil,
23
28
  :username => nil
24
29
  }
25
30
  #:startdoc:
@@ -1,21 +1,27 @@
1
1
  module Astrovan
2
2
  module Update
3
+ # Update the application from git, then create a symlink to the current release.
4
+ #
5
+ # Options:
6
+ # * +git+ - path to git tool. Default is 'git'
3
7
  def update(options = {})
4
8
  shared_repository = self.shared_repository
5
9
  repository = self.repository
6
10
  release_path = self.release_path
7
11
  current_path = self.current_path
8
12
 
13
+ git = options[:git] || self.git
14
+
9
15
  # TODO: do we need branch support, submodule config, etc?
10
16
  exec <<-END, options
11
17
  if [ -d '#{shared_repository}' ]
12
18
  then
13
19
  cd #{shared_repository} &&
14
- git fetch #{repository}
20
+ #{git} fetch #{repository}
15
21
  else
16
- git clone --bare #{repository} #{shared_repository}
22
+ #{git} clone --bare #{repository} #{shared_repository}
17
23
  fi &&
18
- git clone #{shared_repository} #{release_path}
24
+ #{git} clone #{shared_repository} #{release_path}
19
25
  END
20
26
 
21
27
  symlink release_path, options.merge(:to => current_path)
data/test/deploy_test.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
3
  class DeployTest < Test::Unit::TestCase
4
+ GIT = `which git`.chomp
5
+
4
6
  def test_should_deploy
5
7
  using 'astrovan.local', :password => ENV['PASSWORD'] do
6
- deploy 'git://github.com/adamwiggins/scanty.git', :env => { :PATH => '$PATH:/usr/local/git/bin' }
8
+ deploy 'git://github.com/adamwiggins/scanty.git', :git => GIT
7
9
  end
8
10
  end
9
11
 
data/test/rake_test.rb CHANGED
@@ -1,19 +1,17 @@
1
1
  require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
3
  class RakeTest < Test::Unit::TestCase
4
- def setup
5
- @rakefile = File.expand_path(File.join(File.dirname(__FILE__),'rake_test.rake'))
6
- end
4
+ CURRENT_PATH = File.expand_path(File.dirname(__FILE__))
7
5
 
8
6
  def test_should_run_rake_task
9
- using 'astrovan.local', :password => ENV['PASSWORD'], :rakefile => @rakefile do
7
+ using 'astrovan.local', :password => ENV['PASSWORD'], :current_path => CURRENT_PATH, :rakefile => 'rake_test.rake' do
10
8
  rake 'succeed'
11
9
  end
12
10
  end
13
11
 
14
12
  def test_should_fail_when_rake_task_fails
15
13
  assert_raise(RuntimeError) do
16
- using 'astrovan.local', :password => ENV['PASSWORD'], :rakefile => @rakefile do
14
+ using 'astrovan.local', :password => ENV['PASSWORD'], :current_path => CURRENT_PATH, :rakefile => 'rake_test.rake' do
17
15
  rake 'fail'
18
16
  end
19
17
  end
@@ -21,7 +19,7 @@ class RakeTest < Test::Unit::TestCase
21
19
 
22
20
  def test_should_fail_when_rake_task_not_defined
23
21
  assert_raise(RuntimeError) do
24
- using 'astrovan.local', :password => ENV['PASSWORD'], :rakefile => @rakefile do
22
+ using 'astrovan.local', :password => ENV['PASSWORD'], :current_path => CURRENT_PATH, :rakefile => 'rake_test.rake' do
25
23
  rake 'undefined'
26
24
  end
27
25
  end
data/test/update_test.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
3
  class UpdateTest < Test::Unit::TestCase
4
+ GIT = `which git`.chomp
5
+
4
6
  def test_should_update
5
7
  using 'astrovan.local', :password => ENV['PASSWORD'] do
6
- deploy 'git://github.com/adamwiggins/scanty.git', :env => { :PATH => '$PATH:/usr/local/git/bin' } do
8
+ deploy 'git://github.com/adamwiggins/scanty.git', :git => GIT do
7
9
  update
8
10
  end
9
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sbfaulkner-astrovan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - S. Brent Faulkner