Sha256: a5914ca511a43fb46ca9bb64f8ff84bd9afdeaf1d4e0f8cc9ad6c8d49e1f0271

Contents?: true

Size: 1.05 KB

Versions: 7

Compression:

Stored size: 1.05 KB

Contents

class Chef
  module RVM
    module ShellHelpers
      # stub to satisfy VersionCache (library load order not guarenteed)
    end

    module VersionHelpers
      def rvm_version(user = nil)
        VersionCache.fetch_version(user)
      end
    end

    class VersionCache
      class << self
        include Chef::Mixin::ShellOut
        include Chef::RVM::ShellHelpers
      end

      def self.fetch_version(user = nil)
        @@versions ||= Hash.new
        rvm_install = user || "system"
        @@versions[rvm_install] ||= rvm_version(user)
      end

      def self.rvm_version(user = nil)
        cmd = "rvm version | cut -d ' ' -f 2"

        if user
          user_dir    = Etc.getpwnam(user).dir
          environment = { 'USER' => user, 'HOME' => user_dir }
        else
          user_dir    = nil
          environment = nil
        end

        version = shell_out!(
          rvm_wrap_cmd(cmd, user_dir), :env => environment).stdout.strip

        Chef::Log.debug "RVM version = #{version} (#{user || 'system'})"

        version
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
from-scratch-0.7.0 cookbooks/rvm/libraries/chef_rvm_version_helpers.rb
from-scratch-0.6.0 cookbooks/rvm/libraries/chef_rvm_version_helpers.rb
from-scratch-0.5.0 cookbooks/rvm/libraries/chef_rvm_version_helpers.rb
from-scratch-0.3.0 cookbooks/rvm/libraries/chef_rvm_version_helpers.rb
from-scratch-0.2.0 cookbooks/rvm/libraries/chef_rvm_version_helpers.rb
from-scratch-0.1.1 cookbooks/rvm/libraries/chef_rvm_version_helpers.rb
from-scratch-0.1.0 cookbooks/rvm/libraries/chef_rvm_version_helpers.rb