Sha256: c3e4251867b9a132f5500b41aad486fc6439908239ff6e48d74889915c6443ff

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

# encoding: utf-8
include_recipe './resource.rb'
include_recipe 'rtn_rbenv::common'

# load setting
RBENV_USER = (node['rtn_rbenv']['user'] || 'vagrant')
RBENV_USER_HOME = "/home/#{RBENV_USER}"
RBENV_ROOT = "#{RBENV_USER_HOME}/.rbenv"
RBENV_PROFILE_NAME = (node['rtn_rbenv']['profile'] || '.bash_profile')
RBENV_PROFILE_PATH = "#{RBENV_USER_HOME}/#{RBENV_PROFILE_NAME}"

# install rbenv and ruby_build
rbenv_install RBENV_ROOT do
  user RBENV_USER
  profile_path RBENV_PROFILE_PATH
end

# install Ruby and Gems
(node['rtn_rbenv']['versions'] || {}).each do |ruby_version, gems|
  ruby_install ruby_version do
    user RBENV_USER
    profile_path RBENV_PROFILE_PATH
  end
  gems.each do |gem|
    if gem.kind_of?(Hash)
      gem_install gem['name'] do
        self.ruby_version ruby_version
        version gem['version'] if gem['version']
        force gem['force'] if gem['force']
        user RBENV_USER
        profile_path RBENV_PROFILE_PATH
      end
    else
      gem_install gem do
        self.ruby_version ruby_version
        user RBENV_USER
        profile_path RBENV_PROFILE_PATH
      end
    end
  end
end

# set global
if node['rtn_rbenv']['global']
  execute "rbenv global #{node['rtn_rbenv']['global']}" do
    command ". #{RBENV_PROFILE_PATH} && rbenv global #{node['rtn_rbenv']['global']}"
    user RBENV_USER
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
itamae-plugin-recipe-rtn_rbenv-0.1.5 lib/itamae/plugin/recipe/rtn_rbenv/user.rb