Merge branch 'master' of github.com:pre-commit/pre-commit

This commit is contained in:
Ken Struys 2014-03-14 11:27:15 -07:00
commit cb3699007e
4 changed files with 63 additions and 4 deletions

View file

@ -1,7 +1,36 @@
import contextlib
from plumbum import local
from pre_commit.languages import helpers
RVM_ENV = 'rvm_env'
class RubyEnv(object):
def __init__(self):
self.env_prefix = '. {0}/.rvm/scripts/rvm'.format(RVM_ENV)
def run(self, cmd, **kwargs):
return local['bash']['-c', ' '.join([self.env_prefix, cmd])].run(**kwargs)
@contextlib.contextmanager
def in_env():
yield RubyEnv()
def install_environment():
raise NotImplementedError
# Return immediately if we already have a virtualenv
if local.path(RVM_ENV).exists():
return
local['__rvm-env.sh'][RVM_ENV]()
with in_env() as env:
env.run('bundle install')
def run_hook(hook, file_args):
raise NotImplementedError
with in_env() as env:
return helpers.run_hook(env, hook, file_args)