Sha256: 8f6c7b3c29e84a5a28cd8ae98d3afe19a928e28e8792c8c54c440f44c65d815e
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
module GitBumper # This object represents a git tag. It expects the following format of tags: # PREFIX.MAJOR.MINOR.PATCH # It provides some methods to parse and increment version numbers. class Tag REGEX = /\A([a-z]+)([0-9]+)\.([0-9]+)\.([0-9]+)\z/i # Parses a string into a Tag object. # # @param str [String] # @return [Tag] or false if str has an invalid format def self.parse(str) matches = str.scan(REGEX).flatten return false if matches.empty? new(matches[0], matches[1].to_i, matches[2].to_i, matches[3].to_i) end attr_reader :prefix attr_accessor :major, :minor, :patch # @param prefix [String] # @param major [Fixnum] # @param minor [Fixnum] # @param patch [Fixnum] def initialize(prefix, major, minor, patch) @prefix = prefix @major = major @minor = minor @patch = patch end # @return [String] def to_s "#{prefix}#{major}.#{minor}.#{patch}" end # Increments a part of the version. def increment(part) case part when :major @major += 1 when :minor @minor += 1 when :patch @patch += 1 end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
git_bumper-0.1.2 | lib/git_bumper/tag.rb |
git_bumper-0.1.1 | lib/git_bumper/tag.rb |