lib/checkoff/internal/task_selector_evaluator.rb in checkoff-0.43.0 vs lib/checkoff/internal/task_selector_evaluator.rb in checkoff-0.44.0

- old
+ new

@@ -337,10 +337,34 @@ n_days_from_now = (Time.now + (num_days * 24 * 60 * 60)) time < n_days_from_now end end + # :custom_field_greater_than_or_equal_to_n_days_from_now function + class CustomFieldGreaterThanOrEqualToNDaysFromNowFunctionEvaluator < FunctionEvaluator + def matches? + fn?(task_selector, :custom_field_greater_than_or_equal_to_n_days_from_now) + end + + def evaluate_arg?(_index) + false + end + + # @param task [Asana::Resources::Task] + # @param custom_field_name [String] + # @param num_days [Integer] + # @return [Boolean] + def evaluate(task, custom_field_name, num_days) + custom_field = pull_custom_field_by_name_or_raise(task, custom_field_name) + + time_str = custom_field.fetch('display_value') + time = Time.parse(time_str) + n_days_from_now = (Time.now + (num_days * 24 * 60 * 60)) + time >= n_days_from_now + end + end + # String literals class StringLiteralEvaluator < FunctionEvaluator def matches? task_selector.is_a?(String) end @@ -374,9 +398,10 @@ CustomFieldGidValueContainsAllGidsFunctionEvaluator, AndFunctionEvaluator, DuePFunctionEvaluator, DueDateSetPFunctionEvaluator, CustomFieldLessThanNDaysFromNowFunctionEvaluator, + CustomFieldGreaterThanOrEqualToNDaysFromNowFunctionEvaluator, StringLiteralEvaluator, ].freeze # @param task_selector [Array] # @return [Boolean, Object, nil]