~ubuntu-branches/ubuntu/utopic/ctioga2/utopic

« back to all changes in this revision

Viewing changes to lib/ctioga2/utils.rb

  • Committer: Package Import Robot
  • Author(s): Vincent Fourmond
  • Date: 2013-12-27 21:04:22 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20131227210422-a3f0c7alorq6lwq2
Tags: 0.8-1
* New upstream release
* Updated URLs and debian/watch to follow its new location
* Already conforms to standards 3.9.5
* Finally updated VCS URLS

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# For platform detection
15
15
require 'rbconfig'
16
16
 
 
17
# The version
 
18
require 'ctioga2/version'
 
19
 
 
20
 
17
21
module CTioga2
18
22
 
19
23
  # An exception to raise upon to-be-implemented-one-day features
26
30
 
27
31
    # The current version of the program.
28
32
    def self.version
29
 
      if CTIOGA_VERSION =~ /SVN/
30
 
        return "SVN, revision #{SVN_INFO['revision']}#{SVN_INFO['suffix']}, #{SVN_INFO['date']}"
31
 
      else
32
 
        return CTIOGA_VERSION
33
 
      end
34
 
    end
35
 
 
36
 
 
37
 
    # All files should use this function with the appropriate
38
 
    # arguments and have the Date and Revision svn:keyword:. Use this
39
 
    # way:
40
 
    #
41
 
    #  Version::register_svn_info('$Revision: 532 $', '$Date: 2013-09-29 12:13:33 +0200 (Sun, 29 Sep 2013) $')
42
 
    #
43
 
    # To set the correct properties, the following command-line can be
44
 
    # used:
45
 
    #
46
 
    #  svn propset svn:keywords 'Date Revision'
47
 
    def self.register_svn_info(rev_str, date_str)
48
 
      if rev_str =~ /(\d+)/
49
 
        rev = $1
50
 
        str = 'Date'
51
 
        date = date_str.gsub(/\$#{str}:\s*(.*)\$/) { $1 }
52
 
        if SVN_INFO['revision'] < rev.to_i
53
 
          SVN_INFO['revision'] = rev.to_i
54
 
          SVN_INFO['date'] = date
55
 
        end
56
 
        # Hmmm, we want to see how many revisions is git ahead of SVN
57
 
        if rev_str =~ /(\+git\d+)/
58
 
          SVN_INFO['suffix'] = $1
59
 
        end
60
 
      end
61
 
    end
 
33
      return GIT_VERSION
 
34
    end
 
35
 
62
36
 
63
37
    # Returns the date ctioga2 was last modified.
64
38
    def self.last_modified_date
65
 
      SVN_INFO['date'] =~ /([\d-]+)/
66
 
      return $1
 
39
      return GIT_DATE
67
40
    end
68
 
 
69
 
 
70
 
    # The constants are moved here, as they disturb rdoc parsing.
71
 
 
72
 
 
73
 
    # Informations collected about subversion revisions
74
 
    SVN_INFO = { 
75
 
      'revision' => 0,
76
 
      'date' => "old",
77
 
      'suffix' => ''
78
 
    }
79
 
 
80
 
    # The position of the URL, used for getting the version
81
 
    SVN_URL = '$HeadURL: svn+ssh://rubyforge.org/var/svn/ctioga2/releases/ctioga2-0.7/lib/ctioga2/utils.rb $'
82
 
    
83
 
    # The version of ctioga2
84
 
    CTIOGA_VERSION = if SVN_URL =~ /releases\/ctioga2-([^\/]+)/
85
 
                       $1
86
 
                     else
87
 
                       "SVN version"
88
 
                     end
89
 
 
90
 
    register_svn_info('$Revision: 532 $', '$Date: 2013-09-29 12:13:33 +0200 (Sun, 29 Sep 2013) $')
91
 
 
92
41
  end
93
42
 
94
43
  # Various utilities
477
426
  end
478
427
end
479
428
 
480
 
begin
481
 
  # This is a dirty hack in order to ensure that the SVN revision
482
 
  # information is kept up-to-date even when using git-svn. This
483
 
  # file is not present in standard installations.
484
 
  require 'ctioga2/git-fools-svn'
485
 
rescue LoadError => e
486
 
end
487
429