summaryrefslogtreecommitdiff
path: root/lib/oxidized/output/file.rb
diff options
context:
space:
mode:
authorytti <saku@ytti.fi>2013-10-24 02:18:00 -0700
committerytti <saku@ytti.fi>2013-10-24 02:18:00 -0700
commit1b4cf651d5b7e9e032a7bc0636c569d0419f2ded (patch)
treec94da76aee2709a2808a113115fa34b188a5a34c /lib/oxidized/output/file.rb
parentd7d490077ce16e76367773f5a5fe8bca4f84f366 (diff)
parentfeba4c2b9e0faeb40cad32f16d7b024a2d4327ae (diff)
Merge pull request #7 from nopedial/master
finalize fetch API call
Diffstat (limited to 'lib/oxidized/output/file.rb')
-rw-r--r--lib/oxidized/output/file.rb17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/oxidized/output/file.rb b/lib/oxidized/output/file.rb
index 8aaae0e..2ea2302 100644
--- a/lib/oxidized/output/file.rb
+++ b/lib/oxidized/output/file.rb
@@ -25,9 +25,20 @@ class OxFile < Output
open(file, 'w') { |fh| fh.write data }
end
- def fetch node
- IO.readlines File.join(@cfg[:directory], node)
+
+ def fetch node, group
+ cfg_dir = @cfg[:directory]
+ if group != 0 # group is explicitly defined by user
+ IO.readlines File.join(cfg_dir, group, node)
+ else
+ if File.exists? File.join(cfg_dir, node) # node configuration file is stored on base directory
+ IO.readlines File.join(cfg_dir, node)
+ else
+ path = Dir.glob File.join(cfg_dir, '**', node) # fetch node in all groups
+ open(path[0], 'r').readlines
+ end
+ end
end
-
+
end
end