Created
February 8, 2019 17:00
-
-
Save ginowu7/00f66c9f08d5657c64d166abcae77a55 to your computer and use it in GitHub Desktop.
Parsing comment blocks for AB_TEST
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func validateABTests(file: String) { | |
let declaredVariantFile = findPath(file) | |
let variantContents = contents(atPath: declaredVariantFile) | |
let variantTests = regexFor("(.*//\\s*AB_TEST.*)", content: variantContents) | |
variantTests.forEach { | |
guard let expirationDateSerialized = regexFor("((0|1)\\d{1})/((0|1|2)\\d{1})/((19|20)\\d{2})", content: $0).first, | |
let expirationDate = dateFormatter.date(from: expirationDateSerialized) else { | |
fatalError("Incorrect expiration date format: MM/dd/yyyy") | |
} | |
if let expiredTest = regexFor(".+?(?=:)", content: $0).first, expirationDate < currentDate { | |
print("warning: \(expiredTest) AB Test is expired - \n:\($0)") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment