+1 looks good. I'll ping the user to test.
On Wed, Dec 30, 2009 at 1:35 PM, Jesse Wolfe <[email protected]> wrote: > From: Markus Roberts <[email protected]> > > We don't actually rely on iconv's UTF-8 support, so its absence > shouldn't cause the PSON feature to fail on system (e.g. HPUX) > where it isn't fully implemented. > > This change exposed a dependency on library load order that was causing > Puppet::Util::Log to raise an error. I've removed the dependency of > Puppet::Type from Puppet::Util::Log. > > Signed-off-by: Jesse Wolfe <[email protected]> > --- > lib/puppet/external/pson/pure.rb | 2 +- > lib/puppet/util/log.rb | 28 ++++++++++------------------ > lib/puppet/util/log_paths.rb | 14 ++++++++++++++ > spec/unit/parameter.rb | 8 ++++++++ > spec/unit/type.rb | 9 +++++++++ > spec/unit/util/log.rb | 14 ++++++++++++++ > 6 files changed, 56 insertions(+), 19 deletions(-) > > diff --git a/lib/puppet/external/pson/pure.rb > b/lib/puppet/external/pson/pure.rb > index 7bb18aa..53d1ea2 100644 > --- a/lib/puppet/external/pson/pure.rb > +++ b/lib/puppet/external/pson/pure.rb > @@ -50,7 +50,7 @@ module PSON > UTF16toUTF8 = swapper.new(UTF16toUTF8) # :nodoc: > end > rescue Errno::EINVAL, Iconv::InvalidEncoding > - raise MissingUnicodeSupport, "iconv doesn't seem to support > UTF-8/UTF-16 conversions" > + Puppet.warning "iconv doesn't seem to support UTF-8/UTF-16 conversions" > ensure > $VERBOSE = old_verbose > end > diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb > index 4cdad70..90d7229 100644 > --- a/lib/puppet/util/log.rb > +++ b/lib/puppet/util/log.rb > @@ -511,11 +511,16 @@ class Puppet::Util::Log > # If they pass a source in to us, we make sure it is a string, and > # we retrieve any tags we can. > def source=(source) > - # We can't store the actual source, we just store the path. > - # We can't just check for whether it responds to :path, because > - # plenty of providers respond to that in their normal function. > - if (source.is_a?(Puppet::Type) or source.is_a?(Puppet::Parameter)) > and source.respond_to?(:path) > - set_source_from_ral(source) > + if source.respond_to?(:source_descriptors) > + descriptors = source.source_descriptors > + �...@source = descriptors[:path] > + > + descriptors[:tags].each { |t| tag(t) } > + > + [:file, :line, :version].each do |param| > + next unless descriptors[param] > + send(param.to_s + "=", descriptors[param]) > + end > else > @source = source.to_s > end > @@ -528,19 +533,6 @@ class Puppet::Util::Log > def to_s > return @message > end > - > - private > - > - def set_source_from_ral(source) > - �...@source = source.path > - > - source.tags.each { |t| tag(t) } > - > - [:file, :line, :version].each do |param| > - next unless value = source.send(param) > - send(param.to_s + "=", value) > - end > - end > end > > # This is for backward compatibility from when we changed the constant to > Puppet::Util::Log > diff --git a/lib/puppet/util/log_paths.rb b/lib/puppet/util/log_paths.rb > index 1a6bafc..46f6c48 100644 > --- a/lib/puppet/util/log_paths.rb > +++ b/lib/puppet/util/log_paths.rb > @@ -11,5 +11,19 @@ module Puppet::Util::LogPaths > > return "/" + @path.join("/") > end > + > + def source_descriptors > + descriptors = {} > + > + descriptors[:tags] = tags > + > + [:path, :file, :line, :version].each do |param| > + next unless value = send(param) > + descriptors[param] = value > + end > + > + return descriptors > + end > + > end > > diff --git a/spec/unit/parameter.rb b/spec/unit/parameter.rb > index 0548346..e3eaca6 100755 > --- a/spec/unit/parameter.rb > +++ b/spec/unit/parameter.rb > @@ -44,6 +44,14 @@ describe Puppet::Parameter do > @parameter.tags.should == %w{one two foo} > end > > + it "should provide source_descriptors" do > + �[email protected](:line).returns 10 > + �[email protected](:file).returns "file" > + �[email protected](:tags).returns %w{one two} > + �[email protected](:version).returns 50 > + �[email protected]_descriptors.should == {:tags=>["one", "two", > "foo"], :path=>"//foo", :version=>50, :file => "file", :line => 10} > + end > + > describe "when returning the value" do > it "should return nil if no value is set" do > @parameter.value.should be_nil > diff --git a/spec/unit/type.rb b/spec/unit/type.rb > index fe2788e..11bedaa 100755 > --- a/spec/unit/type.rb > +++ b/spec/unit/type.rb > @@ -89,6 +89,15 @@ describe Puppet::Type do > Puppet::Type.type(:mount).new(:name => "foo").version.should == 0 > end > > + it "should provide source_descriptors" do > + resource = Puppet::Type.type(:mount).new(:name => "foo") > + catalog = Puppet::Resource::Catalog.new > + catalog.version = 50 > + catalog.add_resource resource > + > + resource.source_descriptors.should == {:version=>50, > :tags=>["mount", "foo"], :path=>"/Mount[foo]"} > + end > + > describe "when choosing a default provider" do > it "should choose the provider with the highest specificity" do > # Make a fake type > diff --git a/spec/unit/util/log.rb b/spec/unit/util/log.rb > index 35e6a71..97fb2f2 100755 > --- a/spec/unit/util/log.rb > +++ b/spec/unit/util/log.rb > @@ -157,6 +157,20 @@ describe Puppet::Util::Log do > end > end > > + it "should use the source_descriptors" do > + source = stub "source" > + source.stubs(:source_descriptors).returns(:tags => > ["tag","tag2"], :path => "path", :version => 100) > + > + log = Puppet::Util::Log.new(:level => "notice", :message => > :foo) > + log.expects(:tag).with("tag") > + log.expects(:tag).with("tag2") > + log.expects(:version=).with(100) > + > + log.source = source > + > + log.source.should == "path" > + end > + > it "should copy over any version information" do > catalog = Puppet::Resource::Catalog.new > catalog.version = 25 > -- > 1.6.5 > > -- > > You received this message because you are subscribed to the Google Groups > "Puppet Developers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/puppet-dev?hl=en. > > > -- ----------------------------------------------------------- The power of accurate observation is commonly called cynicism by those who have not got it. ~George Bernard Shaw ------------------------------------------------------------ -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
