summaryrefslogtreecommitdiffstats
path: root/lib/puppet/type/k5login.rb
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-09 18:12:17 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-09 18:12:17 -0700
commit3180b9d9b2c844dade1d361326600f7001ec66dd (patch)
tree98fe7c5ac7eb942aac9c39f019a17b0b3f5a57f4 /lib/puppet/type/k5login.rb
parent543225970225de5697734bfaf0a6eee996802c04 (diff)
downloadpuppet-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/type/k5login.rb')
-rw-r--r--lib/puppet/type/k5login.rb130
1 files changed, 65 insertions, 65 deletions
diff --git a/lib/puppet/type/k5login.rb b/lib/puppet/type/k5login.rb
index e192ce479..850e37733 100644
--- a/lib/puppet/type/k5login.rb
+++ b/lib/puppet/type/k5login.rb
@@ -3,85 +3,85 @@
# Plug-in type for handling k5login files
Puppet::Type.newtype(:k5login) do
- @doc = "Manage the .k5login file for a user. Specify the full path to
- the .k5login file as the name and an array of principals as the
- property principals."
+ @doc = "Manage the .k5login file for a user. Specify the full path to
+ the .k5login file as the name and an array of principals as the
+ property principals."
- ensurable
+ ensurable
- # Principals that should exist in the file
- newproperty(:principals, :array_matching => :all) do
- desc "The principals present in the .k5login file."
- end
+ # Principals that should exist in the file
+ newproperty(:principals, :array_matching => :all) do
+ desc "The principals present in the .k5login file."
+ end
- # The path/name of the k5login file
- newparam(:path) do
- isnamevar
- desc "The path to the file to manage. Must be fully qualified."
+ # The path/name of the k5login file
+ newparam(:path) do
+ isnamevar
+ desc "The path to the file to manage. Must be fully qualified."
- validate do |value|
- unless value =~ /^#{File::SEPARATOR}/
- raise Puppet::Error, "File paths must be fully qualified"
- end
- end
+ validate do |value|
+ unless value =~ /^#{File::SEPARATOR}/
+ raise Puppet::Error, "File paths must be fully qualified"
+ end
end
+ end
- # To manage the mode of the file
- newproperty(:mode) do
- desc "Manage the k5login file's mode"
- defaultto { "644" }
- end
+ # To manage the mode of the file
+ newproperty(:mode) do
+ desc "Manage the k5login file's mode"
+ defaultto { "644" }
+ end
- provide(:k5login) do
- desc "The k5login provider is the only provider for the k5login
- type."
+ provide(:k5login) do
+ desc "The k5login provider is the only provider for the k5login
+ type."
- # Does this file exist?
- def exists?
- File.exists?(@resource[:name])
- end
+ # Does this file exist?
+ def exists?
+ File.exists?(@resource[:name])
+ end
- # create the file
- def create
- write(@resource.should(:principals))
- should_mode = @resource.should(:mode)
- unless self.mode == should_mode
- self.mode = should_mode
- end
- end
+ # create the file
+ def create
+ write(@resource.should(:principals))
+ should_mode = @resource.should(:mode)
+ unless self.mode == should_mode
+ self.mode = should_mode
+ end
+ end
- # remove the file
- def destroy
- File.unlink(@resource[:name])
- end
+ # remove the file
+ def destroy
+ File.unlink(@resource[:name])
+ end
- # Return the principals
- def principals(dummy_argument=:work_arround_for_ruby_GC_bug)
- if File.exists?(@resource[:name])
- File.readlines(@resource[:name]).collect { |line| line.chomp }
- else
- :absent
- end
- end
+ # Return the principals
+ def principals(dummy_argument=:work_arround_for_ruby_GC_bug)
+ if File.exists?(@resource[:name])
+ File.readlines(@resource[:name]).collect { |line| line.chomp }
+ else
+ :absent
+ end
+ end
- # Write the principals out to the k5login file
- def principals=(value)
- write(value)
- end
+ # Write the principals out to the k5login file
+ def principals=(value)
+ write(value)
+ end
- # Return the mode as an octal string, not as an integer
- def mode
- "%o" % (File.stat(@resource[:name]).mode & 007777)
- end
+ # Return the mode as an octal string, not as an integer
+ def mode
+ "%o" % (File.stat(@resource[:name]).mode & 007777)
+ end
- # Set the file mode, converting from a string to an integer.
- def mode=(value)
- File.chmod(Integer("0#{value}"), @resource[:name])
- end
+ # Set the file mode, converting from a string to an integer.
+ def mode=(value)
+ File.chmod(Integer("0#{value}"), @resource[:name])
+ end
- private
- def write(value)
- File.open(@resource[:name], "w") { |f| f.puts value.join("\n") }
- end
+ private
+ def write(value)
+ File.open(@resource[:name], "w") { |f| f.puts value.join("\n") }
end
+ end
end