Sha256: 8e3b27ea57cfb0006bdb9f57c741963b83bd53c90aef8428cbc8694bb046e2b4

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

require 'puppet/provider/parsedfile'

Puppet::Type.type(:mailalias).provide(:aliases,
    :parent => Puppet::Provider::ParsedFile,
    :default_target => "/etc/aliases",
    :filetype => :flat
) do
    text_line :comment, :match => /^#/
    text_line :blank, :match => /^\s*$/

    record_line :aliases, :fields => %w{name recipient}, :separator => /\s*:\s*/, :block_eval => :instance do
        def post_parse(record)
            # LAK:NOTE See http://snurl.com/21zf8  [groups_google_com] 
            # It's not sufficient to assign to an existing hash.
            recipient = record[:recipient].split(/\s*,\s*/).collect { |d| d.gsub(/^['"]|['"]$/, '') }
            record[:recipient] = recipient
            record
        end

        def to_line(record)
            dest = record[:recipient].collect do |d|
                # Quote aliases that have non-alpha chars
                if d =~ /[^-\w@.]/
                    '"%s"' % d
                else
                    d
                end
            end.join(",")
            return "%s: %s" % [record[:name], dest]
        end
    end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
puppet-0.24.9 lib/puppet/provider/mailalias/aliases.rb
puppet-0.24.4 lib/puppet/provider/mailalias/aliases.rb
puppet-0.24.5 lib/puppet/provider/mailalias/aliases.rb
puppet-0.24.6 lib/puppet/provider/mailalias/aliases.rb
puppet-0.24.7 lib/puppet/provider/mailalias/aliases.rb
puppet-0.24.8 lib/puppet/provider/mailalias/aliases.rb