Module: RESTFramework::Version
- Defined in:
- lib/rest_framework/version.rb
Constant Summary collapse
- VERSION_FILEPATH =
File.("../../VERSION", __dir__)
Class Method Summary collapse
Class Method Details
.get_version(skip_git: false) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rest_framework/version.rb', line 6 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 |
.stamp_version ⇒ Object
30 31 32 |
# File 'lib/rest_framework/version.rb', line 30 def self.stamp_version File.write(VERSION_FILEPATH, RESTFramework::VERSION) end |
.unstamp_version ⇒ Object
34 35 36 |
# File 'lib/rest_framework/version.rb', line 34 def self.unstamp_version File.delete(VERSION_FILEPATH) if File.exist?(VERSION_FILEPATH) end |