From 449522554473f4b9a261ec06ee6961defb30f7bb Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Wed, 26 Oct 2016 13:32:01 +0300 Subject: fetch should return string, not array Also if group was explicitly given, we referred to wrong directory --- lib/oxidized/output/file.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lib/oxidized/output') diff --git a/lib/oxidized/output/file.rb b/lib/oxidized/output/file.rb index 851e4c5..78db1d5 100644 --- a/lib/oxidized/output/file.rb +++ b/lib/oxidized/output/file.rb @@ -28,18 +28,19 @@ class OxidizedFile < Output end def fetch node, group - cfg_dir = File.expand_path @cfg.directory + cfg_dir = File.expand_path @cfg.directory node_name = node.name if group # group is explicitly defined by user - IO.readlines File.join(cfg_dir, group, node_name) + cfg_dir = File.join File.dirname(cfg_dir), group + File.read File.join(cfg_dir, node_name) else if File.exists? File.join(cfg_dir, node_name) # node configuration file is stored on base directory - IO.readlines File.join(cfg_dir, node_name) + File.read File.join(cfg_dir, node_name) else - path = Dir.glob File.join(cfg_dir, '**', node_name) # fetch node in all groups - return nil if path[0].nil? - open(path[0], 'r').readlines + path = Dir.glob(File.join(cfg_dir, '**', node_name)).first # fetch node in all groups + return nil if not path + File.read path end end end -- cgit v1.2.1