diff options
| author | Saku Ytti <saku@ytti.fi> | 2016-10-26 13:32:01 +0300 | 
|---|---|---|
| committer | Saku Ytti <saku@ytti.fi> | 2016-10-26 13:32:01 +0300 | 
| commit | 449522554473f4b9a261ec06ee6961defb30f7bb (patch) | |
| tree | c3f71f70156158dd6b66aeab4749b155ffcbc6a8 /lib/oxidized | |
| parent | 207a9145c9965b3efe84eb48d3f8ed290b3c30a6 (diff) | |
fetch should return string, not array
Also if group was explicitly given, we referred to wrong directory
Diffstat (limited to 'lib/oxidized')
| -rw-r--r-- | lib/oxidized/output/file.rb | 13 | 
1 files changed, 7 insertions, 6 deletions
| 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 | 
