checkoff 0.104.0 → 0.105.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/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
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