class Dns::CatalogZone::Output::File
Public Class Methods
new(setting)
click to toggle source
# File lib/dns/catalog_zone/output/file.rb, line 27 def initialize(setting) @setting = setting end
Public Instance Methods
output(str)
click to toggle source
# File lib/dns/catalog_zone/output/file.rb, line 31 def output(str) tmp_file = Tempfile.create('catalog_zone') path = tmp_file.path tmp_file.print(str) tmp_file.close FileUtils.mv(path, @setting.output_path) rescue raise "can't write #{@setting.output_path}" ensure File.unlink(path) if File.exist?(path) end
validate()
click to toggle source
# File lib/dns/catalog_zone/output/file.rb, line 43 def validate raise Dns::CatalogZone::ValidateError, 'source type file is output_path' unless @setting.output_path realpath = ::File.expand_path(@setting.output_path) realdirpath = ::File.dirname(realpath) raise Dns::CatalogZone::CantOutput, 'output_path is not writable' unless ::File.writable?(realpath) || \ ::File.writable?(realdirpath) true end