checkoff 0.24.1 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14b36fb42ff1797a222323d199980f2bb5975c7c08f363d14c4a60a4bac2ebad
4
- data.tar.gz: 1e8864d3ecae5f6ef28bb8b3466c2dd6024bc7411e00822fdc451551cf458759
3
+ metadata.gz: 1adcf7ca7bea1514f07f234a4952e550afeb47be68882a631d26b88231839ec4
4
+ data.tar.gz: e2d86531a6e256cbfb9315199b529d6e587263dc6a750c6ab3a28faa8e1f0b12
5
5
  SHA512:
6
- metadata.gz: 73409fb7dc9ae6407bc57ca07599da338faf97449a2bec69df98b333310cffde433f2e006fa2186233ccdc31867a0bcdd13948816babb087a904599c30e816aa
7
- data.tar.gz: f52814a389c1e25bb7d3e050d1eadbbe97613775a0de02a4aaf1e6e74e56d05a23102804a34d12d05a1b0e7f02c88570ad008bc27777aec694cad34cf9081fd3
6
+ metadata.gz: 636615e7e3b49a763e71c867718b6441bde385eb30533263c67030cb9b6febd7a3c233087daec5c30e2ec1e2bf24d0fe97c7480faf6feb18baf121c140e14642
7
+ data.tar.gz: ab00d105d5f79e402c2030a4a982fe3b863270c9477ffa4c4fccf686d79a1280ab3a20561be72311711ee481544a206f2af9785eaaab5db3d3646a466f6f888d
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.24.1)
15
+ checkoff (0.26.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -22,7 +22,7 @@ PATH
22
22
  GEM
23
23
  remote: https://rubygems.org/
24
24
  specs:
25
- activesupport (7.0.4.1)
25
+ activesupport (7.0.4.2)
26
26
  concurrent-ruby (~> 1.0, >= 1.0.2)
27
27
  i18n (>= 1.6, < 2)
28
28
  minitest (>= 5.1)
@@ -167,7 +167,7 @@ GEM
167
167
  simplecov-lcov (0.8.0)
168
168
  simplecov_json_formatter (0.1.3)
169
169
  tomlrb (2.0.3)
170
- tzinfo (2.0.5)
170
+ tzinfo (2.0.6)
171
171
  concurrent-ruby (~> 1.0)
172
172
  undercover (0.4.5)
173
173
  imagen (>= 0.1.8)
@@ -33,14 +33,17 @@ module Checkoff
33
33
  end
34
34
 
35
35
  def merge_args_and_task_selectors(args, new_args, task_selector, new_task_selector)
36
- args = args.merge(new_args)
37
- return [args, task_selector] if new_task_selector == []
36
+ final_args = args.merge(new_args)
38
37
 
39
- raise 'Teach me how to merge task selectors' unless task_selector == []
38
+ final_task_selector = if new_task_selector == []
39
+ task_selector
40
+ elsif task_selector == []
41
+ new_task_selector
42
+ else
43
+ [:and, task_selector, new_task_selector]
44
+ end
40
45
 
41
- task_selector = new_task_selector
42
-
43
- [args, task_selector]
46
+ [final_args, final_task_selector]
44
47
  end
45
48
 
46
49
  VARIANTS = {
@@ -50,6 +53,7 @@ module Checkoff
50
53
  'less_than' => CustomFieldVariant::LessThan,
51
54
  'greater_than' => CustomFieldVariant::GreaterThan,
52
55
  'doesnt_contain_any' => CustomFieldVariant::DoesntContainAny,
56
+ 'contains_any' => CustomFieldVariant::ContainsAny,
53
57
  }.freeze
54
58
 
55
59
  def convert_single_custom_field_params(gid, single_custom_field_params)
@@ -79,6 +79,20 @@ module Checkoff
79
79
  end
80
80
  end
81
81
 
82
+ # This is used in the UI for multi-select fields
83
+ #
84
+ # custom_field_#{gid}.variant = 'contains_any'
85
+ class ContainsAny < CustomFieldVariant
86
+ def convert
87
+ selected_options = fetch_solo_param("custom_field_#{gid}.selected_options").split('~')
88
+
89
+ [{ "custom_fields.#{gid}.is_set" => 'true' },
90
+ ['custom_field_gid_value_contains_any_gid',
91
+ gid,
92
+ selected_options]]
93
+ end
94
+ end
95
+
82
96
  # custom_field_#{gid}.variant = 'no_value'
83
97
  class NoValue < CustomFieldVariant
84
98
  def convert
@@ -27,25 +27,13 @@ module Checkoff
27
27
  end
28
28
 
29
29
  attr_reader :key, :values
30
- end
31
-
32
- # Handle 'any_projects.ids' search url param
33
- class AnyProjectsIds < SimpleParam
34
- def projects
35
- @projects ||= []
36
- end
37
30
 
38
- def sections
39
- @sections ||= []
40
- end
41
-
42
- def parse!
43
- # Inputs:
44
- # 123_column_456 means "abc" project, "def" section
45
- # 123 means "abc" project
46
- # 123~456 means "abc" and "def" projects
47
- project_section_pairs = single_value.split('~')
48
- project_section_pairs.each do |project_section_pair|
31
+ # Inputs:
32
+ # 123_column_456 means "abc" project, "def" section
33
+ # 123 means "abc" project
34
+ # 123~456 means "abc" and "def" projects
35
+ def parse_projects_and_sections(projects, sections)
36
+ single_value.split('~').each do |project_section_pair|
49
37
  project, section = project_section_pair.split('_column_')
50
38
  if section.nil?
51
39
  projects << project
@@ -55,15 +43,31 @@ module Checkoff
55
43
  end
56
44
  end
57
45
 
58
- def convert
59
- parse!
46
+ def convert_from_projects_and_sections(verb)
47
+ projects = []
48
+ sections = []
49
+ parse_projects_and_sections(projects, sections)
60
50
  out = {}
61
- out['projects.any'] = projects.join(',') unless projects.empty?
62
- out['sections.any'] = sections.join(',') unless sections.empty?
51
+ out["projects.#{verb}"] = projects.join(',') unless projects.empty?
52
+ out["sections.#{verb}"] = sections.join(',') unless sections.empty?
63
53
  out.to_a.flatten
64
54
  end
65
55
  end
66
56
 
57
+ # Handle 'any_projects.ids' search url param
58
+ class AnyProjectsIds < SimpleParam
59
+ def convert
60
+ convert_from_projects_and_sections('any')
61
+ end
62
+ end
63
+
64
+ # Handle 'not_projects.ids' search url param
65
+ class NotProjectsIds < SimpleParam
66
+ def convert
67
+ convert_from_projects_and_sections('not')
68
+ end
69
+ end
70
+
67
71
  # Handle 'completion' search url param
68
72
  class Completion < SimpleParam
69
73
  def convert
@@ -116,6 +120,7 @@ module Checkoff
116
120
 
117
121
  ARGS = {
118
122
  'any_projects.ids' => SimpleParam::AnyProjectsIds,
123
+ 'not_projects.ids' => SimpleParam::NotProjectsIds,
119
124
  'completion' => SimpleParam::Completion,
120
125
  'not_tags.ids' => SimpleParam::NotTagsIds,
121
126
  'any_tags.ids' => SimpleParam::AnyTagsIds,
@@ -20,6 +20,17 @@ module Checkoff
20
20
  attr_reader :task_selector
21
21
  end
22
22
 
23
+ # :and function
24
+ class AndFunctionEvaluator < FunctionEvaluator
25
+ def matches?
26
+ fn?(task_selector, :and)
27
+ end
28
+
29
+ def evaluate(_task, lhs, rhs)
30
+ lhs && rhs
31
+ end
32
+ end
33
+
23
34
  # :not function
24
35
  class NotFunctionEvaluator < FunctionEvaluator
25
36
  def matches?
@@ -154,6 +165,7 @@ module Checkoff
154
165
  TagPFunctionEvaluator,
155
166
  CustomFieldValueFunctionEvaluator,
156
167
  CustomFieldGidValueContainsAnyGidFunctionEvaluator,
168
+ AndFunctionEvaluator,
157
169
  ].freeze
158
170
 
159
171
  def evaluate(task_selector)
@@ -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.24.1'
6
+ VERSION = '0.26.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.24.1
4
+ version: 0.26.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-01-22 00:00:00.000000000 Z
11
+ date: 2023-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport