
.pnc.pnc-groovy-client.1.2.2.source-code.Misc.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pnc-groovy-client Show documentation
Show all versions of pnc-groovy-client Show documentation
A client for the PNC REST API
The newest version!
package ca.szc.groovy.pnc
import groovy.transform.PackageScope
import java.security.MessageDigest
@PackageScope
class Misc {
static String sha256(String s) {
MessageDigest.getInstance("SHA-256").digest(s.bytes).encodeHex().toString()
}
static String dashSeparated(String s) {
s.replaceAll(/\B[A-Z]/) { '-' + it }.toLowerCase()
}
static String camelCase(String s) {
s.replaceAll(/-\w/){ it[1].toUpperCase() }
}
static String wordWrap(text, length=80, start=0) {
length = length - start
def sb = new StringBuilder()
def line = ''
text.split(/\s/).each { word ->
if (line.size() + word.size() > length) {
sb.append(line.trim()).append('\n').append(' ' * start)
line = ''
}
line += " $word"
}
sb.append(line.trim()).toString()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy