Sha256: e5fc36c16de80ff01f15f2dbe255f5f8106b41ec7fedf01d070adff8650f0541

Contents?: true

Size: 1.42 KB

Versions: 24

Compression:

Stored size: 1.42 KB

Contents

module Haml
  module Version
    # Returns a hash representing the version of Haml.
    # The :major, :minor, and :teeny keys have their respective numbers.
    # The :string key contains a human-readable string representation of the version.
    # If Haml is checked out from Git,
    # the :rev key will have the revision hash.
    def version
      return @@version if defined?(@@version)

      numbers = File.read(scope('VERSION')).strip.split('.').map { |n| n.to_i }
      @@version = {
        :major => numbers[0],
        :minor => numbers[1],
        :teeny => numbers[2]
      }
      @@version[:string] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.')

      if File.exists?(scope('REVISION'))
        rev = File.read(scope('REVISION')).strip
        rev = nil if rev !~ /^([a-f0-9]+|\(.*\))$/
      end

      if (rev.nil? || rev == '(unknown)') && File.exists?(scope('.git/HEAD'))
        rev = File.read(scope('.git/HEAD')).strip
        if rev =~ /^ref: (.*)$/
          rev = File.read(scope(".git/#{$1}")).strip
        end
      end

      if rev
        @@version[:rev] = rev
        unless rev[0] == ?(
          @@version[:string] << "."
          @@version[:string] << rev[0...7]
        end
      end

      @@version
    end

    # Returns the path of file relative to the Haml root.
    def scope(file) # :nodoc:
      File.expand_path File.join(File.dirname(__FILE__), '..', '..', file)
    end
  end
end

Version data entries

24 entries across 24 versions & 9 rubygems

Version Path
jwhitmire-haml-2.1.0.1 lib/haml/version.rb
jwhitmire-haml-2.1.0.2 lib/haml/version.rb
jwhitmire-haml-2.1.0.3 lib/haml/version.rb
wireframe-haml-2.1.0 lib/haml/version.rb
radiantcms-couchrest_model-0.2.4 vendor/plugins/haml/lib/haml/version.rb
radiantcms-couchrest_model-0.2.2 vendor/plugins/haml/lib/haml/version.rb
radiantcms-couchrest_model-0.2.1 vendor/plugins/haml/lib/haml/version.rb
radiantcms-couchrest_model-0.2 vendor/plugins/haml/lib/haml/version.rb
radiantcms-couchrest_model-0.1.9 vendor/plugins/haml/lib/haml/version.rb
radiantcms-couchrest_model-0.1.8 vendor/plugins/haml/lib/haml/version.rb
radiantcms-couchrest_model-0.1.7 vendor/plugins/haml/lib/haml/version.rb
radiantcms-couchrest_model-0.1.6 vendor/plugins/haml/lib/haml/version.rb
radiantcms-couchrest_model-0.1.5 vendor/plugins/haml/lib/haml/version.rb
radiant-0.8.2 vendor/plugins/haml/lib/haml/version.rb
radiant-rc-0.9.0 vendor/plugins/haml/lib/haml/version.rb
radiant-0.8.1 vendor/plugins/haml/lib/haml/version.rb
haml-2.0.10 lib/haml/version.rb
haml-edge-2.1.1 lib/haml/version.rb
haml-2.0.9 lib/haml/version.rb
haml-2.0.8 lib/haml/version.rb