Sha256: f8beb44d9b7e293cbb13431715ed1fa18151e0997e3942abe17ab7d76f31727d
Contents?: true
Size: 1.05 KB
Versions: 3
Compression:
Stored size: 1.05 KB
Contents
module Oxidized class OxidizedFile < Output require 'fileutils' def initialize @cfg = CFG.output.file end def setup if @cfg.empty? CFGS.user.output.file.directory = File.join(Config::Root, 'configs') CFGS.save :user raise NoConfig, 'no output file config, edit ~/.config/oxidized/config' end end def store node, outputs, opt={} file = @cfg.directory if opt[:group] file = File.join File.dirname(file), opt[:group] end FileUtils.mkdir_p file file = File.join file, node open(file, 'w') { |fh| fh.write outputs.to_cfg } end def fetch node, group cfg_dir = @cfg.directory if group # 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
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
oxidized-0.4.0 | lib/oxidized/output/file.rb |
oxidized-0.3.0 | lib/oxidized/output/file.rb |
oxidized-0.2.4 | lib/oxidized/output/file.rb |