ey-deploy 0.3.2 → 0.3.3

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.
@@ -156,10 +156,7 @@ module EY
156
156
  def self.run(opts={})
157
157
  conf = EY::Deploy::Configuration.new(opts)
158
158
  EY::Server.config = conf
159
-
160
- dep = new(conf)
161
- dep.require_custom_tasks
162
- dep.send(opts["default_task"])
159
+ new(conf).send(opts["default_task"])
163
160
  end
164
161
  end
165
162
  end
@@ -68,7 +68,7 @@ module EY
68
68
  def push_code
69
69
  return if local?
70
70
  run "mkdir -p #{config.repository_cache}"
71
- system(%|rsync -aq -e "#{ssh_command}" #{config.repository_cache}/ #{config.user}@#{hostname}:#{config.repository_cache}|)
71
+ system(%|rsync --delete -aq -e "#{ssh_command}" #{config.repository_cache}/ #{config.user}@#{hostname}:#{config.repository_cache}|)
72
72
  end
73
73
 
74
74
  def run(command)
@@ -10,10 +10,19 @@ module EY
10
10
  end
11
11
 
12
12
  def require_custom_tasks
13
- deploy_file = ["config/eydeploy.rb", "eydeploy.rb"].detect do |file|
14
- File.exists?(File.join(c.repository_cache, file))
13
+ deploy_file = ["config/eydeploy.rb", "eydeploy.rb"].map do |short_file|
14
+ File.join(c.repository_cache, short_file)
15
+ end.detect do |file|
16
+ File.exist?(file)
17
+ end
18
+
19
+ if deploy_file
20
+ puts "~> Loading deployment task overrides from #{deploy_file}"
21
+ instance_eval(File.read(deploy_file))
22
+ true
23
+ else
24
+ false
15
25
  end
16
- require File.join(c.repository_cache, deploy_file) if deploy_file
17
26
  end
18
27
 
19
28
  def roles(*task_roles)
@@ -1,3 +1,3 @@
1
1
  module EY
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.3'
3
3
  end
@@ -0,0 +1,79 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "the EY::Deploy API" do
4
+ it "calls tasks in the right order" do
5
+ class TestDeploy < EY::Deploy
6
+ # cheat a bit; we don't actually want to do these things
7
+ def update_repository_cache() end
8
+ def require_custom_tasks() end
9
+ def callback(*_) end
10
+ def puts(*_) 'stfu' end
11
+
12
+ attr_reader :call_order
13
+ def initialize(*a)
14
+ super
15
+ @call_order = []
16
+ end
17
+
18
+ def push_code() @call_order << 'push_code' end
19
+ def copy_repository_cache() @call_order << 'copy_repository_cache' end
20
+ def create_revision_file() @call_order << 'create_revision_file' end
21
+ def bundle() @call_order << 'bundle' end
22
+ def symlink_configs() @call_order << 'symlink_configs' end
23
+ def migrate() @call_order << 'migrate' end
24
+ def symlink() @call_order << 'symlink' end
25
+ def restart() @call_order << 'restart' end
26
+ def cleanup() @call_order << 'cleanup' end
27
+ end
28
+
29
+ td = TestDeploy.new(EY::Deploy::Configuration.new)
30
+ td.deploy
31
+ td.call_order.should == %w[push_code copy_repository_cache create_revision_file bundle symlink_configs migrate symlink restart cleanup]
32
+ end
33
+
34
+ describe "task overrides" do
35
+ class TestQuietDeploy < EY::Deploy
36
+ def puts(*_) 'quiet' end
37
+ end
38
+
39
+ before(:each) do
40
+ @tempdir = `mktemp -d -t custom_deploy_spec`.strip
41
+ @config = EY::Deploy::Configuration.new('repository_cache' => @tempdir)
42
+ @deploy = TestQuietDeploy.new(@config)
43
+ end
44
+
45
+ def write_eydeploy(relative_path, contents = "def got_new_methods() 'from the file on disk' end")
46
+ FileUtils.mkdir_p(File.join(
47
+ @tempdir,
48
+ File.dirname(relative_path)))
49
+
50
+ File.open(File.join(@tempdir, relative_path), 'w') do |f|
51
+ f.write contents
52
+ end
53
+ end
54
+
55
+ it "requires 'eydeploy.rb' and adds any defined methods to the deploy" do
56
+ write_eydeploy 'eydeploy.rb'
57
+ @deploy.require_custom_tasks.should be_true
58
+ @deploy.got_new_methods.should == 'from the file on disk'
59
+ end
60
+
61
+ it "falls back to 'config/eydeploy.rb'" do
62
+ write_eydeploy 'config/eydeploy.rb'
63
+ @deploy.require_custom_tasks.should be_true
64
+ @deploy.got_new_methods.should == 'from the file on disk'
65
+ end
66
+
67
+ it "lets you super up from any defined methods" do
68
+ write_eydeploy 'eydeploy.rb', "def value() super << ' + derived' end"
69
+
70
+ class TestDeploySuper < TestQuietDeploy
71
+ def value() 'base' end
72
+ end
73
+
74
+ deploy = TestDeploySuper.new(@config)
75
+ deploy.require_custom_tasks.should be_true
76
+ deploy.value.should == "base + derived"
77
+ end
78
+ end
79
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 2
9
- version: 0.3.2
8
+ - 3
9
+ version: 0.3.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - EY Cloud Team
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-26 00:00:00 -07:00
17
+ date: 2010-06-03 00:00:00 -07:00
18
18
  default_executable: eysd
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -142,5 +142,6 @@ signing_key:
142
142
  specification_version: 3
143
143
  summary: A gem that deploys ruby applications on EY Cloud instances
144
144
  test_files:
145
+ - spec/custom_deploy_spec.rb
145
146
  - spec/deploy_hook_spec.rb
146
147
  - spec/spec_helper.rb