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:
mpalmer 2007-05-30 20:36:29 +00:00
Родитель 0a605e8e17
Коммит 37a221c32e
5 изменённых файлов: 11 добавлений и 7 удалений

Просмотреть файл

@ -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.