mina 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/.gitignore +2 -0
  2. data/.travis.yml +14 -5
  3. data/HISTORY.md +45 -1
  4. data/LICENSE +1 -1
  5. data/Makefile +29 -0
  6. data/Notes.md +70 -0
  7. data/Readme.md +1009 -0
  8. data/bin/mina +1 -1
  9. data/data/deploy.rb +13 -7
  10. data/lib/mina/bundler.rb +6 -1
  11. data/lib/mina/chruby.rb +49 -0
  12. data/lib/mina/default.rb +1 -0
  13. data/lib/mina/deploy.rb +17 -1
  14. data/lib/mina/deploy_helpers.rb +4 -4
  15. data/lib/mina/exec_helpers.rb +26 -19
  16. data/lib/mina/foreman.rb +5 -1
  17. data/lib/mina/git.rb +1 -1
  18. data/lib/mina/helpers.rb +22 -13
  19. data/lib/mina/rails.rb +6 -6
  20. data/lib/mina/rbenv.rb +1 -0
  21. data/lib/mina/rvm.rb +2 -4
  22. data/lib/mina/ssh_helpers.rb +2 -1
  23. data/lib/mina/version.rb +1 -1
  24. data/lib/mina/whenever.rb +6 -6
  25. data/mina.gemspec +2 -2
  26. data/spec/command_helper.rb +1 -1
  27. data/spec/commands/cleanup_spec.rb +16 -0
  28. data/spec/commands/command_spec.rb +18 -18
  29. data/spec/commands/custom_config_spec.rb +2 -2
  30. data/spec/commands/deploy_spec.rb +7 -7
  31. data/spec/commands/outside_project_spec.rb +7 -7
  32. data/spec/commands/real_deploy_spec.rb +21 -21
  33. data/spec/commands/verbose_spec.rb +2 -2
  34. data/spec/dsl/invoke_spec.rb +17 -2
  35. data/spec/dsl/queue_spec.rb +4 -4
  36. data/spec/dsl/settings_in_rake_spec.rb +6 -6
  37. data/spec/dsl/settings_spec.rb +16 -10
  38. data/spec/dsl/to_spec.rb +2 -2
  39. data/spec/helpers/exec_helper_spec.rb +19 -0
  40. data/spec/spec_helper.rb +6 -0
  41. data/support/Readme-footer.md +32 -0
  42. data/support/Readme-header.md +16 -0
  43. data/support/guide.md +297 -0
  44. data/support/index.html +53 -0
  45. data/support/to_md.rb +11 -0
  46. data/test_env/config/deploy.rb +2 -0
  47. metadata +96 -61
  48. checksums.yaml +0 -7
  49. data/README.md +0 -114
@@ -12,25 +12,25 @@ describe "Invoking the 'mina' command in a project" do
12
12
  end
13
13
 
14
14
  it "should take care of the lockfile" do
15
- stdout.should =~ /ERROR: another deployment is ongoing/
16
- stdout.should =~ /touch ".*deploy\.lock"/
17
- stdout.should =~ /rm -f ".*deploy\.lock"/
15
+ expect(stdout).to match(/ERROR: another deployment is ongoing/)
16
+ expect(stdout).to match(/touch ".*deploy\.lock"/)
17
+ expect(stdout).to match(/rm -f ".*deploy\.lock"/)
18
18
  end
19
19
 
20
20
  it "should honor releases_path" do
21
- stdout.should include "releases/"
21
+ expect(stdout).to include "releases/"
22
22
  end
23
23
 
24
24
  it "should symlink the current_path" do
25
- stdout.should =~ /ln .*current/
25
+ expect(stdout).to match(/ln .*current/)
26
26
  end
27
27
 
28
28
  it "should include deploy directives" do
29
- stdout.should include "bundle exec rake db:migrate"
29
+ expect(stdout).to include "bundle exec rake db:migrate"
30
30
  end
31
31
 
32
32
  it "should include 'to :launch' directives" do
33
- stdout.should include "touch tmp/restart.txt"
33
+ expect(stdout).to include "touch tmp/restart.txt"
34
34
  end
35
35
  end
36
36
  end
@@ -12,22 +12,22 @@ describe "Invoking the 'mina' command outside a project" do
12
12
  end
13
13
 
14
14
  it 'should print standard help tasks' do
15
- stdout.should include('mina help')
16
- stdout.should include('mina init')
17
- stdout.should include('mina tasks')
15
+ expect(stdout).to include('mina help')
16
+ expect(stdout).to include('mina init')
17
+ expect(stdout).to include('mina tasks')
18
18
  end
19
19
 
20
20
  it "should not print project-specific tasks" do
21
- stdout.should_not include('mina deploy')
22
- stdout.should_not include('mina restart')
23
- stdout.should_not include('mina setup')
21
+ expect(stdout).not_to include('mina deploy')
22
+ expect(stdout).not_to include('mina restart')
23
+ expect(stdout).not_to include('mina setup')
24
24
  end
25
25
 
26
26
  %w[-h --help].each do |arg|
27
27
  it "should have the same output as 'mina #{arg}'" do
28
28
  @previous_output = stdout
29
29
  mina arg
30
- stdout.should == @previous_output
30
+ expect(stdout).to eq(@previous_output)
31
31
  end
32
32
  end
33
33
  end
@@ -21,33 +21,33 @@ describe "Invoking the 'mina' command in a project", :ssh => true do
21
21
  it 'should set up and deploy fine' do
22
22
  print "[setup]" if ENV['verbose']
23
23
  mina 'setup', '--verbose'
24
- File.directory?('deploy').should be_true
25
- File.directory?('deploy/releases').should be_true
26
- File.directory?('deploy/shared').should be_true
27
- File.exists?('deploy/last_version').should be_false
28
- File.exists?('deploy/deploy.lock').should be_false
24
+ expect(File.directory?('deploy')).to be_truthy
25
+ expect(File.directory?('deploy/releases')).to be_truthy
26
+ expect(File.directory?('deploy/shared')).to be_truthy
27
+ expect(File.exists?('deploy/last_version')).to be_falsey
28
+ expect(File.exists?('deploy/deploy.lock')).to be_falsey
29
29
 
30
30
  print "[deploy 1]" if ENV['verbose']
31
31
  mina 'deploy', '--verbose'
32
- stdout.should include "-----> Creating a temporary build path"
33
- stdout.should include "rm -rf .git"
34
- stdout.should include "mkdir -p"
35
- File.exists?('deploy/last_version').should be_true
36
- File.exists?('deploy/deploy.lock').should be_false
37
- File.directory?('deploy/releases').should be_true
38
- File.directory?('deploy/releases/1').should be_true
39
- File.exists?('deploy/releases/1/README.md').should be_true
40
- File.directory?('deploy/releases/2').should be_false
41
- File.exists?('deploy/current').should be_true
42
- File.read('deploy/last_version').strip.should == '1'
43
- File.exists?('deploy/current/tmp/restart.txt').should be_true
32
+ expect(stdout).to include "-----> Creating a temporary build path"
33
+ expect(stdout).to include "rm -rf .git"
34
+ expect(stdout).to include "mkdir -p"
35
+ expect(File.exists?('deploy/last_version')).to be_truthy
36
+ expect(File.exists?('deploy/deploy.lock')).to be_falsey
37
+ expect(File.directory?('deploy/releases')).to be_truthy
38
+ expect(File.directory?('deploy/releases/1')).to be_truthy
39
+ expect(File.exists?('deploy/releases/1/README.md')).to be_truthy
40
+ expect(File.directory?('deploy/releases/2')).to be_falsey
41
+ expect(File.exists?('deploy/current')).to be_truthy
42
+ expect(File.read('deploy/last_version').strip).to eq('1')
43
+ expect(File.exists?('deploy/current/tmp/restart.txt')).to be_truthy
44
44
 
45
45
  # And again, to test out sequential versions and stuff
46
46
  print "[deploy 2]" if ENV['verbose']
47
47
  mina 'deploy'
48
- stdout.should_not include "rm -rf .git"
49
- stdout.should_not include "mkdir -p"
50
- File.directory?('deploy/releases/2').should be_true
51
- File.read('deploy/last_version').strip.should == '2'
48
+ expect(stdout).not_to include "rm -rf .git"
49
+ expect(stdout).not_to include "mkdir -p"
50
+ expect(File.directory?('deploy/releases/2')).to be_truthy
51
+ expect(File.read('deploy/last_version').strip).to eq('2')
52
52
  end
53
53
  end
@@ -10,12 +10,12 @@ describe "Invoking the 'mina' command in a project" do
10
10
  it 'should echo commands in verbose mode' do
11
11
  mina 'deploy', '--verbose', '--simulate'
12
12
 
