annotate lib/redmine/version.rb @ 8:0c83d98252d9 yuya

* Add custom repo prefix and proper auth realm, remove auth cache (seems like an unwise feature), pass DB handle around, various other bits of tidying
author Chris Cannam
date Thu, 12 Aug 2010 15:31:37 +0100
parents 513646585e45
children 1d32c0a0efbf
rev   line source
Chris@0 1 require 'rexml/document'
Chris@0 2
Chris@0 3 module Redmine
Chris@0 4 module VERSION #:nodoc:
Chris@0 5 MAJOR = 1
Chris@0 6 MINOR = 0
Chris@0 7 TINY = 0
Chris@0 8
Chris@0 9 # Branch values:
Chris@0 10 # * official release: nil
Chris@0 11 # * stable branch: stable
Chris@0 12 # * trunk: devel
Chris@0 13 BRANCH = 'devel'
Chris@0 14
Chris@0 15 def self.revision
Chris@0 16 revision = nil
Chris@0 17 entries_path = "#{RAILS_ROOT}/.svn/entries"
Chris@0 18 if File.readable?(entries_path)
Chris@0 19 begin
Chris@0 20 f = File.open(entries_path, 'r')
Chris@0 21 entries = f.read
Chris@0 22 f.close
Chris@0 23 if entries.match(%r{^\d+})
Chris@0 24 revision = $1.to_i if entries.match(%r{^\d+\s+dir\s+(\d+)\s})
Chris@0 25 else
Chris@0 26 xml = REXML::Document.new(entries)
Chris@0 27 revision = xml.elements['wc-entries'].elements[1].attributes['revision'].to_i
Chris@0 28 end
Chris@0 29 rescue
Chris@0 30 # Could not find the current revision
Chris@0 31 end
Chris@0 32 end
Chris@0 33 revision
Chris@0 34 end
Chris@0 35
Chris@0 36 REVISION = self.revision
Chris@0 37 ARRAY = [MAJOR, MINOR, TINY, BRANCH, REVISION].compact
Chris@0 38 STRING = ARRAY.join('.')
Chris@0 39
Chris@0 40 def self.to_a; ARRAY end
Chris@0 41 def self.to_s; STRING end
Chris@0 42 end
Chris@0 43 end