File: lib/redmine/version.rb

Overview
Module Structure
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: Redmine#3
  module: VERSION#4
has properties
constant: MAJOR #5
constant: MINOR #6
constant: TINY #7
constant: BRANCH #13
module method: revision #15
constant: REVISION #37
constant: ARRAY #38
constant: STRING #39
module method: to_a #41
module method: to_s #42

Code

   1  require 'rexml/document'
   2 
   3  module Redmine
   4    module VERSION #:nodoc:
   5      MAJOR = 1
   6      MINOR = 4
   7      TINY  = 0
   8 
   9      # Branch values:
  10      # * official release: nil
  11      # * stable branch:    stable
  12      # * trunk:            devel
  13      BRANCH = 'stable'
  14 
  15      def self.revision
  16        revision = nil
  17        entries_path = "#{Rails.root}/.svn/entries"
  18        if File.readable?(entries_path)
  19          begin
  20            f = File.open(entries_path, 'r')
  21            entries = f.read
  22            f.close
  23            if entries.match(%r{^\d+})
  24              revision = $1.to_i if entries.match(%r{^\d+\s+dir\s+(\d+)\s})
  25            else
  26              xml = REXML::Document.new(entries)
  27              revision =
  28                xml.elements['wc-entries'].elements[1].attributes['revision'].to_i
  29            end
  30          rescue
  31            # Could not find the current revision
  32          end
  33        end
  34        revision
  35      end
  36 
  37      REVISION = self.revision
  38      ARRAY    = [MAJOR, MINOR, TINY, BRANCH, REVISION].compact
  39      STRING   = ARRAY.join('.')
  40 
  41      def self.to_a; ARRAY  end
  42      def self.to_s; STRING end
  43    end
  44  end