5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/common/utils.rb', line 5
def self.flagSplit(str, removeQuotes)
return [] if str == ""
return [str] unless str.include?" "
hasQuote = false
hasDoubleQuote = false
hadQuote = false
ar = []
s = ""
str.split("").each do |i|
hasDoubleQuote = !hasDoubleQuote if !hasQuote and i == '"'
hasQuote = !hasQuote if !hasDoubleQuote and i == '\''
hadQuote = true if hasDoubleQuote
if i == ' '
if not hasDoubleQuote and not hasQuote
if hadQuote and removeQuotes
ar << s[1..-2] if s.length > 2
hadQuote = false
else
ar << s if s.length > 0
end
s = ""
next
end
end
s << i
end
ar << s if s.length > 0
ar
end
|