checkoff 0.46.0 → 0.46.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: a65e8d9c8d8e3012cbe1821983bc48e5151f6c666a454ce627c0084edaac8b46
4
- data.tar.gz: 35f49e9a77c9409278b3f68a6c84f6afefc68727510b13ac322a1988360163af
3
+ metadata.gz: 5a4be48acbc5f3ab9954ca8f7ec3ef64f1c629bfbc0015f158cde7a87fcc4049
4
+ data.tar.gz: 1824e5607d750cc1d9b2161dc897cd4a08fd90c27fea1c4cc7a5f19ee4e2c497
5
5
  SHA512:
6
- metadata.gz: 70162bcc35ac9bb35d3006e7334a0abd36c5b9853b148e3f9ae720761691bb00af8de7f065969f144c01cc5563f78c6a53e90c92f7811ab5bf269eabb30986bc
7
- data.tar.gz: 3b49077f074571a0b09c7a167601ed7bc99f59707505ef10deb187215dcc059cbd1ea04cff64669ae5e7bbf2007a5d0054aeb62658129ff15e93f3a5baf87534
6
+ metadata.gz: 3ef67e1152d4399b8b507a6b6b6555f300ac83ffda4b998a8ae031ada997deabdd60974228db9cb01101bf319a3092a36fa259391c4fbdc6940266e1d53f923d
7
+ data.tar.gz: e04b024a9f4def03f62fb7a8b1498e53ed2d08cc53cff3a5b76bc7f16b6a20402a450704a7f782372b5f3438a7ecad063f1e7047b552d50a360fa7c5d1d60dbc
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.46.0)
15
+ checkoff (0.46.1)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -83,7 +83,7 @@
83
83
  # # just because another object it is associated with (e.g. a subtask)
84
84
  # # is modified. Actions that count as modifying the task include
85
85
  # # assigning, renaming, completing, and adding stories.
86
- # # @return [Asana::Collection<Asana::Resources::Task>]
86
+ # # @return [Enumerable<Asana::Resources::Task>]
87
87
  # def find_all(assignee: nil, workspace: nil, project: nil, section: nil,
88
88
  # tag: nil, user_task_list: nil, completed_since: nil,
89
89
  # modified_since: nil, per_page: 20, options: {}); end
@@ -106,7 +106,7 @@
106
106
  # class Section
107
107
  # # @param project_gid [String]
108
108
  # # @return [Enumerable<Asana::Resources::Section>]
109
- # def get_sections_for_project(client, project_gid:, options: {}); end
109
+ # def get_sections_for_project(project_gid:, options: {}); end
110
110
  # end
111
111
  # class Project
112
112
  # # Returns the compact project records for all projects in the workspace.
@@ -48,9 +48,11 @@ module Checkoff
48
48
 
49
49
  # @return [void]
50
50
  def validate_due_date_through_next!
51
- return if date_url_params.fetch('due_date.operator') == ['through_next']
51
+ due_date_operators = date_url_params.fetch('due_date.operator')
52
52
 
53
- raise 'Teach me how to handle other date modes'
53
+ return if due_date_operators == ['through_next']
54
+
55
+ raise "Teach me how to handle date mode: #{due_date_operators}."
54
56
  end
55
57
 
56
58
  # @return [Hash<String, Array<String>>]
@@ -12,8 +12,12 @@ module Checkoff
12
12
  LONG_CACHE_TIME = MINUTE * 15
13
13
  SHORT_CACHE_TIME = MINUTE * 5
14
14
 
15
+ # @return [Checkoff::Projects]
15
16
  attr_reader :projects
16
17
 
18
+ # @param config [Hash<Symbol, Object>]
19
+ # @param client [Asana::Client]
20
+ # @param projects [Checkoff::Projects]
17
21
  def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
18
22
  client: Checkoff::Clients.new(config: config).client,
