8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/tamebou/parser.rb', line 8
def self.parse(line)
valid_result = line.match(VALID_PATTERN)
return nil if valid_result.nil?
if supported_result = line.match(SINGLE_LINE_VALIDATION_PATTERN)
options_in_str = supported_result[OPTIONS_INDEX]
options = begin
to_hash(options_in_str)
rescue SyntaxError => e
options_in_str
end
{ field_name: supported_result[FIELD_NAME_INDEX], options: options }
else
{ field_name: valid_result[FIELD_NAME_INDEX] }
end
end
|