Please review pull request #208: (#14469) Strip whitespace from frozen strings opened by (hkenney)
Description:
In 1.9.3, strip! did not remove whitespace from frozen strings.
Now using strip instead, this deals with frozen strings too, by
making a copy of them.
- Opened: Mon May 14 21:13:12 UTC 2012
- Based on: puppetlabs:master (634f2f6a57b461926afcb2e07dcfe4ed659f5b0c)
- Requested merge: hkenney:ticket/master/14469_strip_whitespace_from_frozen_strings (7434141e24180140016b48074f1b7322be0e0ef5)
Diff follows:
diff --git a/lib/facter/util/resolution.rb b/lib/facter/util/resolution.rb
index 5ef1e12..63f7ea9 100644
--- a/lib/facter/util/resolution.rb
+++ b/lib/facter/util/resolution.rb
@@ -230,7 +230,7 @@ def value
Facter.show_time "#{self.name}: #{"%.2f" % ms}ms"
unless @preserve_whitespace
- result.strip! if result && result.respond_to?(:strip!)
+ result = result.strip if result && result.respond_to?(:strip)
end
return nil if result == ""
diff --git a/spec/unit/util/resolution_spec.rb b/spec/unit/util/resolution_spec.rb
index e0616e1..96cc4dc 100755
--- a/spec/unit/util/resolution_spec.rb
+++ b/spec/unit/util/resolution_spec.rb
@@ -172,6 +172,13 @@ def handy_method()
@resolve.setcode {' value '}
@resolve.value.should == 'value'
end
+
+ it "should strip whitespace from frozen strings" do
+ result = ' val ue '
+ result.freeze
+ @resolve.setcode{result}
+ @resolve.value.should == 'val ue'
+ end
describe "when given a string" do
[true, false
-- 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.
