Sha256: 2e0752247e4d32ab3da829543484dec1dc08bb443419eb76f949c5d5a608f3d3

Contents?: true

Size: 927 Bytes

Versions: 7

Compression:

Stored size: 927 Bytes

Contents

# frozen_string_literal: true

require 'sem_version'

module GFSM
  module Data
    class Version < SemVersion
      PRERELEASE_BUILD_VERSION = /^(?<prerelease_name>[a-zA-Z\-]+)(\.?)(?<prerelease_version>[0-9]*)$/i

      def bump!(major = false, minor = false, patch = true, pre = false, prerelease_name = "pre")
        if major
          self.major = self.major + 1
          self.minor = 0
          self.patch = 0
        elsif minor
          self.minor = self.minor + 1
          self.patch = 0
        elsif patch
          self.patch = self.patch + 1
        end

        if pre
          preselease_match = self.pre.match(PRERELEASE_BUILD_VERSION) if self.pre
          if preselease_match
            self.pre = preselease_match[:prerelease_name] + "." + (preselease_match[:prerelease_version].to_i + 1).to_s
          else
            self.pre = prerelease_name
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gfsm-0.3.2 lib/data/version.rb
gfsm-0.3.1 lib/data/version.rb
gfsm-0.3.0 lib/data/version.rb
gfsm-0.2.0 lib/data/version.rb
gfsm-0.1.4 lib/data/version.rb
gfsm-0.1.3 lib/data/version.rb
gfsm-0.1.2 lib/data/version.rb