checkoff 0.227.0 → 0.229.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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/checkoff.gemspec +7 -7
  3. data/lib/checkoff/cli.rb +71 -1
  4. data/lib/checkoff/clients.rb +1 -1
  5. data/lib/checkoff/custom_fields.rb +3 -3
  6. data/lib/checkoff/events.rb +3 -3
  7. data/lib/checkoff/internal/asana_event_enrichment.rb +13 -14
  8. data/lib/checkoff/internal/config_loader.rb +4 -2
  9. data/lib/checkoff/internal/logging.rb +3 -0
  10. data/lib/checkoff/internal/project_selector_evaluator.rb +5 -2
  11. data/lib/checkoff/internal/project_timing.rb +0 -2
  12. data/lib/checkoff/internal/search_url/custom_field_param_converter.rb +12 -12
  13. data/lib/checkoff/internal/search_url/custom_field_variant.rb +19 -18
  14. data/lib/checkoff/internal/search_url/date_param_converter.rb +9 -9
  15. data/lib/checkoff/internal/search_url/parser.rb +20 -30
  16. data/lib/checkoff/internal/search_url/results_merger.rb +4 -6
  17. data/lib/checkoff/internal/search_url/simple_param_converter.rb +19 -11
  18. data/lib/checkoff/internal/section_selector_evaluator.rb +7 -3
  19. data/lib/checkoff/internal/selector_classes/common/function_evaluator.rb +3 -2
  20. data/lib/checkoff/internal/selector_classes/common.rb +5 -6
  21. data/lib/checkoff/internal/selector_classes/function_evaluator.rb +2 -3
  22. data/lib/checkoff/internal/selector_classes/project/function_evaluator.rb +3 -2
  23. data/lib/checkoff/internal/selector_classes/section/function_evaluator.rb +2 -2
  24. data/lib/checkoff/internal/selector_classes/section.rb +2 -2
  25. data/lib/checkoff/internal/selector_classes/task/function_evaluator.rb +3 -2
  26. data/lib/checkoff/internal/selector_classes/task.rb +1 -2
  27. data/lib/checkoff/internal/selector_evaluator.rb +2 -2
  28. data/lib/checkoff/internal/task_hashes.rb +3 -3
  29. data/lib/checkoff/internal/task_selector_evaluator.rb +3 -0
  30. data/lib/checkoff/internal/task_timing.rb +0 -2
  31. data/lib/checkoff/internal/thread_local.rb +5 -4
  32. data/lib/checkoff/my_tasks.rb +4 -4
  33. data/lib/checkoff/portfolios.rb +1 -1
  34. data/lib/checkoff/project_selectors.rb +4 -4
  35. data/lib/checkoff/projects.rb +6 -6
  36. data/lib/checkoff/resources.rb +5 -3
  37. data/lib/checkoff/section_selectors.rb +4 -4
  38. data/lib/checkoff/sections.rb +18 -15
  39. data/lib/checkoff/subtasks.rb +2 -2
  40. data/lib/checkoff/tags.rb +7 -3
  41. data/lib/checkoff/task_searches.rb +9 -9
  42. data/lib/checkoff/task_selectors.rb +10 -6
  43. data/lib/checkoff/tasks.rb +5 -5
  44. data/lib/checkoff/timelines.rb +0 -1
  45. data/lib/checkoff/timing.rb +5 -4
  46. data/lib/checkoff/version.rb +1 -1
  47. data/lib/checkoff/workspaces.rb +1 -1
  48. data/rbi/checkoff.rbi +342 -305
  49. data/sig/checkoff.rbs +327 -279
  50. metadata +7 -7
@@ -28,12 +28,15 @@ module Checkoff
28
28
  COMMON_FUNCTION_EVALUATORS = (Checkoff::SelectorClasses::Common.constants.map do |const|
29
29
  Checkoff::SelectorClasses::Common.const_get(const)
30
30
  end - [Checkoff::SelectorClasses::Common::FunctionEvaluator]).freeze
31
+ private_constant :COMMON_FUNCTION_EVALUATORS
31
32
 
