checkoff 0.26.1 → 0.28.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10a2b886559bd9a77cdf03a309825250a99c4e03c251f0c1699b9941aef09e30
4
- data.tar.gz: cab6c6505b28ee63b79c8b6765efc2401d10f4d4ec53b6b86791283a87f5a065
3
+ metadata.gz: bc77ff8291abdf8396b00f06b6a264aced462d4017962f22b12be600ca0838e7
4
+ data.tar.gz: 04cd04ace148582a064b9eb52fa46e738e8621effe5316f8e9dc75909564d3b2
5
5
  SHA512:
6
- metadata.gz: e170ab3b7c20cdf9ccb0f6fc89df6277c5bebecaa1da242f58ddeab3dbedc955e097307ad23c11b88d368ae8aeb5fa73e6c0584a05aeaa335232ec753b7235b7
7
- data.tar.gz: 6ff4dcbeeaa90e46fa67578c44ce68f790de5569b5a3a19c6d7ebf3a9181aa566921b31f4a9afb0504292a274ce4e51c0b5cb0a8480d0be75b435493f4a687dc
6
+ metadata.gz: 1aa7f83850fd0b422d1c9d2e9f0634da82bc16bfd9a84a0116b839921c64448de06b49a7c8af009bfce2c282d5c7b6f65b2cf7e5dc4fdef31724613984010c31
7
+ data.tar.gz: 9317f20ab81c07d64ae5c955ffe345a2849ba966d5faf9de03d73e8712ddac3ad0d1d90ac70dc7af3af54dcf6a12ae48bb80aa8e4ec43eed4368942fae206b32
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.26.1)
15
+ checkoff (0.28.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -49,6 +49,7 @@ module Checkoff
49
49
  VARIANTS = {
50
50
  'is' => CustomFieldVariant::Is,
51
51
  'no_value' => CustomFieldVariant::NoValue,
52
+ 'any_value' => CustomFieldVariant::AnyValue,
52
53
  'is_not' => CustomFieldVariant::IsNot,
53
54
  'less_than' => CustomFieldVariant::LessThan,
54
55
  'greater_than' => CustomFieldVariant::GreaterThan,
@@ -16,6 +16,12 @@ module Checkoff
16
16
 
17
17
  attr_reader :gid, :remaining_params
18
18
 
19
+ def ensure_no_remaining_params!
20
+ return if remaining_params.length.zero?
21
+
22
+ raise "Teach me how to handle these remaining keys: #{remaining_params}"
23
+ end
24
+
19
25
  def fetch_solo_param(param_name)
20
26
  case remaining_params.keys
21
27
  when [param_name]
@@ -96,9 +102,7 @@ module Checkoff
96
102
  # custom_field_#{gid}.variant = 'no_value'
97
103
  class NoValue < CustomFieldVariant
98
104
  def convert
99
- unless remaining_params.length.zero?
100
- raise "Teach me how to handle these remaining keys for #{variant_key}: #{remaining_params}"
101
- end
105
+ ensure_no_remaining_params!
102
106
 
103
107
  api_params = { "custom_fields.#{gid}.is_set" => 'false' }
104
108
  # As of 2023-02, the 'is_set' => 'false' seems to not do
@@ -112,30 +116,38 @@ module Checkoff
112
116
  end
113
117
  end
114
118
 
115
- # custom_field_#{gid}.variant = 'is'
116
- class Is < CustomFieldVariant
119
+ # custom_field_#{gid}.variant = 'any_value'
120
+ #
121
+ # Not used for multi-select fields
122
+ class AnyValue < CustomFieldVariant
117
123
  def convert
118
- unless remaining_params.length == 1
119
- raise "Teach me how to handle these remaining keys for #{variant_key}: #{remaining_params}"
120
- end
124
+ ensure_no_remaining_params!
121
125
 
122
- key, values = remaining_params.to_a[0]
123
- convert_custom_field_is_arg(key, values)
126
+ api_params = { "custom_fields.#{gid}.is_set" => 'true' }
127
+ task_selector = []
128
+ [api_params, task_selector]
124
129
  end
130
+ end
125
131
 
126
- private
132
+ # custom_field_#{gid}.variant = 'is'
133
+ class Is < CustomFieldVariant
134
+ def convert
135
+ selected_options = fetch_solo_param("custom_field_#{gid}.selected_options").split('~')
127
136
 
128
- def convert_custom_field_is_arg(key, values)
129
137
  empty_task_selector = []
130
-
131
- if key.end_with? '.selected_options'
132
- raise "Too many values found for #{key}: #{values}" if values.length != 1
133
-
134
- return [{ "custom_fields.#{gid}.value" => values[0] },
135
- empty_task_selector]
138
+ if selected_options.length == 1
139
+ [{ "custom_fields.#{gid}.value" => selected_options[0] },
140
+ empty_task_selector]
141
+ else
142
+ # As of 2023-01,
143
+ # https://developers.asana.com/reference/searchtasksforworkspace
144
+ # says "Not Supported: searching for multiple exact
145
+ # matches of a custom field". So I guess we have to
146
+ # search this manually.
147
+ api_params = { "custom_fields.#{gid}.is_set" => 'true' }
148
+ task_selector = [:custom_field_gid_value_contains_any_gid, gid, selected_options]
149
+ [api_params, task_selector]
136
150
  end
137
-
138
- raise "Teach me how to handle #{key} = #{values}"
139
151
  end
140
152
  end
141
153
  end
@@ -71,9 +71,14 @@ module Checkoff
71
71
  # Handle 'completion' search url param
72
72
  class Completion < SimpleParam
73
73
  def convert
74
- raise "Teach me how to handle #{key} = #{values}" if single_value != 'incomplete'
75
-
76
- ['completed', false]
74
+ case single_value
75
+ when 'incomplete'
76
+ ['completed', false]
77
+ when 'complete'
78
+ ['completed', true]
79
+ else
80
+ raise "Teach me how to handle #{key} = #{values}"
81
+ end
77
82
  end
78
83
  end
79
84
 
@@ -135,7 +135,9 @@ module Checkoff
135
135
  def evaluate(task, custom_field_gid, custom_field_values_gids)
136
136
  actual_custom_field_values_gids = pull_custom_field_values_gids(task, custom_field_gid)
137
137
 
138
- (custom_field_values_gids - actual_custom_field_values_gids).empty?
138
+ actual_custom_field_values_gids.any? do |custom_field_value|
139
+ custom_field_values_gids.include?(custom_field_value)
140
+ end
139
141
  end
140
142
 
141
143
  private
@@ -3,5 +3,5 @@
3
3
  # Command-line and gem client for Asana (unofficial)
4
4
  module Checkoff
5
5
  # Version of library
6
- VERSION = '0.26.1'
6
+ VERSION = '0.28.0'
7
7
  end
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.26.1
4
+ version: 0.28.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-02-02 00:00:00.000000000 Z
11
+ date: 2023-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport