immosquare-capistrano 0.1.5 → 0.1.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
  SHA256:
3
- metadata.gz: eebe27d1ff19f881f868149c9fe82c829815358786271ee294f30a99ed16d9ed
4
- data.tar.gz: a9c4a37203792db7eddb7e58e82f0cec4925e32c79b501c6513a6953d0c2844e
3
+ metadata.gz: d21992d6862c4412d439d94e332daa87bd4388d897968d622cbcfec44b288f55
4
+ data.tar.gz: d4038ca94a06375b0c01c74f09c94678cf397ac538d866b940b0968cdb9dbecd
5
5
  SHA512:
6
- metadata.gz: 64db57958d1e4efd8871e001e555c8162bbb46906e6ee62f69d9c678d4fd20ec9ad1bff9abe6207c8c2e38054b300c0843f7108088dc8d77c8627bf907234bcf
7
- data.tar.gz: 17736935e39783fd634cad578b0290c767dbf02b565ca803b1208ec74db75cfe1a4b244ca27c810c988f30d2e3b503a5a3410be4e356ab682ae060fac51e905d
6
+ metadata.gz: 76a896e2b628412f9bb2a4b1b4ade6c8def6020dbe73430c64d9c86739b723d7050fc544f9d00a2271d7110ebed1a3d6c50aacc3f61e3061a7b38e8954343313
7
+ data.tar.gz: dc02e35d9e183637e9ce333605b071ef3473c1c25892b8cc0bb23f14d8c2afae91f81b50f9af2696e705ca57de3a46288ab706543eedbc9c3caa15b72bb505ec
@@ -14,11 +14,5 @@ namespace :load do
14
14
  ## SolidQueue
15
15
  ##============================================================##
16
16
  set_if_empty :solid_queue_service_unit_name, -> { "solid_queue_#{fetch(:application)}_#{fetch(:stage)}" }
17
-
18
- ##============================================================##
19
- ## rvm
20
- ##============================================================##
21
- set_if_empty :rvm_ruby_version, -> { "default" }
22
- set_if_empty :rvm_map_bins, -> { ["gem", "rake", "ruby", "bundle"] }
23
17
  end
24
18
  end
@@ -1,6 +1,5 @@
1
1
  require_relative "defaults"
2
2
 
3
-
4
3
  ##============================================================##
5
4
  ## We load rvm tasks
6
5
  ##============================================================##
@@ -13,5 +12,4 @@ load File.expand_path("tasks/rvm.rake", __dir__)
13
12
  ##============================================================##
14
13
  Capistrano::DSL.stages.each do |stage|
15
14
  after stage, "rvm:hook"
16
- # after stage, "rvm:check"
17
15
  end
@@ -13,25 +13,55 @@ namespace :rvm do
13
13
  elsif test("[ -d #{rvm_system_path} ]")
14
14
  rvm_system_path
15
15
  else
16
- raise("RVM path not found on server. Please install RVM first")
16
+ error("RVM path not found on server. Please install RVM first")
17
+ exit(1)
17
18
  end
19
+ info "RVM path detected: #{rvm_path}"
20
+ rvm_bin_path = "#{rvm_path}/bin/rvm"
18
21
 
19
22
  ##============================================================##
20
- ## Log
23
+ ## Set the RVM command map
21
24
  ##============================================================##
22
- info "RVM path detected: #{rvm_path}"
23
-
25
+ SSHKit.config.command_map[:rvm] = rvm_bin_path
24
26
 
25
27
  ##============================================================##
26
- ## Set the RVM command map
28
+ ## Check if the RVM Ruby version is set
27
29
  ##============================================================##
28
- SSHKit.config.command_map[:rvm] = "#{rvm_path}/bin/rvm"
30
+ rvm_ruby_version = fetch(:rvm_ruby_version)
31
+ if rvm_ruby_version.nil?
32
+ error "rvm_ruby_version not set. Please set the rvm_ruby_version in your deploy.rb file with format ruby-x.y.z@your-app-name"
33
+ exit 1
34
+ elsif rvm_ruby_version !~ /^ruby-\d+\.\d+\.\d+@[a-z0-9\-_]+$/i
35
+ error "rvm_ruby_version format is invalid. Please set the rvm_ruby_version in your deploy.rb file with format ruby-x.y.z@your-app-name"
36
+ exit 1
37
+ end
38
+ info "rvm_ruby_version set: #{rvm_ruby_version}"
29
39
 
30
40
  ##============================================================##
31
41
  ## Set the RVM prefix for the commands
32
42
  ##============================================================##
33
- fetch(:rvm_map_bins).each do |command|
34
- SSHKit.config.command_map.prefix[command.to_sym].unshift("#{rvm_path}/bin/rvm #{fetch(:rvm_ruby_version)} do")
43
+ ["gem", "rake", "ruby", "bundle"].each do |command|
44
+ SSHKit.config.command_map.prefix[command.to_sym].unshift("#{rvm_bin_path} #{rvm_ruby_version} do")
45
+ end
46
+
47
+
48
+ ##============================================================##
49
+ ## Check if ruby version is installed
50
+ ##============================================================##
51
+ ruby_version = rvm_ruby_version.split("@").first
52
+ unless test("#{rvm_bin_path} #{ruby_version} do ruby --version")
53
+ error "Ruby version #{ruby_version} is not installed on the server. Please install it first with 'rvm install #{ruby_version}'"
54
+ exit 1
55
+ end
56
+ info "#{ruby_version} is installed on the server."
57
+
58
+ ##============================================================##
59
+ ## Check if gemset exists, if not create it
60
+ ##============================================================##
61
+ gemset_name = rvm_ruby_version.split("@").last
62
+ unless test("#{rvm_bin_path} #{rvm_ruby_version} do rvm gemset list | grep -wq #{gemset_name}")
63
+ info "Creating gemset #{gemset_name} for #{ruby_version}"
64
+ execute :rvm, "#{ruby_version} do rvm gemset create #{gemset_name}"
35
65
  end
36
66
  end
37
67
  end
@@ -1,3 +1,3 @@
1
1
  module ImmosquareCapistrano
2
- VERSION = "0.1.5".freeze
2
+ VERSION = "0.1.6".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: immosquare-capistrano
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - immosquare