recap 1.0.12 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9482ec0ba9c5c48c52f06b67d8d2bd74e111c82a
4
- data.tar.gz: 7c42f98d0ef90594de08e61844ea1e06b5c4d8b9
3
+ metadata.gz: 83721ec6476d41384eea2d9b1eaf90aa1f85db56
4
+ data.tar.gz: 45d5968cdcdc68bc37ff9ab3a7ad0213256a6090
5
5
  SHA512:
6
- metadata.gz: abf13753ada786fc8d52f7e601ef721beb77fd5cc8d5431c6ebe4396bd59756f6db8d941b9a1f833be400f83982cb339740166d7c62ed36b6467309f0b64bce7
7
- data.tar.gz: 69cfb461a89e529c68be44c50c2a61b2a5ec1083cc513e7fbe57afc84734d6b6fda2266127603613faf6ea7ae26ed3cdcc986556517004d9a8a09c12ec2983af
6
+ metadata.gz: 20772b8733768f091517741501fab00f540e7331f2ffc78d17da02dbd0a9cbbc93fc7fb040d144388cd31b70764aaa6a00c775a40ae824415846edc132489119
7
+ data.tar.gz: 678bd37303fe05e240130e231f813df9e335c70c205a7241ed815f233fdda083ab3915bbf8aa3d2363c3b59f17c5b2cabe21d3dd950a8e50f01100675873d94f
@@ -40,18 +40,18 @@ module Recap::Tasks::Bootstrap
40
40
  # `env:edit` tasks). The script loads the `.env` file in the users home folder, creates
41
41
  # a new copy with `export ` prefixed to each line, and sources this new copy.
