class AutoC::Module::EntityContainer::AutoC::Module::EntityContainer::Module::State
@private
Attributes
module[R]
Public Class Methods
new(m)
click to toggle source
Calls superclass method
# File lib/autoc/module.rb, line 109 def initialize(m) super @module = m end
Public Instance Methods
collect()
click to toggle source
# File lib/autoc/module.rb, line 114 def collect self[self.module.header.file_name] = self.module.header.digest self.module.sources.each { |source| self[source.file_name] = source.digest } self end
file_name(= "
click to toggle source
# File lib/autoc/module.rb, line 107 def file_name = "#{self.module.name}.state" def initialize(m) super @module = m end def collect self[self.module.header.file_name] = self.module.header.digest self.module.sources.each { |source| self[source.file_name] = source.digest } self end def read if self.module.stateful? && File.exist?(file_name) # It's OK not to have this file but if it exists it must have proper contents io = File.open(file_name, 'rt', chomp: true) begin hash = {} io.readlines.each do |x| raise 'improper state file format' if (/\s*([^\s]+)\s+\*(.*)/ =~ x).nil? hash[$2] = $1 end update(hash) ensure io.close end end self end def write io = File.open(file_name, 'wt') begin begin each { |file_name, digest| io << "#{digest} *#{file_name}\n" } ensure io.close end rescue File.unlink(file_name) # Delete improperly rendered state file raise end self end end
read()
click to toggle source
# File lib/autoc/module.rb, line 120 def read if self.module.stateful? && File.exist?(file_name) # It's OK not to have this file but if it exists it must have proper contents io = File.open(file_name, 'rt', chomp: true) begin hash = {} io.readlines.each do |x| raise 'improper state file format' if (/\s*([^\s]+)\s+\*(.*)/ =~ x).nil? hash[$2] = $1 end update(hash) ensure io.close end end self end
write()
click to toggle source
# File lib/autoc/module.rb, line 138 def write io = File.open(file_name, 'wt') begin begin each { |file_name, digest| io << "#{digest} *#{file_name}\n" } ensure io.close end rescue File.unlink(file_name) # Delete improperly rendered state file raise end self end