From a6892a93b97833fd5d62f3ec6a74ad09aff31d15 Mon Sep 17 00:00:00 2001 From: ChrisBAshton Date: Thu, 23 Jul 2020 17:36:06 +0100 Subject: [PATCH] Remove Utils lib This only had one (untested) method, called in one place. I've now moved its contents directly to where it was being used. --- lib/govuk_schemas.rb | 1 - lib/govuk_schemas/random_content_generator.rb | 5 ++++- lib/govuk_schemas/utils.rb | 8 -------- 3 files changed, 4 insertions(+), 10 deletions(-) delete mode 100644 lib/govuk_schemas/utils.rb diff --git a/lib/govuk_schemas.rb b/lib/govuk_schemas.rb index 967bb34..c13b91a 100644 --- a/lib/govuk_schemas.rb +++ b/lib/govuk_schemas.rb @@ -1,6 +1,5 @@ require "govuk_schemas/version" require "govuk_schemas/schema" -require "govuk_schemas/utils" require "govuk_schemas/random_example" require "govuk_schemas/document_types" require "govuk_schemas/example" diff --git a/lib/govuk_schemas/random_content_generator.rb b/lib/govuk_schemas/random_content_generator.rb index 1700b70..c2d90a9 100644 --- a/lib/govuk_schemas/random_content_generator.rb +++ b/lib/govuk_schemas/random_content_generator.rb @@ -53,7 +53,10 @@ def anchor end def random_identifier(separator:) - Utils.parameterize(WORDS.sample(@random.rand(1..10), random: @random).join("-")).gsub("-", separator) + WORDS.sample(@random.rand(1..10), random: @random) + .join("-") + .gsub(/[^a-z0-9\-_]+/i, "-") + .gsub("-", separator) end def uuid diff --git a/lib/govuk_schemas/utils.rb b/lib/govuk_schemas/utils.rb deleted file mode 100644 index 0219c47..0000000 --- a/lib/govuk_schemas/utils.rb +++ /dev/null @@ -1,8 +0,0 @@ -module GovukSchemas - # @private - module Utils - def self.parameterize(string) - string.gsub(/[^a-z0-9\-_]+/i, "-") - end - end -end