checkoff 0.103.0 → 0.105.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/checkoff/internal/selector_classes/common/function_evaluator.rb +0 -48
- data/lib/checkoff/internal/selector_classes/project/function_evaluator.rb +0 -48
- data/lib/checkoff/internal/selector_classes/task/function_evaluator.rb +0 -24
- data/lib/checkoff/internal/selector_classes/task.rb +6 -2
- data/lib/checkoff/internal/task_timing.rb +9 -0
- data/lib/checkoff/tasks.rb +10 -6
- data/lib/checkoff/timing.rb +22 -6
- 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: 4edf9b863abc88b80a990f28fa9a966eaff3d48b9ff267ff0f0c572ef20fda87
|
4
|
+
data.tar.gz: e250e14a24ccc7463fc80dac424f9dc04eca6ff43522c8fc5795c4e8ea04390f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9e5100c88fa3a02f678845db245ca271632015ba814c06c6d9cb795cbcf6f0988d7a57676163f66cdcc649c4542f628d91c467512e20531587d8e3391d2a20a
|
7
|
+
data.tar.gz: 626ab57ad3597d651dfea7d41f2fd640286de88d2bfa79cc71c1dff2602db8ecb23536fb32b4e332d8e1f2130405e485f83a62e5e3638c4ced96ea67e1d464f0
|
data/Gemfile.lock
CHANGED
@@ -15,54 +15,6 @@ module Checkoff
|
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
-
# @param project [Asana::Resources::Project]
|
19
|
-
# @param field_name [Symbol]
|
20
|
-
#
|
21
|
-
# @sg-ignore
|
22
|
-
# @return [Date, nil]
|
23
|
-
def pull_date_field_by_name(project, field_name)
|
24
|
-
if field_name == :modified
|
25
|
-
return Time.parse(project.modified_at).to_date unless project.modified_at.nil?
|
26
|
-
|
27
|
-
return nil
|
28
|
-
end
|
29
|
-
|
30
|
-
if field_name == :due
|
31
|
-
return Time.parse(project.due_at).to_date unless project.due_at.nil?
|
32
|
-
|
33
|
-
return Date.parse(project.due_on) unless project.due_on.nil?
|
34
|
-
|
35
|
-
return nil
|
36
|
-
end
|
37
|
-
|
38
|
-
raise "Teach me how to handle field #{field_name}"
|
39
|
-
end
|
40
|
-
|
41
|
-
# @param project [Asana::Resources::Project]
|
42
|
-
# @param field_name [Symbol]
|
43
|
-
#
|
44
|
-
# @sg-ignore
|
45
|
-
# @return [Date, Time, nil]
|
46
|
-
def pull_date_or_time_field_by_name(project, field_name)
|
47
|
-
if field_name == :due
|
48
|
-
return Time.parse(project.due_at) unless project.due_at.nil?
|
49
|
-
|
50
|
-
return Date.parse(project.due_on) unless project.due_on.nil?
|
51
|
-
|
52
|
-
return nil
|
53
|
-
end
|
54
|
-
|
55
|
-
if field_name == :start
|
56
|
-
return Time.parse(project.start_at) unless project.start_at.nil?
|
57
|
-
|
58
|
-
return Date.parse(project.start_on) unless project.start_on.nil?
|
59
|
-
|
60
|
-
return nil
|
61
|
-
end
|
62
|
-
|
63
|
-
raise "Teach me how to handle field #{field_name}"
|
64
|
-
end
|
65
|
-
|
66
18
|
# @sg-ignore
|
67
19
|
# @param project [Asana::Resources::Project]
|
68
20
|
# @param custom_field_gid [String]
|
@@ -18,54 +18,6 @@ module Checkoff
|
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
|
-
# @param project [Asana::Resources::Project]
|
22
|
-
# @param field_name [Symbol]
|
23
|
-
#
|
24
|
-
# @sg-ignore
|
25
|
-
# @return [Date, nil]
|
26
|
-
def pull_date_field_by_name(project, field_name)
|
27
|
-
if field_name == :modified
|
28
|
-
return Time.parse(project.modified_at).to_date unless project.modified_at.nil?
|
29
|
-
|
30
|
-
return nil
|
31
|
-
end
|
32
|
-
|
33
|
-
if field_name == :due
|
34
|
-
return Time.parse(project.due_at).to_date unless project.due_at.nil?
|
35
|
-
|
36
|
-
return Date.parse(project.due_on) unless project.due_on.nil?
|
37
|
-
|
38
|
-
return nil
|
39
|
-
end
|
40
|
-
|
41
|
-
raise "Teach me how to handle field #{field_name}"
|
42
|
-
end
|
43
|
-
|
44
|
-
# @param project [Asana::Resources::Project]
|
45
|
-
# @param field_name [Symbol]
|
46
|
-
#
|
47
|
-
# @sg-ignore
|
48
|
-
# @return [Date, Time, nil]
|
49
|
-
def pull_date_or_time_field_by_name(project, field_name)
|
50
|
-
if field_name == :due
|
51
|
-
return Time.parse(project.due_at) unless project.due_at.nil?
|
52
|
-
|
53
|
-
return Date.parse(project.due_on) unless project.due_on.nil?
|
54
|
-
|
55
|
-
return nil
|
56
|
-
end
|
57
|
-
|
58
|
-
if field_name == :start
|
59
|
-
return Time.parse(project.start_at) unless project.start_at.nil?
|
60
|
-
|
61
|
-
return Date.parse(project.start_on) unless project.start_on.nil?
|
62
|
-
|
63
|
-
return nil
|
64
|
-
end
|
65
|
-
|
66
|
-
raise "Teach me how to handle field #{field_name}"
|
67
|
-
end
|
68
|
-
|
69
21
|
# @sg-ignore
|
70
22
|
# @param project [Asana::Resources::Project]
|
71
23
|
# @param custom_field_gid [String]
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative '../function_evaluator'
|
4
|
-
require 'checkoff/internal/task_timing'
|
5
4
|
|
6
5
|
module Checkoff
|
7
6
|
module SelectorClasses
|
@@ -22,29 +21,6 @@ module Checkoff
|
|
22
21
|
|
23
22
|
private
|
24
23
|
|
25
|
-
# @param task [Asana::Resources::Task]
|
26
|
-
# @param field_name [Symbol]
|
27
|
-
#
|
28
|
-
# @sg-ignore
|
29
|
-
# @return [Date, nil]
|
30
|
-
def pull_date_field_by_name(task, field_name)
|
31
|
-
if field_name == :modified
|
32
|
-
return Time.parse(task.modified_at).to_date unless task.modified_at.nil?
|
33
|
-
|
34
|
-
return nil
|
35
|
-
end
|
36
|
-
|
37
|
-
if field_name == :due
|
38
|
-
return Time.parse(task.due_at).to_date unless task.due_at.nil?
|
39
|
-
|
40
|
-
return Date.parse(task.due_on) unless task.due_on.nil?
|
41
|
-
|
42
|
-
return nil
|
43
|
-
end
|
44
|
-
|
45
|
-
raise "Teach me how to handle field #{field_name}"
|
46
|
-
end
|
47
|
-
|
48
24
|
# @sg-ignore
|
49
25
|
# @param task [Asana::Resources::Task]
|
50
26
|
# @param custom_field_gid [String]
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative 'task/function_evaluator'
|
4
4
|
require 'checkoff/internal/ready_between_relative'
|
5
|
+
require 'checkoff/internal/task_timing'
|
5
6
|
|
6
7
|
module Checkoff
|
7
8
|
module SelectorClasses
|
@@ -160,7 +161,9 @@ module Checkoff
|
|
160
161
|
#
|
161
162
|
# @return [Boolean]
|
162
163
|
def evaluate(task, field_name, num_days)
|
163
|
-
|
164
|
+
task_timing = Checkoff::Internal::TaskTiming.new
|
165
|
+
|
166
|
+
date = task_timing.date_or_time_field_by_name(task, field_name)&.to_date
|
164
167
|
|
165
168
|
return false if date.nil?
|
166
169
|
|
@@ -189,7 +192,8 @@ module Checkoff
|
|
189
192
|
#
|
190
193
|
# @return [Boolean]
|
191
194
|
def evaluate(task, field_name, num_days)
|
192
|
-
|
195
|
+
task_timing = Checkoff::Internal::TaskTiming.new
|
196
|
+
date = task_timing.date_or_time_field_by_name(task, field_name)&.to_date
|
193
197
|
|
194
198
|
return false if date.nil?
|
195
199
|
|
@@ -49,6 +49,13 @@ module Checkoff
|
|
49
49
|
nil
|
50
50
|
end
|
51
51
|
|
52
|
+
# @param task [Asana::Resources::Task]
|
53
|
+
#
|
54
|
+
# @return [Time, nil]
|
55
|
+
def modified_time(task)
|
56
|
+
return @time_class.parse(task.modified_at) unless task.modified_at.nil?
|
57
|
+
end
|
58
|
+
|
52
59
|
# @param task [Asana::Resources::Task]
|
53
60
|
# @param field_name [Symbol]
|
54
61
|
#
|
@@ -59,6 +66,8 @@ module Checkoff
|
|
59
66
|
|
60
67
|
return start_date_or_time(task) if field_name == :start
|
61
68
|
|
69
|
+
return modified_time(task) if field_name == :modified
|
70
|
+
|
62
71
|
return start_date_or_time(task) || due_date_or_time(task) if field_name == :ready
|
63
72
|
|
64
73
|
raise "Teach me how to handle field #{field_name}"
|
data/lib/checkoff/tasks.rb
CHANGED
@@ -50,6 +50,7 @@ module Checkoff
|
|
50
50
|
@client = client
|
51
51
|
@portfolios = portfolios
|
52
52
|
@workspaces = workspaces
|
53
|
+
@timing = Timing.new(today_getter: date_class, now_getter: time_class)
|
53
54
|
end
|
54
55
|
|
55
56
|
# Indicates a task is ready for a person to work on it. This is
|
@@ -63,16 +64,16 @@ module Checkoff
|
|
63
64
|
# * start at is before now
|
64
65
|
#
|
65
66
|
# @param task [Asana::Resources::Task]
|
67
|
+
# @param period [Symbol<:now_or_before,:this_week>]
|
66
68
|
# @param ignore_dependencies [Boolean]
|
67
|
-
def task_ready?(task, ignore_dependencies: false)
|
69
|
+
def task_ready?(task, period: :now_or_before, ignore_dependencies: false)
|
70
|
+
field_name = :ready
|
68
71
|
return false if !ignore_dependencies && incomplete_dependencies?(task)
|
69
72
|
|
70
|
-
|
71
|
-
|
73
|
+
# @type [Date,Time,nil]
|
74
|
+
task_date_or_time = task_timing.date_or_time_field_by_name(task, field_name)
|
72
75
|
|
73
|
-
|
74
|
-
|
75
|
-
(start || due) < @time_class.now
|
76
|
+
timing.in_period?(task_date_or_time, period)
|
76
77
|
end
|
77
78
|
|
78
79
|
# Pull a specific task by name
|
@@ -236,6 +237,9 @@ module Checkoff
|
|
236
237
|
# @return [Asana::Client]
|
237
238
|
attr_reader :client
|
238
239
|
|
240
|
+
# @return [Checkoff::Timing]
|
241
|
+
attr_reader :timing
|
242
|
+
|
239
243
|
# @return [Checkoff::Projects]
|
240
244
|
def projects
|
241
245
|
@projects ||= @sections.projects
|
data/lib/checkoff/timing.rb
CHANGED
@@ -23,24 +23,38 @@ module Checkoff
|
|
23
23
|
SHORT_CACHE_TIME = MINUTE
|
24
24
|
|
25
25
|
# @param today_getter [Class<Date>]
|
26
|
-
|
26
|
+
# @param now_getter [Class<Time>]
|
27
|
+
def initialize(today_getter: Date,
|
28
|
+
now_getter: Time)
|
27
29
|
@today_getter = today_getter
|
30
|
+
@now_getter = now_getter
|
28
31
|
end
|
29
32
|
|
30
|
-
# @param
|
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
|
+
# @param date_or_time [Date,Time,nil]
|
31
41
|
# @param period [Symbol<:indefinite>]
|
32
|
-
def in_period?(
|
33
|
-
return this_week?(
|
42
|
+
def in_period?(date_or_time, period)
|
43
|
+
return this_week?(date_or_time) if period == :this_week
|
34
44
|
|
35
45
|
return true if period == :indefinite
|
36
46
|
|
47
|
+
return now_or_before?(date_or_time) if period == :now_or_before
|
48
|
+
|
37
49
|
raise "Teach me how to handle period #{period.inspect}"
|
38
50
|
end
|
39
51
|
|
40
52
|
private
|
41
53
|
|
42
|
-
# @param
|
43
|
-
def this_week?(
|
54
|
+
# @param date_or_time [Date,Time,nil]
|
55
|
+
def this_week?(date_or_time)
|
56
|
+
return true if date_or_time.nil?
|
57
|
+
|
44
58
|
today = @today_getter.today
|
45
59
|
|
46
60
|
# Beginning of this week (assuming week starts on Sunday)
|
@@ -49,6 +63,8 @@ module Checkoff
|
|
49
63
|
# End of this week (assuming week ends on Saturday)
|
50
64
|
end_of_week = beginning_of_week + 6
|
51
65
|
|
66
|
+
date = date_or_time.to_date
|
67
|
+
|
52
68
|
date >= beginning_of_week && date <= end_of_week
|
53
69
|
end
|
54
70
|
|
data/lib/checkoff/version.rb
CHANGED