checkoff 0.23.0 → 0.24.1

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: 53900365a6e35f146515f3a6043bb12907a67cefa1d0fd86f92b90e700946946
4
- data.tar.gz: 57ccc5292ae4f07fe278697c7377d6187859c5a0b1b0be6b301ca945a18579eb
3
+ metadata.gz: 14b36fb42ff1797a222323d199980f2bb5975c7c08f363d14c4a60a4bac2ebad
4
+ data.tar.gz: 1e8864d3ecae5f6ef28bb8b3466c2dd6024bc7411e00822fdc451551cf458759
5
5
  SHA512:
6
- metadata.gz: f08fb1c0242675a728cf58151c4e9a990cd8bf961fd75ce7e01b154c39e759b557289651ff16033599809f1df251d4bbed45f02c07cb37aa70e7abfb8e714169
7
- data.tar.gz: 248aa5d50f3245dc1af18f4afcef40194d32a57deeb12bec0444965bacbdef523a4a60dda7f473a09deaa8ef1b8a1d499c2d434a02ac83bad41d9c6cd39ebc4b
6
+ metadata.gz: 73409fb7dc9ae6407bc57ca07599da338faf97449a2bec69df98b333310cffde433f2e006fa2186233ccdc31867a0bcdd13948816babb087a904599c30e816aa
7
+ data.tar.gz: f52814a389c1e25bb7d3e050d1eadbbe97613775a0de02a4aaf1e6e74e56d05a23102804a34d12d05a1b0e7f02c88570ad008bc27777aec694cad34cf9081fd3
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.23.0)
15
+ checkoff (0.24.1)
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)
25
+ activesupport (7.0.4.1)
26
26
  concurrent-ruby (~> 1.0, >= 1.0.2)
27
27
  i18n (>= 1.6, < 2)
28
28
  minitest (>= 5.1)
@@ -89,7 +89,7 @@ GEM
89
89
  mixlib-config (>= 2.2.1, < 4)
90
90
  mixlib-shellout
91
91
  method_source (1.0.0)
92
- minitest (5.16.2)
92
+ minitest (5.17.0)
93
93
  minitest-profile (0.0.2)
94
94
  minitest-reporters (1.5.0)
95
95
  ansi
@@ -105,12 +105,12 @@ GEM
105
105
  multi_json (1.15.0)
106
106
  multi_xml (0.6.0)
107
107
  multipart-post (2.1.1)
108
- oauth2 (1.4.7)
109
- faraday (>= 0.8, < 2.0)
108
+ oauth2 (1.4.11)
109
+ faraday (>= 0.17.3, < 3.0)
110
110
  jwt (>= 1.0, < 3.0)
111
111
  multi_json (~> 1.3)
112
112
  multi_xml (~> 0.5)
113
- rack (>= 1.2, < 3)
113
+ rack (>= 1.2, < 4)
114
114
  overcommit (0.58.0)
115
115
  childprocess (>= 0.6.3, < 5)
116
116
  iniparse (~> 1.4)
@@ -122,7 +122,7 @@ GEM
122
122
  coderay (~> 1.1)
123
123
  method_source (~> 1.0)
124
124
  public_suffix (5.0.0)
125
- rack (2.2.4)
125
+ rack (3.0.4.1)
126
126
  rainbow (3.1.1)
127
127
  rake (13.0.3)
128
128
  regexp_parser (2.6.0)
@@ -49,6 +49,7 @@ module Checkoff
49
49
  'is_not' => CustomFieldVariant::IsNot,
50
50
  'less_than' => CustomFieldVariant::LessThan,
51
51
  'greater_than' => CustomFieldVariant::GreaterThan,
52
+ 'doesnt_contain_any' => CustomFieldVariant::DoesntContainAny,
52
53
  }.freeze
53
54
 
54
55
  def convert_single_custom_field_params(gid, single_custom_field_params)
@@ -3,6 +3,7 @@
3
3
  module Checkoff
4
4
  module Internal
5
5
  module SearchUrl
6
+ # https://developers.asana.com/docs/search-tasks-in-a-workspace
6
7
  module CustomFieldVariant
7
8
  # base class for handling different custom_field_#{gid}.variant params
8
9
  class CustomFieldVariant
@@ -48,28 +49,33 @@ module Checkoff
48
49
  end
49
50
  end
50
51
 
52
+ # This is used in the UI for select fields
53
+ #
51
54
  # custom_field_#{gid}.variant = 'is_not'
52
55
  class IsNot < CustomFieldVariant
