]> git.madduck.net Git - puppet/sudo.git/blob - templates/option_line.erb

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

split into files
[puppet/sudo.git] / templates / option_line.erb
1 <%- if @newline_before %>
2 <% end -%>
3 <% if @comment -%>
4 <%= @comment.gsub(/(.{1,78})( +|$\n?)|(.{1,78})/, "# \\1\\3\n") -%>
5 <%- end -%>
6 <%-
7   def format_parameter(param, value)
8     if [true, false].include? value
9       return "#{value ? "" : "!"}#{param}"
10     elsif value.is_a?(String)
11       return "#{param}=\"#{@value}\""
12     else
13       return "#{param}=#{@value}"
14     end
15   end
16
17   def context_list(context, list)
18     if context == "global"
19       return ""
20     else
21       @CMAP = { "host" => '@', "user" => ':', "cmnd" => '!', "runas" => '>' }
22       return "#{@CMAP[context]}#{list.join(',')}"
23     end
24   end
25 -%>
26 Defaults<%= context_list(@context, @_list) %> <%= format_parameter(@param, @value) %>