checkoff 0.21.0 → 0.22.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: '084d67648e9668ace7b8d103e4e1f9ec1d8d66bb0048cc1f8c7d652dd115397c'
4
+ data.tar.gz: e1cf9b3f5639841462290ac1a5228fa5ca3dba3d4e70c62d84644184e63e6b89
5
5
  SHA512:
6
- metadata.gz: '078c32912450408243aea106d973047fabfb4db52c6267f2dd0030894a7f1b898a89acce8115da066e2b1fa2e45560286148a7aa6ccc0632d869797cf4b008aa'
7
- data.tar.gz: 388f84ed37bc63dc68182e4b484e18fc5ab591625840c9f6a4f60fa385340cf6e7c4386cd56ee146100d3d5e99952f8d7c77e9c12c3ae9e47fbabc6b7e9e773e
6
+ metadata.gz: f49cd3bded68cdcc502b26ac03fe6b7e073aaa93294c4104b36c7bfb014fbbc9e3a792fb85d712e39251ec13ce1e7430e067c06a3075120bb37bcf23de457672
7
+ data.tar.gz: a4886b2dabc6332688434e0bce0009c1bf1db10b97588f857dc729320b5f840e4f8368afaf03ea78bdbf2e1025c1f4fa9d23839d19d0df8fa2650839226915f0
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.22.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -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.22.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.22.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-09 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