diff options
author | Tim Smith <tsmith@chef.io> | 2017-12-14 18:41:15 -0800 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2017-12-14 18:41:15 -0800 |
commit | cb61668acd106e13b0db96061ca7875bb7bbba2d (patch) | |
tree | 1a6dd94d4ae00883fbe84d0a5d7cc635fa93eee7 /lib/chef/resource | |
parent | 8c9cc06ee3d0a8abe4984a88882211e63fd86b75 (diff) | |
download | chef-cb61668acd106e13b0db96061ca7875bb7bbba2d.tar.gz |
Don't use .match? which is Ruby 2.4+ only
Added a todo to fix this when Ruby 2.3 support goes away since it's 3x
faster
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef/resource')
-rw-r--r-- | lib/chef/resource/windows_task.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/chef/resource/windows_task.rb b/lib/chef/resource/windows_task.rb index c9e8448938..78076e08e5 100644 --- a/lib/chef/resource/windows_task.rb +++ b/lib/chef/resource/windows_task.rb @@ -105,19 +105,21 @@ class Chef raise ArgumentError, "Invalid value passed for `random_delay`. Please pass seconds as an Integer (e.g. 60) or a String with numeric values only (e.g. '60')." unless numeric_value_in_string?(random_delay) end + # @todo when we drop ruby 2.3 support this should be converted to .match?() instead of =~f def validate_start_day(start_day, frequency) if [:once, :on_logon, :onstart, :on_idle, :none].include? frequency raise ArgumentError, "`start_day` property is not supported with frequency: #{frequency}" end # make sure the start_day is in MM/DD/YYYY format: http://rubular.com/r/cgjHemtWl5 - raise ArgumentError, "`start_day` property must be in the MM/DD/YYYY format." unless /^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](19|20)\d\d$/.match?(start_day) + raise ArgumentError, "`start_day` property must be in the MM/DD/YYYY format." unless /^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](19|20)\d\d$/ =~ start_day end + # @todo when we drop ruby 2.3 support this should be converted to .match?() instead of =~ def validate_start_time(start_time, frequency) if start_time raise ArgumentError, "`start_time` property is not supported with `frequency :none`" if frequency == :none - raise ArgumentError, "`start_time` property must be in the HH:mm format (e.g. 6:20pm -> 18:20)." unless /^[0-2][0-9]:[0-5][0-9]$/.match?(start_time) + raise ArgumentError, "`start_time` property must be in the HH:mm format (e.g. 6:20pm -> 18:20)." unless /^[0-2][0-9]:[0-5][0-9]$/ =~ start_time else raise ArgumentError, "`start_time` needs to be provided with `frequency :once`" if frequency == :once end |