From d58c793702252ae0c1f4d3bd0388771c62810486 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Fri, 4 Dec 2020 14:22:20 +0000 Subject: [PATCH 1/2] Add support for time regex string This updates the random content generator to support outputting a random HH:MM time string when the regex matches. This was required to support the new `time_registration` field being added to the protected food & drink names finder: https://github.com/alphagov/govuk-content-schemas/pull/1031/commits/b767b7b55fe970445c8a08be1cee2dc8ae849278 --- CHANGELOG.md | 4 ++++ lib/govuk_schemas/random_content_generator.rb | 2 ++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 759cacd..497adfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 4.2.0 + +* Add support for generating random HH:MM time strings that match a regex. ([#62](https://github.com/alphagov/govuk_schemas/pull/62)) + # 4.1.1 * Fix RandomSchemaGenerator.new always returning equivalent generators ([#60](https://github.com/alphagov/govuk_schemas/pull/60)) diff --git a/lib/govuk_schemas/random_content_generator.rb b/lib/govuk_schemas/random_content_generator.rb index c2d90a9..e198e50 100644 --- a/lib/govuk_schemas/random_content_generator.rb +++ b/lib/govuk_schemas/random_content_generator.rb @@ -81,6 +81,8 @@ def string_for_regex(pattern) Date.today.iso8601 when "^[1-9][0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[0-1])$" Date.today.iso8601 + when "^(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$" + Time.now.strftime("%H:%m") when "^#.+$" anchor when "[a-z-]" From a133487f9cd1f616f86d2bdf90445d0c0950971d Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Fri, 4 Dec 2020 14:24:12 +0000 Subject: [PATCH 2/2] Bump version to 4.2.0 Includes a new regex generator for HH:MM time strings. --- lib/govuk_schemas/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/govuk_schemas/version.rb b/lib/govuk_schemas/version.rb index 9941f70..22ce071 100644 --- a/lib/govuk_schemas/version.rb +++ b/lib/govuk_schemas/version.rb @@ -1,4 +1,4 @@ module GovukSchemas # @private - VERSION = "4.1.1".freeze + VERSION = "4.2.0".freeze end