lib/docman/info.rb in docman-0.0.13 vs lib/docman/info.rb in docman-0.0.14
- old
+ new
@@ -3,19 +3,20 @@
module Docman
class Info < Hash
include Docman::Context
- attr_accessor :need_rebuild
+ attr_accessor :need_rebuild, :build_mode
def initialize(hash = {})
super
hash.each_pair do |k, v|
self[k] = v
end
self['build_type'] = self['docroot_config'].deploy_target['builders'][self['type']]['handler']
@need_rebuild = Hash.new
+ @changed = Hash.new
end
def version
self['states'][self['state']].nil? ? nil : self['states'][self['state']]['version']
end
@@ -39,10 +40,20 @@
File.open(File.join(self['full_build_path'], 'info.yaml'), 'w') {|f| f.write to_save.to_yaml}
to_save
end
+ def changed?
+ #TODO: need refactor
+ return @changed[self['state']] if not @changed.nil? and @changed.has_key? self['state'] and not @changed[self['state']].nil?
+ @changed[self['state']] = false
+ if need_rebuild?
+ @changed[self['state']] = true
+ end
+ @changed[self['state']]
+ end
+
def need_rebuild?
return @need_rebuild[self['state']] if not @need_rebuild.nil? and @need_rebuild.has_key? self['state'] and not @need_rebuild[self['state']].nil?
@need_rebuild[self['state']] = _need_rebuild?
if @need_rebuild[self['state']]
set_rebuild_recursive(self, true)
@@ -64,13 +75,15 @@
return true unless File.directory? self['full_build_path']
v = stored_version
return true unless v
return true if v['type'] != self['type']
return true if v['build_type'] != self['build_type']
- return true if (not v['version'].nil? and v['version'] != self.version)
+ # return true if (not v['version'].nil? and v['version'] != self.version)
+ @changed[self['state']] = true if (not v['version'].nil? and v['version'] != self.version)
return true if (not v['version_type'].nil? and v['version_type'] != self.version_type)
unless v['state'].nil?
- return true if v['state'] != self['state']
+ # return true if v['state'] != self['state']
+ @changed[self['state']] = true if v['state'] != self['state']
end
false
end
def stored_version
\ No newline at end of file