Sha256: c254473ac942c1a26f36f314e070b7b930e27a03e0c9ae8df7cd71588dfb14a2

Contents?: true

Size: 1.85 KB

Versions: 1

Compression:

Stored size: 1.85 KB

Contents

# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly

forget_cached_commands () {

    # This should detect bash and zsh, which have a hash command that must
    # be called to get it to forget past commands.  Without forgetting
    # past commands the $PATH changes we made may not be respected
    if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
        hash -r
    fi

}

deactivate () {

    if [ -n "$_OLD_SANDBOX_GEM_HOME" ] ; then
        GEM_HOME="$_OLD_SANDBOX_GEM_HOME"
        export GEM_HOME
    else
        unset GEM_HOME
    fi

    if [ -n "$_OLD_SANDBOX_GEM_PATH" ] ; then
        GEM_PATH="$_OLD_SANDBOX_GEM_PATH"
        export GEM_PATH
    else
        unset GEM_PATH
    fi

    if [ -n "$_OLD_SANDBOX_PATH" ] ; then
        PATH="$_OLD_SANDBOX_PATH"
        export PATH
    fi

    if [ -n "$_OLD_SANDBOX_PS1" ] ; then
        PS1="$_OLD_SANDBOX_PS1"
        export PS1
    fi

    unset _OLD_SANDBOX_PATH
    unset _OLD_SANDBOX_GEM_HOME
    unset _OLD_SANDBOX_GEM_PATH
    unset _OLD_SANDBOX_PS1
    unset SANDBOX_ENV

    forget_cached_commands

    if [ ! "$1" = "nondestructive" ] ; then
        # Self destruct!
        unset deactivate
        unset forget_cached_commands
    fi
}

activate () {

    # unset irrelavent variables
    deactivate nondestructive

    # preserve current variables
    _OLD_SANDBOX_GEM_HOME="$GEM_HOME"
    _OLD_SANDBOX_GEM_PATH="$GEM_PATH"
    _OLD_SANDBOX_PATH="$PATH"
    _OLD_SANDBOX_PS1="$PS1"

    # set the sandbox-aware states
    SANDBOX_ENV="<%= target %>"
    PATH="$SANDBOX_ENV/bin:$PATH"
    GEM_HOME="$SANDBOX_ENV/rubygems"
    GEM_PATH="$GEM_HOME"
    PS1="(`basename \"$SANDBOX_ENV\"`) $PS1"

    export SANDBOX_ENV PATH GEM_HOME GEM_PATH PS1

    forget_cached_commands

    unset activate
}

activate

# Thanks to the virtualenv developers (http://pypi.python.org/pypi/virtualenv)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-virtualenv-0.5.1 lib/sandbox/templates/activate.erb