checkoff 0.29.3 → 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: ced71b64a24369d0c0fe302b321d7f1002230d76c8dcdf725f4f638f6123aca2
4
- data.tar.gz: 530c801995de6d17d5dc183edd6211b2c1cf16885bc27be72d9400a9a40eb172
3
+ metadata.gz: 56b8922e030c6770a830b116c1b436f31621670e1a80617e01bf35c5756688fd
4
+ data.tar.gz: efa9bbbf45f71ef73df1ec5e1ebc0501915ae6c92b43d6246e48d9866b76da57
5
5
  SHA512:
6
- metadata.gz: 7fc6c123962608a1ec0209112e1c61a71423f7d410e32b464a637a29681cde1ac4d7c7571cfc54b0a6f7647b93d63f23a6284036dcef9ef43517bb68451f57f7
7
- data.tar.gz: 811034e7770c45ccf89b71e29a394a997143ca567d8aa22b1c4be74e69f9f74242fb40045b0598ec5db1c4ef472478a55c6a99a8efc24c7244e98b77a14affaf
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.3)
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
@@ -24,9 +24,9 @@ module Checkoff
24
24
  SHORT_CACHE_TIME = MINUTE
25
25
 
26
26
  def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
27
- workspaces: Checkoff::Workspaces.new(config: config),
28
- clients: Checkoff::Clients.new(config: config),
29
- client: clients.client)
27
+ client: Checkoff::Clients.new(config: config).client,
28
+ workspaces: Checkoff::Workspaces.new(config: config,
29
+ client: client))
30
30
  @config = config
31
31
  @workspaces = workspaces
32
32
  @client = client
@@ -18,10 +18,11 @@ module Checkoff
18
18
  attr_reader :projects, :workspaces, :time, :my_tasks
19
19
 
20
20
  def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
21
- projects: Checkoff::Projects.new(config: config),
22
- workspaces: Checkoff::Workspaces.new(config: config),
23
- clients: Checkoff::Clients.new(config: config),
24
- client: clients.client,
21
+ client: Checkoff::Clients.new(config: config).client,
22
+ projects: Checkoff::Projects.new(config: config,
23
+ client: client),
24
+ workspaces: Checkoff::Workspaces.new(config: config,
25
+ client: client),
25
26
  time: Time)
26
27
  @projects = projects
27
28
  @workspaces = workspaces
@@ -15,9 +15,9 @@ module Checkoff
15
15
  SHORT_CACHE_TIME = MINUTE * 5
16
16
 
17
17
  def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
18
- sections: Checkoff::Sections.new(config: config),
19
- clients: Checkoff::Clients.new(config: config),
20
- client: clients.client,
18
+ client: Checkoff::Clients.new(config: config).client,
19
+ sections: Checkoff::Sections.new(config: config,
20
+ client: client),
21
21
  time_class: Time,
22
22
  asana_task: Asana::Resources::Task)
23
23
  @config = config
@@ -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.3'
6
+ VERSION = '0.30.0'
7
7
  end
@@ -18,8 +18,7 @@ module Checkoff
18
18
  SHORT_CACHE_TIME = MINUTE
19
19
 
20
20
  def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
21
- clients: Checkoff::Clients.new(config: config),
22
- client: clients.client)
21
+ client: Checkoff::Clients.new(config: config).client)
23
22
  @config = config
24
23
  @client = client
25
24
  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.3
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