From f7962dbbaea44d13cab1b0582be5ab2068539d74 Mon Sep 17 00:00:00 2001 From: Benedikt Trefzer Date: Wed, 24 Nov 2021 13:38:17 +0100 Subject: [PATCH] fix array in print_recursive function (in both templates !) closes: #88 --- spec/defines/virtualhost_spec.rb | 2 +- templates/prosody.cfg.erb | 2 +- templates/virtualhost.cfg.erb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/defines/virtualhost_spec.rb b/spec/defines/virtualhost_spec.rb index 29b0b7f..536a868 100644 --- a/spec/defines/virtualhost_spec.rb +++ b/spec/defines/virtualhost_spec.rb @@ -116,7 +116,7 @@ is_expected.to contain_file(path_avail). \ with_content(%r{^Component "comp1" "muc"$}). \ with_content(%r{^ bo = true;$}). \ - with_content(%r{^ arr = { "one"; "two" };$}).\ + with_content(%r{^ arr = { "one", "two" };$}).\ with_content(%r{^ str = "string";$}) } end diff --git a/templates/prosody.cfg.erb b/templates/prosody.cfg.erb index a722e16..0414c0f 100644 --- a/templates/prosody.cfg.erb +++ b/templates/prosody.cfg.erb @@ -166,7 +166,7 @@ s2s_secure_domains = { def print_recursive(object, indentation = 0) case object when Array - '{ "' + object.join('"; "') + '" }' + '{ ' + object.map {|v| print_recursive(v, 0)}.join(', ') + ' }' when Hash "{\n" + ' ' * (indentation + 2) + object.map {|k,v| "#{k} = " + print_recursive(v, indentation + 2)}.join(";\n" + ' ' * (indentation + 2)) + ";\n" + (' ' * indentation) + '}' when TrueClass, FalseClass diff --git a/templates/virtualhost.cfg.erb b/templates/virtualhost.cfg.erb index 1c637f1..6e7beb4 100644 --- a/templates/virtualhost.cfg.erb +++ b/templates/virtualhost.cfg.erb @@ -21,7 +21,7 @@ VirtualHost "<%= @name %>" def print_recursive(object, indentation = 0) case object when Array - '{ "' + object.join('"; "') + '" }' + '{ ' + object.map {|v| print_recursive(v, 0)}.join(', ') + ' }' when Hash "{\n" + ' ' * (indentation + 2) + object.map {|k,v| "#{k} = " + print_recursive(v, indentation + 2)}.join(";\n" + ' ' * (indentation + 2)) + ";\n" + (' ' * indentation) + '}' when TrueClass, FalseClass