[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35
James Turnbull
james at lovedthanlost.net
Wed Jul 14 10:29:37 UTC 2010
The following commit has been merged in the upstream branch:
commit 22c642df7e705792373c605422d368236e6f5a94
Author: Luke Kanies <luke at madstop.com>
Date: Tue Oct 6 09:03:25 2009 -0700
Extracting language doc support into a module
This is so that you can still use docs without AST
being the parent class.
Signed-off-by: Luke Kanies <luke at madstop.com>
diff --git a/lib/puppet/util/inline_docs.rb b/lib/puppet/util/inline_docs.rb
new file mode 100644
index 0000000..405b539
--- /dev/null
+++ b/lib/puppet/util/inline_docs.rb
@@ -0,0 +1,29 @@
+module Puppet::Util::InlineDocs
+ def self.included(klass)
+ klass.send(:include, InstanceMethods)
+ klass.extend ClassMethods
+ end
+
+ module ClassMethods
+ attr_accessor :use_docs
+ def associates_doc
+ self.use_docs = true
+ end
+ end
+
+ module InstanceMethods
+ attr_writer :doc
+
+ def doc
+ unless defined?(@doc) and @doc
+ @doc = ""
+ end
+ @doc
+ end
+
+ # don't fetch lexer comment by default
+ def use_docs
+ self.class.use_docs
+ end
+ end
+end
diff --git a/spec/unit/util/inline_docs.rb b/spec/unit/util/inline_docs.rb
new file mode 100755
index 0000000..c541d01
--- /dev/null
+++ b/spec/unit/util/inline_docs.rb
@@ -0,0 +1,32 @@
+#!/usr/bin/env ruby
+
+Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+
+require 'puppet/util/file_locking'
+
+class InlineDoccer
+ include Puppet::Util::InlineDocs
+end
+
+describe Puppet::Util::InlineDocs do
+ describe "when included" do
+ it "should create a class method for specifying that docs should be associated" do
+ InlineDoccer.expects(:use_docs=).with true
+ InlineDoccer.associates_doc
+ end
+
+ it "should default to not associating docs" do
+ (!! InlineDoccer.use_docs).should be_false
+ end
+
+ it "should create an instance method for setting documentation" do
+ instance = InlineDoccer.new
+ instance.doc = "foo"
+ instance.doc.should == "foo"
+ end
+
+ it "should default to an empty string for docs" do
+ InlineDoccer.new.doc.should == ""
+ end
+ end
+end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list