13
- stdout.should include %[echo #{Shellwords.escape('$ git')}]
13
+ expect(stdout).to include %[echo #{Shellwords.escape('$ git')}]
14
14
  end
15
15
 
16
16
  it 'should not echo commands when not in verbose mode' do
17
17
  mina 'deploy', '--simulate'
18
18
 
19
- stdout.should_not include %[echo #{Shellwords.escape('$ git')}]
19
+ expect(stdout).not_to include %[echo #{Shellwords.escape('$ git')}]
20
20
  end
21
21
  end
@@ -13,7 +13,7 @@ describe 'Mina' do
13
13
  rake { invoke :clone }
14
14
  }
15
15
 
16
- rake.commands.should == ['git clone']
16
+ expect(rake.commands).to eq(['git clone'])
17
17
  end
18
18
 
19
19
  it '#invoke should work with :reenable option' do
@@ -28,6 +28,21 @@ describe 'Mina' do
28
28
  rake { invoke :pull, :reenable => true }
29
29
  }
30
30
 
31
- rake.commands.should == ['git pull', 'git pull']
31
+ expect(rake.commands).to eq(['git pull', 'git pull'])
32
+ end
33
+
34
+ it '#invoke with task arguments should work with :reenable option' do
35
+
36
+ rake {
37
+ task :hello, [:world] do |t, args|
38
+ queue "echo Hello #{args[:world]}"
39
+ end
40
+ }
41
+
42
+ %w(World Pirate).each { |name|
43
+ rake { invoke :"hello[#{name}]", :reenable => true }
44
+ }
45
+
46
+ expect(rake.commands).to eq(['echo Hello World', 'echo Hello Pirate'])
32
47
  end
33
48
  end
@@ -8,7 +8,7 @@ describe 'Mina' do
8
8
  end
9
9
  invoke :hello
10
10
  }
11
- rake.instance_variable_get(:@hello).should == 'world'
11
+ expect(rake.instance_variable_get(:@hello)).to eq('world')
12
12
  end
13
13
 
14
14
  it '#queue should work' do
@@ -16,7 +16,7 @@ describe 'Mina' do
16
16
  queue 'sudo service nginx restart'
17
17
  }
18
18
 
19
- rake.commands.should == ['sudo service nginx restart']
19
+ expect(rake.commands).to eq(['sudo service nginx restart'])
20
20
  end
21
21
 
22
22
  it '#queue should work with multiple commands' do
@@ -25,7 +25,7 @@ describe 'Mina' do
25
25
  queue 'sudo service nginx restart'
26
26
  }
27
27
 
28
- rake.commands.should == ['echo Restarting', 'sudo service nginx restart']
28
+ expect(rake.commands).to eq(['echo Restarting', 'sudo service nginx restart'])
29
29
  end
30
30
 
31
31
  it '#queue should work inside tasks' do
@@ -44,6 +44,6 @@ describe 'Mina' do
44
44
 
45
45
  rake { invoke :restart }
46
46
 
47
- rake.commands.should == ['echo Restarting', 'touch tmp/restart.txt']
47
+ expect(rake.commands).to eq(['echo Restarting', 'touch tmp/restart.txt'])
48
48
  end
49
49
  end
@@ -4,8 +4,8 @@ describe 'Settings in rake tasks' do
4
4
  it '#set should work' do
5
5
  rake { set :domain, 'localhost' }
6
6
 
7
- rake.domain.should == 'localhost'
8
- rake.settings.domain.should == 'localhost'
7
+ expect(rake.domain).to eq('localhost')
8
+ expect(rake.settings.domain).to eq('localhost')
9
9
  end
10
10
 
11
11
  it '#settings ||= should work' do
@@ -14,8 +14,8 @@ describe 'Settings in rake tasks' do
14
14
  settings.version ||= '3'
15
15
  }
16
16
 
17
- rake.settings.version.should == '2'
18
- rake.version.should == '2'
17
+ expect(rake.settings.version).to eq('2')
18
+ expect(rake.version).to eq('2')
19
19
  end
20
20
 
21
21
  it '#settings with lambdas should work' do
@@ -24,8 +24,8 @@ describe 'Settings in rake tasks' do
24
24
  set :path, lambda { "/var/www/#{version}" }
25
25
  }
26
26
 
27
- rake.path.should == "/var/www/42"
28
- rake.path?.should be_true
27
+ expect(rake.path).to eq("/var/www/42")
28
+ expect(rake.path?).to be_truthy
29
29
  end
30
30
 
31
31
  it '#settings with a bang should work' do
@@ -8,38 +8,43 @@ describe 'Settings' do
8
8
 
9
9
  it 'setting/getting should work' do
10
10
  @settings.domain = '192.168.1.1'
11
- @settings.domain.should == '192.168.1.1'
11
+
12
+ expect(@settings.domain).to eq('192.168.1.1')
12
13
  end
13
14
 
14
15
  it 'question mark should work' do
15
16
  @settings.deploy_to = '/var/www/there'
16
- @settings.deploy_to?.should be_true
17
- @settings.foobar?.should be_false
17
+
18
+ expect(@settings.deploy_to?).to be_truthy
19
+ expect(@settings.foobar?).to be_falsey
18
20
  end
19
21
 
20
22
  it 'question mark should work with nils' do
21
23
  @settings.deploy_to = nil
22
- @settings.deploy_to?.should be_true
23
- @settings.foobar?.should be_false
24
+
25
+ expect(@settings.deploy_to?).to be_truthy
26
+ expect(@settings.foobar?).to be_falsey
24
27
  end
25
28
 
26
29
  it '||= should work (1)' do
27
30
  @settings.x = 2
