Sha256: 79e0f221c5223954e9d4db7f3b64636119a131ffdbc699825446c63b73d5de26

Contents?: true

Size: 933 Bytes

Versions: 4

Compression:

Stored size: 933 Bytes

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)
            record[:recipient] = record[:recipient].split(/\s*,\s*/).collect { |d| d.gsub(/^['"]|['"]$/, '') }
            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

4 entries across 4 versions & 1 rubygems

Version Path
puppet-0.24.0 lib/puppet/provider/mailalias/aliases.rb
puppet-0.24.3 lib/puppet/provider/mailalias/aliases.rb
puppet-0.24.2 lib/puppet/provider/mailalias/aliases.rb
puppet-0.24.1 lib/puppet/provider/mailalias/aliases.rb