lib/docman/info.rb in docman-0.0.3 vs lib/docman/info.rb in docman-0.0.4

- old
+ new

@@ -1,24 +1,36 @@ module Docman class Info < Hash + def initialize(hash = {}) super hash.each_pair do |k, v| self[k] = v end - set_build_type - # self['rebuild'] = need_rebuild? + self['build_type'] = self['docroot_config'].deploy_target['builders'][self['type']]['type'] end - def version(state) - self['states'][state].nil? ? nil : self['states'][state]['version'] + def version + self['states'][self['state']].nil? ? nil : self['states'][self['state']]['version'] end - def version_type(state) - self['states'][state].nil? ? nil : self['states'][state]['type'] + def version_type + self['states'][self['state']].nil? ? nil : self['states'][self['state']]['type'] end + def write_info(result) + to_save = {} + to_save['state'] = self['state'] + to_save['version_type'] = self.version_type unless self.version_type.nil? + to_save['version'] = self.version unless self.version.nil? + # to_save['ref'] = result + to_save['type'] = self['type'] + to_save['build_type'] = self['build_type'] + + File.open("#{self['full_build_path']}/info.yaml", 'w') {|f| f.write to_save.to_yaml} + end + def need_rebuild? return TRUE if Docman::Application.instance.options[:force] return TRUE unless File.directory? self['full_build_path'] info_filename = File.join(self['full_build_path'], 'info.yaml') return TRUE unless File.file?(info_filename) @@ -26,10 +38,11 @@ return TRUE if version['type'] != self['type'] return TRUE if version['build_type'] != self['build_type'] false end - def set_build_type - Docman::Application.instance.deploy_target['builders'][self['type']]['type'] + def state=(state) + self['state'] = state end + end end \ No newline at end of file