checkoff 0.53.1 → 0.54.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/search_url/date_param_converter.rb +73 -36
- 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: 2a26bf5e53147ab791087492c23a9a050c6bdeef1d0edadba9a4d3d4741c32bf
|
4
|
+
data.tar.gz: 403940c20a3e08c11904192168fbd6d0df95b012cd17e025148a777223b0f30c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5421aa9a82b335176e2cd98e0bba600acbaa61cc5e8c45fd876c13eeb5d2d1d750740f56a92cf8f556d79faf7b8ac162452d7ff6d30dff9719df5ffeba4930f
|
7
|
+
data.tar.gz: 8dd35cf8d9009cb1bf76fd0b662a0d5bbde874a25c7cad914424131dc8d5e508ce0e39f0c2ba690b2ff3936bda3076ea9b6ec1eff6416ea032cd24bb0b10da59
|
data/Gemfile.lock
CHANGED
@@ -13,34 +13,88 @@ module Checkoff
|
|
13
13
|
@date_url_params = date_url_params
|
14
14
|
end
|
15
15
|
|
16
|
+
# @sg-ignore
|
17
|
+
# @return [Array(Hash<String, String>, Array<[Symbol, Array]>)]
|
18
|
+
def convert
|
19
|
+
return [{}, []] if date_url_params.empty?
|
20
|
+
|
21
|
+
out = nil
|
22
|
+
|
23
|
+
%w[due_date start_date].each do |prefix|
|
24
|
+
next unless date_url_params.key? "#{prefix}.operator"
|
25
|
+
raise 'Teach me how to handle simultaneous date parameters' unless out.nil?
|
26
|
+
|
27
|
+
out = convert_for_prefix(prefix)
|
28
|
+
end
|
29
|
+
|
30
|
+
raise "Teach me to handle these parameters: #{date_url_params.inspect}" unless date_url_params.empty?
|
31
|
+
|
32
|
+
out
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
# @sg-ignore
|
38
|
+
# @param prefix [String]
|
39
|
+
# @return [Array(Hash<String, String>, Array<[Symbol, Array]>)]
|
40
|
+
def convert_for_prefix(prefix)
|
41
|
+
# example params:
|
42
|
+
# due_date.operator=through_next
|
43
|
+
# due_date.value=0
|
44
|
+
# due_date.unit=day
|
45
|
+
operator = get_single_param("#{prefix}.operator")
|
46
|
+
|
47
|
+
out = if operator == 'through_next'
|
48
|
+
handle_through_next(prefix)
|
49
|
+
elsif operator == 'between'
|
50
|
+
handle_between(prefix)
|
51
|
+
else
|
52
|
+
raise "Teach me how to handle date mode: #{operator.inspect}."
|
53
|
+
end
|
54
|
+
|
55
|
+
# mark these as done by deleting from the hash
|
56
|
+
date_url_params.delete_if { |k, _| k.start_with? prefix }
|
57
|
+
|
58
|
+
out
|
59
|
+
end
|
60
|
+
|
61
|
+
# https://developers.asana.com/docs/search-tasks-in-a-workspace
|
62
|
+
API_PREFIX = {
|
63
|
+
'due_date' => 'due_on',
|
64
|
+
'start_date' => 'start_on',
|
65
|
+
}.freeze
|
66
|
+
|
67
|
+
# @param prefix [String]
|
16
68
|
# @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
|
-
|
69
|
+
def handle_through_next(prefix)
|
70
|
+
value = get_single_param("#{prefix}.value").to_i
|
19
71
|
|
20
|
-
validate_unit_is_day!
|
72
|
+
validate_unit_is_day!(prefix)
|
21
73
|
|
22
74
|
# @sg-ignore
|
23
75
|
# @type [Date]
|
24
|
-
before = Date.today +
|
76
|
+
before = Date.today + value
|
77
|
+
|
25
78
|
# 'due_on.before' => '2023-01-01',
|
26
79
|
# 'due_on.after' => '2023-01-01',
|
27
80
|
# [{ 'due_on.before' => '2023-09-01' }, []]
|
28
|
-
[{
|
81
|
+
[{ "#{API_PREFIX.fetch(prefix)}.before" => before.to_s }, []]
|
29
82
|
end
|
30
83
|
|
84
|
+
# @param prefix [String]
|
31
85
|
# @return [Array(Hash<String, String>, Array<[Symbol, Array]>)] See https://developers.asana.com/docs/search-tasks-in-a-workspace
|
32
|
-
def handle_between
|
33
|
-
|
34
|
-
raise
|
86
|
+
def handle_between(prefix)
|
87
|
+
after = get_single_param("#{prefix}.after")
|
88
|
+
raise "Teach me how to handle #{prefix}.before" if date_url_params.key? "#{prefix}.before"
|
35
89
|
|
36
|
-
validate_unit_not_provided!
|
90
|
+
validate_unit_not_provided!(prefix)
|
37
91
|
|
38
92
|
# Example value: 1702857600000
|
39
93
|
# +1 is because API seems to operate on inclusive ranges
|
40
94
|
# @type [Date]
|
41
95
|
# @sg-ignore
|
42
|
-
after = Time.at(
|
43
|
-
[{
|
96
|
+
after = Time.at(after.to_i / 1000).to_date + 1
|
97
|
+
[{ "#{API_PREFIX.fetch(prefix)}.after" => after.to_s }, []]
|
44
98
|
end
|
45
99
|
|
46
100
|
# @param param_key [String]
|
@@ -55,37 +109,20 @@ module Checkoff
|
|
55
109
|
value[0]
|
56
110
|
end
|
57
111
|
|
58
|
-
# @
|
59
|
-
def convert
|
60
|
-
return [{}, []] if date_url_params.empty?
|
61
|
-
|
62
|
-
# example params:
|
63
|
-
# due_date.operator=through_next
|
64
|
-
# due_date.value=0
|
65
|
-
# due_date.unit=day
|
66
|
-
due_date_operator = get_single_param('due_date.operator')
|
67
|
-
|
68
|
-
return handle_through_next if due_date_operator == 'through_next'
|
69
|
-
|
70
|
-
return handle_between if due_date_operator == 'between'
|
71
|
-
|
72
|
-
raise "Teach me how to handle date mode: #{due_date_operator.inspect}."
|
73
|
-
end
|
74
|
-
|
75
|
-
private
|
76
|
-
|
112
|
+
# @param prefix [String]
|
77
113
|
# @return [void]
|
78
|
-
def validate_unit_not_provided!
|
79
|
-
return unless date_url_params.key?
|
114
|
+
def validate_unit_not_provided!(prefix)
|
115
|
+
return unless date_url_params.key? "#{prefix}.unit"
|
80
116
|
|
81
|
-
raise "Teach me how to handle other
|
117
|
+
raise "Teach me how to handle other #{prefix}.unit for these params: #{date_url_params.inspect}"
|
82
118
|
end
|
83
119
|
|
120
|
+
# @param prefix [String]
|
84
121
|
# @return [void]
|
85
|
-
def validate_unit_is_day!
|
86
|
-
unit = date_url_params.fetch(
|
122
|
+
def validate_unit_is_day!(prefix)
|
123
|
+
unit = date_url_params.fetch("#{prefix}.unit").fetch(0)
|
87
124
|
|
88
|
-
raise
|
125
|
+
raise "Teach me how to handle other time units: #{unit}" unless unit == 'day'
|
89
126
|
end
|
90
127
|
|
91
128
|
# @return [Hash<String, Array<String>>]
|
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.54.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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|