- autotags = {}; autotags['point'] = {}; autotags['way'] = {}; autotags['POI'] = {}
- File.open("#{Rails.root}/config/potlatch/autocomplete.txt") do |file|
- file.each_line do|line|
- t = line.chomp
- if t =~ /^([\w:]+)\/(\w+)\s+(.+)$/
- tag = $1; type = $2; values = $3
- if values == '-' then autotags[type][tag] = []
- else autotags[type][tag] = values.split(',').sort.reverse end
- end
+ autotags = { "point" => {}, "way" => {}, "POI" => {} }
+ File.open(Rails.root.join("config/potlatch/autocomplete.txt")) do |file|
+ file.each_line do |line|
+ next unless line.chomp =~ %r{^([\w:]+)/(\w+)\s+(.+)$}
+
+ tag = Regexp.last_match(1)
+ type = Regexp.last_match(2)
+ values = Regexp.last_match(3)
+ autotags[type][tag] = if values == "-"
+ []
+ else
+ values.split(",").sort.reverse
+ end