blob: b988c1a5b6a6a65e4fea1497eaee42d7992e2e2f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
module Oxidized
class OxFile < Output
require 'fileutils'
def initialize
@cfg = CFG.output[:file]
end
def setup
if not @cfg
CFG.output[:file] = {
:directory => File.join(Config::Root, 'configs')
}
CFG.save
end
end
def update node, data, 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 data }
end
end
end
|