checkoff 0.111.0 → 0.113.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 +0 -29
- data/lib/checkoff/internal/task_timing.rb +1 -1
- data/lib/checkoff/tasks.rb +20 -0
- data/lib/checkoff/timing.rb +30 -7
- data/lib/checkoff/version.rb +1 -1
- metadata +2 -3
- data/lib/checkoff/internal/ready_between_relative.rb +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d2b22635f5b5c89add793da4b37ed9bdf3a1c943476fac5d8b16825d06491a6
|
4
|
+
data.tar.gz: 1faf6e1ab7a7168cac91f888a62a03a638de20eb83e2f9c23ffce66828da44a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bec50f216ca19ca2820feffe1424de08ed95cdab7369e78971d42dbc9e69620e966b8a9e4b76d4a9e55e2cffd30b12cbf9579c4f1acc83cd99d7b9a95fa77248
|
7
|
+
data.tar.gz: db6380ac15afc8fce0aada0179b8ae3e9a4bf303c6df7086010c1aaab6d58af848ccba62563fcacff6884dc6dd1c2821e83d63a8a37188ab10a6e31dbe04a35b
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'task/function_evaluator'
|
4
|
-
require 'checkoff/internal/ready_between_relative'
|
5
4
|
require 'checkoff/internal/task_timing'
|
6
5
|
|
7
6
|
module Checkoff
|
@@ -146,34 +145,6 @@ module Checkoff
|
|
146
145
|
end
|
147
146
|
end
|
148
147
|
|
149
|
-
# :ready_between_relative function
|
150
|
-
class ReadyBetweenRelativePFunctionEvaluator < FunctionEvaluator
|
151
|
-
FUNCTION_NAME = :ready_between_relative
|
152
|
-
|
153
|
-
def matches?
|
154
|
-
fn?(selector, FUNCTION_NAME)
|
155
|
-
end
|
156
|
-
|
157
|
-
# @param _index [Integer]
|
158
|
-
def evaluate_arg?(_index)
|
159
|
-
false
|
160
|
-
end
|
161
|
-
|
162
|
-
# @param task [Asana::Resources::Task]
|
163
|
-
# @param beginning_num_days_from_now [Integer]
|
164
|
-
# @param end_num_days_from_now [Integer]
|
165
|
-
# @param ignore_dependencies [Boolean]
|
166
|
-
#
|
167
|
-
# @return [Boolean]
|
168
|
-
def evaluate(task, beginning_num_days_from_now, end_num_days_from_now, ignore_dependencies: false)
|
169
|
-
ready_between_relative = Checkoff::Internal::ReadyBetweenRelative.new(tasks: @tasks,
|
170
|
-
client: @client)
|
171
|
-
ready_between_relative.ready_between_relative?(task,
|
172
|
-
beginning_num_days_from_now, end_num_days_from_now,
|
173
|
-
ignore_dependencies: ignore_dependencies)
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
148
|
# :last_story_created_less_than_n_days_ago function
|
178
149
|
class LastStoryCreatedLessThanNDaysAgoFunctionEvaluator < FunctionEvaluator
|
179
150
|
FUNCTION_NAME = :last_story_created_less_than_n_days_ago
|
data/lib/checkoff/tasks.rb
CHANGED
@@ -86,6 +86,19 @@ module Checkoff
|
|
86
86
|
timing.in_period?(task_date_or_time, period)
|
87
87
|
end
|
88
88
|
|
89
|
+
# @param task [Asana::Resources::Task]
|
90
|
+
# @param field_name [Symbol,Array]
|
91
|
+
# :start - start_at or start_on (first set)
|
92
|
+
# :due - due_at or due_on (first set)
|
93
|
+
# :ready - start_at or start_on or due_at or due_on (first set)
|
94
|
+
# :modified - modified_at
|
95
|
+
# [:custom_field, "foo"] - 'Date' custom field type named 'foo'
|
96
|
+
#
|
97
|
+
# @return [Date, Time, nil]
|
98
|
+
def date_or_time_field_by_name(task, field_name)
|
99
|
+
task_timing.date_or_time_field_by_name(task, field_name)
|
100
|
+
end
|
101
|
+
|
89
102
|
# Pull a specific task by name
|
90
103
|
#
|
91
104
|
# @param workspace_name [String]
|
@@ -193,6 +206,13 @@ module Checkoff
|
|
193
206
|
task_hashes.task_to_h(task)
|
194
207
|
end
|
195
208
|
|
209
|
+
# @param task_data [Hash]
|
210
|
+
#
|
211
|
+
# @return [Asana::Resources::Task]
|
212
|
+
def h_to_task(task_data)
|
213
|
+
Asana::Resources::Task.new(task_data, client: client)
|
214
|
+
end
|
215
|
+
|
196
216
|
# True if the task is in a project which is in the given portfolio
|
197
217
|
#
|
198
218
|
# @param task [Asana::Resources::Task]
|
data/lib/checkoff/timing.rb
CHANGED
@@ -73,8 +73,7 @@ module Checkoff
|
|
73
73
|
def greater_than_or_equal_to_n_days_from_now?(date_or_time, num_days)
|
74
74
|
return false if date_or_time.nil?
|
75
75
|
|
76
|
-
|
77
|
-
date_or_time >= n_days_from_now
|
76
|
+
date_or_time >= n_days_from_now(num_days)
|
78
77
|
end
|
79
78
|
|
80
79
|
# @param date_or_time [Date,Time,nil]
|
@@ -95,8 +94,7 @@ module Checkoff
|
|
95
94
|
def less_than_n_days_from_now?(date_or_time, num_days)
|
96
95
|
return false if date_or_time.nil?
|
97
96
|
|
98
|
-
|
99
|
-
date_or_time < n_days_from_now
|
97
|
+
date_or_time < n_days_from_now(num_days)
|
100
98
|
end
|
101
99
|
|
102
100
|
# @param date_or_time [Date,Time,nil]
|
@@ -123,6 +121,29 @@ module Checkoff
|
|
123
121
|
date_or_time.to_time < @now_getter.now
|
124
122
|
end
|
125
123
|
|
124
|
+
# @param num_days [Integer]
|
125
|
+
#
|
126
|
+
# @return [Time]
|
127
|
+
def n_days_from_now(num_days)
|
128
|
+
(@now_getter.now + (num_days * 24 * 60 * 60))
|
129
|
+
end
|
130
|
+
|
131
|
+
# @param date_or_time [Date,Time,nil]
|
132
|
+
# @param beginning_num_days_from_now [Integer,nil]
|
133
|
+
# @param end_num_days_from_now [Integer,nil]
|
134
|
+
def between_relative_days?(date_or_time, beginning_num_days_from_now, end_num_days_from_now)
|
135
|
+
start_time = n_days_from_now(beginning_num_days_from_now || -99_999)
|
136
|
+
end_time = n_days_from_now(end_num_days_from_now || 99_999)
|
137
|
+
|
138
|
+
return false if date_or_time.nil?
|
139
|
+
|
140
|
+
if date_or_time.is_a?(Time)
|
141
|
+
date_or_time > start_time && date_or_time <= end_time
|
142
|
+
else
|
143
|
+
date_or_time > start_time.to_date && date_or_time <= end_time.to_date
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
126
147
|
# @param date_or_time [Date,Time,nil]
|
127
148
|
# @param period_name [Symbol]
|
128
149
|
# @param args [Object]
|
@@ -133,15 +154,17 @@ module Checkoff
|
|
133
154
|
return less_than_n_days_from_now?(date_or_time, *args) if period_name == :less_than_n_days_from_now
|
134
155
|
|
135
156
|
if period_name == :greater_than_or_equal_to_n_days_from_now
|
136
|
-
return greater_than_or_equal_to_n_days_from_now?(date_or_time,
|
137
|
-
*args)
|
157
|
+
return greater_than_or_equal_to_n_days_from_now?(date_or_time, *args)
|
138
158
|
end
|
139
159
|
|
140
160
|
if period_name == :greater_than_or_equal_to_n_days_from_today
|
141
161
|
return greater_than_or_equal_to_n_days_from_today?(date_or_time, *args)
|
142
162
|
end
|
143
163
|
|
144
|
-
|
164
|
+
# @sg-ignore
|
165
|
+
return between_relative_days?(date_or_time, *args) if period_name == :between_relative_days
|
166
|
+
|
167
|
+
raise "Teach me how to handle period [#{period_name.inspect}, #{args.map(&:inspect).join(', ')}]"
|
145
168
|
end
|
146
169
|
|
147
170
|
# bundle exec ./time.rb
|
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.113.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-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -134,7 +134,6 @@ 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
|
138
137
|
- lib/checkoff/internal/search_url.rb
|
139
138
|
- lib/checkoff/internal/search_url/custom_field_param_converter.rb
|
140
139
|
- lib/checkoff/internal/search_url/custom_field_variant.rb
|
@@ -1,63 +0,0 @@
|
|
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 client [Asana::Client]
|
9
|
-
# @param task_timing [Checkoff::Internal::TaskTiming]
|
10
|
-
# @param tasks [Checkoff::Tasks]
|
11
|
-
def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
|
12
|
-
client: Checkoff::Clients.new(config: config).client,
|
13
|
-
task_timing: ::Checkoff::Internal::TaskTiming.new(client: client),
|
14
|
-
tasks: ::Checkoff::Tasks.new(config: config,
|
15
|
-
client: 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
|