summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-12-14 19:23:53 -0800
committerGitHub <noreply@github.com>2017-12-14 19:23:53 -0800
commit74903a467bbff0a28600f54764ca6e24d17e6f8b (patch)
tree1a6dd94d4ae00883fbe84d0a5d7cc635fa93eee7
parent8c9cc06ee3d0a8abe4984a88882211e63fd86b75 (diff)
parentcb61668acd106e13b0db96061ca7875bb7bbba2d (diff)
downloadchef-74903a467bbff0a28600f54764ca6e24d17e6f8b.tar.gz
Merge pull request #6675 from chef/windows_task_ruby23
Don't use .match? which is Ruby 2.4+ only in windows_task
-rw-r--r--lib/chef/resource/windows_task.rb6
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