diff options
author | Tim Smith <tsmith@chef.io> | 2018-11-24 13:56:48 -0800 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-11-24 13:56:48 -0800 |
commit | 35f32a12f756c50a9cfd17ab9224853c2161fc0e (patch) | |
tree | 4e5cfe43b8cf6cf8476c6682b43383522c41a7b7 /lib/ohai/plugins/powershell.rb | |
parent | a946ff969ae335b163a1766901ccd960ad6dc4eb (diff) | |
download | ohai-35f32a12f756c50a9cfd17ab9224853c2161fc0e.tar.gz |
Require Ruby 2.5 or later
As we do every year Ohai 15 will drop support for the N-2 support of Ruby. In the ~5 weeks Ruby 2.6 comes out so by the time we release this new version of Ohai N-2 will be Ruby 2.4.
Also while we're at it get rid of the begins in rescue blocks. Ruby 2.5 doesn't require this and it's on the path to ruby throwing errors eventually. It's a Ruby < 2.4-ism.
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/ohai/plugins/powershell.rb')
-rw-r--r-- | lib/ohai/plugins/powershell.rb | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/lib/ohai/plugins/powershell.rb b/lib/ohai/plugins/powershell.rb index 52dc8f6f..728e5b11 100644 --- a/lib/ohai/plugins/powershell.rb +++ b/lib/ohai/plugins/powershell.rb @@ -20,39 +20,39 @@ Ohai.plugin(:Powershell) do depends "languages" collect_data(:windows) do - begin - so = shell_out("powershell.exe -NoLogo -NonInteractive -NoProfile -command $PSVersionTable") - # Sample output: - # - # Name Value - # ---- ----- - # PSVersion 4.0 - # WSManStackVersion 3.0 - # SerializationVersion 1.1.0.1 - # CLRVersion 4.0.30319.34014 - # BuildVersion 6.3.9600.16394 - # PSCompatibleVersions {1.0, 2.0, 3.0, 4.0} - # PSRemotingProtocolVersion 2.2 - if so.exitstatus == 0 - powershell = Mash.new - version_info = {} - so.stdout.strip.each_line do |line| - kv = line.strip.split(/\s+/, 2) - version_info[kv[0]] = kv[1] if kv.length == 2 - end - powershell[:version] = version_info["PSVersion"] - powershell[:ws_man_stack_version] = version_info["WSManStackVersion"] - powershell[:serialization_version] = version_info["SerializationVersion"] - powershell[:clr_version] = version_info["CLRVersion"] - powershell[:build_version] = version_info["BuildVersion"] - powershell[:compatible_versions] = parse_compatible_versions - powershell[:remoting_protocol_version] = version_info["PSRemotingProtocolVersion"] - languages[:powershell] = powershell unless powershell.empty? + so = shell_out("powershell.exe -NoLogo -NonInteractive -NoProfile -command $PSVersionTable") + # Sample output: + # + # Name Value + # ---- ----- + # PSVersion 4.0 + # WSManStackVersion 3.0 + # SerializationVersion 1.1.0.1 + # CLRVersion 4.0.30319.34014 + # BuildVersion 6.3.9600.16394 + # PSCompatibleVersions {1.0, 2.0, 3.0, 4.0} + # PSRemotingProtocolVersion 2.2 + + if so.exitstatus == 0 + powershell = Mash.new + version_info = {} + so.stdout.strip.each_line do |line| + kv = line.strip.split(/\s+/, 2) + version_info[kv[0]] = kv[1] if kv.length == 2 end - rescue Ohai::Exceptions::Exec - logger.trace('Plugin Powershell: Could not shell_out "powershell.exe -NoLogo -NonInteractive -NoProfile -command $PSVersionTable". Skipping plugin') + powershell[:version] = version_info["PSVersion"] + powershell[:ws_man_stack_version] = version_info["WSManStackVersion"] + powershell[:serialization_version] = version_info["SerializationVersion"] + powershell[:clr_version] = version_info["CLRVersion"] + powershell[:build_version] = version_info["BuildVersion"] + powershell[:compatible_versions] = parse_compatible_versions + powershell[:remoting_protocol_version] = version_info["PSRemotingProtocolVersion"] + languages[:powershell] = powershell unless powershell.empty? end + rescue Ohai::Exceptions::Exec + logger.trace('Plugin Powershell: Could not shell_out "powershell.exe -NoLogo -NonInteractive -NoProfile -command $PSVersionTable". Skipping plugin') + end def version_command |