Skip to content

Commit

Permalink
simple app : add snippet for vim
Browse files Browse the repository at this point in the history
  • Loading branch information
dotmobo committed Dec 31, 2015
1 parent 730657e commit 04ba794
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pydiploy/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,14 @@ def generate_fabfile():
return f.read()


def generate_fabfile_simple():

fab_sample_simple = resource_filename("pydiploy", "examples/simple_fabfile.py")

with open(fab_sample_simple) as f:
return f.read()


def process_releases():
""" Populates env vars for releases (current, old...) """
if fabtools.files.is_dir(env.remote_releases_path):
Expand Down
6 changes: 5 additions & 1 deletion tests/test_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from pydiploy import version
from pydiploy.prepare import (_get_current_role, build_env,
check_req_pydiploy_version, generate_fabfile,
init_params, process_releases, tag, test_config)
init_params, process_releases, tag, test_config,
generate_fabfile_simple)


class PrepareCheck(TestCase):
Expand Down Expand Up @@ -226,6 +227,9 @@ def test_check_req_pydiploy_version(self):
def test_generate_fabfile(self):
generate_fabfile()

def test_generate_fabfile_simple(self):
generate_fabfile_simple()

@patch('fabtools.files.is_dir', return_value=True)
@patch('fabric.api.run', return_value="4.0")
def test_process_releases(self, api_run, is_dir):
Expand Down
18 changes: 18 additions & 0 deletions tools/pydiploy-vim/plugin/insertfabfilesimple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
try:
import pydiploy
import vim
import string

fabile = string.join(vim.current.buffer, "\n")
fabfile = pydiploy.prepare.generate_fabfile_simple()

filename = vim.current.buffer.name

f = open(filename, 'w')
f.write(fabfile)
f.close()

print "Fabfile for simple app written to "+filename

except ImportError, e:
print "Pydiploy package not installed, please run: pip install pydiploy"
18 changes: 18 additions & 0 deletions tools/pydiploy-vim/plugin/pydiployfabfilesimple.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
if !has('python')
finish
endif

function! InsertFabfileSimple()

if filereadable($HOME."/.vim/bundle/pydiploy-vim/plugin/insertfabfilesimple.py")
pyfile $HOME/.vim/bundle/pydiploy-vim/plugin/insertfabfilesimple.py
elseif filereadable($HOME."/.vim/plugin/insertfabfilesimple.py")
pyfile $HOME/.vim/plugin/insertfabfilesimple.py
else
call confirm("Error: insertfabfilesimple.py cannot be found! Please reinstall the plugin", 'OK')
finish
endif
:e
endfunc

command! PYDIPLOYFABSIMPLE call InsertFabfileSimple()

0 comments on commit 04ba794

Please sign in to comment.