summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaku Ytti <saku@ytti.fi>2016-10-26 13:32:01 +0300
committerSaku Ytti <saku@ytti.fi>2016-10-26 13:32:01 +0300
commit449522554473f4b9a261ec06ee6961defb30f7bb (patch)
treec3f71f70156158dd6b66aeab4749b155ffcbc6a8
parent207a9145c9965b3efe84eb48d3f8ed290b3c30a6 (diff)
fetch should return string, not array
Also if group was explicitly given, we referred to wrong directory
-rw-r--r--Gemfile.lock2
-rw-r--r--lib/oxidized/output/file.rb13
2 files changed, 8 insertions, 7 deletions
diff --git a/Gemfile.lock b/Gemfile.lock
index 373fdbe..ab52715 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- oxidized (0.17.0)
+ oxidized (0.18.0)
asetus (~> 0.1)
net-ssh (~> 3.0.2)
net-telnet
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