Module: AutoC::Module::SmartRenderer
Instance Attribute Summary collapse
-
#digest ⇒ Object
readonly
def render_contents(stream).
Instance Method Summary collapse
Instance Attribute Details
#digest ⇒ Object (readonly)
def render_contents(stream)
180 181 182 |
# File 'lib/autoc/module.rb', line 180 def digest @digest end |
Instance Method Details
#render ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/autoc/module.rb', line 182 def render io = stream _file_name = io.path # Memorize temporary file name begin begin render_contents(io) @digest = io.digest ensure io.close end rescue File.unlink(_file_name) # Remove improperly rendered temporary file raise else if !File.exist?(file_name) || self.module.digests[file_name] != digest File.rename(_file_name, file_name) # Rendered temporary has different digest - replace original permanent file with it else File.unlink(_file_name) # New temporary has the same digest as permanent - no need to replace the latter, delete the temporary instead end end end |