Handle array values idiomatically

This commit is contained in:
Nate Riffe 2013-08-08 07:40:00 -05:00
parent d044268f07
commit a930f53a4a
4 changed files with 26 additions and 26 deletions

View File

@ -1,6 +1,6 @@
acl <%= @name %> { acl <%= @name %> {
<%- @addresses.each do |address| -%> <%- Array(@addresses).each do |address| -%>
<%= address %>; <%= address %>;
<%- end -%> <%- end -%>
}; };

View File

@ -5,9 +5,9 @@ include "<%= @confdir %>/views.conf";
options { options {
directory "<%= @cachedir %>"; directory "<%= @cachedir %>";
<%- if not @forwarders.empty? -%> <%- if @forwarders and @forwarders != '' -%>
forwarders { forwarders {
<%- @forwarders.each do |forwarder| -%> <%- Array(@forwarders).each do |forwarder| -%>
<%= forwarder %>; <%= forwarder %>;
<%- end -%> <%- end -%>
}; };

View File

@ -1,17 +1,17 @@
view "<%= @name %>" { view "<%= @name %>" {
<%- if not @match_clients.empty? -%> <%- if @match_clients and @match_clients != '' -%>
match-clients { match-clients {
<%- @match_clients.each do |match_client| -%> <%- Array(@match_clients).each do |match_client| -%>
<%= match_client %>; <%= match_client %>;
<%- end -%> <%- end -%>
}; };
<%- end -%> <%- end -%>
<%- if not @match_destinations.empty? -%> <%- if @match_destinations and @match_destinations != '' -%>
match-destinations { match-destinations {
<%- @match_destinations.each do |match_destination| -%> <%- Array(@match_destinations).each do |match_destination| -%>
<%= match_destination %>; <%= match_destination %>;
<%- end -%> <%- end -%>
}; };
<%- end -%> <%- end -%>
recursion <%= @recursion ? 'yes' : 'no' %>; recursion <%= @recursion ? 'yes' : 'no' %>;
@ -19,7 +19,7 @@ view "<%= @name %>" {
include "<%= @confdir %>/named.conf.default-zones"; include "<%= @confdir %>/named.conf.default-zones";
<%- end -%> <%- end -%>
<%- @zones.each do |zone| -%> <%- Array(@zones).each do |zone| -%>
include "<%= @confdir %>/zones/<%= zone %>.conf"; include "<%= @confdir %>/zones/<%= zone %>.conf";
<%- end -%> <%- end -%>
}; };

View File

@ -5,7 +5,7 @@ zone "<%= @_domain %>" {
<%- if @has_zone_file -%> <%- if @has_zone_file -%>
<%- if @dnssec -%> <%- if @dnssec -%>
auto-dnssec maintain; auto-dnssec maintain;
<%- if @key_directory == '' -%> <%- if @key_directory and @key_directory != '' -%>
key-directory "<%= @cachedir %>/<%= @name %>"; key-directory "<%= @cachedir %>/<%= @name %>";
<%- else -%> <%- else -%>
key-directory "<%= @key_directory %>"; key-directory "<%= @key_directory %>";
@ -15,48 +15,48 @@ zone "<%= @_domain %>" {
file "<%= @cachedir %>/<%= @name %>/<%= @_domain %>"; file "<%= @cachedir %>/<%= @name %>/<%= @_domain %>";
<%- end -%> <%- end -%>
notify <%= @ns_notify ? 'yes' : 'no' %>; notify <%= @ns_notify ? 'yes' : 'no' %>;
<%- if not @also_notify.empty? -%> <%- if @also_notify and @also_notify != '' -%>
also-notify { also-notify {
<%- @also_notify.each do |server| -%> <%- Array(@also_notify).each do |server| -%>
<%= server %>; <%= server %>;
<%- end -%> <%- end -%>
}; };
<%- end -%> <%- end -%>
<%- if not @allow_notify.empty? -%> <%- if @allow_notify and @allow_notify != '' -%>
allow-notify { allow-notify {
<%- @allow_notify.each do |server| -%> <%- Array(@allow_notify).each do |server| -%>
<%= server %>; <%= server %>;
<%- end -%> <%- end -%>
}; };
<%- end -%> <%- end -%>
<%- end -%> <%- end -%>
<%- if not @masters.empty? -%> <%- if @masters and @masters != '' -%>
masters { masters {
<%- @masters.each do |master| -%> <%- Array(@masters).each do |master| -%>
<%= master %>; <%= master %>;
<%- end -%> <%- end -%>
}; };
<%- end -%> <%- end -%>
<%- if not @allow_updates.empty? -%> <%- if @allow_updates and @allow_updates != '' -%>
allow-update { allow-update {
<%- @allow_updates.each do |allow_update| -%> <%- Array(@allow_updates).each do |allow_update| -%>
<%= allow_update %>; <%= allow_update %>;
<%- end -%> <%- end -%>
}; };
<%- end -%> <%- end -%>
<%- if not @allow_transfers.empty? -%> <%- if @allow_transfers and @allow_transfers != '' -%>
allow-transfer { allow-transfer {
<%- @allow_transfers.each do |allow_transfer| -%> <%- Array(@allow_transfers).each do |allow_transfer| -%>
<%= allow_transfer %>; <%= allow_transfer %>;
<%- end -%> <%- end -%>
}; };
<%- end -%> <%- end -%>
<%- if @forward != '' -%> <%- if @forward != '' -%>
forward <%= @forward %>; forward <%= @forward %>;
<%- end -%> <%- end -%>
<%- if not @forwarders.empty? -%> <%- if @forwarders and @forwarders != '' -%>
forwarders { forwarders {
<%- @forwarders.each do |forwarder| -%> <%- Array(@forwarders).each do |forwarder| -%>
<%= forwarder %>; <%= forwarder %>;
<%- end -%> <%- end -%>
}; };