diff options
| author | Markus Roberts <Markus@reality.com> | 2010-07-09 18:12:17 -0700 |
|---|---|---|
| committer | Markus Roberts <Markus@reality.com> | 2010-07-09 18:12:17 -0700 |
| commit | 3180b9d9b2c844dade1d361326600f7001ec66dd (patch) | |
| tree | 98fe7c5ac7eb942aac9c39f019a17b0b3f5a57f4 /lib/puppet/provider/maillist | |
| parent | 543225970225de5697734bfaf0a6eee996802c04 (diff) | |
| download | puppet-3180b9d9b2c844dade1d361326600f7001ec66dd.tar.gz puppet-3180b9d9b2c844dade1d361326600f7001ec66dd.tar.xz puppet-3180b9d9b2c844dade1d361326600f7001ec66dd.zip | |
Code smell: Two space indentation
Replaced 106806 occurances of ^( +)(.*$) with
The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people
who learned ruby in the 1900s) uses two-space indentation.
3 Examples:
The code:
end
# Tell getopt which arguments are valid
def test_get_getopt_args
element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new
assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args")
becomes:
end
# Tell getopt which arguments are valid
def test_get_getopt_args
element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new
assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args")
The code:
assert_equal(str, val)
assert_instance_of(Float, result)
end
# Now test it with a passed object
becomes:
assert_equal(str, val)
assert_instance_of(Float, result)
end
# Now test it with a passed object
The code:
end
assert_nothing_raised do
klass[:Yay] = "boo"
klass["Cool"] = :yayness
end
becomes:
end
assert_nothing_raised do
klass[:Yay] = "boo"
klass["Cool"] = :yayness
end
Diffstat (limited to 'lib/puppet/provider/maillist')
| -rwxr-xr-x | lib/puppet/provider/maillist/mailman.rb | 174 |
1 files changed, 87 insertions, 87 deletions
diff --git a/lib/puppet/provider/maillist/mailman.rb b/lib/puppet/provider/maillist/mailman.rb index cfb788b31..4fdc20a69 100755 --- a/lib/puppet/provider/maillist/mailman.rb +++ b/lib/puppet/provider/maillist/mailman.rb @@ -1,110 +1,110 @@ require 'puppet/provider/parsedfile' Puppet::Type.type(:maillist).provide(:mailman) do - if [ "CentOS", "RedHat", "Fedora" ].any? { |os| Facter.value(:operatingsystem) == os } - commands :list_lists => "/usr/lib/mailman/bin/list_lists", :rmlist => "/usr/lib/mailman/bin/rmlist", :newlist => "/usr/lib/mailman/bin/newlist" - commands :mailman => "/usr/lib/mailman/mail/mailman" - else - # This probably won't work for non-Debian installs, but this path is sure not to be in the PATH. - commands :list_lists => "list_lists", :rmlist => "rmlist", :newlist => "newlist" - commands :mailman => "/var/lib/mailman/mail/mailman" - end + if [ "CentOS", "RedHat", "Fedora" ].any? { |os| Facter.value(:operatingsystem) == os } + commands :list_lists => "/usr/lib/mailman/bin/list_lists", :rmlist => "/usr/lib/mailman/bin/rmlist", :newlist => "/usr/lib/mailman/bin/newlist" + commands :mailman => "/usr/lib/mailman/mail/mailman" + else + # This probably won't work for non-Debian installs, but this path is sure not to be in the PATH. + commands :list_lists => "list_lists", :rmlist => "rmlist", :newlist => "newlist" + commands :mailman => "/var/lib/mailman/mail/mailman" + end - mk_resource_methods + mk_resource_methods - # Return a list of existing mailman instances. - def self.instances - list_lists.split("\n").reject { |line| line.include?("matching mailing lists") }.collect do |line| - name, description = line.sub(/^\s+/, '').sub(/\s+$/, '').split(/\s+-\s+/) - description = :absent if description.include?("no description available") - new(:ensure => :present, :name => name, :description => description) - end + # Return a list of existing mailman instances. + def self.instances + list_lists.split("\n").reject { |line| line.include?("matching mailing lists") }.collect do |line| + name, description = line.sub(/^\s+/, '').sub(/\s+$/, '').split(/\s+-\s+/) + description = :absent if description.include?("no description available") + new(:ensure => :present, :name => name, :description => description) end + end - # Prefetch our list list, yo. - def self.prefetch(lists) - instances.each do |prov| - if list = lists[prov.name] || lists[prov.name.downcase] - list.provider = prov - end - end + # Prefetch our list list, yo. + def self.prefetch(lists) + instances.each do |prov| + if list = lists[prov.name] || lists[prov.name.downcase] + list.provider = prov + end end + end - def aliases - mailman = self.class.command(:mailman) - name = self.name.downcase - aliases = {name => "| #{mailman} post #{name}"} - %w{admin bounces confirm join leave owner request subscribe unsubscribe}.each do |address| - aliases["#{name}-#{address}"] = "| #{mailman} #{address} #{name}" - end - aliases + def aliases + mailman = self.class.command(:mailman) + name = self.name.downcase + aliases = {name => "| #{mailman} post #{name}"} + %w{admin bounces confirm join leave owner request subscribe unsubscribe}.each do |address| + aliases["#{name}-#{address}"] = "| #{mailman} #{address} #{name}" end + aliases + end - # Create the list. - def create - args = [] - if val = @resource[:mailserver] - args << "--emailhost" << val - end - if val = @resource[:webserver] - args << "--urlhost" << val - end - - args << self.name - if val = @resource[:admin] - args << val - else - raise ArgumentError, "Mailman lists require an administrator email address" - end - if val = @resource[:password] - args << val - else - raise ArgumentError, "Mailman lists require an administrator password" - end - newlist(*args) + # Create the list. + def create + args = [] + if val = @resource[:mailserver] + args << "--emailhost" << val end - - # Delete the list. - def destroy(purge = false) - args = [] - args << "--archives" if purge - args << self.name - rmlist(*args) + if val = @resource[:webserver] + args << "--urlhost" << val end - # Does our list exist already? - def exists? - properties[:ensure] != :absent + args << self.name + if val = @resource[:admin] + args << val + else + raise ArgumentError, "Mailman lists require an administrator email address" end - - # Clear out the cached values. - def flush - @property_hash.clear + if val = @resource[:password] + args << val + else + raise ArgumentError, "Mailman lists require an administrator password" end + newlist(*args) + end - # Look up the current status. - def properties - if @property_hash.empty? - @property_hash = query || {:ensure => :absent} - @property_hash[:ensure] = :absent if @property_hash.empty? - end - @property_hash.dup - end + # Delete the list. + def destroy(purge = false) + args = [] + args << "--archives" if purge + args << self.name + rmlist(*args) + end + + # Does our list exist already? + def exists? + properties[:ensure] != :absent + end - # Remove the list and its archives. - def purge - destroy(true) + # Clear out the cached values. + def flush + @property_hash.clear + end + + # Look up the current status. + def properties + if @property_hash.empty? + @property_hash = query || {:ensure => :absent} + @property_hash[:ensure] = :absent if @property_hash.empty? end + @property_hash.dup + end + + # Remove the list and its archives. + def purge + destroy(true) + end - # Pull the current state of the list from the full list. We're - # getting some double entendre here.... - def query - self.class.instances.each do |list| - if list.name == self.name or list.name.downcase == self.name - return list.properties - end - end - nil + # Pull the current state of the list from the full list. We're + # getting some double entendre here.... + def query + self.class.instances.each do |list| + if list.name == self.name or list.name.downcase == self.name + return list.properties + end end + nil + end end |
