Sha256: 3e9a86d81ce86a7a30f3346a982e4c4933356d081be5b2166e207e43c0fcf27a

Contents?: true

Size: 1.63 KB

Versions: 19

Compression:

Stored size: 1.63 KB

Contents

module Compass
  module Version
    # 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
      if defined?(@version)
        @version
      else
        read_version
      end
    end

    protected

    def scope(file) # :nodoc:
      File.join(File.dirname(__FILE__), '..', '..', file)
    end

    def read_version
      require 'yaml'
      @version = YAML::load(File.read(scope('VERSION.yml')))
      @version[:teeny]  = @version[:patch]
      @version[:string] = "#{@version[:major]}.#{@version[:minor]}"
      @version[:string] << ".#{@version[:patch]}" if @version[:patch]
      @version[:string] << ".#{@version[:build]}" if @version[:build]
      @version[:string] << ".#{@version[:state]}" if @version[:state]
      @version[:string] << ".#{@version[:iteration]}" if @version[:iteration]
      if !ENV['OFFICIAL'] && r = revision
        @version[:string] << ".#{r[0..6]}"
      end
      @version
    end

    def revision
      revision_from_git
    end

    def revision_from_git
      if File.exists?(scope('.git/HEAD'))
        Dir.chdir scope(".") do
          `git rev-parse HEAD`
        end
      end
    end

  end
  extend Compass::Version
  def self.const_missing(const)
    # This avoid reading from disk unless the VERSION is requested.
    if const == :VERSION
      version[:string]
    else
      super
    end
  end
end

Version data entries

19 entries across 18 versions & 3 rubygems

Version Path
sadui-0.0.4 vendor/bundle/ruby/2.1.0/gems/compass-0.12.3/lib/compass/version.rb
sadui-0.0.4 vendor/bundle/ruby/2.0.0/gems/compass-0.12.3/lib/compass/version.rb
compass-0.12.5 lib/compass/version.rb
compass-0.12.4 lib/compass/version.rb
compass-0.12.3 lib/compass/version.rb
compass-0.13.alpha.12 lib/compass/version.rb
compass-0.13.alpha.10 lib/compass/version.rb
compass-0.13.alpha.9 lib/compass/version.rb
compass-0.13.alpha.8 lib/compass/version.rb
compass-0.13.alpha.7 lib/compass/version.rb
compass-0.13.alpha.6 lib/compass/version.rb
compass-0.13.alpha.5 lib/compass/version.rb
compass-sourcemaps-0.12.4.sourcemaps.a4836f1 lib/compass/version.rb
compass-0.13.alpha.4 lib/compass/version.rb
compass-0.13.alpha.3 lib/compass/version.rb
compass-0.13.alpha.2 lib/compass/version.rb
compass-0.12.2 lib/compass/version.rb
compass-0.12.2.rc.1 lib/compass/version.rb
compass-0.12.2.rc.0 lib/compass/version.rb