Skip to content

Instantly share code, notes, and snippets.

View Sutto's full-sized avatar

Darcy Laycock Sutto

View GitHub Profile
class X
def self.ruby_command
@@ruby_command ||= begin
real_rvm_ruby = self.rvm_ruby_string
real_rvm_path = self.rvm_path
filename = nil
if !real_rvm_ruby.nil? && !real_rvm_path.nil?
rvm_ruby = File.join(real_rvm_path, "wrappers", real_rvm_ruby, "ruby")
filename = rvm_ruby if File.exists?(rvm_ruby)
@Sutto
Sutto / gist:549577
Created August 25, 2010 14:10 — forked from tyx/gist:549520
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
$LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! File.expand_path(File.dirname(File.dirname(__FILE__)))
rescue LoadError
# RVM is unavailable at this point.
raise "RVM ruby lib is currently unavailable."
# Substitute rvm in the first line for whatever group it is installed at.
if groups | grep -q rvm ; then
[[ -s "/usr/local/lib/rvm" ]] && source "/usr/local/lib/rvm"
fi
#!/bin/bash
echo "Cleaning up packages"
apt-get --purge remove
echo "Removing ssh"
apt-get --purge -y remove openssh-server
echo "Cleaning up RVM"
rvm cleanup all
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
$LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
rescue LoadError
# RVM is unavailable at this point.
raise "RVM ruby lib is currently unavailable."
#!/usr/bin/env bash
__rvm_system_wide_permissions() {
[[ -z "$1" ]] && return 1
chown -R root:"$rvm_group_name" "$1"
chmod -R g+w "$1"
[[ -d "$1" ]] && find "$1" -type d -exec chmod g+s '{}' +
}
# Require root to install it.

An introduction to rvm_sandboxed

So, under the hook, rvm uses a variety of environment variables to tell it where to locate things. Out of the box, these variables are current:

  • rvm_path - the directory in which rvm is installed (e.g. typically ~/.rvm)
  • rvm_prefix - basically, ${rvm_prefix}rvm is used to build the default rvm_path. It tells rvm how to build the default rvm_path, rvm_bin_path and rvm_man_path. This also relies on the rvm_sandboxed argument
  • rvm_sandboxed - tells rvm how to behave when working with rvm_prefix. See "How does rvm_sandboxed work?" below for more information.
#!/usr/bin/env bash
[[ -f /etc/rvmrc ]] && source /etc/rvmrc
[[ -f "$HOME/.rvmrc" ]] && source "$HOME/.rvmrc"
rvm_path="${rvm_path:-"$HOME/.rvm"}"
mkdir -p "$rvm_path/src/"
builtin cd "$rvm_path/src"
#!/usr/bin/env bash
[[ -f /etc/rvmrc ]] && source /etc/rvmrc
[[ -f "$HOME/.rvmrc" ]] && source "$HOME/.rvmrc"
rvm_path="${rvm_path:-$HOME/.rvm}"
export rvm_path
mkdir -p "$rvm_path/src/"
module SimpleSortable
def is_sortable(field = :position, options = {})
cattr_accessor :sortable_field, :sortable_condition_field
self.sortable_field = field.to_sym
if options[:if_field]
self.sortable_condition_field = options[:if_field]
scope :sortable_items, where(sortable_condition_field => true)
else
scope :sortable_items, unscoped