Sha256: edfa6ff3265d4ea11dd8bda4352d4df33900c119c4deb549e237ca8418a98a41
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 KB
Contents
module Oxidized class OxidizedFile < Output require 'fileutils' attr_reader :commitref def initialize super @cfg = Oxidized.config.output.file end def setup return unless @cfg.empty? Oxidized.asetus.user.output.file.directory = File.join(Config::ROOT, 'configs') Oxidized.asetus.save :user raise NoConfig, 'no output file config, edit ~/.config/oxidized/config' end def store(node, outputs, opt = {}) file = File.expand_path @cfg.directory file = File.join File.dirname(file), opt[:group] if opt[:group] FileUtils.mkdir_p file file = File.join file, node File.write(file, outputs.to_cfg) @commitref = file end def fetch(node, group) cfg_dir = File.expand_path @cfg.directory node_name = node.name if group # group is explicitly defined by user cfg_dir = File.join File.dirname(cfg_dir), group File.read File.join(cfg_dir, node_name) elsif File.exist? File.join(cfg_dir, node_name) # node configuration file is stored on base directory File.read File.join(cfg_dir, node_name) else path = Dir.glob(File.join(File.dirname(cfg_dir), '**', node_name)).first # fetch node in all groups File.read path end rescue Errno::ENOENT nil end def version(_node, _group) # not supported [] end def get_version(_node, _group, _oid) 'not supported' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
oxidized-0.30.1 | lib/oxidized/output/file.rb |
oxidized-0.30.0 | lib/oxidized/output/file.rb |