checkoff 0.26.1 → 0.27.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: bac942429684609678acb06e7426577be0bfd0239b9bf7ca4123e71484125746
4
+ data.tar.gz: 5cad1409ce70028e43f52789878b3d2cbcfaceb3bfcd26b230890a27d9d87fbf
5
5
  SHA512:
6
- metadata.gz: e170ab3b7c20cdf9ccb0f6fc89df6277c5bebecaa1da242f58ddeab3dbedc955e097307ad23c11b88d368ae8aeb5fa73e6c0584a05aeaa335232ec753b7235b7
7
- data.tar.gz: 6ff4dcbeeaa90e46fa67578c44ce68f790de5569b5a3a19c6d7ebf3a9181aa566921b31f4a9afb0504292a274ce4e51c0b5cb0a8480d0be75b435493f4a687dc
6
+ metadata.gz: b68f2aa40aef9ecfe7fb4fbbe1bfac3b48f99c7cdf4ed1ed6308f93e3f4ac9f0d8b289bd5e82a7e1e05ee189b9fc62ca7cf6e07a237cb5d626318509ec24f5b8
7
+ data.tar.gz: 493cc1f59007c7fce4146e3bebae38a9447fa57cf418079afd835783529f8952c981e4bf86819fc8ec66f40f2c32a251da43fccafaf064316bee90f8bdbf781a
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.27.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
@@ -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.27.0'
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz