summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/module.rb13
-rwxr-xr-xspec/unit/module.rb16
2 files changed, 27 insertions, 2 deletions
diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb
index 38ff2bf55..3a6f04d15 100644
--- a/lib/puppet/module.rb
+++ b/lib/puppet/module.rb
@@ -1,5 +1,8 @@
+require 'puppet/util/logging'
+
# Support for modules
class Puppet::Module
+ include Puppet::Util::Logging
TEMPLATES = "templates"
FILES = "files"
@@ -118,6 +121,14 @@ class Puppet::Module
subpath("plugins")
end
+ def to_s
+ result = "Module %s" % name
+ if path
+ result += "(%s)" % path
+ end
+ result
+ end
+
private
def find_init_manifest
@@ -133,7 +144,7 @@ class Puppet::Module
def backward_compatible_plugins_dir
if dir = File.join(path, "plugins") and FileTest.exist?(dir)
- Puppet.warning "Module %s uses the deprecated 'plugins' directory for ruby extensions; please move to 'lib'" % name
+ warning "using the deprecated 'plugins' directory for ruby extensions; please move to 'lib'"
return dir
else
return File.join(path, "lib")
diff --git a/spec/unit/module.rb b/spec/unit/module.rb
index 9839d4092..29883dc26 100755
--- a/spec/unit/module.rb
+++ b/spec/unit/module.rb
@@ -29,6 +29,20 @@ describe Puppet::Module do
Puppet::Module.find(nil, "myenv").should be_nil
end
+ it "should provide support for logging" do
+ Puppet::Module.ancestors.should be_include(Puppet::Util::Logging)
+ end
+
+ it "should be able to be converted to a string" do
+ Puppet::Module.new("foo").to_s.should == "Module foo"
+ end
+
+ it "should add the path to its string form if the module is found" do
+ mod = Puppet::Module.new("foo")
+ mod.stubs(:path).returns "/a"
+ mod.to_s.should == "Module foo(/a)"
+ end
+
it "should require a name at initialization" do
lambda { Puppet::Module.new }.should raise_error(ArgumentError)
end
@@ -152,7 +166,7 @@ describe Puppet::Module do
mod.stubs(:path).returns "/a/foo"
FileTest.expects(:exist?).with("/a/foo/plugins").returns true
- Puppet.expects(:warning)
+ mod.expects(:warning)
mod.plugin_directory.should == "/a/foo/plugins"
end