19
23
  projects: Checkoff::Projects.new(config: config,
@@ -26,13 +30,23 @@ module Checkoff
26
30
  # Given a 'My Tasks' project object, pull all tasks, then provide
27
31
  # a Hash of tasks with section name -> task list of the
28
32
  # uncompleted tasks.
29
- def tasks_by_section_for_my_tasks(project, extra_fields: [])
33
+ #
34
+ # @param project [Asana::Resources::Project]
35
+ # @param only_uncompleted [Boolean]
36
+ # @param extra_fields [Array<String>]
37
+ # @return [Hash<String, Enumerable<Asana::Resources::Task>>]
38
+ def tasks_by_section_for_my_tasks(project,
39
+ only_uncompleted: true,
40
+ extra_fields: [])
30
41
  raw_tasks = projects.tasks_from_project(project,
42
+ only_uncompleted: only_uncompleted,
31
43
  extra_fields: extra_fields + ['assignee_section.name'])
32
44
  active_tasks = projects.active_tasks(raw_tasks)
33
45
  by_my_tasks_section(active_tasks, project.gid)
34
46
  end
35
47
 
48
+ # @param name [String]
49
+ # @return [String, nil]
36
50
  def section_key(name)
37
51
  return nil if name == 'Recently assigned'
38
52
 
@@ -41,10 +55,14 @@ module Checkoff
41
55
 
42
56
  # Given a list of tasks in 'My Tasks', pull a Hash of tasks with
43
57
  # section name -> task list
58
+ #
59
+ # @param tasks [Enumerable<Asana::Resources::Task>]
60
+ # @param project_gid [String]
61
+ # @return [Hash<String, Enumerable<Asana::Resources::Task>>]
44
62
  def by_my_tasks_section(tasks, project_gid)
45
63
  by_section = {}
46
64
  sections = client.sections.get_sections_for_project(project_gid: project_gid)
47
- sections.each { |section| by_section[section_key(section.name)] = [] }
65
+ sections.each_entry { |section| by_section[section_key(section.name)] = [] }
48
66
  tasks.each do |task|
49
67
  assignee_section = task.assignee_section
50
68
  current_section = section_key(assignee_section.name)
@@ -56,6 +74,7 @@ module Checkoff
56
74
 
57
75
  private
58
76
 
77
+ # @return [Asana::Client]
59
78
  attr_reader :client
60
79
  end
61
80
  end
@@ -91,12 +91,14 @@ module Checkoff
91
91
  # @param [Boolean] only_uncompleted
92
92
  # @param [Array<String>] extra_fields
93
93
  # @return [Enumerable<Asana::Resources::Task>]
94
- def tasks_from_project(project, only_uncompleted: true, extra_fields: [])
94
+ def tasks_from_project(project,
95
+ only_uncompleted: true,
96
+ extra_fields: [])
95
97
  options = task_options
96
98
  options[:completed_since] = '9999-12-01' if only_uncompleted
97
99
  options[:project] = project.gid
98
100
  options[:options][:fields] += extra_fields
99
- client.tasks.find_all(**options).to_a
101
+ client.tasks.find_all(**options)
100
102
  end
101
103
  cache_method :tasks_from_project, SHORT_CACHE_TIME
102
104
 
@@ -65,17 +65,21 @@ module Checkoff
65
65
  # tasks with section name -> task list of the uncompleted tasks
66
66
  # @param workspace_name [String]
67
67
  # @param project_name [String, Symbol]
68
+ # @param only_uncompleted [Boolean]
68
69
  # @param extra_fields [Array<String>]
69
70
  # @return [Hash{[String, nil] => Enumerable<Asana::Resources::Task>}]
70
- def tasks_by_section(workspace_name, project_name, extra_fields: [])
71
+ def tasks_by_section(workspace_name,
72
+ project_name,
73
+ only_uncompleted: true,
74
+ extra_fields: [])
71
75
  raise ArgumentError, 'Provided nil workspace name' if workspace_name.nil?
72
76
  raise ArgumentError, 'Provided nil project name' if project_name.nil?
73
77
 
74
78
  project = project_or_raise(workspace_name, project_name)
75
79
  if project_name == :my_tasks
76
- my_tasks.tasks_by_section_for_my_tasks(project, extra_fields: extra_fields)
80
+ my_tasks.tasks_by_section_for_my_tasks(project, only_uncompleted: only_uncompleted, extra_fields: extra_fields)
77
81
  else
78
- tasks_by_section_for_project(project, extra_fields: extra_fields)
82
+ tasks_by_section_for_project(project, only_uncompleted: only_uncompleted, extra_fields: extra_fields)
79
83
  end
80
84
  end
81
85
 
@@ -140,10 +144,15 @@ module Checkoff
140
144
  # Given a project object, pull all tasks, then provide a Hash of
141
145
  # tasks with section name -> task list of the uncompleted tasks
142
146
  # @param project [Asana::Resources::Project]
147
+ # @param only_uncompleted [Boolean]
143
148
  # @param extra_fields [Array<String>]
144
149
  # @return [Hash<[String,nil], Enumerable<Asana::Resources::Task>>]
145
- def tasks_by_section_for_project(project, extra_fields: [])
146
- raw_tasks = projects.tasks_from_project(project, extra_fields: extra_fields)
150
+ def tasks_by_section_for_project(project,
151
+ only_uncompleted: true,
152
+ extra_fields: [])
153
+ raw_tasks = projects.tasks_from_project(project,
154
+ only_uncompleted: only_uncompleted,
155
+ extra_fields: extra_fields)
147
156
  active_tasks = projects.active_tasks(raw_tasks)
148
157
  by_section(active_tasks, project.gid)
149
158
  end
@@ -165,7 +174,7 @@ module Checkoff
165
174
  by_section = {}
166
175
  # @sg-ignore
167
176
  sections = client.sections.get_sections_for_project(project_gid: project_gid)
168
- sections.each { |section| by_section[section_key(section.name)] = [] }
177
+ sections.each_entry { |section| by_section[section_key(section.name)] = [] }
169
178
  tasks.each { |task| file_task_by_section(by_section, task, project_gid) }
170
179
  by_section
171
180
  end
@@ -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.46.0'
6
+ VERSION = '0.46.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.46.0
4
+ version: 0.46.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-09-01 00:00:00.000000000 Z
11
+ date: 2023-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport