Groovy web console

subscribe to the feed Subscribe
to this
sem var without prerelease and meta (via #groovywebconsole)
tweet this snippet Tweet

sem var without prerelease and meta

Published 9 months ago by juan tkaczyszyn
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
 * Extract Version Numbers from String
 * (discards preRelease and metadata)
 * @input String semantic version string
 * @return String stripped of preRelease and metadata
def extractVersionNumbers( String input ) {
  input.findAll( /^\d+\.\d+\.\d+/ )[0]

 * Create Map from two Lists
 * @keys List of keys
 * @values List of values
 * @return Map

def splitVersion(String version) {
    return extractVersionNumbers(version)
            .collect({versionChunk -> versionChunk.toInteger()})