28
31
  @settings.x ||= 3
29
- @settings.x.should == 2
32
+
33
+ expect(@settings.x).to eq(2)
30
34
  end
31
35
 
32
36
  it '||= should work (2)' do
33
37
  @settings.x ||= 3
34
- @settings.x.should == 3
38
+
39
+ expect(@settings.x).to eq(3)
35
40
  end
36
41
 
37
42
  it 'lambdas should work' do
38
43
  @settings.path = lambda { "/var/www/#{@settings.version}" }
39
44
  @settings.version = '3'
40
45
 
41
- @settings.path?.should be_true
42
- @settings.path.should == "/var/www/3"
46
+ expect(@settings.path?).to be_truthy
47
+ expect(@settings.path).to eq("/var/www/3")
43
48
  end
44
49
 
45
50
  it 'bangs should check for settings' do
@@ -48,7 +53,8 @@ describe 'Settings' do
48
53
 
49
54
  it 'bangs should return settings' do
50
55
  @settings.version = 4
51
- @settings.version!.should == 4
56
+
57
+ expect(@settings.version!).to eq(4)
52
58
  end
53
59
  end
54
60
  end
data/spec/dsl/to_spec.rb CHANGED
@@ -14,7 +14,7 @@ describe 'Mina' do
14
14
 
15
15
  rake { invoke :deploy }
16
16
 
17
- rake.commands.should == ['git clone']
18
- rake.commands(:restart).should == ['touch tmp/restart.txt']
17
+ expect(rake.commands).to eq(['git clone'])
18
+ expect(rake.commands(:restart)).to eq(['touch tmp/restart.txt'])
19
19
  end
20
20
  end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Exec Helpers' do
4
+ before :each do
5
+ @exec = Object.new
6
+ @exec.send :extend, Mina::ExecHelpers
7
+
8
+ allow(@exec).to receive(:print_char)
9
+ end
10
+
11
+ it 'pretty_system' do
12
+ @exec.pretty_system "echo 'Hello there'"
13
+
14
+ expect(@exec).to have_received(:print_char).
15
+ with("e").with("r").with("e").with("h").with("t").
16
+ with(" ").
17
+ with("o").with("l").with("l").with("e").with("H")
18
+ end
19
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  require 'mina'
2
2
  require 'rake'
3
3
 
4
+ RSpec.configure do |config|
5
+ config.order = 'random'
6
+ config.seed = '12345'
7
+ end
8
+
4
9
  class RakeScope
5
10
  include Rake::DSL if Rake.const_defined?(:DSL)
6
11
  include Mina::Helpers
@@ -19,3 +24,4 @@ end
19
24
  def root(*a)
20
25
  File.join File.expand_path('../../', __FILE__), *a
21
26
  end
27
+
@@ -0,0 +1,32 @@
1
+
2
+ Acknowledgements
3
+ ----------------
4
+
5
+ © 2012-2014, Nadarei. Released under the [MIT
6
+ License](http://www.opensource.org/licenses/mit-license.php).
7
+
8
+ Mina is authored and maintained by [Rico Sta. Cruz][rsc] and [Michael
9
+ Galero][mg] with help from its [contributors][c]. It is sponsored by our
10
+ startup, [Nadarei][nd].
11
+
12
+ * [Nadarei](http://nadarei.co) (nadarei.co)
13
+ * [Github](http://github.com/nadarei) (@nadarei)
14
+
15
+ Rico:
16
+
17
+ * [My website](http://ricostacruz.com) (ricostacruz.com)
18
+ * [Github](http://github.com/rstacruz) (@rstacruz)
19
+ * [Twitter](http://twitter.com/rstacruz) (@rstacruz)
20
+
21
+ Michael:
22
+
23
+ * [My website][mg] (michaelgalero.com)
24
+ * [Github](http://github.com/mikong) (@mikong)
25
+
26
+ [rsc]: http://ricostacruz.com
27
+ [mg]: http://devblog.michaelgalero.com/
28
+ [c]: http://github.com/nadarei/mina/contributors
29
+ [nd]: http://nadarei.co
30
+ [issues]: https://github.com/nadarei/mina/issues
31
+ [trello]: https://trello.com/board/mina/4fc8b3023d9c9a4d72e573e6
32
+
@@ -0,0 +1,16 @@
1
+ # Mina
2
+
3
+ Really fast deployer and server automation tool.
4
+
5
+ Mina works really fast because it's a deploy Bash script generator. It
6
+ generates an entire procedure as a Bash script and runs it remotely in the
7
+ server.
8
+
9
+ Compare this to the likes of Vlad or Capistrano, where each command
10
+ is run separately on their own SSH sessions. Mina only creates *one* SSH
11
+ session per deploy, minimizing the SSH connection overhead.
12
+
13
+ $ gem install mina
14
+ $ mina
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)