module R::Version
#
This software is provided ‘as-is’, without any express or implied # warranty. In no event will the authors be held liable for any damages # arising from the use of this software. #
#
Permission is granted to anyone to use this software for any purpose, # including commercial applications, and to alter it and redistribute it # freely, subject to the following restrictions: #
#
-
The origin of this software must not be misrepresented; you must not # claim that you wrote the original software. If you use this software in # a product, an acknowledgment in the product documentation would be # appreciated but is not required. #
#
-
Altered source versions must be plainly marked as such, and must not be # misrepresented as being the original software. #
#
-
This notice may not be removed or altered from any source distribution. #
#
Version
info.
Public Class Methods
Return the latest commit that is running.
# File lib/rub/r/version-git.rb, line 53 def self.commit `#{@@cdto}; git rev-parse HEAD`.chomp end
Commit and if it is dirty.
# File lib/rub/r/version.rb, line 61 def self.commit_dirty commit + ( dirty? ? '-dirty' : '' ) end
If anything has changed since the last commit.
# File lib/rub/r/version-git.rb, line 58 def self.dirty? `#{@@cdto}; git diff --exit-code` $? != 0 end
The number of commits from the latest version tag.
# File lib/rub/r/version-git.rb, line 35 def self.dist_from_tag `#{@@cdto}; git rev-list HEAD ^#{tag} --count`.to_i end
Returns a version string in the format of the --version
command switch.
# File lib/rub/r/version.rb, line 74 def self.info_string "#{slug} (#{name}) #{string}" end
Pretty Program Name.
# File lib/rub/r/version.rb, line 28 def self.name 'Rub' end
Returns the version number as a string.
# File lib/rub/r/version.rb, line 51 def self.number_string version.join('.') end
If the version information has been prerendered.
If this is false dirty information is probably pretty accurate. If this is true they might have been changed since the rendering occurred.
# File lib/rub/r/version.rb, line 69 def self.rendered? false end
Command
name.
# File lib/rub/r/version.rb, line 38 def self.slug stub + R::Version.version_major end
Returns a formatted version string.
# File lib/rub/r/version.rb, line 79 def self.string a = [] a << number_string if dist_from_tag > 0 a << dist_from_tag a << "g#{commit[0,8]}" end if dirty? a << 'dirty' end a.join '-' end
Short easy-to-type name.
# File lib/rub/r/version.rb, line 33 def self.stub 'rub' end
The latest version tag.
# File lib/rub/r/version-git.rb, line 30 def self.tag @@tagcache ||= `#{@@cdto}; git describe --match 'v[0-9]*.*.*' --abbrev=0`.chomp end
Return a string describing the current version.
Returns an overly verbose string giving all useful (and more) information about the current state of the source.
# File lib/rub/r/version.rb, line 99 def self.verbose out = [] out << "You are using Rub, a platform and language independent build system.\n" out << "https://github.com/kevincox/rub\n" out << "\n" out << "You are using commit #{commit}" if dirty? out << " but the source you are running has been modified since then" end out << ".\n" out << "Commit #{commit[0,8]} is" if dist_from_tag > 0 out << " #{dist_from_tag} commits after" end out << " version #{number_string}.\n" if rendered? out << "\n" out << "NOTE: This information was accurate at the time of" out << " installation. Rub can not detect changes since then." end out.join end
Version
number as a list.
Returns a list of three elements with the major, minor and patch numbers respectively.
# File lib/rub/r/version.rb, line 46 def self.version [version_major, version_minor, version_patch] end
Latest tag and current commit.
# File lib/rub/r/version.rb, line 56 def self.version_commit number_string + '.' + commit[0,8] end
Major version number.
# File lib/rub/r/version-git.rb, line 40 def self.version_major tag.sub @@regex, '\1' end
Minor version number.
# File lib/rub/r/version-git.rb, line 44 def self.version_minor tag.sub @@regex, '\2' end
Patch number.
# File lib/rub/r/version-git.rb, line 48 def self.version_patch tag.sub @@regex, '\3' end