Sha256: c5bc0f8057f8ed010122c0fe728e6b5231bd8cd85cb59f7f00ddfd35a7a36be0

Contents?: true

Size: 1004 Bytes

Versions: 1

Compression:

Stored size: 1004 Bytes

Contents

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?
    end

    def version(state)
      self['states'][state].nil? ? nil : self['states'][state]['version']
    end

    def version_type(state)
      self['states'][state].nil? ? nil : self['states'][state]['type']
    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)
      version = YAML::load_file(info_filename)
      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']
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
docman-0.0.3 lib/docman/info.rb