Sha256: 23b785c898e03f697af41a6c09cc3ef1c8183447f3e4496737e76006c351751d

Contents?: true

Size: 1011 Bytes

Versions: 9

Compression:

Stored size: 1011 Bytes

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 --broken 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.blank?
      rescue SystemCallError
      end

      # No VERSION file, so version is unknown.
      return '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

9 entries across 9 versions & 1 rubygems

Version Path
rest_framework-0.4.1 lib/rest_framework/version.rb
rest_framework-0.4.0 lib/rest_framework/version.rb
rest_framework-0.3.7 lib/rest_framework/version.rb
rest_framework-0.3.6 lib/rest_framework/version.rb
rest_framework-0.3.5 lib/rest_framework/version.rb
rest_framework-0.3.4 lib/rest_framework/version.rb
rest_framework-0.3.3 lib/rest_framework/version.rb
rest_framework-0.3.2 lib/rest_framework/version.rb
rest_framework-0.3.0 lib/rest_framework/version.rb