diff options
Diffstat (limited to 'lib/chef/resource/cron_d.rb')
-rw-r--r-- | lib/chef/resource/cron_d.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/chef/resource/cron_d.rb b/lib/chef/resource/cron_d.rb index 6fcca2a231..2c3b0bcb9f 100644 --- a/lib/chef/resource/cron_d.rb +++ b/lib/chef/resource/cron_d.rb @@ -35,9 +35,11 @@ class Chef # @return [Boolean] valid or not? def self.validate_numeric(spec, min, max) return true if spec == "*" + # binding.pry if spec.respond_to? :to_int return false unless spec >= min && spec <= max + return true end @@ -45,6 +47,7 @@ class Chef spec.split(%r{\/|-|,}).each do |x| next if x == "*" return false unless x =~ /^\d+$/ + x = x.to_i return false unless x >= min && x <= max end @@ -56,12 +59,14 @@ class Chef # @return [Boolean] valid or not? def self.validate_month(spec) return true if spec == "*" + if spec.respond_to? :to_int validate_numeric(spec, 1, 12) elsif spec.respond_to? :to_str return true if spec == "*" # Named abbreviations are permitted but not as part of a range or with stepping return true if %w{jan feb mar apr may jun jul aug sep oct nov dec}.include? spec.downcase + # 1-12 are legal for months validate_numeric(spec, 1, 12) else @@ -74,12 +79,14 @@ class Chef # @return [Boolean] valid or not? def self.validate_dow(spec) return true if spec == "*" + if spec.respond_to? :to_int validate_numeric(spec, 0, 7) elsif spec.respond_to? :to_str return true if spec == "*" # Named abbreviations are permitted but not as part of a range or with stepping return true if %w{sun mon tue wed thu fri sat}.include? spec.downcase + # 0-7 are legal for days of week validate_numeric(spec, 0, 7) else |