summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-11-23 15:33:02 -0800
committerJay Mundrawala <jdmundrawala@gmail.com>2015-11-23 15:51:27 -0800
commit1a3e38ee32863b37ac753a91ef66b013bf35f900 (patch)
treee5c9084309ca8c27189380395b6313aafff050a1
parent8d685f1714e2071d408b87225d23dd2815be55d3 (diff)
downloadchef-jdm/fix-pscred.tar.gz
Implement to_text on PsCredential instead of messing with inspectjdm/fix-pscred
-rw-r--r--lib/chef/resource/dsc_resource.rb19
-rw-r--r--lib/chef/util/powershell/ps_credential.rb2
2 files changed, 11 insertions, 10 deletions
diff --git a/lib/chef/resource/dsc_resource.rb b/lib/chef/resource/dsc_resource.rb
index a6a03b778b..1dcde8de96 100644
--- a/lib/chef/resource/dsc_resource.rb
+++ b/lib/chef/resource/dsc_resource.rb
@@ -27,16 +27,17 @@ class Chef
# to inspect. This is useful for properties that hold
# objects such as PsCredential, where we do not want
# to dump the actual ivars
- class SafePrintArray < Array
+ class ToTextHash < Hash
def to_text
- descriptions = self.map do |obj|
- if obj.respond_to(:to_text)
- obj.to_text
- else
- obj.inspect
- end
+ descriptions = self.map do |(property, obj)|
+ obj_text = if obj.respond_to?(:to_text)
+ obj.to_text
+ else
+ obj.inspect
+ end
+ "#{property}=>#{obj_text}"
end
- "[#{descriptions.join(', ')}]"
+ "{#{descriptions.join(', ')}}"
end
end
@@ -46,7 +47,7 @@ class Chef
def initialize(name, run_context)
super
- @properties = SafePrintArray.new
+ @properties = ToTextHash.new
@resource = nil
@reboot_action = :nothing
end
diff --git a/lib/chef/util/powershell/ps_credential.rb b/lib/chef/util/powershell/ps_credential.rb
index 4afb3bb828..2fc0650e5f 100644
--- a/lib/chef/util/powershell/ps_credential.rb
+++ b/lib/chef/util/powershell/ps_credential.rb
@@ -30,7 +30,7 @@ class Chef::Util::Powershell
end
alias to_s to_psobject
- alias inspect to_psobject
+ alias to_text to_psobject
private