From fdf4741c239cb25ade03236e74659da62b6097a0 Mon Sep 17 00:00:00 2001 From: artonix101 Date: Tue, 16 Dec 2025 22:27:21 +0100 Subject: [PATCH 1/2] Add GB size unit support - Add GB to size unit parsing - Add tests for GB size units --- REFERENCE.md | 6 +++--- spec/type_aliases/squid_size_spec.rb | 3 +++ types/size.pp | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index 6f2b169..0fb77f7 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -44,7 +44,7 @@ By setting optional `ssl` parameter to `true` will create https_port entries ins * [`Squid::Action::SslBump`](#Squid--Action--SslBump): Possible SSLBump options * [`Squid::PkgEnsure`](#Squid--PkgEnsure): Custom type representing package status and/or version -* [`Squid::Size`](#Squid--Size): Custom type containing the numeral value and the unit of messurement (Kilo- or Megabyte) +* [`Squid::Size`](#Squid--Size): Custom type containing the numeral value and the unit of messurement (Kilo-, Mega- or Gigabyte) ## Classes @@ -1717,7 +1717,7 @@ Alias of `Variant[Pattern[/^\d.*/], Enum['present', 'latest', 'absent', 'purged' ### `Squid::Size` -Custom type containing the numeral value and the unit of messurement (Kilo- or Megabyte) +Custom type containing the numeral value and the unit of messurement (Kilo-, Mega- or Gigabyte) -Alias of `Pattern[/^\d+ [KM]B$/]` +Alias of `Pattern[/^\d+ [KMG]B$/]` diff --git a/spec/type_aliases/squid_size_spec.rb b/spec/type_aliases/squid_size_spec.rb index e572146..e78f28f 100644 --- a/spec/type_aliases/squid_size_spec.rb +++ b/spec/type_aliases/squid_size_spec.rb @@ -7,6 +7,7 @@ it { is_expected.to allow_value('1 MB') } it { is_expected.to allow_value('10 KB') } it { is_expected.to allow_value('9876543210 KB') } + it { is_expected.to allow_value('1 GB') } it { is_expected.not_to allow_value('-1 KB') } it { is_expected.not_to allow_value('1 kB') } it { is_expected.not_to allow_value('1 Kb') } @@ -14,4 +15,6 @@ it { is_expected.not_to allow_value('1 KBB') } it { is_expected.not_to allow_value('a KBB') } it { is_expected.not_to allow_value('1KB') } + it { is_expected.not_to allow_value('1 gb') } + it { is_expected.not_to allow_value('1 Gb') } end diff --git a/types/size.pp b/types/size.pp index cb52b3a..5fb45b0 100644 --- a/types/size.pp +++ b/types/size.pp @@ -1,3 +1,3 @@ # @summary # Custom type containing the numeral value and the unit of messurement (Kilo- or Megabyte) -type Squid::Size = Pattern[/^\d+ [KM]B$/] +type Squid::Size = Pattern[/^\d+ [KMG]B$/] From 0849835f98c8bfd530bfa187629ca30712db2b90 Mon Sep 17 00:00:00 2001 From: artonix101 Date: Tue, 16 Dec 2025 23:22:32 +0100 Subject: [PATCH 2/2] add gb to size units --- REFERENCE.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index 0fb77f7..6f2b169 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -44,7 +44,7 @@ By setting optional `ssl` parameter to `true` will create https_port entries ins * [`Squid::Action::SslBump`](#Squid--Action--SslBump): Possible SSLBump options * [`Squid::PkgEnsure`](#Squid--PkgEnsure): Custom type representing package status and/or version -* [`Squid::Size`](#Squid--Size): Custom type containing the numeral value and the unit of messurement (Kilo-, Mega- or Gigabyte) +* [`Squid::Size`](#Squid--Size): Custom type containing the numeral value and the unit of messurement (Kilo- or Megabyte) ## Classes @@ -1717,7 +1717,7 @@ Alias of `Variant[Pattern[/^\d.*/], Enum['present', 'latest', 'absent', 'purged' ### `Squid::Size` -Custom type containing the numeral value and the unit of messurement (Kilo-, Mega- or Gigabyte) +Custom type containing the numeral value and the unit of messurement (Kilo- or Megabyte) -Alias of `Pattern[/^\d+ [KMG]B$/]` +Alias of `Pattern[/^\d+ [KM]B$/]`