Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function! ApiaryToPhp()
- set ignorecase
- set textwidth=80
- " turn to $table->tipe..('field');(tipe..)...
- execute "normal! dt`r'f`r'"
- execute "normal! ldt(lyi("
- execute "normal! 0i$table->\<ESC>pa(\<ESC>f';a);\<ESC>"
- " save description as comment if type is lookup
- " for easier setup relationship manually
- let notLookup = ["string", "boolean", "number"]
- execute "normal! 0f;f)yb"
- let type = @"
- " " delete rest of text
- execute "normal! 0f;ld$"
- if index(notLookup, type) == -1
- " paste text, and reformat to 80 char limit
- execute "normal! O// \<ESC>pv`[`]gqj"
- endif
- " add nullable if not required
- execute "normal! 0f>lye"
- let type = @"
- if type == "required"
- " delete required text
- execute "normal! 0f>ldf\<space>\<ESC>"
- else
- " add ->nullable()
- execute "normal! $i->nullable()\<ESC>"
- endif
- " change
- " number => integer
- " string => no change
- " boolean => no change
- " other string, and put comment
- execute "normal! 0f>lye"
- let type = @"
- if type == "number"
- execute "normal! 0f>lceinteger\<ESC>"
- elseif type == "string"
- execute "normal! 0"
- elseif type == "boolean"
- execute "normal! 0"
- else
- execute "normal! 0f>lcestring\<ESC>"
- endif
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement