Add a grammatically correct 'has_feature' alias, and switch to using it where appropriate in existing code
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2542 980ebf18-57e1-0310-9a29-db15c13687c0
This commit is contained in:
Родитель
0a605e8e17
Коммит
37a221c32e
|
@ -19,7 +19,7 @@ Puppet::Type.type(:user).provide :netinfo, :parent => Puppet::Provider::NameServ
|
|||
|
||||
autogen_defaults :home => "/var/empty", :shell => "/usr/bin/false", :password => '********'
|
||||
|
||||
has_features :manages_passwords
|
||||
has_feature :manages_passwords
|
||||
|
||||
verify :gid, "GID must be an integer" do |value|
|
||||
value.is_a? Integer
|
||||
|
|
|
@ -20,7 +20,7 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
|
|||
has_features :manages_homedir, :allows_duplicates
|
||||
|
||||
if Puppet.features.libshadow? and (Facter.value(:kernel) == "Linux")
|
||||
has_features :manages_passwords
|
||||
has_feature :manages_passwords
|
||||
end
|
||||
|
||||
def addcmd
|
||||
|
|
|
@ -168,6 +168,8 @@ module Puppet::Util::ProviderFeatures
|
|||
@declared_features << name
|
||||
end
|
||||
end
|
||||
# Aaah, grammatical correctness
|
||||
@feature_module.send(:alias_method, :has_feature, :has_features)
|
||||
end
|
||||
@feature_module
|
||||
end
|
||||
|
|
|
@ -254,7 +254,7 @@ class TestTypeAttributes < Test::Unit::TestCase
|
|||
|
||||
# Now make similar providers
|
||||
nope = type.provide(:nope) {}
|
||||
maybe = type.provide(:maybe) { has_features :fone}
|
||||
maybe = type.provide(:maybe) { has_feature :fone}
|
||||
yep = type.provide(:yep) { has_features :fone, :ftwo}
|
||||
|
||||
attrs = [:none, :one, :two]
|
||||
|
|
|
@ -346,6 +346,8 @@ class TestProviderFeatures < Test::Unit::TestCase
|
|||
|
||||
assert(provider.respond_to?(:has_features),
|
||||
"Provider did not get 'has_features' method added")
|
||||
assert(provider.respond_to?(:has_feature),
|
||||
"Provider did not get the 'has_feature' alias method")
|
||||
|
||||
# One with the numeric methods and nothing else
|
||||
@type.provide(:numbers) do
|
||||
|
@ -358,17 +360,17 @@ class TestProviderFeatures < Test::Unit::TestCase
|
|||
define_method(:one) {}
|
||||
define_method(:two) {}
|
||||
|
||||
has_features :alpha
|
||||
has_feature :alpha
|
||||
end
|
||||
|
||||
# And just the declaration
|
||||
@type.provide(:letters) do
|
||||
has_features :alpha
|
||||
has_feature :alpha
|
||||
end
|
||||
|
||||
# And a provider that declares it has our methodless feature.
|
||||
@type.provide(:none) do
|
||||
has_features :nomeths
|
||||
has_feature :nomeths
|
||||
end
|
||||
|
||||
should = {:nothing => [], :both => [:numeric, :alpha],
|
||||
|
@ -392,7 +394,7 @@ class TestProviderFeatures < Test::Unit::TestCase
|
|||
|
||||
# and appropriate providers
|
||||
nope = @type.provide(:nope) {}
|
||||
maybe = @type.provide(:maybe) { has_features(:alpha) }
|
||||
maybe = @type.provide(:maybe) { has_feature(:alpha) }
|
||||
yep = @type.provide(:yep) { has_features(:alpha, :numeric) }
|
||||
|
||||
# Now make sure our providers answer correctly.
|
||||
|
|
Загрузка…
Ссылка в новой задаче