summaryrefslogtreecommitdiff
path: root/lib/oxidized/output/file.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/output/file.rb')
-rw-r--r--lib/oxidized/output/file.rb25
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/oxidized/output/file.rb b/lib/oxidized/output/file.rb
index 8aaae0e..08272a5 100644
--- a/lib/oxidized/output/file.rb
+++ b/lib/oxidized/output/file.rb
@@ -25,9 +25,28 @@ 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?("#{cfg_dir}/#{node}") # node configuration file is stored on base directory
+ IO.readlines File.join(cfg_dir, node)
+ else
+ Dir.foreach(cfg_dir) do |sub_dir|
+ next if sub_dir == '.' or sub_dir == '..'
+ if File.directory?("#{cfg_dir}/#{sub_dir}")
+ files = Dir.entries("#{cfg_dir}/#{sub_dir}")
+ files.each do |f|
+ next if File.directory?("#{cfg_dir}/#{sub_dir}/#{f}") or f == '.' or f == '..'
+ IO.readlines File.join(cfg_dir, sub_dir, f) if f == node # node configuration file found on sub directory
+ end
+ end
+ end
+ end
+ end
end
-
+
end
end