Module: FFaker::SemVer

Extended by:
ModuleUtils, SemVer
Included in:
SemVer
Defined in:
lib/ffaker/sem_ver.rb

Constant Summary collapse

UPDATE =
%w[major minor patch].freeze

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, underscore, unique

Methods included from RandomUtils

#fetch_sample, #rand, #shuffle

Instance Method Details

#next(previous_version = '0.0.0') ⇒ Object


10
11
12
13
14
15
16
17
# File 'lib/ffaker/sem_ver.rb', line 10

def next(previous_version = '0.0.0')
  major, minor, patch = previous_version.split('.').map(&:to_i)
  case fetch_sample(UPDATE)
  when 'major' then "#{major + 1}.0.0"
  when 'minor' then "#{major}.#{minor + 1}.0"
  when 'patch' then "#{major}.#{minor}.#{patch + 1}"
  end
end