checkoff 0.23.0 → 0.24.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: 53900365a6e35f146515f3a6043bb12907a67cefa1d0fd86f92b90e700946946
4
- data.tar.gz: 57ccc5292ae4f07fe278697c7377d6187859c5a0b1b0be6b301ca945a18579eb
3
+ metadata.gz: 26474f8f2f94c75d46d16eadd8c773a22d139d56e0d4bcaaae4c698519e8fa89
4
+ data.tar.gz: fc1b3a92a5736360fec289c1f2c156bc6570ad465fe8ecfdaa63a1b5a10cef5f
5
5
  SHA512:
6
- metadata.gz: f08fb1c0242675a728cf58151c4e9a990cd8bf961fd75ce7e01b154c39e759b557289651ff16033599809f1df251d4bbed45f02c07cb37aa70e7abfb8e714169
7
- data.tar.gz: 248aa5d50f3245dc1af18f4afcef40194d32a57deeb12bec0444965bacbdef523a4a60dda7f473a09deaa8ef1b8a1d499c2d434a02ac83bad41d9c6cd39ebc4b
6
+ metadata.gz: 80a903a43039264b205cb4ae61f4637360d8a9b4db4cf47062fd4d8e0ed127f420e6da5baebb30c2cbde792261c2265133157f45a19f7cfea8f0577b862327ac
7
+ data.tar.gz: f6a30feeda861f28f96bb8a7a6b38d68bd3a4042bf21b7521c4382c1b2107aeee8a04c405d5f79fe7fec0acfe27bce778f48ff93c00d27bc552b3f0e531a0359
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.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -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
 
@@ -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.0'
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz