summaryrefslogtreecommitdiff
path: root/chef-utils
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-02-26 12:59:20 -0800
committerGitHub <noreply@github.com>2020-02-26 12:59:20 -0800
commit0a9a6070eb17936ff13c0114ed620b9efddd1d5e (patch)
tree3b98db73217c86fce3c2e8a3d5e622ed210d2e71 /chef-utils
parent005d5fc87bba0ac8ea9eba87edbe2ac22f4389d3 (diff)
parentcf453de40ea9e8f70069b11890d52a09d96d441a (diff)
downloadchef-0a9a6070eb17936ff13c0114ed620b9efddd1d5e.tar.gz
Merge pull request #9400 from chef/lcg/platform_version_sugar
Convert the node[:platform_version] to a Chef::VersionString
Diffstat (limited to 'chef-utils')
-rw-r--r--chef-utils/lib/chef-utils/version_string.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/chef-utils/lib/chef-utils/version_string.rb b/chef-utils/lib/chef-utils/version_string.rb
index 7a7096909f..e0888b346e 100644
--- a/chef-utils/lib/chef-utils/version_string.rb
+++ b/chef-utils/lib/chef-utils/version_string.rb
@@ -27,8 +27,13 @@ module ChefUtils
#
# @param val [String] Version string to parse.
def initialize(val)
- super
- @parsed_version = ::Gem::Version.create(self)
+ val = "" unless val
+ super(val)
+ begin
+ @parsed_version = ::Gem::Version.create(self)
+ rescue ArgumentError
+ @parsed_version = nil
+ end
end
# @!group Compat wrappers for String
@@ -135,7 +140,12 @@ module ChefUtils
when Regexp
super
else
- Gem::Requirement.create(other) =~ parsed_version
+ begin
+ Gem::Requirement.create(other) =~ parsed_version
+ rescue ArgumentError
+ # one side of the comparison wasn't parseable
+ super
+ end
end
end