32
33
  TASK_FUNCTION_EVALUATORS = (Checkoff::SelectorClasses::Task.constants.map do |const|
33
34
  Checkoff::SelectorClasses::Task.const_get(const)
34
35
  end - [Checkoff::SelectorClasses::Task::FunctionEvaluator]).freeze
36
+ private_constant :TASK_FUNCTION_EVALUATORS
35
37
 
36
38
  FUNCTION_EVALUTORS = (COMMON_FUNCTION_EVALUATORS + TASK_FUNCTION_EVALUATORS).freeze
39
+ private_constant :FUNCTION_EVALUTORS
37
40
 
38
41
  # @return [Array<Class<Checkoff::SelectorClasses::Task::FunctionEvaluator>>]
39
42
  def function_evaluators
@@ -30,7 +30,6 @@ module Checkoff
30
30
  end
31
31
 
32
32
  # @param task [Asana::Resources::Task]
33
- # @param field_name [Symbol]
34
33
  #
35
34
  # @sg-ignore
36
35
  # @return [Date, Time, nil]
@@ -43,7 +42,6 @@ module Checkoff
43
42
  end
44
43
 
45
44
  # @param task [Asana::Resources::Task]
46
- # @param field_name [Symbol]
47
45
  #
48
46
  # @sg-ignore
49
47
  # @return [Date, Time, nil]
@@ -1,15 +1,16 @@
1
- # typed: strict
1
+ # typed: true
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Checkoff
5
5
  module Internal
6
6
  # Manage thread lock variables in a block
7
7
  class ThreadLocal
8
- # @sg-ignore
8
+ # @generic T
9
9
  # @param name [Symbol]
10
10
  # @param value [Object,Boolean]
11
- #
12
- # @return [Object,Boolean]
11
+ # @yieldreturn [generic<T>]
12
+ # @sg-ignore
13
+ # @return [generic<T>]
13
14
  def with_thread_local_variable(name, value, &block)
14
15
  old_value = Thread.current[name]
15
16
  Thread.current[name] = value
@@ -1,4 +1,4 @@
1
- # typed: false
1
+ # typed: true
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'forwardable'
@@ -16,7 +16,7 @@ module Checkoff
16
16
  # @return [Checkoff::Projects]
17
17
  attr_reader :projects
18
18
 
19
- # @param config [Checkoff::Internal::EnvFallbackConfigLoader]
19
+ # @param config [Checkoff::Internal::EnvFallbackConfigLoader,Hash]
20
20
  # @param client [Asana::Client]
21
21
  # @param projects [Checkoff::Projects]
22
22
  def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
@@ -35,7 +35,7 @@ module Checkoff
35
35
  # @param project [Asana::Resources::Project]
36
36
  # @param only_uncompleted [Boolean]
37
37
  # @param extra_fields [Array<String>]
38
- # @return [Hash<String, Enumerable<Asana::Resources::Task>>]
38
+ # @return [Hash{String => Enumerable<Asana::Resources::Task>}]
39
39
  def tasks_by_section_for_my_tasks(project,
40
40
  only_uncompleted: true,
41
41
  extra_fields: [])
@@ -59,7 +59,7 @@ module Checkoff
59
59
  #
60
60
  # @param tasks [Enumerable<Asana::Resources::Task>]
61
61
  # @param project_gid [String]
62
- # @return [Hash<String, Enumerable<Asana::Resources::Task>>]
62
+ # @return [Hash{String => Enumerable<Asana::Resources::Task>}]
63
63
  def by_my_tasks_section(tasks, project_gid)
64
64
  by_section = {}
