File: version.rb

package info (click to toggle)
ruby-compass 1.0.3~dfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 8,184 kB
  • ctags: 1,789
  • sloc: ruby: 12,904; makefile: 100; perl: 43; xml: 14; sh: 4
file content (42 lines) | stat: -rw-r--r-- 1,271 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require 'compass/generated_version'
module Compass
  module Version
    def scope(file) # :nodoc:
      File.join(File.dirname(__FILE__), '..', '..', file)
    end

    def parse_version(version, name)
      nil_or_int = lambda{|i| i.nil? ? nil : i.to_i}
      segments = version.split(".")
      {
        :string => version,
        :name => name,
        :major => nil_or_int.call(segments.shift),
        :minor => nil_or_int.call(segments.shift),
        :patch => nil_or_int.call(segments.shift),
        :state => segments.shift,
        :iteration => nil_or_int.call(segments.shift)
      }
    end

    # Returns a hash representing the version.
    # The :major, :minor, and :teeny keys have their respective numbers.
    # The :string key contains a human-readable string representation of the version.
    # The :rev key will have the current revision hash.
    #
    # This method swiped from Haml and then modified, some credit goes to Nathan Weizenbaum
    def version
      Compass::VERSION_DETAILS
    end
  end

  extend Compass::Version

  unless defined?(::Compass::VERSION)
    VERSION = File.read(scope("VERSION")).strip 
    VERSION_NAME = File.read(scope("VERSION_NAME")).strip
  end

  VERSION_DETAILS = parse_version(VERSION, VERSION_NAME)

end