Sha256: e7031cc160720c532625eef9631c2ace3e96c69932a72e1d8e50030151aae7a4

Contents?: true

Size: 1.2 KB

Versions: 47

Compression:

Stored size: 1.2 KB

Contents

# Do not use Rails-specific helper methods here (e.g., `blank?`) so the module can run standalone.
module RESTFramework
  module Version
    VERSION_FILEPATH = File.expand_path("../../VERSION", __dir__)

    def self.get_version(skip_git: false)
      # First, attempt to get the version from git.
      unless skip_git
        version = `git describe --dirty 2>/dev/null`&.strip
        return version unless !version || version.empty?
      end

      # Git failed or was skipped, so try to find a VERSION file.
      begin
        version = File.read(VERSION_FILEPATH)&.strip
        return version unless !version || version.empty?
      rescue SystemCallError
      end

      # If that fails, then try to get a plain commit SHA from git.
      unless skip_git
        version = `git describe --dirty --always`&.strip
        return "0.#{version}" unless !version || version.empty?
      end

      # No VERSION file, so version is unknown.
      return "0.unknown"
    end

    def self.stamp_version
      File.write(VERSION_FILEPATH, RESTFramework::VERSION)
    end

    def self.unstamp_version
      File.delete(VERSION_FILEPATH) if File.exist?(VERSION_FILEPATH)
    end
  end

  VERSION = Version.get_version
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
rest_framework-0.8.15 lib/rest_framework/version.rb
rest_framework-0.8.14 lib/rest_framework/version.rb
rest_framework-0.8.13 lib/rest_framework/version.rb
rest_framework-0.8.12 lib/rest_framework/version.rb
rest_framework-0.8.11 lib/rest_framework/version.rb
rest_framework-0.8.10 lib/rest_framework/version.rb
rest_framework-0.8.9 lib/rest_framework/version.rb
rest_framework-0.8.8 lib/rest_framework/version.rb
rest_framework-0.8.7 lib/rest_framework/version.rb
rest_framework-0.8.6 lib/rest_framework/version.rb
rest_framework-0.8.5 lib/rest_framework/version.rb
rest_framework-0.8.4 lib/rest_framework/version.rb
rest_framework-0.8.3 lib/rest_framework/version.rb
rest_framework-0.8.2 lib/rest_framework/version.rb
rest_framework-0.8.1 lib/rest_framework/version.rb
rest_framework-0.8.0 lib/rest_framework/version.rb
rest_framework-0.7.12 lib/rest_framework/version.rb
rest_framework-0.7.11 lib/rest_framework/version.rb
rest_framework-0.7.10 lib/rest_framework/version.rb
rest_framework-0.7.9 lib/rest_framework/version.rb