Module: MagicRecipes::Rvm

Defined in:
lib/magic_recipes/rvm.rb

Overview

RVM - Deploy-Recipes

little helper to work on crazy rvm mashine … mine dont accept the standard rvm handling

Tasks:
    • -

Callbacks:
    • -

Class Method Summary collapse

Class Method Details

.load_into(configuration) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/magic_recipes/rvm.rb', line 14

def self.load_into(configuration)
  configuration.load do
    
    # => http://stackoverflow.com/questions/7313232/rvm-capistrano-and-bundler-path-issues
    # => http://stackoverflow.com/questions/6968066/confused-by-rvms-instructions-for-capistrano
    
    ## change to rvm-capistrano gem, so commited out
    # $:.unshift(File.expand_path('./lib', ENV['rvm_path']))
    require 'rvm/capistrano'
    
    
    ## Example of new stuff:
    # set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"")
    # set :rvm_install_ruby_params, '--1.9'      # for jruby/rbx default to 1.9 mode
    # before 'deploy:setup', 'rvm:install_rvm'   # install RVM
    # before 'deploy:setup', 'rvm:install_ruby'  # install Ruby and create gemset, or:
    before 'deploy:setup', 'rvm:create_gemset' # only create gemset
    
    
    set_default :rails_env,     'production'
    set_default :rvm_ruby,      '1.9.3'
    set_default :rvm_patch,     'p0'
    set_default :rvm_gemset,    'global'
    set_default :rvm_path,      '/usr/local/rvm'
    
    # set :rvm_type,              :system
    set :rvm_type,              :user
    set :rvm_ruby_string,       "ruby-#{rvm_ruby}-#{rvm_patch}@#{rvm_gemset}"
    set :rvm_bin_path,          "#{rvm_path}/bin"
    set :rvm_lib_path,          "#{rvm_path}/lib"
    set :remote_bin_path,       "#{rvm_path}/gems/ruby-#{rvm_ruby}-#{rvm_patch}/bin/"
    set :use_rvm,               true
    
    set :rvm_cmd,               "source '#{rvm_path}/scripts/rvm' && rvm use #{rvm_ruby}-#{rvm_patch}@#{rvm_gemset}"
    
    # => set :default_environment, {
    # =>   'PATH'            => "#{rvm_path}/gems/ruby/1.9.1/bin:#{rvm_bin_path}/bin:#{remote_bin_path}:$PATH",
    # =>   'RUBY_VERSION'    => "#{rvm_ruby}",
    # =>   'GEM_HOME'        => "#{rvm_path}/gems/#{rvm_ruby_string}",
    # =>   'GEM_PATH'        => "#{rvm_path}/gems/#{rvm_ruby_string}",
    # =>   'BUNDLE_PATH'     => "#{rvm_path}/gems/#{rvm_ruby_string}"
    # => }

    set :bundle_dir,            "#{rvm_path}/gems/#{rvm_ruby_string}"
    set :bundle_flags,          "--deployment --verbose"
    
    namespace :rvm do
      desc "Create gemset"
      rvm_task :create_gemset do
        # run "source '#{rvm_path}/scripts/rvm' && rvm use #{rvm_ruby}-#{rvm_patch} && rvm gemset create #{rvm_gemset}"
        # run "rvm #{rvm_ruby}-#{rvm_patch} do rvm gemset create #{rvm_gemset}"
        run "source '#{rvm_path}/scripts/rvm' && rvm use #{rvm_ruby}-#{rvm_patch}@#{rvm_gemset} --create", :shell => :bash
      end
    end
    
    # eof
    
  end
end