65
65
  sections = client.sections.get_sections_for_project(project_gid:,
@@ -27,7 +27,7 @@ module Checkoff
27
27
  LONG_CACHE_TIME = T.let(MINUTE * 15, Numeric)
28
28
  SHORT_CACHE_TIME = T.let(MINUTE, Numeric)
29
29
 
30
- # @param config [Checkoff::Internal::EnvFallbackConfigLoader]
30
+ # @param config [Checkoff::Internal::EnvFallbackConfigLoader,Hash]
31
31
  # @param workspaces [Checkoff::Workspaces]
32
32
  # @param clients [Checkoff::Clients]
33
33
  # @param client [Asana::Client]
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # typed: false
2
+ # typed: true
3
3
 
4
4
  # frozen_string_literal: true
5
5
 
@@ -20,7 +20,7 @@ module Checkoff
20
20
  LONG_CACHE_TIME = MINUTE * 15
21
21
  SHORT_CACHE_TIME = MINUTE
22
22
 
23
- # @param config [Hash<Symbol, Object>,Checkoff::Internal::EnvFallbackConfigLoader]
23
+ # @param config [Hash{Symbol => Object}, Checkoff::Internal::EnvFallbackConfigLoader]
24
24
  # @param workspaces [Checkoff::Workspaces]
25
25
  # @param projects [Checkoff::Projects]
26
26
  # @param custom_fields [Checkoff::CustomFields]
@@ -42,13 +42,13 @@ module Checkoff
42
42
  end
43
43
 
44
44
  # @param [Asana::Resources::Project] project
45
- # @param [Array<(Symbol, Array)>] project_selector Filter based on
45
+ # @param [Array(Symbol, Array)] project_selector Filter based on
46
46
  # project details. Examples: [:tag, 'foo'] [:not, [:tag, 'foo']] [:tag, 'foo']
47
47
  # @return [Boolean]
48
48
  def filter_via_project_selector(project, project_selector)
49
49
  evaluator = ProjectSelectorEvaluator.new(project:, projects:, custom_fields:,
50
50
  workspaces:, portfolios:)
51
- evaluator.evaluate(project_selector)
51
+ !!evaluator.evaluate(project_selector)
52
52
  end
53
53
 
54
54
  private
@@ -1,4 +1,4 @@
1
- # typed: false
1
+ # typed: true
2
2
 
3
3
  # frozen_string_literal: true
4
4
 
@@ -33,7 +33,7 @@ module Checkoff
33
33
  # @!parse
34
34
  # extend CacheMethod::ClassMethods
35
35
 
36
- # @param config [Checkoff::Internal::EnvFallbackConfigLoader]
36
+ # @param config [Checkoff::Internal::EnvFallbackConfigLoader,Hash]
37
37
  # @param client [Asana::Client]
38
38
  # @param workspaces [Checkoff::Workspaces]
39
39
  # @param project_hashes [Checkoff::Internal::ProjectHashes]
@@ -68,7 +68,7 @@ module Checkoff
68
68
  # @param extra_fields [Array<String>]
69
69
  # @param [Boolean] only_uncompleted
70
70
  #
71
- # @return [Hash{Symbol => Object}]
71
+ # @return [Hash{Symbol => undefined}]
72
72
  def task_options(extra_fields: [], only_uncompleted: false)
73
73
  options = {
74
74
  per_page: 100,
@@ -91,7 +91,7 @@ module Checkoff
91
91
  #
92
92
  # @param extra_project_fields [Array<String>]
93
93
  #
94
- # @return [Hash<Symbol, Object>]
94
+ # @return [Hash{Symbol => Object}]
95
95
  def project_options(extra_project_fields: [])
96
96
  { fields: project_fields(extra_project_fields:) }
97
97
  end
@@ -212,14 +212,14 @@ module Checkoff
212
212
  # date is today or in the past.
213
213
  #
214
214
  # @param project [Asana::Resources::Project]
215
- # @param period [Symbol,Array] See Checkoff::Timing#in_period? - :now_or_before,:this_week
215
+ # @param period [Symbol, Array(Symbol, Integer)] See Checkoff::Timing#in_period? - :now_or_before,:this_week
216
216
  def project_ready?(project, period: :now_or_before)
217
217
  in_period?(project, :ready, period)
218
218
  end
219
219
 
220
220
  # @param project [Asana::Resources::Project]
221
221
  # @param field_name [Symbol,Array]
222
- # @param period [Symbol,Array] See Checkoff::Timing#in_period? - :now_or_before,:this_week
222
+ # @param period [Symbol, Array(Symbol,Integer)] See Checkoff::Timing#in_period? - :now_or_before,:this_week
223
223
  def in_period?(project, field_name, period)
224
224
  # @type [Date,Time,nil]
225
225
  project_date = project_timing.date_or_time_field_by_name(project, field_name)
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # typed: false
2
+ # typed: true
3
3
 
4
4
  # frozen_string_literal: true
5
5
 
@@ -57,12 +57,14 @@ module Checkoff
57
57
  # @param gid [String]
58
58
  # @param resource_type [String,nil]
59
59
  #
60
- # @return [Array<([Asana::Resource, nil], [String,nil])>]
60
+ # @return [Array([Asana::Resource, nil], [String,nil])]
61
61
  def resource_by_gid(gid, resource_type: nil)
62
62
  %w[task section project].each do |resource_type_to_try|
63
63
  next unless [resource_type_to_try, nil].include?(resource_type)
64
64
 
65
- resource = method(:"fetch_#{resource_type_to_try}_gid").call(gid)
65
+ # @type [Asana::Resources::Resource, nil]
66
+ resource = T.cast(method(:"fetch_#{resource_type_to_try}_gid").call(gid),
67
+ T.nilable(Asana::Resources::Resource))
66
68
  return [resource, resource_type_to_try] if resource
67
69
  end
68
70
  [nil, nil]
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # typed: false
2
+ # typed: true
3
3
 
4
4
  # frozen_string_literal: true
5
5
 
@@ -20,7 +20,7 @@ module Checkoff
20
20
  LONG_CACHE_TIME = MINUTE * 15
21
21
  SHORT_CACHE_TIME = MINUTE
22
22
 
23
- # @param config [Hash<Symbol, Object>,Checkoff::Internal::EnvFallbackConfigLoader]
23
+ # @param config [Hash{Symbol => Object}, Checkoff::Internal::EnvFallbackConfigLoader]
24
24
  # @param workspaces [Checkoff::Workspaces]
25
25
  # @param sections [Checkoff::Sections]
26
26
  # @param custom_fields [Checkoff::CustomFields]
@@ -39,14 +39,14 @@ module Checkoff
39
39
  end
40
40
 
41
41
  # @param [Asana::Resources::Section] section
42
- # @param [Array<(Symbol, Array)>] section_selector Filter based on
42
+ # @param [Array(Symbol, Array)] section_selector Filter based on
43
43
  # section details. Examples: [:tag, 'foo'] [:not, [:tag, 'foo']] [:tag, 'foo']
44
44
  # @return [Boolean]
45
45
  def filter_via_section_selector(section, section_selector)
46
46
  # @sg-ignore
47
47
  evaluator = SectionSelectorEvaluator.new(section:, sections:, custom_fields:,
48
48
  client:)
49
- evaluator.evaluate(section_selector)
49
+ !!evaluator.evaluate(section_selector)
50
50
  end
51
51
 
52
52
  private
@@ -1,4 +1,4 @@
1
- # typed: false
1
+ # typed: true
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'forwardable'
@@ -34,7 +34,7 @@ module Checkoff
34
34
  # @return [Checkoff::MyTasks]
35
35
  attr_reader :my_tasks
36
36
 
37
- # @param config [Checkoff::Internal::EnvFallbackConfigLoader]
37
+ # @param config [Checkoff::Internal::EnvFallbackConfigLoader,Hash]
38
38
  # @param client [Asana::Client]
39
39
  # @param projects [Checkoff::Projects]
40
40
  # @param workspaces [Checkoff::Workspaces]
@@ -84,13 +84,13 @@ module Checkoff
84
84
  # @param project_name [String, Symbol]
85
85
  # @param only_uncompleted [Boolean]
86
86
  # @param extra_fields [Array<String>]
87
- # @return [Hash{[String, nil] => Enumerable<Asana::Resources::Task>}]
87
+ # @return [Hash{String, nil => Enumerable<Asana::Resources::Task>}]
88
88
  def tasks_by_section(workspace_name,
89
89
  project_name,
90
90
  only_uncompleted: true,
91
91
  extra_fields: [])
92
- raise ArgumentError, 'Provided nil workspace name' if workspace_name.nil?
93
- raise ArgumentError, 'Provided nil project name' if project_name.nil?
92
+ raise ArgumentError, 'Provided nil workspace name' if T.unsafe(workspace_name).nil?
93
+ raise ArgumentError, 'Provided nil project name' if T.unsafe(project_name).nil?
94
94
 
95
95
  project = project_or_raise(workspace_name, project_name)
96
96
  if project_name == :my_tasks
@@ -141,10 +141,12 @@ module Checkoff
141
141
  # @param project_name [String, Symbol]
142
142
  # @param section_name [String, nil]
143
143
  #
144
+ # @sg-ignore
144
145
  # @return [Array<String>]
145
146
  def section_task_names(workspace_name, project_name, section_name)
146
147
  task_array = tasks(workspace_name, project_name, section_name)
147
- task_array.map(&:name)
148
+ # @type [Array<String>]
149
+ T.cast(task_array.map(&:name), T::Array[String])
148
150
  end
149
151
  cache_method :section_task_names, SHORT_CACHE_TIME
150
152
 
@@ -222,7 +224,7 @@ module Checkoff
222
224
  def section(workspace_name, project_name, section_name, extra_section_fields: [])
223
225
  sections = sections_or_raise(workspace_name, project_name,
224
226
  extra_fields: extra_section_fields)
225
- sections.find { |section| section_key(section.name)&.chomp(':') == section_name&.chomp(':') }
227
+ sections.find { |section| section_key(T.cast(section.name, String))&.chomp(':') == section_name&.chomp(':') }
226
228
  end
227
229
 
228
230
  private
@@ -249,7 +251,7 @@ module Checkoff
249
251
  # @param project [Asana::Resources::Project]
250
252
  # @param only_uncompleted [Boolean]
251
253
  # @param extra_fields [Array<String>]
252
- # @return [Hash<[String,nil], Enumerable<Asana::Resources::Task>>]
254
+ # @return [Hash{String,nil => Enumerable<Asana::Resources::Task>}]
253
255
  def tasks_by_section_for_project(project,
254
256
  only_uncompleted: true,
255
257
  extra_fields: [])
@@ -263,7 +265,7 @@ module Checkoff
263
265
  # Given a list of tasks, pull a Hash of tasks with section name -> task list
264
266
  # @param tasks [Enumerable<Asana::Resources::Task>]
265
267
  # @param project_gid [String]
266
- # @return [Hash<[String,nil], Enumerable<Asana::Resources::Task>>]
268
+ # @return [Hash{String, nil => Enumerable<Asana::Resources::Task>}]
267
269
  def by_section(tasks, project_gid)
268
270
  by_section = {}
269
271
  # @sg-ignore
@@ -275,18 +277,19 @@ module Checkoff
275
277
  end
276
278
  cache_method :by_section, LONG_CACHE_TIME
277
279
 
278
- # @param by_section [Hash{[String, nil] => Enumerable<Asana::Resources::Task>}]
280
+ # @param by_section [Hash{String, nil => Array<Asana::Resources::Task>}]
279
281
  # @param task [Asana::Resources::Task]
280
282
  # @param project_gid [String]
281
283
  # @return [void]
282
284
  def file_task_by_section(by_section, task, project_gid)
283
- # @sg-ignore
284
- # @type [Array<Hash>]
285
- membership = task.memberships.find { |m| m['project']['gid'] == project_gid }
285
+ membership = task.memberships.find { |m| T.cast(m['project'], T::Hash[String, T.untyped])['gid'] == project_gid }
286
286
  raise "Could not find task in project_gid #{project_gid}: #{task}" if membership.nil?
287
287
 
288
+ section = T.cast(membership['section'], T::Hash[String, T.untyped])
289
+ section_name = T.cast(section['name'], String)
290
+
288
291
  # @type [String, nil]
289
- current_section = section_key(membership['section']['name'])
292
+ current_section = section_key(section_name)
290
293
 
291
294
  # @sg-ignore
292
295
  by_section.fetch(current_section) << task
@@ -296,7 +299,7 @@ module Checkoff
296
299
  # @param project_name [String, Symbol]
297
300
  # @return [Asana::Resources::Project]
298
301
  def project_or_raise(workspace_name, project_name)
299
- raise ArgumentError, 'Provide nil project_name' if project_name.nil?
302
+ raise ArgumentError, 'Provide nil project_name' if T.unsafe(project_name).nil?
300
303
 
301
304
  project = projects.project(workspace_name, project_name)
302
305
  if project.nil?
@@ -41,7 +41,7 @@ module Checkoff
41
41
  #
42
42
  # @param tasks [Enumerable<Asana::Resources::Task>]
43
43
  #
44
- # @return [Hash<[nil,String], Enumerable<Asana::Resources::Task>>]
44
+ # @return [Hash{nil,String => Enumerable<Asana::Resources::Task>}]
45
45
  def by_section(tasks)
46
46
  current_section = nil
47
47
  by_section = { nil => [] }
@@ -106,7 +106,7 @@ module Checkoff
106
106
  # @param by_section [Hash]
107
107
  # @param task [Asana::Resources::Task]
108
108
  #
109
- # @return [Array<(String, Hash)>]
109
+ # @return [Array(String, Hash)]
110
110
  def file_task_by_section(current_section, by_section, task)
111
111
  if subtask_section?(task)
112
112
  current_section = task.name
data/lib/checkoff/tags.rb CHANGED
@@ -1,6 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
  # typed: true
3
4
 
5
+ require 'asana'
6
+ require 'asana/resources/tag'
7
+
4
8
  # frozen_string_literal: true
5
9
 
6
10
  require 'forwardable'
@@ -24,7 +28,7 @@ module Checkoff
24
28
  LONG_CACHE_TIME = T.let(MINUTE * 15, Numeric)
25
29
  SHORT_CACHE_TIME = T.let(MINUTE, Numeric)
26
30
 
27
- # @param config [Checkoff::Internal::EnvFallbackConfigLoader]
31
+ # @param config [Checkoff::Internal::EnvFallbackConfigLoader,Hash]
28
32
  # @param clients [Checkoff::Clients]
29
33
  # @param client [Asana::Client]
30
34
  # @param projects [Checkoff::Projects]
@@ -105,10 +109,10 @@ module Checkoff
105
109
  # @return [Asana::Client]
106
110
  attr_reader :client
107
111
 
108
- # @param options [Hash<Symbol, Object>]
112
+ # @param options [Hash{Symbol => Object}]
109
113
  #
110
114
  # @sg-ignore
111
- # @return [Hash<Symbol, Object>]
115
+ # @return [Hash{Symbol => Object}]
112
116
  def build_params(options)
113
117
  { limit: options[:per_page], completed_since: options[:completed_since] }.reject do |_, v|
114
118
  v.nil? || Array(v).empty?
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # typed: false
2
+ # typed: true
3
3
 
4
4
  # frozen_string_literal: true
5
5
 
@@ -33,7 +33,7 @@ module Checkoff
33
33
  # @!parse
34
34
  # extend CacheMethod::ClassMethods
35
35
 
36
- # @param config [Hash<Symbol, Object>,Checkoff::Internal::EnvFallbackConfigLoader]
36
+ # @param config [Hash{Symbol => Object}, Checkoff::Internal::EnvFallbackConfigLoader]
37
37
  # @param workspaces [Checkoff::Workspaces]
38
38
  # @param task_selectors [Checkoff::TaskSelectors]
39
39
  # @param projects [Checkoff::Projects]
@@ -83,10 +83,10 @@ module Checkoff
83
83
  #
84
84
  # https://developers.asana.com/reference/searchtasksforworkspace
85
85
  #
86
- # @param [Hash<String, Object>] api_params
86
+ # @param [Hash{String => Object}] api_params
87
87
  # @param [String] workspace_gid
88
88
  # @param [Array<String>] extra_fields
89
- # @param [Array] task_selector
89
+ # @param [Symbol, Array<Symbol, Integer, Array>] task_selector
90
90
  # @param [Boolean] fetch_all Ensure all results are provided by manually paginating
91
91
  #
92
92
  # @return [Enumerable<Asana::Resources::Task>]
@@ -121,7 +121,7 @@ module Checkoff
121
121
  #
122
122
  # https://developers.asana.com/reference/searchtasksforworkspace
123
123
  #
124
- # @param [Hash<String, Object>] api_params
124
+ # @param [Hash{String => Object}] api_params
125
125
  # @param [String] workspace_gid
126
126
  # @param [Array<String>] extra_fields
127
127
  #
@@ -147,11 +147,10 @@ module Checkoff
147
147
  # see sort_by field at
148
148
  # https://developers.asana.com/reference/searchtasksforworkspace
149
149
  #
150
- # @param [Hash<String, Object>] api_params
150
+ # @param [Hash{String => Object}] api_params
151
151
  # @param [String] workspace_gid
152
152
  # @param [String] url
153
153
  # @param [Array<String>] extra_fields
154
- # @param [Boolean] fetch_all Ensure all results are provided by manually paginating
155
154
  #
156
155
  # @return [Enumerable<Asana::Resources::Task>]
157
156
  def iterated_raw_task_search(api_params, workspace_gid:, extra_fields:)
@@ -191,9 +190,10 @@ module Checkoff
191
190
  end
192
191
 
193
192
  # @param [Array<String>] extra_fields
194
- # @return [Hash<String, Object>]
193
+ # @sg-ignore
194
+ # @return [Hash{Symbol => undefined}]
195
195
  def calculate_api_options(extra_fields)
196
- # @type [Hash<Symbol, Object>]
196
+ # @type [Hash{Symbol => undefined}]
197
197
  all_options = projects.task_options(extra_fields: ['custom_fields'] + extra_fields)
198
198
  all_options[:options]
199
199
  end
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # typed: false
2
+ # typed: true
3
3
 
4
4
  # frozen_string_literal: true
5
5
 
@@ -25,6 +25,7 @@ module Checkoff
25
25
  # @param [Asana::Client] client
26
26
  # @param [Checkoff::Tasks] tasks
27
27
  # @param [Checkoff::Timelines] timelines
28
+ # @param [Checkoff::CustomFields] custom_fields
28
29
  def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
29
30
  client: Checkoff::Clients.new(config:).client,
30
31
  tasks: Checkoff::Tasks.new(config:,
@@ -40,13 +41,13 @@ module Checkoff
40
41
  end
41
42
 
42
43
  # @param [Asana::Resources::Task] task
43
- # @param [Array<(Symbol, Array)>] task_selector Filter based on
44
- # task details. Examples: [:tag, 'foo'] [:not, [:tag, 'foo']] [:tag, 'foo']
44
+ # @param [Symbol, Array<Symbol, Integer, Array>] task_selector Filter based on
45
+ # task details. Examples: [:tag, 'foo'] [:not, [:tag, 'foo']] [:tag, 'foo']
45
46
  # @return [Boolean]
46
47
  def filter_via_task_selector(task, task_selector)
47
48
  evaluator = TaskSelectorEvaluator.new(task:, tasks:, timelines:,
48
49
  custom_fields:)
49
- evaluator.evaluate(task_selector)
50
+ !!evaluator.evaluate(task_selector)
50
51
  end
51
52
 
52
53
  private
@@ -75,10 +76,13 @@ module Checkoff
75
76
  ARGV[0] || raise('Please pass workspace name as first argument')
76
77
  end
77
78
 
78
- # @return [Array]
79
+ # @sg-ignore
80
+ # @return [Array(Symbol, Array)]
79
81
  def task_selector
80
82
  task_selector_json = ARGV[2] || raise('Please pass task_selector in JSON form as third argument')
81
- JSON.parse(task_selector_json)
83
+
84
+ # @return [Symbol, Array]
85
+ T.cast(JSON.parse(task_selector_json), [Symbol, Array])
82
86
  end
83
87
 
84
88
  # @return [void]
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # typed: false
3
+ # typed: true
4
4
 
5
5
  # frozen_string_literal: true
6
6
 
@@ -32,7 +32,7 @@ module Checkoff
32
32
  LONG_CACHE_TIME = MINUTE * 15
33
33
  SHORT_CACHE_TIME = MINUTE * 5
34
34
 
35
- # @param config [Checkoff::Internal::EnvFallbackConfigLoader]
35
+ # @param config [Hash, Checkoff::Internal::EnvFallbackConfigLoader]
36
36
  # @param client [Asana::Client]
37
37
  # @param workspaces [Checkoff::Workspaces]
38
38
  # @param sections [Checkoff::Sections]
@@ -265,9 +265,9 @@ module Checkoff
265
265
  # <regular keys from API response>
266
266
  # +
267
267
  # unwrapped:
268
- # membership_by_section_gid: Hash<String, Hash (membership)>
269
- # membership_by_project_gid: Hash<String, Hash (membership)>
270
- # membership_by_project_name: Hash<String, Hash (membership)>
268
+ # membership_by_section_gid: Hash{String => Hash (membership)>
269
+ # membership_by_project_gid: Hash{String => Hash (membership)>
270
+ # membership_by_project_name: Hash{String => Hash (membership)>
271
271
  # task: String (name)
272
272
  #
273
273
  # @param task [Asana::Resources::Task]
@@ -47,7 +47,6 @@ module Checkoff
47
47
 
48
48
  # @param task [Asana::Resources::Task]
49
49
  # @param limit_to_portfolio_gid [String, nil]
50
- # @param project_name [String]
51
50
  def task_dependent_on_previous_section_last_milestone?(task, limit_to_portfolio_gid: nil)
52
51
  task_data = @tasks.task_to_h(task)
53
52
  # @sg-ignore
@@ -35,7 +35,7 @@ module Checkoff
35
35
  end
36
36
 
37
37
  # @param date_or_time [Date,Time,nil]
38
- # @param period [Symbol,Array<(Symbol,Integer)>]
38
+ # @param period [Symbol, Array(Symbol,Integer)]
39
39
  #
40
40
  # Valid values: :this_week, :now_or_before, :indefinite, [:less_than_n_days_ago, Integer]
41
41
  def in_period?(date_or_time, period)
@@ -120,7 +120,7 @@ module Checkoff
120
120
 
121
121
  date = date_or_time.to_date
122
122
 
123
- date >= beginning_of_week && date <= end_of_week
123
+ date.between?(beginning_of_week, end_of_week)
124
124
  end
125
125
 
126
126
  # @param date_or_time [Date,Time,nil]
@@ -137,10 +137,10 @@ module Checkoff
137
137
 
138
138
  date = date_or_time.to_date
139
139
 
140
- date >= beginning_of_week && date <= end_of_week
140
+ date.between?(beginning_of_week, end_of_week)
141
141
  end
142
142
 
143
- # @type [Hash<Symbol,Integer>]
143
+ # @type [Hash{Symbol => Integer}]
144
144
  WDAY_FROM_DAY_OF_WEEK = {
145
145
  monday: 1,
146
146
  tuesday: 2,
@@ -150,6 +150,7 @@ module Checkoff
150
150
  saturday: 6,
151
151
  sunday: 0,
152
152
  }.freeze
153
+ private_constant :WDAY_FROM_DAY_OF_WEEK
153
154
 
154
155
  # @param date_or_time [Date,Time,nil]
155
156
  # @param day_of_week [Symbol]
@@ -4,5 +4,5 @@
4
4
  # Command-line and gem client for Asana (unofficial)
5
5
  module Checkoff
6
6
  # Version of library
7
- VERSION = '0.227.0'
7
+ VERSION = '0.229.0'
8
8
  end
@@ -22,7 +22,7 @@ module Checkoff
22
22
  # @!parse
23
23
  # extend CacheMethod::ClassMethods
24
24
 
25
- # @param config [Checkoff::Internal::EnvFallbackConfigLoader]
25
+ # @param config [Hash, Checkoff::Internal::EnvFallbackConfigLoader]
26
26
  # @param client [Asana::Client]
27
27
  # @param asana_workspace [Class<Asana::Resources::Workspace>]
28
28
  def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),