checkoff 0.21.0 → 0.23.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: d7c237ce35c02738d3170942d13d3d47d02d0fc0ed65eb78b836b7c444aed241
4
- data.tar.gz: 8ab5d779ab9feadeeb66d12294e25f8b2baf0de32d8a917618f3adc26c77a4ea
3
+ metadata.gz: 53900365a6e35f146515f3a6043bb12907a67cefa1d0fd86f92b90e700946946
4
+ data.tar.gz: 57ccc5292ae4f07fe278697c7377d6187859c5a0b1b0be6b301ca945a18579eb
5
5
  SHA512:
6
- metadata.gz: '078c32912450408243aea106d973047fabfb4db52c6267f2dd0030894a7f1b898a89acce8115da066e2b1fa2e45560286148a7aa6ccc0632d869797cf4b008aa'
7
- data.tar.gz: 388f84ed37bc63dc68182e4b484e18fc5ab591625840c9f6a4f60fa385340cf6e7c4386cd56ee146100d3d5e99952f8d7c77e9c12c3ae9e47fbabc6b7e9e773e
6
+ metadata.gz: f08fb1c0242675a728cf58151c4e9a990cd8bf961fd75ce7e01b154c39e759b557289651ff16033599809f1df251d4bbed45f02c07cb37aa70e7abfb8e714169
7
+ data.tar.gz: 248aa5d50f3245dc1af18f4afcef40194d32a57deeb12bec0444965bacbdef523a4a60dda7f473a09deaa8ef1b8a1d499c2d434a02ac83bad41d9c6cd39ebc4b
data/.gitignore CHANGED
@@ -58,3 +58,6 @@ requirements_dev.txt.installed
58
58
  /spec/reports/
59
59
  /tmp/
60
60
  /coverage/
61
+
62
+ # direnv
63
+ /.envrc
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.21.0)
15
+ checkoff (0.23.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -48,6 +48,7 @@ module Checkoff
48
48
  'no_value' => CustomFieldVariant::NoValue,
49
49
  'is_not' => CustomFieldVariant::IsNot,
50
50
  'less_than' => CustomFieldVariant::LessThan,
51
+ 'greater_than' => CustomFieldVariant::GreaterThan,
51
52
  }.freeze
52
53
 
53
54
  def convert_single_custom_field_params(gid, single_custom_field_params)
@@ -14,34 +14,40 @@ module Checkoff
14
14
  private
15
15
 
16
16
  attr_reader :gid, :remaining_params
17
- end
18
17
 
19
- # custom_field_#{gid}.variant = 'less_than'
20
- class LessThan < CustomFieldVariant
21
- def convert
22
- max_param = "custom_field_#{gid}.max"
18
+ def fetch_solo_param(param_name)
23
19
  case remaining_params.keys
24
- when [max_param]
25
- convert_single_custom_field_less_than_params_max_param(max_param)
20
+ when [param_name]
21
+ param_values = remaining_params.fetch(param_name)
22
+ unless param_values.length == 1
23
+ raise "Teach me how to handle these remaining keys for #{param_name}: #{remaining_params}"
24
+ end
25
+
26
+ param_values[0]
26
27
  else
27
28
  raise "Teach me how to handle #{remaining_params}"
28
29
  end
29
30
  end
31
+ end
30
32
 
31
- private
32
-
33
- def convert_single_custom_field_less_than_params_max_param(max_param)
34
- max_values = remaining_params.fetch(max_param)
35
- unless max_values.length == 1
36
- raise "Teach me how to handle these remaining keys for #{max_param}: #{remaining_params}"
37
- end
38
-
39
- max_value = max_values[0]
33
+ # custom_field_#{gid}.variant = 'less_than'
34
+ class LessThan < CustomFieldVariant
35
+ def convert
36
+ max_value = fetch_solo_param("custom_field_#{gid}.max")
40
37
  empty_task_selector = []
41
38
  [{ "custom_fields.#{gid}.less_than" => max_value }, empty_task_selector]
42
39
  end
43
40
  end
44
41
 
42
+ # custom_field_#{gid}.variant = 'greater_than'
43
+ class GreaterThan < CustomFieldVariant
44
+ def convert
45
+ max_value = fetch_solo_param("custom_field_#{gid}.min")
46
+ empty_task_selector = []
47
+ [{ "custom_fields.#{gid}.greater_than" => max_value }, empty_task_selector]
48
+ end
49
+ end
50
+
45
51
  # custom_field_#{gid}.variant = 'is_not'
46
52
  class IsNot < CustomFieldVariant
47
53
  def convert
@@ -5,32 +5,69 @@ require_relative 'custom_field_param_converter'
5
5
  module Checkoff
6
6
  module Internal
7
7
  module SearchUrl
8
+ # See
9
+ # https://developers.asana.com/docs/search-tasks-in-a-workspace
10
+ # for the return value of 'convert' here:
8
11
  module SimpleParam
9
12
  # base class for handling different types of search url params
10
13
  class SimpleParam
11
- def initialize(values:)
14
+ def initialize(key:, values:)
15
+ @key = key
12
16
  @values = values
