checkoff 0.107.0 → 0.108.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 +1 -9
- 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: a6f58b9f4020d786886f43c7c3422b55b99143796be35fcccf7d46cc6d3369d8
|
4
|
+
data.tar.gz: 39b470be2c13d3e32d545f9914d935ee1fb8a8f2705e5cdb799a2ae2bab8bf71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df03add2cd762e7e4ce70ec769d316d96b718f59eb418c340557822894f202d28b92796ae0d02e42b5e9e8d1f1ca607c294a4ce64ac92e71e1a6a556d4eeba72
|
7
|
+
data.tar.gz: 89ad98040c6ea65313d51206394f5af2ddcd2671a0b9ea403ecbf3466df564dbe7e09f64932838d7f8d06302d9abf9c29dd8f8dbaad28cf2342795269e5ec2f5
|
data/Gemfile.lock
CHANGED
@@ -193,15 +193,7 @@ module Checkoff
|
|
193
193
|
#
|
194
194
|
# @return [Boolean]
|
195
195
|
def evaluate(task, field_name, num_days)
|
196
|
-
|
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
|
196
|
+
@tasks.in_period?(task, field_name, [:greater_than_or_equal_to_n_days_from_today, num_days])
|
205
197
|
end
|
206
198
|
end
|
207
199
|
|
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