From d0332d05222169ffdbdb65d6d4e79b45a2bf789e Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sun, 3 Jun 2018 22:05:42 +0100 Subject: Support specifying multiple values for a single key In the hash_to_arguments method of GovukGuix::Job. --- app/jobs/govuk_guix/job.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/jobs/govuk_guix/job.rb b/app/jobs/govuk_guix/job.rb index fdac507..357c8ca 100644 --- a/app/jobs/govuk_guix/job.rb +++ b/app/jobs/govuk_guix/job.rb @@ -81,13 +81,15 @@ class GovukGuix::Job < Que::Job end def hash_to_arguments(hash) - hash.map do |(key, value)| + hash.flat_map do |(key, value)| transformed_key = key.tr('_', '-') if value == true - "--#{transformed_key}" + ["--#{transformed_key}"] + elsif value.kind_of?(Array) + value.map { |x| "--#{transformed_key}=#{x}" } else - "--#{transformed_key}=#{value}" + ["--#{transformed_key}=#{value}"] end end end -- cgit v1.2.3