recap 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Vagrantfile CHANGED
@@ -7,11 +7,11 @@ Vagrant::Config.run do |config|
7
7
  # please see the online documentation at vagrantup.com.
8
8
 
9
9
  # Every Vagrant virtual environment requires a box to build off of.
10
- config.vm.box = "lucid64"
10
+ config.vm.box = "precise64"
11
11
 
12
12
  # The url from where the 'config.vm.box' box will be fetched if it
13
13
  # doesn't already exist on the user's system.
14
- config.vm.box_url = "http://files.vagrantup.com/lucid64.box"
14
+ config.vm.box_url = "http://files.vagrantup.com/precise64.box"
15
15
 
16
16
  # Boot with a GUI so you can see the screen. (Default is headless)
17
17
  # config.vm.boot_mode = :gui
@@ -4,19 +4,9 @@ require 'tempfile'
4
4
  # as part of a deployments
5
5
 
6
6
  module Recap::Support::CapistranoExtensions
7
- # Run a command as the given user
8
- def as_user(user, command, pwd = deploy_to)
9
- sudo "su - #{user} -c 'cd #{pwd} && #{command}'"
10
- end
11
-
12
- # Run a command as root
13
- def as_root(command, pwd = deploy_to)
14
- as_user 'root', command, pwd
15
- end
16
-
17
7
  # Run a command as the application user
18
8
  def as_app(command, pwd = deploy_to)
19
- as_user application_user, command, pwd
9
+ sudo "su - #{application_user} -c 'cd #{pwd} && #{command}'"
20
10
  end
21
11
 
22
12
  # Put a string into a file as the application user
@@ -65,8 +55,8 @@ module Recap::Support::CapistranoExtensions
65
55
  # Find the latest tag from the repository. As `git tag` returns tags in order, and our release
66
56
  # tags are timestamps, the latest tag will always be the last in the list.
67
57
  def latest_tag_from_repository
68
- result = capture_git("tag | tail -n1").strip
69
- result.empty? ? nil : result
58
+ tags = capture_git("tag").strip.split
59
+ tags.grep(/^[0-9]{17}/).last
70
60
  end
71
61
 
72
62
  # Does the given file exist within the deployment directory?
@@ -33,9 +33,8 @@ module Recap::Tasks::Deploy
33
33
  # directory. The default is `/home/#{application_user}/app`.
34
34
  set(:deploy_to) { "/home/#{application_user}/app" }
35
35
 
36
- # Each release is marked by a unique tag, generated with the current timestamp. While this can be
37
- # changed, it's not recommended, as the sort order of the tag names is important; later tags must
38
- # be listed after earlier tags.
36
+ # Each release is marked by a unique tag, generated with the current timestamp. This should
37
+ # not be changed, as the format is matched in the list of tags to find deploy tags.
39
38
  set(:release_tag) { Time.now.utc.strftime("%Y%m%d%H%M%S") }
40
39
 
41
40
  # On tagging a release, a message is also recorded alongside the tag. This message can contain
@@ -1,6 +1,6 @@
1
1
  # Recap encourages the storage of application configuration (such as database passwords, S3 keys and
2
2
  # other things that change between deploys) in environment variables.
3
- # [12factor.net](http://www.12factor.net) has [http://www.12factor.net/config](a good set of reasons
3
+ # [12factor.net](http://www.12factor.net) has [a good set of reasons](http://www.12factor.net/config)
4
4
  # why this is desirable).
5
5
  #
6
6
  # To enable this, [recap](https://github.com/freerange/recap) stores these configuration variables
@@ -35,6 +35,7 @@ module Recap::Tasks::Foreman
35
35
  desc 'Export foreman configuration'
36
36
  task :default do
37
37
  if deployed_file_exists?(procfile)
38
+ sudo "mkdir -p #{deploy_to}/log"
38
39
  sudo "chown #{application_user}: #{deploy_to}/log"
39
40
  as_app foreman_export_command
40
41
  sudo "rm -f #{foreman_export_location}/#{application}*"
@@ -23,7 +23,7 @@ module Recap::Tasks::Rails
23
23
  end
24
24
 
25
25
  task :migrate do
26
- if deployed_file_changed?("db/schema.rb")
26
+ if deployed_file_exists?("db/schema.rb") && deployed_file_changed?("db/schema.rb")
27
27
  as_app './bin/rake db:migrate'
28
28
  end
29
29
  end
data/lib/recap/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Recap
2
- VERSION = '1.0.5'
2
+ VERSION = '1.0.6'
3
3
  end
@@ -100,6 +100,7 @@ describe Recap::Tasks::Foreman do
100
100
  describe 'foreman:export' do
101
101
  it 'runs the foreman export command, then moves the exported files to the export location' do
102
102
  namespace.stubs(:deployed_file_exists?).with(config.procfile).returns(true)
103
+ namespace.expects(:sudo).with("mkdir -p #{config.deploy_to}/log").in_sequence(commands)
103
104
  namespace.expects(:sudo).with("chown #{config.application_user}: #{config.deploy_to}/log").in_sequence(commands)
104
105
  namespace.expects(:as_app).with(config.foreman_export_command).in_sequence(commands)
105
106
  namespace.expects(:sudo).with("rm -f #{config.foreman_export_location}/#{config.application}*").in_sequence(commands)
@@ -37,15 +37,25 @@ describe Recap::Tasks::Rails do
37
37
 
38
38
  describe 'rails:db:migrate' do
39
39
  it 'runs migrations if the schema has changed' do
40
+ namespace.stubs(:deployed_file_exists?).with('db/schema.rb').returns(true)
40
41
  namespace.stubs(:deployed_file_changed?).with('db/schema.rb').returns(true)
41
42
  namespace.expects(:as_app).with('./bin/rake db:migrate')
42
43
  config.find_and_execute_task('rails:db:migrate')
43
44
  end
45
+
44
46
  it 'does nothing if the schema has not changed' do
47
+ namespace.stubs(:deployed_file_exists?).with('db/schema.rb').returns(true)
45
48
  namespace.stubs(:deployed_file_changed?).with('db/schema.rb').returns(false)
46
49
  namespace.expects(:as_app).never
47
50
  config.find_and_execute_task('rails:db:migrate')
48
51
  end
52
+
53
+ it 'does nothing if the schema does not exist' do
54
+ namespace.stubs(:deployed_file_exists?).with('db/schema.rb').returns(false)
55
+ namespace.stubs(:deployed_file_changed?).with('db/schema.rb').returns(true)
56
+ namespace.expects(:as_app).never
57
+ config.find_and_execute_task('rails:db:migrate')
58
+ end
49
59
  end
50
60
 
51
61
  describe 'assets:precompile' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-25 00:00:00.000000000 Z
12
+ date: 2012-12-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
@@ -266,7 +266,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
266
266
  version: '0'
267
267
  segments:
268
268
  - 0
269
- hash: -3430921790514361122
269
+ hash: -2984683490822306722
270
270
  required_rubygems_version: !ruby/object:Gem::Requirement
271
271
  none: false
272
272
  requirements:
@@ -275,10 +275,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
275
275
  version: '0'
276
276
  segments:
277
277
  - 0
278
- hash: -3430921790514361122
278
+ hash: -2984683490822306722
279
279
  requirements: []
280
280
  rubyforge_project:
281
- rubygems_version: 1.8.24
281
+ rubygems_version: 1.8.23
282
282
  signing_key:
283
283
  specification_version: 3
284
284
  summary: GIT based deployment recipes for Capistrano