42
42
  put_as_app %{
43
- if [ -s "$HOME/.env" ]; then
44
- sed -e 's/\\r//g' -e 's/^/export /g' $HOME/.env > $HOME/.recap-env-export
45
- . $HOME/.recap-env-export
43
+ if [ -s #{application_home}/.env ]; then
44
+ sed -e 's/\\r//g' -e 's/^/export /g' #{application_home}/.env > #{application_home}/.recap-env-export
45
+ . #{application_home}/.recap-env-export
46
46
  fi
47
47
  }, "#{application_home}/.recap"
48
48
 
49
49
  # Finally, `.profile` needs to source the `.recap` script, so that the configuration environment is
50
50
  # available whenever the environment is loaded.
51
- as_app "touch .profile", "~"
51
+ as_app "touch .profile", "#{application_home}"
52
52
 
53
- if exit_code("grep '\\. $HOME/\\.recap' #{application_home}/.profile") != "0"
54
- as_app %{echo ". \\$HOME/.recap" >> .profile}, "~"
53
+ if exit_code("grep '\\. #{application_home}/\\.recap' #{application_home}/.profile") != "0"
54
+ as_app %{echo ". #{application_home}/.recap" >> .profile}, "#{application_home}"
55
55
  end
56
56
  end
57
57
 
@@ -67,7 +67,7 @@ fi
67
67
  sudo "usermod --append -G #{application_group} #{remote_username}"
68
68
 
69
69
  if repository.match /github\.com/
70
- run "(mkdir -p ~/.ssh && touch ~/.ssh/known_hosts && ssh-keygen -f ~/.ssh/known_hosts -H -F github.com | grep 'github.com') || ssh-keyscan -H github.com > ~/.ssh/known_hosts"
70
+ run "(mkdir -p #{application_home}/.ssh && touch #{application_home}/.ssh/known_hosts && ssh-keygen -f #{application_home}/.ssh/known_hosts -H -F github.com | grep 'github.com') || ssh-keyscan -H github.com > #{application_home}/.ssh/known_hosts"
71
71
  end
72
72
  end
73
73
 
@@ -12,6 +12,11 @@ module Recap::Tasks::Foreman
12
12
  # Foreman startup scripts are exported in `upstart` format by default.
13
13
  set(:foreman_export_format, "upstart")
14
14
 
15
+ # Foreman startup scripts are generated based on the standard templates by default
16
+ set(:foreman_template, nil)
17
+
18
+ set(:foreman_template_option) { foreman_template ? "--template #{foreman_template}" : nil}
19
+
15
20
  # Scripts are exported (as the the application user) to a temporary location first.
16
21
  set(:foreman_tmp_location) { "#{deploy_to}/tmp/foreman" }
17
22
 
@@ -19,12 +24,12 @@ module Recap::Tasks::Foreman
19
24
  set(:foreman_export_location, "/etc/init")
20
25
 
21
26
  # The standard foreman export.
22
- set(:foreman_export_command) { "./bin/foreman export #{foreman_export_format} #{foreman_tmp_location} --procfile #{procfile} --app #{application} --user #{application_user} --log #{deploy_to}/log" }
27
+ set(:foreman_export_command) { "./bin/foreman export #{foreman_export_format} #{foreman_tmp_location} --procfile #{procfile} --app #{application} --user #{application_user} --log #{deploy_to}/log #{foreman_template_option}" }
23
28
 
24
29
  namespace :export do
25
- # After each deployment, the startup scripts are exported if the `Procfile` has changed.
30
+ # After each deployment, the startup scripts are exported if either the `Procfile` or any custom Foreman templates have changed.
26
31
  task :if_changed do
27
- if trigger_update?(procfile)
32
+ if trigger_update?(procfile) || (foreman_template && trigger_update?(foreman_template))
28
33
  top.foreman.export.default
29
34
  end
30
35
  end
@@ -71,4 +76,4 @@ module Recap::Tasks::Foreman
71
76
  after 'deploy:update_code', 'foreman:export:if_changed'
72
77
  after 'deploy:restart', 'foreman:restart'
73
78
  end
74
- end
79
+ end
@@ -69,4 +69,4 @@ Your remote user must be a member of the '#{application_group}' group in order t
69
69
  end
70
70
  end
71
71
  end
72
- end
72
+ end
data/lib/recap/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Recap
2
- VERSION = '1.0.12'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -38,6 +38,23 @@ describe Recap::Tasks::Foreman do
38
38
  end
39
39
  end
40
40
 
41
+ describe '#foreman_template' do
42
+ it 'defaults to nil' do
43
+ config.foreman_template.should be_nil
44
+ end
45
+ end
46
+
47
+ describe '#foreman_template_option' do
48
+ it 'is nil if foreman_template is unset' do
49
+ config.foreman_template_option.should be_nil
50
+ end
51
+
52
+ it 'points at the foreman_template if set' do
53
+ config.set :foreman_template, '/path/to/template'
54
+ config.foreman_template_option.should eql('--template /path/to/template')
55
+ end
56
+ end
57
+
41
58
  describe '#foreman_export_location' do
42
59
  it 'defaults to /etc/init' do
43
60
  config.foreman_export_location.should eql('/etc/init')
@@ -52,6 +69,7 @@ describe Recap::Tasks::Foreman do
52
69
 
53
70
  describe '#foreman_export_command' do
54
71
  before :each do
72
+ config.set :foreman_template_option, ''
55
73
  config.set :foreman_export_format, '<export-format>'
56
74
  config.set :foreman_tmp_location, '<tmp-location>'
57
75
  end
@@ -79,11 +97,20 @@ describe Recap::Tasks::Foreman do
79
97
  config.set :deploy_to, '/custom/deploy/location'
80
98
  config.foreman_export_command.index("--log /custom/deploy/location/log").should_not be_nil
81
99
  end
100
+
101
+ it 'includes --template option if set' do
102
+ config.set :foreman_template_option, '--template /path/to/template'
103
+ config.foreman_export_command.index("--template /path/to/template").should_not be_nil
104
+ end
82
105
  end
83
106
  end
84
107
 
85
108
  describe 'Tasks' do
86
109
  describe 'foreman:export:if_changed' do
110
+ before :each do
111
+ namespace.stubs(:trigger_update?).with(config.procfile).returns(false)
112
+ end
113
+
87
114
  it 'calls foreman:export if the Procfile has changed' do
88
115
  namespace.stubs(:trigger_update?).with(config.procfile).returns(true)
89
116
  namespace.export.expects(:default)
@@ -91,10 +118,22 @@ describe Recap::Tasks::Foreman do
91
118
  end
92
119
 
93
120
  it 'skips foreman:export if the Procfile has not changed' do
94
- namespace.stubs(:trigger_update?).with(config.procfile).returns(false)
95
121
  namespace.export.expects(:default).never
96
122
  config.find_and_execute_task('foreman:export:if_changed')
97
123
  end
124
+
125
+ describe 'foreman_template is set' do
126
+ before :each do
127
+ config.set :foreman_template, 'config/foreman/upstart'
128
+ namespace.stubs(:trigger_update?).with(config.foreman_template).returns(false)
129
+ end
130
+
131
+ it 'calls foreman:export if any of the templates have changed' do
132
+ namespace.stubs(:trigger_update?).with(config.foreman_template).returns(true)
133
+ namespace.export.expects(:default)
134
+ config.find_and_execute_task('foreman:export:if_changed')
135
+ end
136
+ end
98
137
  end
99
138
 
100
139
  describe 'foreman:export' do
@@ -158,4 +197,4 @@ describe Recap::Tasks::Foreman do
158
197
  end
159
198
  end
160
199
  end
161
- end
200
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.12
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Ward
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-28 00:00:00.000000000 Z
11
+ date: 2013-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano