checkoff 0.29.4 → 0.30.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: a73a81aadb4e180a59baf5eac5184070a677d791ead8d608f894e71950e03125
4
- data.tar.gz: '0590cbfeefb9b56600dfd2450e3731ea8472d4efa21b1b8e6adf4719e949425f'
3
+ metadata.gz: 56b8922e030c6770a830b116c1b436f31621670e1a80617e01bf35c5756688fd
4
+ data.tar.gz: efa9bbbf45f71ef73df1ec5e1ebc0501915ae6c92b43d6246e48d9866b76da57
5
5
  SHA512:
6
- metadata.gz: 2459b37ea4a58cc8198ad0d6fa43f772d70e3278ec77254d35471d299b06c5afe00c901f7992e305d3ad392727c35977ac80b977f11dddbb1f1f0c1e4e148804
7
- data.tar.gz: 90c1d606f7d2babcf8056e3464aa84d5f7994a1adab568f156468462d46acbccd8b52e0119e7a522a8c4b9083f8e9a17a55f05ec333c567223e50b4b8fb92dba
6
+ metadata.gz: 9b09f82050f2a5b15fc15c8b34ef70093cc7502e64cc5a59d90bc475fce7cdd957dfe4e00d5223ab7c185c2b7f5ddaddc27f1830264c70b3b2279389032c114a
7
+ data.tar.gz: 05627d4fc018a5eae0bf06a226dccf0819ac836a297f56c221b69b5b255f74e2e3501ab8f3e99bfffd4c65984d712e667c9c2e0332fba407fb00f95f7c27a582
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.29.4)
15
+ checkoff (0.30.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -55,6 +55,7 @@ module Checkoff
55
55
  'greater_than' => CustomFieldVariant::GreaterThan,
56
56
  'doesnt_contain_any' => CustomFieldVariant::DoesntContainAny,
57
57
  'contains_any' => CustomFieldVariant::ContainsAny,
58
+ 'contains_all' => CustomFieldVariant::ContainsAll,
58
59
  }.freeze
59
60
 
60
61
  def convert_single_custom_field_params(gid, single_custom_field_params)
@@ -99,6 +99,20 @@ module Checkoff
99
99
  end
100
100
  end
101
101
 
102
+ # This is used in the UI for multi-select fields
103
+ #
104
+ # custom_field_#{gid}.variant = 'contains_all'
105
+ class ContainsAll < CustomFieldVariant
106
+ def convert
107
+ selected_options = fetch_solo_param("custom_field_#{gid}.selected_options").split('~')
108
+
109
+ [{ "custom_fields.#{gid}.is_set" => 'true' },
110
+ ['custom_field_gid_value_contains_all_gids',
111
+ gid,
112
+ selected_options]]
113
+ end
114
+ end
115
+
102
116
  # custom_field_#{gid}.variant = 'no_value'
103
117
  class NoValue < CustomFieldVariant
104
118
  def convert
@@ -35,6 +35,35 @@ module Checkoff
35
35
  end
36
36
 
37
37
  attr_reader :task_selector
38
+
39
+ def pull_enum_values(custom_field)
40
+ resource_subtype = custom_field.fetch('resource_subtype')
41
+ case resource_subtype
42
+ when 'enum'
43
+ [custom_field.fetch('enum_value')]
44
+ when 'multi_enum'
45
+ custom_field.fetch('multi_enum_values')
46
+ else
47
+ raise "Teach me how to handle resource_subtype #{resource_subtype}"
48
+ end
49
+ end
50
+
51
+ def find_gids(custom_field, enum_value)
52
+ if enum_value.nil?
53
+ []
54
+ else
55
+ raise "Unexpected enabled value on custom field: #{custom_field}" if enum_value.fetch('enabled') == false
56
+
57
+ [enum_value.fetch('gid')]
58
+ end
59
+ end
60
+
61
+ def pull_custom_field_values_gids(task, custom_field_gid)
62
+ custom_field = pull_custom_field_or_raise(task, custom_field_gid)
63
+ pull_enum_values(custom_field).flat_map do |enum_value|
64
+ find_gids(custom_field, enum_value)
65
+ end
66
+ end
38
67
  end
39
68
 
40
69
  # :and function
@@ -152,35 +181,23 @@ module Checkoff
152
181
  custom_field_values_gids.include?(custom_field_value)
153
182
  end
154
183
  end
184
+ end
155
185
 
156
- private
157
-
158
- def pull_enum_values(custom_field)
159
- resource_subtype = custom_field.fetch('resource_subtype')
160
- case resource_subtype
161
- when 'enum'
162
- [custom_field.fetch('enum_value')]
163
- when 'multi_enum'
164
- custom_field.fetch('multi_enum_values')
165
- else
166
- raise "Teach me how to handle resource_subtype #{resource_subtype}"
167
- end
186
+ # :custom_field_gid_value_contains_all_gids function
187
+ class CustomFieldGidValueContainsAllGidsFunctionEvaluator < FunctionEvaluator
188
+ def matches?
189
+ fn?(task_selector, :custom_field_gid_value_contains_all_gids)
168
190
  end
169
191
 
170
- def find_gids(custom_field, enum_value)
171
- if enum_value.nil?
172
- []
173
- else
174
- raise "Unexpected enabled value on custom field: #{custom_field}" if enum_value.fetch('enabled') == false
175
-
176
- [enum_value.fetch('gid')]
177
- end
192
+ def evaluate_arg?(_index)
193
+ false
178
194
  end
179
195
 
180
- def pull_custom_field_values_gids(task, custom_field_gid)
181
- custom_field = pull_custom_field_or_raise(task, custom_field_gid)
182
- pull_enum_values(custom_field).flat_map do |enum_value|
183
- find_gids(custom_field, enum_value)
196
+ def evaluate(task, custom_field_gid, custom_field_values_gids)
197
+ actual_custom_field_values_gids = pull_custom_field_values_gids(task, custom_field_gid)
198
+
199
+ custom_field_values_gids.all? do |custom_field_value|
200
+ actual_custom_field_values_gids.include?(custom_field_value)
184
201
  end
185
202
  end
186
203
  end
@@ -200,6 +217,7 @@ module Checkoff
200
217
  CustomFieldValueFunctionEvaluator,
201
218
  CustomFieldGidValueFunctionEvaluator,
202
219
  CustomFieldGidValueContainsAnyGidFunctionEvaluator,
220
+ CustomFieldGidValueContainsAllGidsFunctionEvaluator,
203
221
  AndFunctionEvaluator,
204
222
  DuePFunctionEvaluator,
205
223
  ].freeze
@@ -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.29.4'
6
+ VERSION = '0.30.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.29.4
4
+ version: 0.30.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-23 00:00:00.000000000 Z
11
+ date: 2023-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport