diff --git a/spec/defines/virtualhost_spec.rb b/spec/defines/virtualhost_spec.rb index 4c7d236..16c730f 100644 --- a/spec/defines/virtualhost_spec.rb +++ b/spec/defines/virtualhost_spec.rb @@ -121,6 +121,15 @@ } end + context 'with nested array and hash custom options' do + let(:params) { { custom_options: { external_services: [{ 'type' => 'turns', 'algorithm' => 'turn' }] } } } + + it { + is_expected.to contain_file(path_avail). \ + with_content(%r#^external_services = {\n {\n type = "turns";\n algorithm = "turn";\n }\n}#) + } + end + context 'with disco items' do let(:params) { { disco_items: %w[foo bar] } } diff --git a/templates/prosody.cfg.erb b/templates/prosody.cfg.erb index a722e16..8278da6 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('"; "') + '" }' + "{\n" + ' ' * (indentation + 2) + object.map {|v| print_recursive(v, indentation + 2)}.join('; ') + "\n" + (' ' * indentation) + '}' 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..2469fce 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('"; "') + '" }' + "{\n" + ' ' * (indentation + 2) + object.map {|v| print_recursive(v, indentation + 2)}.join('; ') + "\n" + (' ' * indentation) + '}' when Hash "{\n" + ' ' * (indentation + 2) + object.map {|k,v| "#{k} = " + print_recursive(v, indentation + 2)}.join(";\n" + ' ' * (indentation + 2)) + ";\n" + (' ' * indentation) + '}' when TrueClass, FalseClass