Module: CTioga2::Version

Defined in:
lib/ctioga2/utils.rb

Overview

A small module to deal with versions and dates

Constant Summary collapse

SVN_INFO =

Informations collected about subversion revisions

{ 
  'revision' => 0,
  'date' => "old",
  'suffix' => ''
}
SVN_URL =

The position of the URL, used for getting the version

'$HeadURL$'
CTIOGA_VERSION =

The version of ctioga2

if SVN_URL =~ /releases\/ctioga2-([^\/]+)/
  $1
else
  "SVN version"
end

Class Method Summary collapse

Class Method Details

.last_modified_dateObject

Returns the date ctioga2 was last modified.



60
61
62
63
# File 'lib/ctioga2/utils.rb', line 60

def self.last_modified_date
  SVN_INFO['date'] =~ /([\d-]+)/
  return $1
end

.register_svn_info(rev_str, date_str) ⇒ Object

All files should use this function with the appropriate arguments and have the Date and Revision svn:keyword:. Use this way:

Version::register_svn_info('$Revision$', '$Date$')

To set the correct properties, the following command-line can be used:

svn propset svn:keywords 'Date Revision'


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ctioga2/utils.rb', line 43

def self.register_svn_info(rev_str, date_str)
  if rev_str =~ /(\d+)/
    rev = $1
    str = 'Date'
    date = date_str.gsub(/\$#{str}:\s*(.*)\$/) { $1 }
    if SVN_INFO['revision'] < rev.to_i
      SVN_INFO['revision'] = rev.to_i
      SVN_INFO['date'] = date
    end
    # Hmmm, we want to see how many revisions is git ahead of SVN
    if rev_str =~ /(\+git\d+)/
      SVN_INFO['suffix'] = $1
    end
  end
end

.versionObject

The current version of the program.



25
26
27
28
29
30
31
# File 'lib/ctioga2/utils.rb', line 25

def self.version
  if CTIOGA_VERSION =~ /SVN/
    return "SVN, revision #{SVN_INFO['revision']}#{SVN_INFO['suffix']}, #{SVN_INFO['date']}"
  else
    return CTIOGA_VERSION
  end
end