checkoff 0.107.0 → 0.109.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/checkoff/internal/selector_classes/task.rb +20 -52
- data/lib/checkoff/timing.rb +35 -9
- data/lib/checkoff/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 199142d4090e6eb4196958d2c73958fefdfa864c0e7e69a5e8a589f198465b2e
|
4
|
+
data.tar.gz: aa0739c73ce5359fe1f965e4c46674bf3a7d79a603d7bcc683f671cd5e039fd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fce61c75d5175ad6c7ae37263f3065efc796dc496dd290616bd6cf1bb69518149231e6da378f6ee5573a8f17d1a55e73179da30e46820a61b237038b62483ff3
|
7
|
+
data.tar.gz: e7e2cadb887aaacb9fea39058bea689f087da8719ceba75931b768f92b170ca16bf2f93fe7731a18c4a5ebd00660ece4bfdf4f466f712bf98f7d74dc66d1e0b6
|
data/Gemfile.lock
CHANGED
@@ -97,6 +97,26 @@ module Checkoff
|
|
97
97
|
# rubocop:enable Style/OptionalBooleanParameter
|
98
98
|
end
|
99
99
|
|
100
|
+
# :in_period? function
|
101
|
+
class InPeriodPFunctionEvaluator < FunctionEvaluator
|
102
|
+
def matches?
|
103
|
+
fn?(selector, :in_period?)
|
104
|
+
end
|
105
|
+
|
106
|
+
# @param _index [Integer]
|
107
|
+
def evaluate_arg?(_index)
|
108
|
+
false
|
109
|
+
end
|
110
|
+
|
111
|
+
# @param task [Asana::Resources::Task]
|
112
|
+
# @param field_name [Symbol] See Checksoff::Tasks#in_period?
|
113
|
+
# @param period [Symbol,Array<Symbol>] See Checkoff::Timing#in_period?
|
114
|
+
# @return [Boolean]
|
115
|
+
def evaluate(task, field_name, period)
|
116
|
+
@tasks.in_period?(task, field_name, period)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
100
120
|
# :unassigned function
|
101
121
|
class UnassignedPFunctionEvaluator < FunctionEvaluator
|
102
122
|
def matches?
|
@@ -153,58 +173,6 @@ module Checkoff
|
|
153
173
|
end
|
154
174
|
end
|
155
175
|
|
156
|
-
# :field_less_than_n_days_ago
|
157
|
-
class FieldLessThanNDaysAgoPFunctionEvaluator < FunctionEvaluator
|
158
|
-
FUNCTION_NAME = :field_less_than_n_days_ago
|
159
|
-
|
160
|
-
def matches?
|
161
|
-
fn?(selector, FUNCTION_NAME)
|
162
|
-
end
|
163
|
-
|
164
|
-
def evaluate_arg?(_index)
|
165
|
-
false
|
166
|
-
end
|
167
|
-
|
168
|
-
# @param task [Asana::Resources::Task]
|
169
|
-
# @param field_name [Symbol]
|
170
|
-
# @param num_days [Integer]
|
171
|
-
#
|
172
|
-
# @return [Boolean]
|
173
|
-
def evaluate(task, field_name, num_days)
|
174
|
-
@tasks.in_period?(task, field_name, [:less_than_n_days_ago, num_days])
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
# :field_greater_than_or_equal_to_n_days_from_today
|
179
|
-
class FieldGreaterThanOrEqualToNDaysFromTodayPFunctionEvaluator < FunctionEvaluator
|
180
|
-
FUNCTION_NAME = :field_greater_than_or_equal_to_n_days_from_today
|
181
|
-
|
182
|
-
def matches?
|
183
|
-
fn?(selector, FUNCTION_NAME)
|
184
|
-
end
|
185
|
-
|
186
|
-
def evaluate_arg?(_index)
|
187
|
-
false
|
188
|
-
end
|
189
|
-
|
190
|
-
# @param task [Asana::Resources::Task]
|
191
|
-
# @param field_name [Symbol]
|
192
|
-
# @param num_days [Integer]
|
193
|
-
#
|
194
|
-
# @return [Boolean]
|
195
|
-
def evaluate(task, field_name, num_days)
|
196
|
-
task_timing = Checkoff::Internal::TaskTiming.new
|
197
|
-
date = task_timing.date_or_time_field_by_name(task, field_name)&.to_date
|
198
|
-
|
199
|
-
return false if date.nil?
|
200
|
-
|
201
|
-
# @sg-ignore
|
202
|
-
n_days_from_today = Date.today + num_days
|
203
|
-
# @sg-ignore
|
204
|
-
date >= n_days_from_today
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
176
|
# :custom_field_less_than_n_days_from_now function
|
209
177
|
class CustomFieldLessThanNDaysFromNowFunctionEvaluator < FunctionEvaluator
|
210
178
|
FUNCTION_NAME = :custom_field_less_than_n_days_from_now
|
data/lib/checkoff/timing.rb
CHANGED
@@ -30,13 +30,6 @@ module Checkoff
|
|
30
30
|
@now_getter = now_getter
|
31
31
|
end
|
32
32
|
|
33
|
-
# @param date_or_time [Date,Time,nil]
|
34
|
-
def now_or_before?(date_or_time)
|
35
|
-
return true if date_or_time.nil?
|
36
|
-
|
37
|
-
date_or_time.to_time < @now_getter.now
|
38
|
-
end
|
39
|
-
|
40
33
|
# @param date_or_time [Date,Time,nil]
|
41
34
|
# @param period [Symbol,Array<(Symbol,Integer)>]
|
42
35
|
#
|
@@ -54,8 +47,7 @@ module Checkoff
|
|
54
47
|
period_name = period.first
|
55
48
|
args = period[1..]
|
56
49
|
|
57
|
-
|
58
|
-
return less_than_n_days_ago?(date_or_time, *args) if period_name == :less_than_n_days_ago
|
50
|
+
return compound_in_period?(date_or_time, period_name, *args)
|
59
51
|
end
|
60
52
|
|
61
53
|
raise "Teach me how to handle period #{period.inspect}"
|
@@ -63,6 +55,19 @@ module Checkoff
|
|
63
55
|
|
64
56
|
private
|
65
57
|
|
58
|
+
# @param date_or_time [Date,Time,nil]
|
59
|
+
# @param num_days [Integer]
|
60
|
+
def greater_than_or_equal_to_n_days_from_today?(date_or_time, num_days)
|
61
|
+
return false if date_or_time.nil?
|
62
|
+
|
63
|
+
date = date_or_time.to_date
|
64
|
+
|
65
|
+
# @sg-ignore
|
66
|
+
n_days_from_today = @today_getter.today + num_days
|
67
|
+
# @sg-ignore
|
68
|
+
date >= n_days_from_today
|
69
|
+
end
|
70
|
+
|
66
71
|
# @param date_or_time [Date,Time,nil]
|
67
72
|
# @param num_days [Integer]
|
68
73
|
def less_than_n_days_ago?(date_or_time, num_days)
|
@@ -93,6 +98,27 @@ module Checkoff
|
|
93
98
|
date >= beginning_of_week && date <= end_of_week
|
94
99
|
end
|
95
100
|
|
101
|
+
# @param date_or_time [Date,Time,nil]
|
102
|
+
def now_or_before?(date_or_time)
|
103
|
+
return true if date_or_time.nil?
|
104
|
+
|
105
|
+
date_or_time.to_time < @now_getter.now
|
106
|
+
end
|
107
|
+
|
108
|
+
# @param date_or_time [Date,Time,nil]
|
109
|
+
# @param period_name [Symbol]
|
110
|
+
# @param args [Object]
|
111
|
+
def compound_in_period?(date_or_time, period_name, *args)
|
112
|
+
# @sg-ignore
|
113
|
+
return less_than_n_days_ago?(date_or_time, *args) if period_name == :less_than_n_days_ago
|
114
|
+
|
115
|
+
if period_name == :greater_than_or_equal_to_n_days_from_today
|
116
|
+
return greater_than_or_equal_to_n_days_from_today?(date_or_time,
|
117
|
+
*args)
|
118
|
+
end
|
119
|
+
raise "Teach me how to handle period [#{period_name.inspect}, #{args.join(', ')}]"
|
120
|
+
end
|
121
|
+
|
96
122
|
# bundle exec ./time.rb
|
97
123
|
# :nocov:
|
98
124
|
class << self
|
data/lib/checkoff/version.rb
CHANGED