Created
April 29, 2013 20:24
-
-
Save ctoestreich/5484489 to your computer and use it in GitHub Desktop.
Test for splitting grails params for scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
assert doSplit('''-compile | |
-wsdl=some/path''') == ['-compile','-wsdl','some/path'] | |
assert doSplit('-compile -wsdl=some/path') == ['-compile','-wsdl','some/path'] | |
assert doSplit('''-compile -wsdl=some/path | |
-test ''') == ['-compile','-wsdl','some/path', '-test'] | |
assert doSplit('''-compile | |
-wsdl=some/path/to/wsdl | |
-mark=12,123,123''') == ['-compile', '-wsdl', 'some/path/to/wsdl', '-mark', '12,123,123'] | |
assert doSplit('-compile -wsdl=some/path/to/wsdl -mark=12,123,123') == ['-compile', '-wsdl', 'some/path/to/wsdl', '-mark', '12,123,123'] | |
assert doSplit('-compile') == ['-compile'] | |
private doSplit(string){ | |
return string.split(/(\n|[ ]|=)/).collect{ it.trim() }.findResults { it && it != '' ? it : null } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment