checkoff 0.50.0 → 0.52.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/config/definitions.rb +17 -1
- data/lib/checkoff/internal/search_url/date_param_converter.rb +49 -19
- data/lib/checkoff/internal/task_selector_evaluator.rb +49 -6
- 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: c150952f6929705defdcfb0d506308ca1d5e285e732eb6715fcb9c03a78e8ad4
|
4
|
+
data.tar.gz: ac88caf643edccda95c7fcf345e601bcee87f6f1e59b0af83136fe7194420766
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d4a6454075c4e2332b3c59ca3f93b3358b77f77f8bf43e2c7e28f9a615d73b204edc3b1ac00b51acbe109355ae3b6a16b30944bd13ea6be653dc28e2e45d857
|
7
|
+
data.tar.gz: 774fb7f8311cc540f762f36d30f79b59de16897105ae8a34496585a5c1c6e19353b37736b691b98b3bc447a88685bdd73db297dbaa23f2bde1b3d70f0ef47ab2
|
data/Gemfile.lock
CHANGED
data/config/definitions.rb
CHANGED
@@ -4,9 +4,21 @@
|
|
4
4
|
# @!parse
|
5
5
|
# class Time
|
6
6
|
# class << self
|
7
|
-
# # @param
|
7
|
+
# # @param time [String]
|
8
8
|
# # @return [Time]
|
9
|
+
# def parse(time); end
|
10
|
+
# end
|
11
|
+
# # https://ruby-doc.org/3.2.2/exts/date/Time.html#method-i-to_date#
|
12
|
+
# # @return [Date]
|
13
|
+
# def to_date; end
|
14
|
+
# end
|
15
|
+
# class Date
|
16
|
+
# class << self
|
17
|
+
# # @param date [String]
|
18
|
+
# # @return [Date]
|
9
19
|
# def parse(date); end
|
20
|
+
# # @return [Date]
|
21
|
+
# def today; end
|
10
22
|
# end
|
11
23
|
# end
|
12
24
|
# module Asana
|
@@ -26,6 +38,10 @@
|
|
26
38
|
# module Resources
|
27
39
|
# # https://developers.asana.com/reference/gettask
|
28
40
|
# class Task
|
41
|
+
# # @return [String,nil]
|
42
|
+
# def due_at; end
|
43
|
+
# # @return [String,nil]
|
44
|
+
# def due_on; end
|
29
45
|
# # @return [Hash<String, String>, nil]
|
30
46
|
# def assignee; end
|
31
47
|
# # @return [String, nil]
|
@@ -14,6 +14,45 @@ module Checkoff
|
|
14
14
|
end
|
15
15
|
|
16
16
|
# @return [Array(Hash<String, String>, Array<[Symbol, Array]>)] See https://developers.asana.com/docs/search-tasks-in-a-workspace
|
17
|
+
def handle_through_next
|
18
|
+
due_date_value = get_single_param('due_date.value').to_i
|
19
|
+
|
20
|
+
validate_unit_is_day!
|
21
|
+
|
22
|
+
# @sg-ignore
|
23
|
+
# @type [Date]
|
24
|
+
before = Date.today + due_date_value
|
25
|
+
# 'due_on.before' => '2023-01-01',
|
26
|
+
# 'due_on.after' => '2023-01-01',
|
27
|
+
# [{ 'due_on.before' => '2023-09-01' }, []]
|
28
|
+
[{ 'due_on.before' => before.to_s }, []]
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [Array(Hash<String, String>, Array<[Symbol, Array]>)] See https://developers.asana.com/docs/search-tasks-in-a-workspace
|
32
|
+
def handle_between
|
33
|
+
due_date_after = get_single_param('due_date.after')
|
34
|
+
raise 'Teach me how to handle due_date_before' if date_url_params.key? 'due_date.before'
|
35
|
+
|
36
|
+
validate_unit_not_provided!
|
37
|
+
|
38
|
+
# Example value: 1702857600000
|
39
|
+
after = Time.at(due_date_after.to_i / 1000).to_date
|
40
|
+
[{ 'due_on.after' => after.to_s }, []]
|
41
|
+
end
|
42
|
+
|
43
|
+
# @param param_key [String]
|
44
|
+
# @return [String]
|
45
|
+
def get_single_param(param_key)
|
46
|
+
raise "Expected #{param_key} to have at least one value" unless date_url_params.key? param_key
|
47
|
+
|
48
|
+
value = date_url_params.fetch(param_key)
|
49
|
+
|
50
|
+
raise "Expected #{param_key} to have one value" if value.length != 1
|
51
|
+
|
52
|
+
value[0]
|
53
|
+
end
|
54
|
+
|
55
|
+
# @return [Array(Hash<String, String>, Array<[Symbol, Array]>)]
|
17
56
|
def convert
|
18
57
|
return [{}, []] if date_url_params.empty?
|
19
58
|
|
@@ -21,38 +60,29 @@ module Checkoff
|
|
21
60
|
# due_date.operator=through_next
|
22
61
|
# due_date.value=0
|
23
62
|
# due_date.unit=day
|
24
|
-
|
63
|
+
due_date_operator = get_single_param('due_date.operator')
|
25
64
|
|
26
|
-
|
65
|
+
return handle_through_next if due_date_operator == 'through_next'
|
27
66
|
|
28
|
-
|
29
|
-
# @type [Date]
|
30
|
-
before = Date.today + value
|
67
|
+
return handle_between if due_date_operator == 'between'
|
31
68
|
|
32
|
-
|
33
|
-
|
34
|
-
# 'due_on.before' => '2023-01-01',
|
35
|
-
# 'due_on.after' => '2023-01-01',
|
36
|
-
# [{ 'due_on.before' => '2023-09-01' }, []]
|
37
|
-
[{ 'due_on.before' => before.to_s }, []]
|
69
|
+
raise "Teach me how to handle date mode: #{due_date_operator.inspect}."
|
38
70
|
end
|
39
71
|
|
40
72
|
private
|
41
73
|
|
42
74
|
# @return [void]
|
43
|
-
def
|
44
|
-
|
75
|
+
def validate_unit_not_provided!
|
76
|
+
return unless date_url_params.key? 'due_date.unit'
|
45
77
|
|
46
|
-
raise
|
78
|
+
raise "Teach me how to handle other due_date.unit for these params: #{date_url_params.inspect}"
|
47
79
|
end
|
48
80
|
|
49
81
|
# @return [void]
|
50
|
-
def
|
51
|
-
|
52
|
-
|
53
|
-
return if due_date_operators == ['through_next']
|
82
|
+
def validate_unit_is_day!
|
83
|
+
unit = date_url_params.fetch('due_date.unit').fetch(0)
|
54
84
|
|
55
|
-
raise
|
85
|
+
raise 'Teach me how to handle other time units' unless unit == 'day'
|
56
86
|
end
|
57
87
|
|
58
88
|
# @return [Hash<String, Array<String>>]
|
@@ -38,9 +38,21 @@ module Checkoff
|
|
38
38
|
# @sg-ignore
|
39
39
|
# @return [Date, nil]
|
40
40
|
def pull_date_field_by_name_or_raise(task, field_name)
|
41
|
-
|
41
|
+
if field_name == :modified
|
42
|
+
return Time.parse(task.modified_at).to_date unless task.modified_at.nil?
|
42
43
|
|
43
|
-
|
44
|
+
return nil
|
45
|
+
end
|
46
|
+
|
47
|
+
if field_name == :due
|
48
|
+
return Time.parse(task.due_at).to_date unless task.due_at.nil?
|
49
|
+
|
50
|
+
return Date.parse(task.due_on) unless task.due_on.nil?
|
51
|
+
|
52
|
+
return nil
|
53
|
+
end
|
54
|
+
|
55
|
+
raise "Teach me how to handle field #{field_name}"
|
44
56
|
end
|
45
57
|
|
46
58
|
# @sg-ignore
|
@@ -372,13 +384,43 @@ module Checkoff
|
|
372
384
|
#
|
373
385
|
# @return [Boolean]
|
374
386
|
def evaluate(task, field_name, num_days)
|
375
|
-
|
387
|
+
date = pull_date_field_by_name_or_raise(task, field_name)
|
376
388
|
|
377
|
-
return false if
|
389
|
+
return false if date.nil?
|
378
390
|
|
379
|
-
n_days_ago = (Time.now - (num_days * 24 * 60 * 60))
|
380
391
|
# @sg-ignore
|
381
|
-
|
392
|
+
n_days_ago = Date.today - num_days
|
393
|
+
# @sg-ignore
|
394
|
+
date < n_days_ago
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
# :field_greater_than_or_equal_to_n_days_from_today
|
399
|
+
class FieldGreaterThanOrEqualToNDaysFromTodayFunctionEvaluator < FunctionEvaluator
|
400
|
+
FUNCTION_NAME = :field_greater_than_or_equal_to_n_days_from_today
|
401
|
+
|
402
|
+
def matches?
|
403
|
+
fn?(task_selector, FUNCTION_NAME)
|
404
|
+
end
|
405
|
+
|
406
|
+
def evaluate_arg?(_index)
|
407
|
+
false
|
408
|
+
end
|
409
|
+
|
410
|
+
# @param task [Asana::Resources::Task]
|
411
|
+
# @param field_name [Symbol]
|
412
|
+
# @param num_days [Integer]
|
413
|
+
#
|
414
|
+
# @return [Boolean]
|
415
|
+
def evaluate(task, field_name, num_days)
|
416
|
+
date = pull_date_field_by_name_or_raise(task, field_name)
|
417
|
+
|
418
|
+
return false if date.nil?
|
419
|
+
|
420
|
+
# @sg-ignore
|
421
|
+
n_days_from_today = Date.today + num_days
|
422
|
+
# @sg-ignore
|
423
|
+
date >= n_days_from_today
|
382
424
|
end
|
383
425
|
end
|
384
426
|
|
@@ -481,6 +523,7 @@ module Checkoff
|
|
481
523
|
Checkoff::TaskSelectorClasses::UnassignedPFunctionEvaluator,
|
482
524
|
Checkoff::TaskSelectorClasses::DueDateSetPFunctionEvaluator,
|
483
525
|
Checkoff::TaskSelectorClasses::FieldLessThanNDaysAgoFunctionEvaluator,
|
526
|
+
Checkoff::TaskSelectorClasses::FieldGreaterThanOrEqualToNDaysFromTodayFunctionEvaluator,
|
484
527
|
Checkoff::TaskSelectorClasses::CustomFieldLessThanNDaysFromNowFunctionEvaluator,
|
485
528
|
Checkoff::TaskSelectorClasses::CustomFieldGreaterThanOrEqualToNDaysFromNowFunctionEvaluator,
|
486
529
|
Checkoff::TaskSelectorClasses::StringLiteralEvaluator,
|
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.52.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-09-
|
11
|
+
date: 2023-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|