summaryrefslogtreecommitdiff
path: root/lib/oxidized/source/csv.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/source/csv.rb')
-rw-r--r--lib/oxidized/source/csv.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/oxidized/source/csv.rb b/lib/oxidized/source/csv.rb
index a0ce848..d498e0b 100644
--- a/lib/oxidized/source/csv.rb
+++ b/lib/oxidized/source/csv.rb
@@ -20,18 +20,20 @@ class CSV < Source
nodes = []
open(File.expand_path @cfg.file).each_line do |line|
next if line.match(/^\s*#/)
- data = line.chomp.split @cfg.delimiter
+ data = line.chomp.split(@cfg.delimiter, -1)
next if data.empty?
# map node parameters
keys = {}
@cfg.map.each do |key, position|
- keys[key.to_sym] = data[position]
+ keys[key.to_sym] = node_var_interpolate data[position]
end
keys[:model] = map_model keys[:model] if keys.key? :model
- # map node specific vars, empty value is considered as nil
+ # map node specific vars
vars = {}
- @cfg.vars_map.each { |key, position| vars[key.to_sym] = data[position].to_s.empty? ? nil : data[position] }
+ @cfg.vars_map.each do |key, position|
+ vars[key.to_sym] = node_var_interpolate data[position]
+ end
keys[:vars] = vars unless vars.empty?
nodes << keys