mina 0.3.4 → 0.3.6

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: 7c6b0b3ddff51096031d949735044ec53b0c2484
4
- data.tar.gz: 9645495211ff5442aad8b0986735da7d93157d86
3
+ metadata.gz: 76fbf68f7148a388b239003646be8ccc30ff6a5a
4
+ data.tar.gz: 593f35381e2513afc1ce719617fa7e25d3bbf90a
5
5
  SHA512:
6
- metadata.gz: b70f4bcecbf9673c99898e5ee87d06b2db3adfd50545db587964f3e9a713112142d16fbd4eadba6a7c9a9711350a1bf0577d70b7a3b32b00d9be815901e2a7dd
7
- data.tar.gz: a4d75cb1b9d44f45e8c7535b8b345cc061ad717f993d346779152af44265cc141e8e086f70abcd1d99b9b90a585e5a8a4edcdd22146af9a27a740d5fa50f6d2f
6
+ metadata.gz: 10d3b8bcd6dc310b58e0889c248965e3edd425048ed37047c18a3c077f3cfee105bb555b47b0677a9678fd932076b2651b61e6eca15de35c68f56065acb3f588
7
+ data.tar.gz: c75d7b3fa4e741b289bf30c19623f6ef6f5847685d5202f9f86e60cb1fbde080a00d8c61220195b9f074614edacf1078a8705644cdb725dea6490950c2dfb8b3
data/Makefile CHANGED
@@ -17,6 +17,7 @@ support/modules.md: \
17
17
  lib/mina/rbenv.rb \
18
18
  lib/mina/rvm.rb \
19
19
  lib/mina/npm.rb \
20
+ lib/mina/tools.rb \
20
21
  lib/mina/whenever.rb
21
22
  cat $^ | ruby support/to_md.rb > $@
22
23
 
data/Readme.md CHANGED
@@ -13,7 +13,7 @@ session per deploy, minimizing the SSH connection overhead.
13
13
  $ gem install mina
14
14
  $ mina
15
15
 