13
17
  end
14
18
 
15
19
  private
16
20
 
17
- attr_reader :values
21
+ def single_value
22
+ @single_value ||= begin
23
+ raise "Teach me how to handle #{key} = #{values}" if values.length != 1
24
+
25
+ values.fetch(0)
26
+ end
27
+ end
28
+
29
+ attr_reader :key, :values
18
30
  end
19
31
 
20
32
  # Handle 'any_projects.ids' search url param
21
33
  class AnyProjectsIds < SimpleParam
34
+ def projects
35
+ @projects ||= []
36
+ end
37
+
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|
49
+ project, section = project_section_pair.split('_column_')
50
+ if section.nil?
51
+ projects << project
52
+ else
53
+ sections << section
54
+ end
55
+ end
56
+ end
57
+
22
58
  def convert
23
- ['projects.any', values.join(',')]
59
+ parse!
60
+ out = {}
61
+ out['projects.any'] = projects.join(',') unless projects.empty?
62
+ out['sections.any'] = sections.join(',') unless sections.empty?
63
+ out.to_a.flatten
24
64
  end
25
65
  end
26
66
 
27
67
  # Handle 'completion' search url param
28
68
  class Completion < SimpleParam
29
69
  def convert
30
- raise "Teach me how to handle #{key} = #{values}" if values.length != 1
31
-
32
- value = values.fetch(0)
33
- raise "Teach me how to handle #{key} = #{values}" if value != 'incomplete'
70
+ raise "Teach me how to handle #{key} = #{values}" if single_value != 'incomplete'
34
71
 
35
72
  ['completed', false]
36
73
  end
@@ -39,13 +76,27 @@ module Checkoff
39
76
  # Handle 'not_tags.ids' search url param
40
77
  class NotTagsIds < SimpleParam
41
78
  def convert
42
- raise "Teach me how to handle #{key} = #{values}" if values.length != 1
43
-
44
- value = values.fetch(0)
45
- tag_ids = value.split('~')
79
+ tag_ids = single_value.split('~')
46
80
  ['tags.not', tag_ids.join(',')]
47
81
  end
48
82
  end
83
+
84
+ # handle 'subtask' search url param
85
+ class Subtask < SimpleParam
86
+ def convert
87
+ return ['is_subtask', false] if single_value == 'is_not_subtask'
88
+
89
+ raise "Teach me how to handle #{key} = #{values}"
90
+ end
91
+ end
92
+
93
+ # Handle 'any_tags.ids' search url param
94
+ class AnyTagsIds < SimpleParam
95
+ def convert
96
+ tag_ids = single_value.split('~')
97
+ ['tags.any', tag_ids.join(',')]
98
+ end
99
+ end
49
100
  end
50
101
 
51
102
  # Convert simple parameters - ones where the param name itself
@@ -56,9 +107,9 @@ module Checkoff
56
107
  end
57
108
 
58
109
  def convert
59
- simple_url_params.to_a.to_h do |key, values|
60
- convert_arg(key, values)
61
- end
110
+ simple_url_params.to_a.flat_map do |key, values|
111
+ convert_arg(key, values).each_slice(2).to_a
112
+ end.to_h
62
113
  end
63
114
 
64
115
  private
@@ -67,12 +118,14 @@ module Checkoff
67
118
  'any_projects.ids' => SimpleParam::AnyProjectsIds,
68
119
  'completion' => SimpleParam::Completion,
69
120
  'not_tags.ids' => SimpleParam::NotTagsIds,
121
+ 'any_tags.ids' => SimpleParam::AnyTagsIds,
122
+ 'subtask' => SimpleParam::Subtask,
70
123
  }.freeze
71
124
 
72
125
  # https://developers.asana.com/docs/search-tasks-in-a-workspace
73
126
  def convert_arg(key, values)
74
127
  clazz = ARGS.fetch(key)
75
- clazz.new(values: values).convert
128
+ clazz.new(key: key, values: values).convert
76
129
  end
77
130
 
78
131
  attr_reader :simple_url_params
@@ -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.21.0'
6
+ VERSION = '0.23.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.21.0
4
+ version: 0.23.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: 2022-12-02 00:00:00.000000000 Z
11
+ date: 2023-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -341,7 +341,6 @@ extensions: []
341
341
  extra_rdoc_files: []
342
342
  files:
343
343
  - ".circleci/config.yml"
344
- - ".envrc"
345
344
  - ".git-hooks/pre_commit/circle_ci.rb"
346
345
  - ".gitattributes"
347
346
  - ".gitignore"
data/.envrc DELETED
@@ -1,4 +0,0 @@
1
- # shellcheck shell=bash
2
- PATH_add bin
3
- export ASANA__PERSONAL_ACCESS_TOKEN="op://Private/Asana access token - VLD read-write/token" ASANA__DEFAULT_ASSIGNEE_GID="op://Private/Asana access token - VLD read-write/default_workspace_gid" ASANA__DEFAULT_WORKSPACE_GID="op://Private/Asana access token - VLD read-write/default_workspace_gid"
4
- direnv_load with-op op run --cache -- direnv dump