# Path: revolver/core.py
# def run(*args, **kwargs):
#     if not env.sudo_forced:
#         return _run(*args, **kwargs)
# 
#     return sudo(*args, **kwargs)
# 
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
# 
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
# 
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):


from revolver.core import run
from revolver import directory as dir
from revolver import package, file
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, with_statement



def install():
    package.ensure(["curl", "git-core"])

    url = "https://raw.github.com/CHH/phpenv/master/bin/phpenv-install.sh"
    if not dir.exists(".phpenv"):
        run("curl -s %s | bash" % url)
    else:
        run("curl -s %s | UPDATE=yes bash" % url)

    dir.create(".phpenv/versions")

    _ensure_autoload(".bashrc")
    _ensure_autoload(".zshrc")


def ensure():
    if not dir.exists(".phpenv"):
        install()


def _ensure_autoload(filename):
    # TODO: Make sure that `~/.rbenv/bin` takes precedence in the PATH over
    #       `~/.phpenv/bin` by placing it before, so rbenv gets used from
    #       `~/.rbenv`. For more informations: https://github.com/CHH/phpenv

# Path: revolver/core.py
# def run(*args, **kwargs):
#     if not env.sudo_forced:
#         return _run(*args, **kwargs)
# 
#     return sudo(*args, **kwargs)
# 
# Path: revolver/directory.py
# def temp_local():
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def create(path, recursive=False, mode=None, owner=None, group=None):
# 
# Path: revolver/package.py
# def is_installed(name):
# def install_ppa(name):
# 
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):


# Path: revolver/tool/php_phpenv.py
from revolver.core import run
from revolver import directory as dir
from revolver import package, file

# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, with_statement



def install():
    package.ensure(["curl", "git-core"])

    url = "https://raw.github.com/CHH/phpenv/master/bin/phpenv-install.sh"
    if not dir.exists(".phpenv"):
        run("curl -s %s | bash" % url)
    else:
        run("curl -s %s | UPDATE=yes bash" % url)

    dir.create(".phpenv/versions")

    _ensure_autoload(".bashrc")
    _ensure_autoload(".zshrc")


def ensure():
    if not dir.exists(".phpenv"):
        install()


def _ensure_autoload(filename):
    # TODO: Make sure that `~/.rbenv/bin` takes precedence in the PATH over
    #       `~/.phpenv/bin` by placing it before, so rbenv gets used from
    #       `~/.rbenv`. For more informations: https://github.com/CHH/phpenv

    file.append(filename, 'export PATH="$HOME/.phpenv/bin:$PATH"')