16
- [![Build Status](https://travis-ci.org/mina-deploy/mina.svg?branch=master)](https://travis-ci.org/mina-deploy/mina) [![Gem Version](https://badge.fury.io/rb/mina.svg)](http://badge.fury.io/rb/mina)
16
+ [![Build Status](https://travis-ci.org/mina-deploy/mina.svg?branch=master)](https://travis-ci.org/mina-deploy/mina) [![Gem Version](https://badge.fury.io/rb/mina.svg)](http://badge.fury.io/rb/mina) [![Inline docs](http://inch-ci.org/github/mina-deploy/mina.svg?branch=master)](http://inch-ci.org/github/mina-deploy/mina)
17
17
 
18
18
  User guide
19
19
  ==========
@@ -837,6 +837,9 @@ their own.
837
837
  ### git:clone
838
838
  Clones the Git repository. Meant to be used inside a deploy script.
839
839
 
840
+ ### git:revision
841
+ Gets the current git revision deployed on server.
842
+
840
843
  # Modules: Rails
841
844
  Adds settings and tasks for managing Rails projects.
842
845
 
@@ -887,6 +890,14 @@ release.
887
890
  Override this if you have custom asset paths declared in your Rails's
888
891
  `config.assets.paths` setting.
889
892
 
893
+ ### compiled_asset_path
894
+ The path to be copied to the new release.
895
+
896
+ The path your assets are compiled to. If your `assets_path` assets have changed,
897
+ this is the folder that gets copied accross from the current release to the new release.
898
+
899
+ Override this if you have custom public asset paths.
900
+
890
901
  ### rake_assets_precompile
891
902
  The command to invoke when precompiling assets.
892
903
  Override me if you like.
@@ -919,6 +930,9 @@ Opens the Ruby console for the currently-deployed version.
919
930
  $ mina console
920
931
  ~~~
921
932
 
933
+ ### log
934
+ Tail log from server
935
+
922
936
  ## Deploy tasks
923
937
  These tasks are meant to be invoked inside deploy scripts, not invoked on
924
938
  their own.
@@ -927,6 +941,8 @@ their own.
927
941
 
928
942
  ### rails:db_migrate:force
929
943
 
944
+ ### rails:db_create
945
+
930
946
  ### rails:db_rollback
931
947
 
932
948
  ### rails:assets_precompile:force
@@ -1060,8 +1076,8 @@ Installs node modules. Takes into account if executed `in_directory` and namespa
1060
1076
  ### bower:install
1061
1077
  Installs bower modules. Takes into account if executed `in_directory` and namespaces the installed modules in the shared folder.
1062
1078
 
1063
- ### bower:install
1064
- Installs bower modules. Takes into account if executed `in_directory` and namespaces the installed modules in the shared folder.
1079
+ ### grunt:install
1080
+ Launch a task with grunt. Set the grunt_task (defaults to \"build\") variable before calling this.
1065
1081
 
1066
1082
  # Modules: Whenever
1067
1083
  Adds settings and tasks for managing projects with [whenever].
@@ -1074,7 +1090,9 @@ require 'mina/whenever'
1074
1090
  task :deploy => :environment do
1075
1091
  deploy do
1076
1092
  ...
1077
- invoke :'whenever:update'
1093
+ to :launch do
1094
+ invoke :'whenever:update'
1095
+ end
1078
1096
  end
1079
1097
  ~~~
1080
1098
 
@@ -1105,8 +1123,7 @@ end
1105
1123
  Acknowledgements
1106
1124
  ----------------
1107
1125
 
1108
- © 2012-2015, Nadarei. Released under the [MIT
1109
- License](http://www.opensource.org/licenses/mit-license.php).
1126
+ © 2012-2015, Nadarei. Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
1110
1127
 
1111
1128
  Mina is authored and maintained by [Rico Sta. Cruz][rsc] and [Michael
1112
1129
  Galero][mg] with help from its [contributors][c]. It is sponsored by our
data/data/deploy.rb CHANGED
@@ -20,7 +20,7 @@ set :branch, 'master'
20
20
 
21
21
  # Manually create these paths in shared/ (eg: shared/config/database.yml) in your server.
22
22
  # They will be linked in the 'deploy:link_shared_paths' step.
23
- set :shared_paths, ['config/database.yml', 'log']
23
+ set :shared_paths, ['config/database.yml', 'config/secrets.yml', 'log']
24
24
 
25
25
  # Optional settings:
26
26
  # set :user, 'foobar' # Username in the server to SSH to.
@@ -49,7 +49,15 @@ task :setup => :environment do
49
49
  queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/config"]
50
50
 
51
51
  queue! %[touch "#{deploy_to}/#{shared_path}/config/database.yml"]
52
- queue %[echo "-----> Be sure to edit '#{deploy_to}/#{shared_path}/config/database.yml'."]
52
+ queue! %[touch "#{deploy_to}/#{shared_path}/config/secrets.yml"]
53
+ queue %[echo "-----> Be sure to edit '#{deploy_to}/#{shared_path}/config/database.yml' and 'secrets.yml'."]
54
+
55
+ queue %[
56
+ repo_host=`echo $repo | sed -e 's/.*@//g' -e 's/:.*//g'` &&
57
+ repo_port=`echo $repo | grep -o ':[0-9]*' | sed -e 's/://g'` &&
58
+ if [ -z "${repo_port}" ]; then repo_port=22; fi &&
59
+ ssh-keyscan -p $repo_port -H $repo_host >> ~/.ssh/known_hosts
60
+ ]
53
61
  end
54
62
 
55
63
  desc "Deploys the current version to the server."
@@ -80,4 +88,3 @@ end
80
88
  # - http://nadarei.co/mina/tasks
81
89
  # - http://nadarei.co/mina/settings
82
90
  # - http://nadarei.co/mina/helpers
83
-
data/data/deploy.sh.erb CHANGED
@@ -1,10 +1,14 @@
1
1
  <%
2
2
  prepare = commands(:default).map { |s| "(\n\n#{indent 2, s}\n\n)" }.join(" && ")
3
+ build = commands(:build).map { |s| "(\n\n#{indent 2, s}\n\n)" }.join(" && ")
3
4
  launch = commands(:launch).map { |s| "(\n\n#{indent 2, s}\n\n)" }.join(" && ")
4
5
  clean = commands(:clean).map { |s| "(\n\n#{indent 2, s}\n\n)" }.join(" && ")
5
6
  %>
6
7
  #!/usr/bin/env bash
7
8
 
9
+ # Bail out ASAP
10
+ set -e
11
+
8
12
  # Go to the deploy path
9
13
  cd "<%= deploy_to %>" || (
10
14
  echo "! ERROR: not set up."
@@ -25,7 +29,7 @@ fi
25
29
  if [ -e "<%= lock_file %>" ]; then
26
30
  echo "! ERROR: another deployment is ongoing."
27
31
  echo "The file '<%= lock_file %>' was found."
28
- echo "If no other deployment is ongoing, delete the file to continue."
32
+ echo "If no other deployment is ongoing, run 'mina deploy:force_unlock' to delete the file."
29
33
  exit 17
30
34
  fi
31
35
 
@@ -49,16 +53,29 @@ fi
49
53
  <%= echo_cmd %[cd "$build_path"] %> &&
50
54
  (
51
55
  <%= indent 4, (prepare.empty? ? "true" : prepare) %>
52
- )
56
+ ) &&
57
+ echo "-----> Deploy finished"
53
58
  ) &&
54
59
 
55
60
  #
56
- # Rename to the real release path, then symlink 'current'
61
+ # Build
57
62
  (
58
- echo "-----> Build finished"
63
+ echo "-----> Building"
59
64
  echo "-----> Moving build to $release_path"
60
65
  <%= echo_cmd %[mv "$build_path" "$release_path"] %> &&
66
+ <%= echo_cmd %[cd "$release_path"] %> &&
67
+ (
68
+ <%= indent 4, (build.empty? ? "true" : build) %>
69
+ ) &&
70
+ echo "-----> Build finished"
61
71
 
72
+ ) &&
73
+
74
+ #
75
+ # Launching
76
+ # Rename to the real release path, then symlink 'current'
77
+ (
78
+ echo "-----> Launching"
62
79
  echo "-----> Updating the <%= current_path %> symlink" &&
63
80
  <%= echo_cmd %[ln -nfs "$release_path" "#{current_path}"] %>
64
81
  ) &&
data/lib/mina/foreman.rb CHANGED
@@ -43,12 +43,13 @@ set_default :foreman_log, lambda { "#{deploy_to!}/#{shared_path}/log" }
43
43
  set_default :foreman_sudo, true
44
44
  set_default :foreman_format, 'upstart'
45
45
  set_default :foreman_location, '/etc/init'
46
+ set_default :foreman_procfile, 'Procfile'
46
47
 
47
48
  namespace :foreman do
48
49
  desc 'Export the Procfile to Ubuntu upstart scripts'
49
50
  task :export do
50
51
  sudo_cmd = "sudo" if foreman_sudo
51
- export_cmd = "#{sudo_cmd} bundle exec foreman export #{foreman_format} #{foreman_location} -a #{foreman_app} -u #{foreman_user} -d #{deploy_to!}/#{current_path!} -l #{foreman_log}"
52
+ export_cmd = "#{sudo_cmd} bundle exec foreman export #{foreman_format} #{foreman_location} -a #{foreman_app} -u #{foreman_user} -d #{deploy_to!}/#{current_path!} -l #{foreman_log} -f #{foreman_procfile}"
52
53
 
53
54
  queue %{
54
55
  echo "-----> Exporting foreman procfile for #{foreman_app}"
data/lib/mina/git.rb CHANGED
@@ -52,6 +52,7 @@ namespace :git do
52
52
  status = %[
53
53
  echo "-----> Using this git commit" &&
54
54
  echo &&
55
+ #{echo_cmd %[git rev-parse HEAD > .mina_git_revision]} &&
55
56
  #{echo_cmd %[git --no-pager log --format='%aN (%h):%n> %s' -n 1]} &&
56
57
  #{echo_cmd %[rm -rf .git]} &&
57
58
  echo
@@ -59,4 +60,10 @@ namespace :git do
59
60
 
60
61
  queue clone + status
61
62
  end
63
+
64
+ # ### git:revision
65
+ # Gets the current git revision deployed on server.
66
+ task :revision do
67
+ queue %[cat #{deploy_to}/current/.mina_git_revision]
68
+ end
62
69
  end
data/lib/mina/helpers.rb CHANGED
@@ -125,7 +125,7 @@ module Mina
125
125
  # die 2
126
126
  # die 2, "Tests failed"
127
127
 
128
- def die(code=1, msg=null)
128
+ def die(msg=nil, code=1)
129
129
  str = "Failed with status #{code}"
130
130
  str += " (#{msg})" if msg
131
131
  err = Failed.new(str)
@@ -19,15 +19,12 @@ module Mina
19
19
  # local("ls", return: true)
20
20
 
21
21
  def local(cmd, options = {})
22
- require 'shellwords'
23
-
24
- cmd = cmd.join("\n") if cmd.is_a?(Array)
25
- script = Shellwords.escape(cmd)
22
+ script = cmd.join("\n") if cmd.is_a?(Array)
26
23
 
27
24
  if options[:return] == true
28
25
  `#{script}`
29
26
  elsif simulate_mode?
30
- Local.simulate(cmd)
27
+ Local.simulate(script)
31
28
  else
32
29
  result = Local.invoke(script, self)
33
30
  Local.ensure_successful result, self
@@ -64,16 +61,18 @@ module Mina
64
61
  code = "#{script}"
65
62
 
66
63
  # Certain environments can't do :pretty mode.
67
- term_mode = :exec if term_mode == :pretty && !pretty_supported?
64
+ term_mode = :exec if term_mode == :pretty && !pretty_supported?
68
65
 
69
66
  case term_mode
70
67
  when :pretty
68
+ require 'shellwords'
69
+ code = Shellwords.escape(code)
71
70
  this.pretty_system(code)
72
71
  when :exec
73
- exec code
72
+ Kernel.exec code
74
73
  else
75
- system code
76
- $?.to_i
74
+ Kernel.system code
75
+ $?.exitstatus
77
76
  end
78
77
  end
79
78
 
data/lib/mina/npm.rb CHANGED
@@ -77,8 +77,8 @@ namespace :bower do
77
77
  end
78
78
 
79
79
  namespace :grunt do
80
- # ### bower:install
81
- # Installs bower modules. Takes into account if executed `in_directory` and namespaces the installed modules in the shared folder.
80
+ # ### grunt:install
81
+ # Launch a task with grunt. Set the grunt_task (defaults to \"build\") variable before calling this.
82
82
  desc "Launch a task with grunt. Set the grunt_task (defaults to \"build\") variable before calling this."
83
83
  task :task => :environment do
84
84
  queue %{
data/lib/mina/rails.rb CHANGED
@@ -52,6 +52,16 @@ set_default :rails, lambda { %{#{bundle_prefix} rails} }
52
52
 
53
53
  set_default :asset_paths, ['vendor/assets/', 'app/assets/']
54
54
 
55
+ # ### compiled_asset_path
56
+ # The path to be copied to the new release.
57
+ #
58
+ # The path your assets are compiled to. If your `assets_path` assets have changed,
59
+ # this is the folder that gets copied accross from the current release to the new release.
60
+ #
61
+ # Override this if you have custom public asset paths.
62
+
63
+ set_default :compiled_asset_path, 'public/assets'
64
+
55
65
  # ### rake_assets_precompile
56
66
  # The command to invoke when precompiling assets.
57
67
  # Override me if you like.
@@ -75,7 +85,7 @@ make_run_task = lambda { |name, sample_args|
75
85
 
76
86
  def check_for_changes_script(options={})
77
87
  diffs = options[:at].map { |path|
78
- %[diff -r "#{deploy_to}/#{current_path}/#{path}" "./#{path}" 2>/dev/null]
88
+ %[diff -rN "#{deploy_to}/#{current_path}/#{path}" "./#{path}" 2>/dev/null]
79
89
  }.join("\n")
80
90
 
81
91
  unindent %[
@@ -125,6 +135,13 @@ task :console => :environment do
125
135
  queue echo_cmd %[cd "#{deploy_to!}/#{current_path!}" && #{rails} console && exit]
126
136
  end
127
137
 
138
+ # ### log
139
+ # Tail log from server
140
+ desc "Tail log from server"
141
+ task :log => :environment do
142
+ queue %[tail -f #{deploy_to}/#{current_path}/log/#{rails_env}.log]
143
+ end
144
+
128
145
  # ## Deploy tasks
129
146
  # These tasks are meant to be invoked inside deploy scripts, not invoked on
130
147
  # their own.
@@ -166,6 +183,15 @@ namespace :rails do
166
183
  }
167
184
  end
168
185
 
186
+ # ### rails:db_create
187
+ desc "Creates the Rails database."
188
+ task :'db_create' do
189
+ queue %{
190
+ echo "-----> Creating database"
191
+ #{echo_cmd %[#{rake} db:create]}
192
+ }
193
+ end
194
+
169
195
  # ### rails:db_rollback
170
196
  desc "Rollbacks the Rails database."
171
197
  task :'db_rollback' do
@@ -195,11 +221,12 @@ namespace :rails do
195
221
  'Precompiling asset files'
196
222
 
197
223
  queue check_for_changes_script \
198
- :check => 'public/assets/',
224
+ :check => compiled_asset_path,
199
225
  :at => [*asset_paths],
200
226
  :skip => %[
201
227
  echo "-----> Skipping asset precompilation"
202
- #{echo_cmd %[cp -R "#{deploy_to}/#{current_path}/public/assets" "./public"]}
228
+ #{echo_cmd %[mkdir -p "#{deploy_to}/$build_path/#{compiled_asset_path}"]}
229
+ #{echo_cmd %[cp -R "#{deploy_to}/#{current_path}/#{compiled_asset_path}/." "#{deploy_to}/$build_path/#{compiled_asset_path}"]}
203
230
  ],
204
231
  :changed => %[
205
232
  echo "-----> #{message}"
data/lib/mina/ry.rb ADDED
@@ -0,0 +1,55 @@
1
+ # # Modules: ry
2
+ # Adds settings and tasks for managing [ry] installations.
3
+ #
4
+ # [ry]: https://github.com/jneen/ry
5
+ #
6
+ # require 'mina/ry'
7
+ #
8
+ # ## Common usage
9
+ #
10
+ # task :environment do
11
+ # invoke :'ry[ruby-1.9.3-p392]'
12
+ # # or without parameter to use default ruby version
13
+ # invoke :'ry'
14
+ # end
15
+ #
16
+ # task :deploy => :environment do
17
+ # ...
18
+ # end
19
+
20
+ # ## Settings
21
+ # Any and all of these settings can be overriden in your `deploy.rb`.
22
+
23
+ # ### ry_path
24
+ # Path where *ry* init scripts are installed.
25
+ #
26
+ set_default :ry_path, "$HOME/.local"
27
+
28
+ # ## Tasks
29
+
30
+ # ### ry[version]
31
+ # Switch to given Ruby version
32
+
33
+ task :ry, :env do |t, args|
34
+ unless args[:env]
35
+ print_status "Task 'ry' without argument will use default Ruby version."
36
+ end
37
+
38
+ queue %{
39
+ echo "-----> ry to version: '#{args[:env] || '**not specified**'}'"
40
+
41
+ echo "-----> Loading ry"
42
+ if [[ ! -e "#{ry_path}/bin" ]]; then
43
+ echo "! ry not found"
44
+ echo "! If ry is installed, check your :ry_path setting."
45
+ exit 1
46
+ fi
47
+ #{echo_cmd %{export PATH="#{ry_path}/bin:$PATH"}}
48
+ #{echo_cmd %{eval "$(ry setup)"}}
49
+
50
+ RY_RUBY="#{args[:env]}"
51
+ if [ -n "$RY_RUBY" ]; then
52
+ #{echo_cmd %{ry use $RY_RUBY}} || exit 1
53
+ fi
54
+ }
55
+ end
@@ -54,6 +54,7 @@ module Mina
54
54
  args << " -p #{port}" if port?
55
55
  args << " -A" if forward_agent?
56
56
  args << " #{ssh_options}" if ssh_options?
57
+ args << " -o StrictHostKeyChecking=no"
57
58
  args << " -t"
58
59
  "ssh #{args}"
59
60
  end
data/lib/mina/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Mina
2
2
  def self.version
3
- "0.3.4"
3
+ "0.3.6"
4
4
  end
5
5
  end
data/lib/mina/whenever.rb CHANGED
@@ -10,26 +10,28 @@
10
10
  # task :deploy => :environment do
11
11
  # deploy do
12
12
  # ...
13
- # invoke :'whenever:update'
13
+ # to :launch do
14
+ # invoke :'whenever:update'
15
+ # end
14
16
  # end
15
17
 
16
18
  namespace :whenever do
17
19
  desc "Clear crontab"
18
- task :clear do
20
+ task :clear => :environment do
19
21
  queue %{
20
22
  echo "-----> Clear crontab for #{domain}_#{rails_env}"
21
23
  #{echo_cmd %[cd #{deploy_to!}/#{current_path!} ; #{bundle_bin} exec whenever --clear-crontab #{domain}_#{rails_env} --set 'environment=#{rails_env}&path=#{deploy_to!}/#{current_path!}']}
22
24
  }
23
25
  end
24
26
  desc "Update crontab"
25
- task :update do
27
+ task :update => :environment do
26
28
  queue %{
27
29
  echo "-----> Update crontab for #{domain}_#{rails_env}"
28
30
  #{echo_cmd %[cd #{deploy_to!}/#{current_path!} ; #{bundle_bin} exec whenever --update-crontab #{domain}_#{rails_env} --set 'environment=#{rails_env}&path=#{deploy_to!}/#{current_path!}']}
29
31
  }
30
32
  end
31
33
  desc "Write crontab"
32
- task :write do
34
+ task :write => :environment do
33
35
  queue %{
34
36
  echo "-----> Update crontab for #{domain}_#{rails_env}"
35
37
  #{echo_cmd %[cd #{deploy_to!}/#{current_path!} ; #{bundle_bin} exec whenever --write-crontab #{domain}_#{rails_env} --set 'environment=#{rails_env}&path=#{deploy_to!}/#{current_path!}']}
@@ -29,6 +29,10 @@ describe "Invoking the 'mina' command in a project" do
29
29
  expect(stdout).to include "bundle exec rake db:migrate"
30
30
  end
31
31
 
32
+ it "should include 'to :build' directives" do
33
+ stdout.should include "touch build.txt"
34
+ end
35
+
32
36
  it "should include 'to :launch' directives" do
33
37
  expect(stdout).to include "touch tmp/restart.txt"
34
38
  end
@@ -30,6 +30,7 @@ describe "Invoking the 'mina' command in a project", :ssh => true do
30
30
  print "[deploy 1]" if ENV['verbose']
31
31
  mina 'deploy', '--verbose'
32
32
  expect(stdout).to include "-----> Creating a temporary build path"
33
+ expect(stdout).to include "git rev-parse HEAD > .mina_git_revision"
33
34
  expect(stdout).to include "rm -rf .git"
34
35
  expect(stdout).to include "mkdir -p"
35
36
  expect(File.exists?('deploy/last_version')).to be_truthy
@@ -41,6 +42,7 @@ describe "Invoking the 'mina' command in a project", :ssh => true do
41
42
  expect(File.exists?('deploy/current')).to be_truthy
42
43
  expect(File.read('deploy/last_version').strip).to eq('1')
43
44
  expect(File.exists?('deploy/current/tmp/restart.txt')).to be_truthy
45
+ expect(File.exists?('deploy/current/.mina_git_revision')).to be_truthy
44
46
 
45
47
  # And again, to test out sequential versions and stuff
46
48
  print "[deploy 2]" if ENV['verbose']
@@ -49,5 +51,6 @@ describe "Invoking the 'mina' command in a project", :ssh => true do
49
51
  expect(stdout).not_to include "mkdir -p"
50
52
  expect(File.directory?('deploy/releases/2')).to be_truthy
51
53
  expect(File.read('deploy/last_version').strip).to eq('2')
54
+ expect(File.exists?('deploy/current/.mina_git_revision')).to be_truthy
52
55
  end
53
56
  end
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mina::LocalHelpers::Local do
4
+ describe '.invoke' do
5
+ let :scope do
6
+ double("rake_application").tap do |scope|
7
+ allow(scope).to receive(:settings).and_return(settings)
8
+ end
9
+ end
10
+
11
+ let(:settings) { OpenStruct.new }
12
+
13
+ it 'uses the pretty system with shell-escaped command when term_mode is set to :pretty and pretty is supported' do
14
+ settings.term_mode = :pretty
15
+ cmd = %[echo "hello"]
16
+
17
+ allow(described_class).to receive(:pretty_supported?).and_return(true)
18
+ expect(scope).to receive(:pretty_system).with(Shellwords.escape(cmd)).and_return(0)
19
+
20
+ described_class.invoke(cmd, scope)
21
+ end
22
+
23
+ it 'does NOT use the pretty system when term_mode is set to :pretty and pretty is NOT supported' do
24
+ settings.term_mode = :pretty
25
+ cmd = %[echo "hello"]
26
+
27
+ allow(described_class).to receive(:pretty_supported?).and_return(false)
28
+ expect(scope).not_to receive(:pretty_system)
29
+ expect(Kernel).to receive(:exec).and_return(0)
30
+
31
+ described_class.invoke(cmd, scope)
32
+ end
33
+
34
+ it 'returns the sub-shell exit status when using the pretty system' do
35
+ settings.term_mode = :pretty
36
+
37
+ allow(described_class).to receive(:pretty_supported?).and_return(true)
38
+ allow(scope).to receive(:pretty_system).with("return0").and_return(0)
39
+ allow(scope).to receive(:pretty_system).with("return13").and_return(13)
40
+
41
+ expect(described_class.invoke("return0", scope)).to eq 0
42
+ expect(described_class.invoke("return13", scope)).to eq 13
43
+ end
44
+
45
+ it 'calls Kernel.exec with non shell-escaped command when term_mode is :exec' do
46
+ settings.term_mode = :exec
47
+ cmd = %[echo "hello"]
48
+
49
+ expect(Kernel).to receive(:exec).with(cmd).and_return(0)
50
+
51
+ described_class.invoke(cmd, scope)
52
+ end
53
+
54
+ it 'calls Kernel.system with non shell-escaped command when term_mode is not :pretty nor :exec' do
55
+ settings.term_mode = nil
56
+ cmd = %[echo "hello"]
57
+
58
+ expect(Kernel).to receive(:system).with(cmd).and_return("hello\n")
59
+
60
+ described_class.invoke(cmd, scope)
61
+ end
62
+
63
+ it 'returns the sub-shell exit status when using Kernel.system' do
64
+ settings.term_mode = nil
65
+
66
+ expect(described_class.invoke(%[/bin/sh -c 'exit 0'], scope)).to eq 0
67
+ expect(described_class.invoke(%[/bin/sh -c 'exit 13'], scope)).to eq 13
68
+ end
69
+ end
70
+ end
@@ -13,4 +13,4 @@ session per deploy, minimizing the SSH connection overhead.
13
13
  $ gem install mina
14
14
  $ mina
15
15
 
16
- [![Build Status](https://travis-ci.org/mina-deploy/mina.svg?branch=master)](https://travis-ci.org/mina-deploy/mina) [![Gem Version](https://badge.fury.io/rb/mina.svg)](http://badge.fury.io/rb/mina)
16
+ [![Build Status](https://travis-ci.org/mina-deploy/mina.svg?branch=master)](https://travis-ci.org/mina-deploy/mina) [![Gem Version](https://badge.fury.io/rb/mina.svg)](http://badge.fury.io/rb/mina) [![Inline docs](http://inch-ci.org/github/mina-deploy/mina.svg?branch=master)](http://inch-ci.org/github/mina-deploy/mina)
@@ -49,6 +49,9 @@ task :deploy => :environment do
49
49
  invoke :'rails:db_migrate'
50
50
  end
51
51
 
52
+ to :build do
53
+ queue "touch build.txt"
54
+ end
52
55
  to :launch do
53
56
  invoke :'passenger:restart'
54
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rico Sta. Cruz
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-27 00:00:00.000000000 Z
12
+ date: 2015-07-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -107,6 +107,7 @@ files:
107
107
  - lib/mina/rake.rb
108
108
  - lib/mina/rbenv.rb
109
109
  - lib/mina/rvm.rb
110
+ - lib/mina/ry.rb
110
111
  - lib/mina/settings.rb
111
112
  - lib/mina/ssh_helpers.rb
112
113
  - lib/mina/tools.rb
@@ -132,6 +133,7 @@ files:
132
133
  - spec/fixtures/custom_file_env/custom_deploy.rb
133
134
  - spec/fixtures/empty_env/config/deploy.rb
134
135
  - spec/helpers/exec_helper_spec.rb
136
+ - spec/helpers/local_helper_spec.rb
135
137
  - spec/helpers/output_helper_spec.rb
136
138
  - spec/spec_helper.rb
137
139
  - support/Readme-footer.md
@@ -160,8 +162,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
162
  version: '0'
161
163
  requirements: []
162
164
  rubyforge_project:
163
- rubygems_version: 2.2.2
165
+ rubygems_version: 2.4.5
164
166
  signing_key:
165
167
  specification_version: 4
166
168
  summary: Really fast deployer and server automation tool.
167
169
  test_files: []
170
+ has_rdoc: