checkoff 0.101.0 → 0.103.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/ready_between_relative.rb +63 -0
- data/lib/checkoff/internal/selector_classes/task/function_evaluator.rb +0 -1
- data/lib/checkoff/internal/selector_classes/task.rb +5 -45
- data/lib/checkoff/tasks.rb +14 -1
- data/lib/checkoff/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18ab918128cd0d805829245306102209f7715f9dfa580a8861b4e97be7aa3b31
|
4
|
+
data.tar.gz: 0c40f9f30d1a0441de43140dcd442d783c7b6ae5e584e9b0ed23e13acbe5e35e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b0ce332d7ee01af5680511dd1c7da6b7654f94b153b3240d344c64663ebc71ceaff79bc4ae2fb01846430904e167a36b81d55ac581f992524eef3dae50c6783
|
7
|
+
data.tar.gz: 738deef8848a424fe874711c874f83b70b14320b9df49a85da6b187da8e817887a3d3de9b63cc65411cf866e5813eb759d5c051eaf9b3c1d50726a98fa3dde33
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Checkoff
|
4
|
+
module Internal
|
5
|
+
# Determine whether a task is due within a relative date range
|
6
|
+
class ReadyBetweenRelative
|
7
|
+
# @param config [Hash<Symbol, Object>]
|
8
|
+
# @param clients [Checkoff::Clients]
|
9
|
+
# @param task_timing [Checkoff::Internal::TaskTiming]
|
10
|
+
# @param tasks [Checkoff::Tasks]
|
11
|
+
def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
|
12
|
+
clients: Checkoff::Clients.new(config: config),
|
13
|
+
task_timing: ::Checkoff::Internal::TaskTiming.new,
|
14
|
+
tasks: ::Checkoff::Tasks.new(config: config,
|
15
|
+
client: clients.client))
|
16
|
+
@task_timing = task_timing
|
17
|
+
@tasks = tasks
|
18
|
+
end
|
19
|
+
|
20
|
+
# @param task [Asana::Resources::Task]
|
21
|
+
# @param beginning_num_days_from_now [Integer]
|
22
|
+
# @param end_num_days_from_now [Integer]
|
23
|
+
# @param ignore_dependencies [Boolean]
|
24
|
+
#
|
25
|
+
# @return [Boolean]
|
26
|
+
def ready_between_relative?(task,
|
27
|
+
beginning_num_days_from_now,
|
28
|
+
end_num_days_from_now,
|
29
|
+
ignore_dependencies: false)
|
30
|
+
beginning_n_days_from_now_time = (Time.now + (beginning_num_days_from_now * 24 * 60 * 60))
|
31
|
+
end_n_days_from_now_time = (Time.now + (end_num_days_from_now * 24 * 60 * 60))
|
32
|
+
|
33
|
+
# @type [Date, Time, nil]
|
34
|
+
ready_date_or_time = @task_timing.date_or_time_field_by_name(task, :ready)
|
35
|
+
|
36
|
+
return false if ready_date_or_time.nil?
|
37
|
+
|
38
|
+
in_range = ready_in_range?(ready_date_or_time,
|
39
|
+
beginning_n_days_from_now_time,
|
40
|
+
end_n_days_from_now_time)
|
41
|
+
|
42
|
+
return false unless in_range
|
43
|
+
|
44
|
+
return false if !ignore_dependencies && @tasks.incomplete_dependencies?(task)
|
45
|
+
|
46
|
+
true
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
# @param ready_date_or_time [Date, Time]
|
52
|
+
# @param start_time [Time]
|
53
|
+
# @param end_time [Time]
|
54
|
+
def ready_in_range?(ready_date_or_time, start_time, end_time)
|
55
|
+
if ready_date_or_time.is_a?(Time)
|
56
|
+
ready_date_or_time > start_time && ready_date_or_time <= end_time
|
57
|
+
else
|
58
|
+
ready_date_or_time > start_time.to_date && ready_date_or_time <= end_time.to_date
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'task/function_evaluator'
|
4
|
+
require 'checkoff/internal/ready_between_relative'
|
4
5
|
|
5
6
|
module Checkoff
|
6
7
|
module SelectorClasses
|
@@ -134,51 +135,10 @@ module Checkoff
|
|
134
135
|
#
|
135
136
|
# @return [Boolean]
|
136
137
|
def evaluate(task, beginning_num_days_from_now, end_num_days_from_now, ignore_dependencies: false)
|
137
|
-
ready_between_relative
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
private
|
143
|
-
|
144
|
-
# @param task [Asana::Resources::Task]
|
145
|
-
# @param beginning_num_days_from_now [Integer]
|
146
|
-
# @param end_num_days_from_now [Integer]
|
147
|
-
# @param ignore_dependencies [Boolean]
|
148
|
-
#
|
149
|
-
# @return [Boolean]
|
150
|
-
def ready_between_relative?(task,
|
151
|
-
beginning_num_days_from_now,
|
152
|
-
end_num_days_from_now,
|
153
|
-
ignore_dependencies: false)
|
154
|
-
beginning_n_days_from_now_time = (Time.now + (beginning_num_days_from_now * 24 * 60 * 60))
|
155
|
-
end_n_days_from_now_time = (Time.now + (end_num_days_from_now * 24 * 60 * 60))
|
156
|
-
|
157
|
-
# @type [Date, Time, nil]
|
158
|
-
ready_date_or_time = @task_timing.date_or_time_field_by_name(task, :ready)
|
159
|
-
|
160
|
-
return false if ready_date_or_time.nil?
|
161
|
-
|
162
|
-
in_range = ready_in_range?(ready_date_or_time,
|
163
|
-
beginning_n_days_from_now_time,
|
164
|
-
end_n_days_from_now_time)
|
165
|
-
|
166
|
-
return false unless in_range
|
167
|
-
|
168
|
-
return false if !ignore_dependencies && @tasks.incomplete_dependencies?(task)
|
169
|
-
|
170
|
-
true
|
171
|
-
end
|
172
|
-
|
173
|
-
# @param ready_date_or_time [Date, Time]
|
174
|
-
# @param start_time [Time]
|
175
|
-
# @param end_time [Time]
|
176
|
-
def ready_in_range?(ready_date_or_time, start_time, end_time)
|
177
|
-
if ready_date_or_time.is_a?(Time)
|
178
|
-
ready_date_or_time > start_time && ready_date_or_time <= end_time
|
179
|
-
else
|
180
|
-
ready_date_or_time > start_time.to_date && ready_date_or_time <= end_time.to_date
|
181
|
-
end
|
138
|
+
ready_between_relative = Checkoff::Internal::ReadyBetweenRelative.new(tasks: @tasks)
|
139
|
+
ready_between_relative.ready_between_relative?(task,
|
140
|
+
beginning_num_days_from_now, end_num_days_from_now,
|
141
|
+
ignore_dependencies: ignore_dependencies)
|
182
142
|
end
|
183
143
|
end
|
184
144
|
|
data/lib/checkoff/tasks.rb
CHANGED
@@ -76,6 +76,7 @@ module Checkoff
|
|
76
76
|
end
|
77
77
|
|
78
78
|
# Pull a specific task by name
|
79
|
+
#
|
79
80
|
# @param workspace_name [String]
|
80
81
|
# @param project_name [String, Symbol]
|
81
82
|
# @param section_name [String, nil, Symbol]
|
@@ -98,7 +99,8 @@ module Checkoff
|
|
98
99
|
end
|
99
100
|
cache_method :task, SHORT_CACHE_TIME
|
100
101
|
|
101
|
-
# Pull a specific task by
|
102
|
+
# Pull a specific task by GID
|
103
|
+
#
|
102
104
|
# @param task_gid [String]
|
103
105
|
# @param extra_fields [Array<String>]
|
104
106
|
# @return [Asana::Resources::Task, nil]
|
@@ -110,9 +112,12 @@ module Checkoff
|
|
110
112
|
end
|
111
113
|
cache_method :task_by_gid, SHORT_CACHE_TIME
|
112
114
|
|
115
|
+
# Add a task
|
116
|
+
#
|
113
117
|
# @param name [String]
|
114
118
|
# @param workspace_gid [String]
|
115
119
|
# @param assignee_gid [String]
|
120
|
+
#
|
116
121
|
# @return [Asana::Resources::Task]
|
117
122
|
def add_task(name,
|
118
123
|
workspace_gid: @workspaces.default_workspace_gid,
|
@@ -122,12 +127,17 @@ module Checkoff
|
|
122
127
|
workspace: workspace_gid, name: name)
|
123
128
|
end
|
124
129
|
|
130
|
+
# Return user-accessible URL for a task
|
131
|
+
#
|
125
132
|
# @param task [Asana::Resources::Task]
|
133
|
+
#
|
126
134
|
# @return [String] end-user URL to the task in question
|
127
135
|
def url_of_task(task)
|
128
136
|
"https://app.asana.com/0/0/#{task.gid}/f"
|
129
137
|
end
|
130
138
|
|
139
|
+
# True if any of the task's dependencies are marked incomplete
|
140
|
+
#
|
131
141
|
# @param task [Asana::Resources::Task]
|
132
142
|
def incomplete_dependencies?(task)
|
133
143
|
# Avoid a redundant fetch. Unfortunately, Ruby SDK allows
|
@@ -166,11 +176,14 @@ module Checkoff
|
|
166
176
|
# task: String (name)
|
167
177
|
#
|
168
178
|
# @param task [Asana::Resources::Task]
|
179
|
+
#
|
169
180
|
# @return [Hash]
|
170
181
|
def task_to_h(task)
|
171
182
|
task_hashes.task_to_h(task)
|
172
183
|
end
|
173
184
|
|
185
|
+
# True if the task is in a project which is in the given portfolio
|
186
|
+
#
|
174
187
|
# @param task [Asana::Resources::Task]
|
175
188
|
# @param portfolio_name [String]
|
176
189
|
# @param workspace_name [String]
|
data/lib/checkoff/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: checkoff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.103.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vince Broz
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- lib/checkoff/internal/config_loader.rb
|
135
135
|
- lib/checkoff/internal/create-class.sh
|
136
136
|
- lib/checkoff/internal/project_selector_evaluator.rb
|
137
|
+
- lib/checkoff/internal/ready_between_relative.rb
|
137
138
|
- lib/checkoff/internal/search_url.rb
|
138
139
|
- lib/checkoff/internal/search_url/custom_field_param_converter.rb
|
139
140
|
- lib/checkoff/internal/search_url/custom_field_variant.rb
|