53
56
  def convert
54
- case remaining_params.keys
55
- when ["custom_field_#{gid}.selected_options"]
56
- convert_single_custom_field_is_not_params_selected_options
57
- else
58
- raise "Teach me how to handle #{remaining_params}"
59
- end
60
- end
57
+ selected_options = fetch_solo_param("custom_field_#{gid}.selected_options").split('~')
61
58
 
62
- private
59
+ [{ "custom_fields.#{gid}.is_set" => 'true' },
60
+ ['not',
61
+ ['custom_field_gid_value_contains_any_gid',
62
+ gid,
63
+ selected_options]]]
64
+ end
65
+ end
63
66
 
64
- def convert_single_custom_field_is_not_params_selected_options
65
- selected_options = remaining_params.fetch("custom_field_#{gid}.selected_options")
66
- raise "Teach me how to handle #{remaining_params}" unless selected_options.length == 1
67
+ # This is used in the UI for multi-select fields
68
+ #
69
+ # custom_field_#{gid}.variant = 'doesnt_contain_any'
70
+ class DoesntContainAny < CustomFieldVariant
71
+ def convert
72
+ selected_options = fetch_solo_param("custom_field_#{gid}.selected_options").split('~')
67
73
 
68
74
  [{ "custom_fields.#{gid}.is_set" => 'true' },
69
75
  ['not',
70
76
  ['custom_field_gid_value_contains_any_gid',
71
77
  gid,
72
- selected_options.fetch(0).split('~')]]]
78
+ selected_options]]]
73
79
  end
74
80
  end
75
81
 
@@ -105,24 +105,40 @@ module Checkoff
105
105
  end
106
106
 
107
107
  matched_custom_field = custom_fields.find { |data| data.fetch('gid') == custom_field_gid }
108
- raise "Could not find custom field with gid #{custom_field_gid}" if matched_custom_field.nil?
108
+ if matched_custom_field.nil?
109
+ raise "Could not find custom field with gid #{custom_field_gid} in #{task.gid} with #{custom_fields}"
110
+ end
109
111
 
110
112
  matched_custom_field
111
113
  end
112
114
 
113
- def pull_custom_field_values_gids(task, custom_field_gid)
114
- matched_custom_field = pull_custom_field_or_raise(task, custom_field_gid)
115
+ def pull_enum_values(custom_field)
116
+ resource_subtype = custom_field.fetch('resource_subtype')
117
+ case resource_subtype
118
+ when 'enum'
119
+ [custom_field.fetch('enum_value')]
120
+ when 'multi_enum'
121
+ custom_field.fetch('multi_enum_values')
122
+ else
123
+ raise "Teach me how to handle resource_subtype #{resource_subtype}"
124
+ end
125
+ end
115
126
 
116
- enum_value = matched_custom_field.fetch('enum_value')
117
- actual_custom_field_values_gids = []
118
- unless enum_value.nil?
119
- if enum_value.fetch('enabled') == false
120
- raise "Unexpected enabled value on custom field: #{matched_custom_field}"
121
- end
127
+ def find_gids(custom_field, enum_value)
128
+ if enum_value.nil?
129
+ []
130
+ else
131
+ raise "Unexpected enabled value on custom field: #{custom_field}" if enum_value.fetch('enabled') == false
122
132
 
123
- actual_custom_field_values_gids = [enum_value.fetch('gid')]
133
+ [enum_value.fetch('gid')]
134
+ end
135
+ end
136
+
137
+ def pull_custom_field_values_gids(task, custom_field_gid)
138
+ custom_field = pull_custom_field_or_raise(task, custom_field_gid)
139
+ pull_enum_values(custom_field).flat_map do |enum_value|
140
+ find_gids(custom_field, enum_value)
124
141
  end
125
- actual_custom_field_values_gids
126
142
  end
127
143
  end
128
144
 
@@ -21,7 +21,7 @@ module Checkoff
21
21
  DAY = 24 * HOUR
22
22
  REALLY_LONG_CACHE_TIME = HOUR * 1
23
23
  LONG_CACHE_TIME = MINUTE * 15
24
- SHORT_CACHE_TIME = MINUTE * 5
24
+ SHORT_CACHE_TIME = MINUTE
25
25
 
26
26
  def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
27
27
  workspaces: Checkoff::Workspaces.new(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.23.0'
6
+ VERSION = '0.24.1'
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.23.0
4
+ version: 0.24.1
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-16 00:00:00.000000000 Z
11
+ date: 2023-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport