version.rb
44 lines
| 1.0 KiB
| text/x-ruby
|
RubyLexer
|
r813 | require 'rexml/document' | ||
|
r450 | module Redmine | ||
module VERSION #:nodoc: | ||||
|
r9346 | MAJOR = 2 | ||
MINOR = 0 | ||||
|
r9549 | TINY = 1 | ||
|
r5429 | |||
|
r2034 | # Branch values: | ||
# * official release: nil | ||||
# * stable branch: stable | ||||
# * trunk: devel | ||||
|
r9512 | BRANCH = 'stable' | ||
|
r450 | |||
|
r813 | def self.revision | ||
revision = nil | ||||
|
r5963 | entries_path = "#{Rails.root}/.svn/entries" | ||
|
r813 | if File.readable?(entries_path) | ||
begin | ||||
f = File.open(entries_path, 'r') | ||||
entries = f.read | ||||
f.close | ||||
|
r5429 | if entries.match(%r{^\d+}) | ||
revision = $1.to_i if entries.match(%r{^\d+\s+dir\s+(\d+)\s}) | ||||
else | ||||
xml = REXML::Document.new(entries) | ||||
revision = | ||||
xml.elements['wc-entries'].elements[1].attributes['revision'].to_i | ||||
end | ||||
rescue | ||||
# Could not find the current revision | ||||
end | ||||
end | ||||
revision | ||||
|
r813 | end | ||
REVISION = self.revision | ||||
|
r5429 | ARRAY = [MAJOR, MINOR, TINY, BRANCH, REVISION].compact | ||
STRING = ARRAY.join('.') | ||||
|
r6401 | |||
|
r5429 | def self.to_a; ARRAY end | ||
|
r6401 | def self.to_s; STRING end | ||
|
r450 | end | ||
end | ||||