Module: Version
- Included in:
- Options
- Defined in:
- lib/version.rb
Overview
Methods for finding out the Riff version
Instance Method Summary collapse
- #dirty? ⇒ Boolean
- #git_branch ⇒ Object
- #git_version(dirty) ⇒ Object
- #rubygems_version ⇒ Object
- #semantic_version ⇒ Object
-
#semantify_git_version(raw) ⇒ Object
Turn git describe output into a semantic version, inspired by riff.gemspec.
- #version ⇒ Object
Instance Method Details
#dirty? ⇒ Boolean
45 46 47 |
# File 'lib/version.rb', line 45 def dirty? return git_version(true).include?('-dirty') end |
#git_branch ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/version.rb', line 49 def git_branch git_result = `cd #{__dir__} ; git rev-parse --abbrev-ref HEAD 2> /dev/null` if $CHILD_STATUS.success? return git_result.chomp else return nil end end |
#git_version(dirty) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/version.rb', line 5 def git_version(dirty) dirty_flag = dirty ? '--dirty' : '' version = `cd #{__dir__} ; git describe #{dirty_flag} 2> /dev/null`.chomp if $CHILD_STATUS.success? return version else return nil end end |
#rubygems_version ⇒ Object
15 16 17 |
# File 'lib/version.rb', line 15 def rubygems_version return Gem::Specification.find_by_name('riffdiff').version.to_s end |
#semantic_version ⇒ Object
41 42 43 |
# File 'lib/version.rb', line 41 def semantic_version return semantify_git_version(git_version(false)) end |
#semantify_git_version(raw) ⇒ Object
Turn git describe output into a semantic version, inspired by riff.gemspec
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/version.rb', line 20 def semantify_git_version(raw) return nil if raw.nil? return raw if raw.end_with? '-dirty' return (raw + '.0') if /^[0-9]+\.[0-9]+$/.match(raw) if /^([0-9]+\.[0-9]+)-([0-9]+)-/.match(raw) return "#{$1}.#{$2}" end return raw end |
#version ⇒ Object
34 35 36 37 38 39 |
# File 'lib/version.rb', line 34 def version semantic_git_version = semantify_git_version(git_version(false)) return semantic_git_version unless semantic_git_version.nil? return rubygems_version end |