checkoff 0.99.0 → 0.101.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/config/definitions.rb +4 -0
- data/lib/checkoff/internal/selector_classes/task.rb +51 -13
- data/lib/checkoff/internal/task_timing.rb +2 -0
- data/lib/checkoff/portfolios.rb +10 -0
- data/lib/checkoff/tasks.rb +20 -0
- data/lib/checkoff/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6242a956ad83d3a1818be59711f4ba42040d7051dac2dd0ba2c8a2e5ed29f244
|
4
|
+
data.tar.gz: 515a08a90d20a58956256f76248f01d7a5fd52c6ac14e1fbd8215a6eb33dcc6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8575f32ba5e2130117784cdf0b6e3f9bd40a11c918ffd99208457cd8dde84f7333da5ffc09096f520bccb28f6451da0605f3a3073002de89e8b9d75800371dfa
|
7
|
+
data.tar.gz: 037b01300963f231ba1401eb55beb47aff94deb9baab62c3d952876de3d3afc6d5a2c427bb717f5bdc0b8faa8cf3029bdd844de8d955ae3d600ebf9b2ee20835
|
data/Gemfile.lock
CHANGED
data/config/definitions.rb
CHANGED
@@ -114,7 +114,7 @@ module Checkoff
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
-
# :
|
117
|
+
# :ready_between_relative function
|
118
118
|
class ReadyBetweenRelativePFunctionEvaluator < FunctionEvaluator
|
119
119
|
FUNCTION_NAME = :ready_between_relative
|
120
120
|
|
@@ -134,24 +134,34 @@ module Checkoff
|
|
134
134
|
#
|
135
135
|
# @return [Boolean]
|
136
136
|
def evaluate(task, beginning_num_days_from_now, end_num_days_from_now, ignore_dependencies: false)
|
137
|
+
ready_between_relative?(task,
|
138
|
+
beginning_num_days_from_now, end_num_days_from_now,
|
139
|
+
ignore_dependencies: ignore_dependencies)
|
140
|
+
end
|
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)
|
137
154
|
beginning_n_days_from_now_time = (Time.now + (beginning_num_days_from_now * 24 * 60 * 60))
|
138
155
|
end_n_days_from_now_time = (Time.now + (end_num_days_from_now * 24 * 60 * 60))
|
139
156
|
|
140
157
|
# @type [Date, Time, nil]
|
141
|
-
|
142
|
-
@task_timing.date_or_time_field_by_name(task, :due)
|
158
|
+
ready_date_or_time = @task_timing.date_or_time_field_by_name(task, :ready)
|
143
159
|
|
144
|
-
return false if
|
160
|
+
return false if ready_date_or_time.nil?
|
145
161
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
task_date_or_time <= end_n_days_from_now_time
|
150
|
-
else
|
151
|
-
# if date
|
152
|
-
task_date_or_time > beginning_n_days_from_now_time.to_date &&
|
153
|
-
task_date_or_time <= end_n_days_from_now_time.to_date
|
154
|
-
end
|
162
|
+
in_range = ready_in_range?(ready_date_or_time,
|
163
|
+
beginning_n_days_from_now_time,
|
164
|
+
end_n_days_from_now_time)
|
155
165
|
|
156
166
|
return false unless in_range
|
157
167
|
|
@@ -159,6 +169,17 @@ module Checkoff
|
|
159
169
|
|
160
170
|
true
|
161
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
|
182
|
+
end
|
162
183
|
end
|
163
184
|
|
164
185
|
# :field_less_than_n_days_ago
|
@@ -373,6 +394,23 @@ module Checkoff
|
|
373
394
|
limit_to_portfolio_gid: limit_to_portfolio_gid)
|
374
395
|
end
|
375
396
|
end
|
397
|
+
|
398
|
+
# :in_portfolio_named? function
|
399
|
+
class InPortfolioNamedFunctionEvaluator < FunctionEvaluator
|
400
|
+
FUNCTION_NAME = :in_portfolio_named?
|
401
|
+
|
402
|
+
def matches?
|
403
|
+
fn?(selector, FUNCTION_NAME)
|
404
|
+
end
|
405
|
+
|
406
|
+
# @param task [Asana::Resources::Task]
|
407
|
+
# @param portfolio_name [String]
|
408
|
+
#
|
409
|
+
# @return [Boolean]
|
410
|
+
def evaluate(task, portfolio_name)
|
411
|
+
@tasks.in_portfolio_named?(task, portfolio_name)
|
412
|
+
end
|
413
|
+
end
|
376
414
|
end
|
377
415
|
end
|
378
416
|
end
|
data/lib/checkoff/portfolios.rb
CHANGED
@@ -78,6 +78,16 @@ module Checkoff
|
|
78
78
|
end
|
79
79
|
cache_method :portfolio_by_gid, SHORT_CACHE_TIME
|
80
80
|
|
81
|
+
# @param workspace_name [String]
|
82
|
+
# @param portfolio_name [String]
|
83
|
+
#
|
84
|
+
# @return [Enumerable<Asana::Resources::Project>]
|
85
|
+
def projects_in_portfolio(workspace_name, portfolio_name)
|
86
|
+
portfolio = portfolio_or_raise(workspace_name, portfolio_name)
|
87
|
+
portfolio.get_items
|
88
|
+
end
|
89
|
+
cache_method :projects_in_portfolio, LONG_CACHE_TIME
|
90
|
+
|
81
91
|
private
|
82
92
|
|
83
93
|
# @return [Checkoff::Workspaces]
|
data/lib/checkoff/tasks.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
# frozen_string_literal: true
|
4
4
|
|
5
5
|
require_relative 'sections'
|
6
|
+
require_relative 'portfolios'
|
6
7
|
require_relative 'workspaces'
|
7
8
|
require_relative 'internal/config_loader'
|
8
9
|
require_relative 'internal/task_timing'
|
@@ -26,6 +27,7 @@ module Checkoff
|
|
26
27
|
# @param client [Asana::Client]
|
27
28
|
# @param workspaces [Checkoff::Workspaces]
|
28
29
|
# @param sections [Checkoff::Sections]
|
30
|
+
# @param portfolios [Checkoff::Portfolios]
|
29
31
|
# @param time_class [Class<Time>]
|
30
32
|
# @param date_class [Class<Date>]
|
31
33
|
# @param asana_task [Class<Asana::Resources::Task>]
|
@@ -35,6 +37,8 @@ module Checkoff
|
|
35
37
|
client: client),
|
36
38
|
sections: Checkoff::Sections.new(config: config,
|
37
39
|
client: client),
|
40
|
+
portfolios: Checkoff::Portfolios.new(config: config,
|
41
|
+
client: client),
|
38
42
|
time_class: Time,
|
39
43
|
date_class: Date,
|
40
44
|
asana_task: Asana::Resources::Task)
|
@@ -44,6 +48,7 @@ module Checkoff
|
|
44
48
|
@date_class = date_class
|
45
49
|
@asana_task = asana_task
|
46
50
|
@client = client
|
51
|
+
@portfolios = portfolios
|
47
52
|
@workspaces = workspaces
|
48
53
|
end
|
49
54
|
|
@@ -166,6 +171,21 @@ module Checkoff
|
|
166
171
|
task_hashes.task_to_h(task)
|
167
172
|
end
|
168
173
|
|
174
|
+
# @param task [Asana::Resources::Task]
|
175
|
+
# @param portfolio_name [String]
|
176
|
+
# @param workspace_name [String]
|
177
|
+
def in_portfolio_named?(task,
|
178
|
+
portfolio_name,
|
179
|
+
workspace_name: @workspaces.default_workspace.name)
|
180
|
+
portfolio_projects = @portfolios.projects_in_portfolio(workspace_name, portfolio_name)
|
181
|
+
task.memberships.any? do |membership|
|
182
|
+
project_gid = membership.fetch('project').fetch('gid')
|
183
|
+
portfolio_projects.any? do |portfolio_project|
|
184
|
+
portfolio_project.gid == project_gid
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
169
189
|
private
|
170
190
|
|
171
191
|
# @return [Checkoff::Internal::TaskTiming]
|
data/lib/checkoff/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: checkoff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.101.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vince Broz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|