Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. function! ApiaryToPhp()
  2. set ignorecase
  3. set textwidth=80
  4. " turn to $table->tipe..('field');(tipe..)...
  5. execute "normal! dt`r'f`r'"
  6. execute "normal! ldt(lyi("
  7. execute "normal! 0i$table->\<ESC>pa(\<ESC>f';a);\<ESC>"
  8. " save description as comment if type is lookup
  9. " for easier setup relationship manually
  10. let notLookup = ["string", "boolean", "number"]
  11. execute "normal! 0f;f)yb"
  12. let type = @"
  13. " " delete rest of text
  14. execute "normal! 0f;ld$"
  15. if index(notLookup, type) == -1
  16. " paste text, and reformat to 80 char limit
  17. execute "normal! O// \<ESC>pv`[`]gqj"
  18. endif
  19.  
  20. " add nullable if not required
  21. execute "normal! 0f>lye"
  22. let type = @"
  23. if type == "required"
  24. " delete required text
  25. execute "normal! 0f>ldf\<space>\<ESC>"
  26. else
  27. " add ->nullable()
  28. execute "normal! $i->nullable()\<ESC>"
  29. endif
  30.  
  31. " change
  32. " number => integer
  33. " string => no change
  34. " boolean => no change
  35. " other string, and put comment
  36. execute "normal! 0f>lye"
  37. let type = @"
  38. if type == "number"
  39. execute "normal! 0f>lceinteger\<ESC>"
  40. elseif type == "string"
  41. execute "normal! 0"
  42. elseif type == "boolean"
  43. execute "normal! 0"
  44. else
  45. execute "normal! 0f>lcestring\<ESC>"
  46. endif
  47. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement