mina 1.0.0.beta2 → 1.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +384 -0
- data/Readme.md +3 -3
- data/data/deploy.rb +8 -6
- data/data/deploy.sh.erb +1 -1
- data/docs/3rd_party_plugins.md +2 -0
- data/docs/getting_started.md +22 -0
- data/docs/migrating.md +1 -1
- data/lib/mina.rb +3 -3
- data/lib/mina/application.rb +1 -0
- data/lib/mina/backend/remote.rb +6 -6
- data/lib/mina/commands.rb +4 -3
- data/lib/mina/configuration.rb +2 -1
- data/lib/mina/dsl.rb +8 -1
- data/lib/mina/helpers/internal.rb +8 -3
- data/lib/mina/helpers/output.rb +4 -0
- data/lib/mina/runner/pretty.rb +1 -1
- data/lib/mina/runner/printer.rb +1 -0
- data/lib/mina/version.rb +1 -1
- data/mina.gemspec +1 -1
- data/spec/lib/mina/application_spec.rb +35 -35
- data/spec/lib/mina/backend/local_spec.rb +1 -0
- data/spec/lib/mina/backend/remote_spec.rb +2 -0
- data/spec/lib/mina/commands_spec.rb +6 -7
- data/spec/lib/mina/configuration_spec.rb +1 -1
- data/spec/lib/mina/helpers/internal_spec.rb +3 -1
- data/spec/lib/mina/helpers/output_spec.rb +5 -20
- data/spec/lib/mina/runner_spec.rb +1 -4
- data/spec/spec_helper.rb +14 -3
- data/spec/support/outputs/bundle_clean.txt +2 -0
- data/spec/support/outputs/bundle_install.txt +2 -0
- data/spec/support/outputs/chruby.txt +9 -0
- data/spec/support/outputs/console.txt +1 -0
- data/spec/support/outputs/deploy_cleanup.txt +2 -0
- data/spec/support/outputs/deploy_force_unlock.txt +2 -0
- data/spec/support/outputs/deploy_link_shared_paths.txt +13 -0
- data/spec/support/outputs/git_clone.txt +1 -0
- data/spec/support/outputs/git_clone_commit.txt +1 -0
- data/spec/support/outputs/git_revision.txt +1 -0
- data/spec/support/outputs/log.txt +1 -0
- data/spec/support/outputs/rails_assets_precompile.txt +1 -0
- data/spec/support/outputs/rails_db_create.txt +2 -0
- data/spec/support/outputs/rails_db_migrate.txt +1 -0
- data/spec/support/outputs/rails_db_rollback.txt +2 -0
- data/spec/support/outputs/rbenv_load.txt +1 -0
- data/spec/support/outputs/rollback.txt +2 -0
- data/spec/support/outputs/run.txt +1 -0
- data/spec/support/outputs/rvm_use.txt +1 -0
- data/spec/support/outputs/ry.txt +15 -0
- data/spec/support/outputs/setup.txt +14 -0
- data/spec/support/outputs/ssh_keyscan.txt +3 -0
- data/spec/support/rake_example_group.rb +30 -0
- data/spec/tasks/bundler_spec.rb +15 -0
- data/spec/tasks/default_spec.rb +35 -0
- data/spec/tasks/deploy_spec.rb +33 -0
- data/spec/tasks/git_spec.rb +21 -0
- data/spec/tasks/init_spec.rb +16 -0
- data/spec/tasks/rails_spec.rb +45 -0
- data/spec/tasks/ruby_managers_spec.rb +33 -0
- data/tasks/mina/bundler.rb +5 -5
- data/tasks/mina/chruby.rb +8 -10
- data/tasks/mina/default.rb +5 -1
- data/tasks/mina/deploy.rb +33 -29
- data/tasks/mina/git.rb +20 -8
- data/tasks/mina/install.rb +1 -0
- data/tasks/mina/rails.rb +15 -15
- data/tasks/mina/rbenv.rb +6 -8
- data/tasks/mina/rvm.rb +16 -20
- data/tasks/mina/ry.rb +10 -14
- data/test_env/config/deploy.rb +5 -5
- metadata +35 -6
- data/spec/lib/mina_spec.rb +0 -7
- data/spec/support/run_helper.rb +0 -36
@@ -27,10 +27,7 @@ describe Mina::Runner do
|
|
27
27
|
it 'runs the commands on a backend' do
|
28
28
|
instance.set(:execution_mode, :printer)
|
29
29
|
runner = Mina::Runner.new(['ls -al'], :local)
|
30
|
-
|
31
|
-
runner.run
|
32
|
-
end
|
33
|
-
expect(out).to eq("\\[\\\"ls\\ -al\\\"\\]\n")
|
30
|
+
expect { runner.run }.to output("\\[\\\"ls\\ -al\\\"\\]\n").to_stdout
|
34
31
|
end
|
35
32
|
end
|
36
33
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -12,14 +12,25 @@ require 'rspec'
|
|
12
12
|
require 'pry'
|
13
13
|
|
14
14
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
15
|
+
Rake.application = Mina::Application.new
|
16
|
+
Dir["./tasks/mina/**/*.rb"].each { |f| require f }
|
15
17
|
|
16
18
|
RSpec.configure do |config|
|
17
|
-
config.include
|
19
|
+
config.include RakeExampleGroup, type: :rake
|
18
20
|
|
19
21
|
config.raise_errors_for_deprecations!
|
20
22
|
config.order = 'random'
|
21
23
|
|
22
|
-
config.
|
23
|
-
Mina::Configuration.instance.
|
24
|
+
config.before(:all, type: :rake) do
|
25
|
+
Mina::Configuration.instance.set :simulate, true
|
26
|
+
Mina::Configuration.instance.set :domain, 'localhost'
|
27
|
+
Mina::Configuration.instance.set :deploy_to, "#{Dir.pwd}/deploy"
|
28
|
+
Mina::Configuration.instance.set :repository, "#{Mina.root_path}"
|
29
|
+
Mina::Configuration.instance.set :shared_paths, ['config/database.yml', 'log']
|
30
|
+
Mina::Configuration.instance.set :keep_releases, 2
|
31
|
+
end
|
32
|
+
|
33
|
+
config.after(:all, type: :rake) do
|
34
|
+
Mina::Configuration.instance.remove :simulate
|
24
35
|
end
|
25
36
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
\(cd\ .*/deploy/current\ &&\ RAILS_ENV="production"\ bundle\ exec\ rails\ console\)
|
@@ -0,0 +1,2 @@
|
|
1
|
+
echo\ "\-\-\-\-\->\ Cleaning\ up\ old\ releases\ \(keeping\ 2\)"
|
2
|
+
\(cd\ .*/deploy/releases\ &&\ count=\$\(ls\ \-A1\ \|\ sort\ \-rn\ \|\ wc\ \-l\)\ &&\ remove=\$\(\(count\ >\ 2\ \?\ count\ \-\ 2\ :\ 0\)\)\ &&\ ls\ \-A1\ \|\ sort\ \-rn\ \|\ tail\ \-n\ \$remove\ \|\ xargs\ rm\ \-rf\ \{\}\)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
echo "-----> Symlinking shared paths"
|
2
|
+
mkdir -p ./vendor
|
3
|
+
rm -rf "./vendor/bundle"
|
4
|
+
ln -s ".*deploy/shared/vendor/bundle" "./vendor/bundle"
|
5
|
+
mkdir -p .
|
6
|
+
rm -rf "./log"
|
7
|
+
ln -s ".*deploy/shared/log" "./log"
|
8
|
+
mkdir -p ./tmp
|
9
|
+
rm -rf "./tmp/cache"
|
10
|
+
ln -s ".*deploy/shared/tmp/cache" "./tmp/cache"
|
11
|
+
mkdir -p ./public
|
12
|
+
rm -rf "./public/assets"
|
13
|
+
ln -s ".*deploy/shared/public/assets" "./public/assets"
|
@@ -0,0 +1 @@
|
|
1
|
+
if\ \[\ !\ \-d\ ".*/deploy/scm/objects"\ \];\ then\s*echo\ "\-\-\-\-\->\ Cloning\ the\ Git\ repository"\s*git\ clone\ ".*"\ ".*/deploy/scm"\ \-\-bare\s*else\s*echo\ "\-\-\-\-\->\ Fetching\ new\ git\ commits"\s*\(cd\ ".*/deploy/scm"\ &&\ git\ fetch\ ".*"\ "master:master"\ \-\-force\)\s*fi\ &&\s*echo\ "\-\-\-\-\->\ Using\ git\ branch\ 'master'"\ &&\s*git\ clone\ ".*/deploy/scm"\ \.\ \-\-recursive\ \-\-branch\ "master"\necho\ "\-\-\-\-\->\ Using\ this\ git\ commit"\ngit\ rev\-parse\ HEAD\ >\ \.mina_git_revision\ngit\ \-\-no\-pager\ log\ \-\-format="%aN\ \(%h\):%n>\ %s"\ \-n\ 1\nrm\ \-rf\ \.git
|
@@ -0,0 +1 @@
|
|
1
|
+
echo\ "\-\-\-\-\->\ Using\ git\ commit\ \\"123456\\""\ngit\ clone\ ".*"\ \.\ \-\-recursive\ngit\ checkout\ \-b\ current_release\ "123456"\ \-\-force\necho\ "\-\-\-\-\->\ Using\ this\ git\ commit"\ngit\ rev\-parse\ HEAD\ >\ \.mina_git_revision\ngit\ \-\-no\-pager\ log\ \-\-format="%aN\ \(%h\):%n>\ %s"\ \-n\ 1\nrm\ \-rf\ \.git
|
@@ -0,0 +1 @@
|
|
1
|
+
cat .*deploy/current/.mina_git_revision
|
@@ -0,0 +1 @@
|
|
1
|
+
\(cd\ .*deploy/shared/log\ &&\ tail\ \-f\ production\.log\)
|
@@ -0,0 +1 @@
|
|
1
|
+
if\ diff\ \-qrN\ ".*/deploy/current/vendor/assets/"\ "\./vendor/assets/"\ 2>/dev/null\ &&\ diff\ \-qrN\ ".*/deploy/current/app/assets/"\ "\./app/assets/"\ 2>/dev/null\s*then\s*echo\ "\-\-\-\-\->\ Skipping\ asset\ precompilation"\s*else\s*echo\ "\-\-\-\-\->\ Precompiling\ asset\ files"\s*RAILS_ENV="production"\ bundle\ exec\ rake\ assets:precompile\s*fi
|
@@ -0,0 +1 @@
|
|
1
|
+
if\ diff\ \-qrN\ ".*deploy/current/db/migrate"\ "\./db/migrate"\ 2>/dev/null\s*then\s*echo\ "\-\-\-\-\->\ DB\ migrations\ unchanged;\ skipping\ DB\ migration"\s*else\s*echo\ "\-\-\-\-\->\ Migrating\ database"\s*RAILS_ENV="production"\ bundle\ exec\ rake\ db:migrate\s*fi
|
@@ -0,0 +1 @@
|
|
1
|
+
echo\ "\-\-\-\-\->\ Loading\ rbenv"\nexport\ RBENV_ROOT="\$HOME/\.rbenv"\nexport\ PATH="\$HOME/\.rbenv/bin:\$PATH"\s*if\ !\ which\ rbenv\ >/dev/null;\ then\s*echo\ "!\ rbenv\ not\ found"\s*echo\ "!\ If\ rbenv\ is\ installed,\ check\ your\ :rbenv_path\ setting\."\s*exit\ 1\s*fi\s*eval\ "\$\(rbenv\ init\ \-\)"
|
@@ -0,0 +1,2 @@
|
|
1
|
+
echo\ "\-\-\-\-\->\ Rolling\ back\ to\ previous\ release"
|
2
|
+
\(cd\ .*/deploy/releases\ &&\ rollback_release=\$\(ls\ \-1A\ \|\ sort\ \-n\ \|\ tail\ \-n\ 2\ \|\ head\ \-n\ 1\)\ &&\ echo\ "\-\-\-\-\->\ Rollbacking\ to\ release:\ \$rollback_release"\ &&\ ln\ \-nfs\ .*/deploy/releases/\$rollback_release\ .*/deploy/current\ &&\ current_release=\$\(ls\ \-1A\ \|\ sort\ \-n\ \|\ tail\ \-n\ 1\)\ &&\ echo\ "\-\-\-\-\->\ Deleting\ current\ release:\ \$current_release"\ &&\ rm\ \-rf\ .*/deploy/releases/\$current_release\)
|
@@ -0,0 +1 @@
|
|
1
|
+
\(cd .*deploy && ls -al\)
|
@@ -0,0 +1 @@
|
|
1
|
+
echo\ "\-\-\-\-\->\ Using\ RVM\ environment\ \\\"123\\\"\"\s*if\ \[\[\ !\ \-s\ "\$HOME/\.rvm/scripts/rvm"\ \]\];\ then\s*echo\ "!\ Ruby\ Version\ Manager\ not\ found"\s*echo\ "!\ If\ RVM\ is\ installed,\ check\ your\ :rvm_path\ setting\."\s*exit 1\s*fi\s*source\ \$HOME/\.rvm/scripts/rvm\n\s*echo\ \"\-\-\-\-\-\>\ rvm\ use\ \\\"123\\\"\ \-\-create\"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
echo "-----> Loading ry"
|
2
|
+
|
3
|
+
if [[ ! -e "$HOME/.local/bin" ]]; then
|
4
|
+
echo "! ry not found"
|
5
|
+
echo "! If ry is installed, check your :ry_path setting."
|
6
|
+
exit 1
|
7
|
+
fi
|
8
|
+
|
9
|
+
export PATH="$HOME/.local/bin:$PATH"
|
10
|
+
eval "$(ry setup)"
|
11
|
+
RY_RUBY=""
|
12
|
+
|
13
|
+
if [ -n "$RY_RUBY" ]; then
|
14
|
+
ry use $RY_RUBY || exit 1
|
15
|
+
fi
|
@@ -0,0 +1,14 @@
|
|
1
|
+
echo "-----> Setting up .*deploy"
|
2
|
+
mkdir -p ".*deploy"
|
3
|
+
chown -R $(whoami) ".*deploy"
|
4
|
+
chmod g+rx,u+rwx ".*deploy"
|
5
|
+
mkdir -p ".*deploy/releases"
|
6
|
+
chmod g+rx,u+rwx ".*deploy/releases"
|
7
|
+
mkdir -p ".*deploy/shared"
|
8
|
+
chmod g+rx,u+rwx ".*deploy/shared"
|
9
|
+
(cd .*deploy/shared && mkdir -p "vendor/bundle" && chmod g+rx,u+rwx "vendor/bundle" && mkdir -p "log" && chmod g+rx,u+rwx "log" && mkdir -p "tmp/cache" && chmod g+rx,u+rwx "tmp/cache" && mkdir -p "public/assets" && chmod g+rx,u+rwx "public/assets")
|
10
|
+
tree ".*deploy" || ls -al ".*deploy"
|
11
|
+
|
12
|
+
if ! ssh-keygen -H -F &>/dev/null; then
|
13
|
+
ssh-keyscan -t rsa -p 22 -H >> ~/.ssh/known_hosts
|
14
|
+
fi
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module RakeExampleGroup
|
2
|
+
extend RSpec::Matchers::DSL
|
3
|
+
|
4
|
+
def self.included(klass)
|
5
|
+
klass.instance_eval do
|
6
|
+
let(:rake) { Rake.application }
|
7
|
+
let(:task_name) { self.class.description }
|
8
|
+
let(:run_commands) { rake['run_commands']}
|
9
|
+
let(:reset!) { rake['reset!'] }
|
10
|
+
subject { rake[task_name] }
|
11
|
+
|
12
|
+
after do
|
13
|
+
subject.reenable
|
14
|
+
run_commands.reenable
|
15
|
+
reset!.invoke
|
16
|
+
reset!.reenable
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def invoke_all(args = nil)
|
22
|
+
subject.invoke(args)
|
23
|
+
run_commands.invoke
|
24
|
+
end
|
25
|
+
|
26
|
+
def output_file(filename)
|
27
|
+
content = File.read("./spec/support/outputs/#{filename}.txt")
|
28
|
+
Regexp.new(content)
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'bundler', type: :rake do
|
4
|
+
describe 'bundle:install' do
|
5
|
+
it 'bundle install' do
|
6
|
+
expect { invoke_all }.to output(output_file('bundle_install')).to_stdout
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'bundle:clean' do
|
11
|
+
it 'bundle clean' do
|
12
|
+
expect { invoke_all }.to output(output_file('bundle_clean')).to_stdout
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'default', type: :rake do
|
4
|
+
describe 'ssh_keyscan' do
|
5
|
+
it 'scans ssh' do
|
6
|
+
expect { invoke_all }.to output(output_file('ssh_keyscan')).to_stdout
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'run' do
|
11
|
+
it 'runs command' do
|
12
|
+
subject.invoke('ls -al')
|
13
|
+
expect { run_commands.invoke }.to output(output_file('run')).to_stdout
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'exits if no command given' do
|
17
|
+
expect { subject.invoke }.to raise_error(SystemExit)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'ssh' do
|
22
|
+
it 'runs ssh' do
|
23
|
+
expect_any_instance_of(Kernel).to receive(:exec)
|
24
|
+
subject.invoke
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'debug_configuration_variables' do
|
29
|
+
it 'prints configrtion variables' do
|
30
|
+
Mina::Configuration.instance.set(:debug_configuration_variables, true)
|
31
|
+
expect { invoke_all }.to output(/------- Printing current config variables -------/).to_stdout
|
32
|
+
Mina::Configuration.instance.remove(:debug_configuration_variables)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'deploy', type: :rake do
|
4
|
+
describe 'deploy:force_unlock' do
|
5
|
+
it 'deploy force_unlock' do
|
6
|
+
expect { invoke_all }.to output(output_file('deploy_force_unlock')).to_stdout
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'deploy:link_shared_paths' do
|
11
|
+
it 'deploy link_shared_paths' do
|
12
|
+
expect { invoke_all }.to output(output_file('deploy_link_shared_paths')).to_stdout
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'deploy:cleanup' do
|
17
|
+
it 'deploy cleanup' do
|
18
|
+
expect { invoke_all }.to output(output_file('deploy_cleanup')).to_stdout
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'rollback' do
|
23
|
+
it 'rollback' do
|
24
|
+
expect { invoke_all }.to output(output_file('rollback')).to_stdout
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'setup' do
|
29
|
+
it 'setup' do
|
30
|
+
expect { invoke_all }.to output(output_file('setup')).to_stdout
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'git', type: :rake do
|
4
|
+
describe 'git:clone' do
|
5
|
+
it 'git clone' do
|
6
|
+
expect { invoke_all }.to output(output_file('git_clone')).to_stdout
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'git clone with commit' do
|
10
|
+
Mina::Configuration.instance.set(:commit, '123456')
|
11
|
+
expect { invoke_all }.to output(output_file('git_clone_commit')).to_stdout
|
12
|
+
Mina::Configuration.instance.remove(:commit)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'git:revision' do
|
17
|
+
it 'git revision' do
|
18
|
+
expect { invoke_all }.to output(output_file('git_revision')).to_stdout
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'init', type: :rake do
|
4
|
+
it 'creates new deploy rb' do
|
5
|
+
allow(File).to receive(:exist?).and_return(true)
|
6
|
+
expect(FileUtils).to receive(:mkdir_p)
|
7
|
+
expect(FileUtils).to receive(:cp)
|
8
|
+
|
9
|
+
expect { subject.invoke }.to output("-----> Created ./config/deploy.rb\nEdit this file, then run `mina setup` after.\n").to_stdout
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'doesnt create deploy rb if already exists' do
|
13
|
+
allow(File).to receive(:exist?).and_return(false)
|
14
|
+
expect { subject.invoke }.to raise_error(SystemExit)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'rails', type: :rake do
|
4
|
+
describe 'console' do
|
5
|
+
it 'starts console' do
|
6
|
+
expect { invoke_all }.to output(output_file('console')).to_stdout
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'log' do
|
11
|
+
it 'tails log' do
|
12
|
+
expect { invoke_all }.to output(output_file('log')).to_stdout
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'rails:db_migrate' do
|
17
|
+
it 'rails db migrate' do
|
18
|
+
expect { invoke_all }.to output(output_file('rails_db_migrate')).to_stdout
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'rails:db_create' do
|
23
|
+
it 'rails db create' do
|
24
|
+
expect { invoke_all }.to output(output_file('rails_db_create')).to_stdout
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'rails:db_rollback' do
|
29
|
+
it 'rails db rollback' do
|
30
|
+
expect { invoke_all }.to output(output_file('rails_db_rollback')).to_stdout
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'rails:assets_precompile' do
|
35
|
+
it 'rails assets precompile' do
|
36
|
+
expect { invoke_all }.to output(output_file('rails_assets_precompile')).to_stdout
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# describe 'rollback' do
|
41
|
+
# it 'rollback' do
|
42
|
+
# expect { invoke_all }.to output(output_file('rollback')).to_stdout
|
43
|
+
# end
|
44
|
+
# end
|
45
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'ruby_managers', type: :rake do
|
4
|
+
describe 'ry' do
|
5
|
+
it 'ry' do
|
6
|
+
expect { invoke_all }.to output(output_file('ry')).to_stdout
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'rbenv:load' do
|
11
|
+
it 'rbenv:load' do
|
12
|
+
expect { invoke_all }.to output(output_file('rbenv_load')).to_stdout
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'chruby' do
|
17
|
+
it 'chruby' do
|
18
|
+
expect { invoke_all('123') }.to output(output_file('chruby')).to_stdout
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'rvm:use' do
|
23
|
+
it 'rvm:use' do
|
24
|
+
expect { invoke_all('123') }.to output(output_file('rvm_use')).to_stdout
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# describe 'rvm:wrapper' do
|
29
|
+
# it 'rails db migrate' do
|
30
|
+
# expect { invoke_all('123') }.to output('').to_stdout
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
end
|
data/tasks/mina/bundler.rb
CHANGED
@@ -3,19 +3,19 @@ require 'mina/default'
|
|
3
3
|
set :bundle_bin, 'bundle'
|
4
4
|
set :bundle_path, 'vendor/bundle'
|
5
5
|
set :bundle_withouts, 'development test'
|
6
|
-
set :bundle_options, -> {
|
6
|
+
set :bundle_options, -> { %(--without #{fetch(:bundle_withouts)} --path "#{fetch(:bundle_path)}" --deployment) }
|
7
7
|
set :shared_dirs, fetch(:shared_dirs, []).push(fetch(:bundle_path))
|
8
8
|
|
9
9
|
namespace :bundle do
|
10
10
|
desc 'Install gem dependencies using Bundler.'
|
11
11
|
task install: :environment do
|
12
|
-
comment
|
13
|
-
command
|
12
|
+
comment %(Installing gem dependencies using Bundler)
|
13
|
+
command %(#{fetch(:bundle_bin)} install #{fetch(:bundle_options)})
|
14
14
|
end
|
15
15
|
|
16
16
|
desc 'Cleans up unused gems in your bundler directory'
|
17
17
|
task :clean do
|
18
|
-
comment
|
19
|
-
command
|
18
|
+
comment %(Cleans up unsed gems)
|
19
|
+
command %(#{fetch(:bundle_bin)} clean #{fetch(:bundle_options)})
|
20
20
|
end
|
21
21
|
end
|
data/tasks/mina/chruby.rb
CHANGED
@@ -2,18 +2,16 @@ set :chruby_path, '/etc/profile.d/chruby.sh'
|
|
2
2
|
|
3
3
|
task :chruby, :env do |_, args|
|
4
4
|
unless args[:env]
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
puts "Task 'chruby' needs a Ruby version as an argument."
|
6
|
+
puts "Example: invoke :'chruby[ruby-1.9.3-p392]'"
|
7
|
+
exit 1
|
8
8
|
end
|
9
9
|
|
10
|
-
comment
|
11
|
-
command %(
|
12
|
-
if [[ ! -s "#{fetch(:chruby_path)}" ]]; then
|
10
|
+
comment %(chruby to version: \\"#{args[:env]}\\")
|
11
|
+
command %(if [[ ! -s "#{fetch(:chruby_path)}" ]]; then
|
13
12
|
echo "! chruby.sh init file not found"
|
14
13
|
exit 1
|
15
|
-
fi
|
16
|
-
)
|
17
|
-
command "
|
18
|
-
command "chruby '#{args[:env]}' || exit 1"
|
14
|
+
fi)
|
15
|
+
command %(source #{fetch(:chruby_path)})
|
16
|
+
command %(chruby "#{args[:env]}" || exit 1)
|
19
17
|
end
|