checkoff 0.31.0 → 0.32.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: 9098d5cbdef080b54a70384a623e904981f3c9b395a445c2d30c0c6ce734c4f7
4
- data.tar.gz: 59b28f88a8f4bb7f6c9bd5cc03f28dda3232032670f08aa304bdcf6c7d824290
3
+ metadata.gz: 318fa6ab4d3237eb9eaf57d752ba2ef13e0082a4d2d7656069fb58b1b2011165
4
+ data.tar.gz: 0c7f23448c07873c281a1b6cc93719df9d0e3ef952d5b43f6bc947ad5a0ca491
5
5
  SHA512:
6
- metadata.gz: bab2cdcbb4aad51cdb444d108a47cc13a1cff97567db5455894364b010cdb851f9c66bcd420d1add74e0b64e3e5358d64ba7873d5f25cb074595e7edbe805f1a
7
- data.tar.gz: 3d579e7e952155057addede0bd1c7877986a3900cd77f341eaf9d09b0f80604fae1105d6ba1f247694f5ec52fa50fb6d830c083a2a75f4a56845874772b0df5a
6
+ metadata.gz: 1bd96a96a0306d78c0b88f37aaa705a8d0d9c9552f35159bd70d2a3bfcbd84308903ce772c92c399d229cad9b21165ad751bfab269f6539bd3435a3ccfa20640
7
+ data.tar.gz: 1de9712b43b014a0c0103af61807c6ecf9d17df2ed961b12577ec5b9df6d4e486801f73a302563648da6b1deb42923bbffb59c11def81ea371782e66ffa55a64
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.31.0)
15
+ checkoff (0.32.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -15,8 +15,11 @@ module Checkoff
15
15
  attr_reader :projects
16
16
 
17
17
  def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
18
- projects: Checkoff::Projects.new(config: config))
18
+ client: Checkoff::Clients.new(config: config).client,
19
+ projects: Checkoff::Projects.new(config: config,
20
+ client: client))
19
21
  @config = config
22
+ @client = client
20
23
  @projects = projects
21
24
  end
22
25
 
@@ -27,20 +30,32 @@ module Checkoff
27
30
  raw_tasks = projects.tasks_from_project(project,
28
31
  extra_fields: extra_fields + ['assignee_section.name'])
29
32
  active_tasks = projects.active_tasks(raw_tasks)
30
- by_my_tasks_section(active_tasks)
33
+ by_my_tasks_section(active_tasks, project.gid)
34
+ end
35
+
36
+ def section_key(name)
37
+ return nil if name == 'Recently assigned'
38
+
39
+ name
31
40
  end
32
41
 
33
42
  # Given a list of tasks in 'My Tasks', pull a Hash of tasks with
34
43
  # section name -> task list
35
- def by_my_tasks_section(tasks)
44
+ def by_my_tasks_section(tasks, project_gid)
36
45
  by_section = {}
46
+ sections = client.sections.get_sections_for_project(project_gid: project_gid)
47
+ sections.each { |section| by_section[section_key(section.name)] = [] }
37
48
  tasks.each do |task|
38
49
  assignee_section = task.assignee_section
39
- current_section = assignee_section.name
50
+ current_section = section_key(assignee_section.name)
40
51
  by_section[current_section] ||= []
41
52
  by_section[current_section] << task
42
53
  end
43
54
  by_section
44
55
  end
56
+
57
+ private
58
+
59
+ attr_reader :client
45
60
  end
46
61
  end
@@ -26,7 +26,7 @@ module Checkoff
26
26
  time: Time)
27
27
  @projects = projects
28
28
  @workspaces = workspaces
29
- @my_tasks = Checkoff::MyTasks.new(config: config, projects: projects)
29
+ @my_tasks = Checkoff::MyTasks.new(config: config, projects: projects, client: client)
30
30
  @client = client
31
31
  @time = time
32
32
  end
@@ -89,19 +89,24 @@ module Checkoff
89
89
  # Given a project object, pull all tasks, then provide a Hash of
90
90
  # tasks with section name -> task list of the uncompleted tasks
91
91
  def tasks_by_section_for_project(project, extra_fields: [])
92
- # print("project: #{project}")
93
92
  raw_tasks = projects.tasks_from_project(project, extra_fields: extra_fields)
94
- # print("raw_tasks[0]: #{raw_tasks[0]}")
95
93
  active_tasks = projects.active_tasks(raw_tasks)
96
94
  by_section(active_tasks, project.gid)
97
95
  end
98
96
 
97
+ def section_key(name)
98
+ inbox_section_names = ['(no section)', 'Untitled section', 'Inbox']
99
+ return nil if inbox_section_names.include?(name)
100
+
101
+ name
102
+ end
103
+
99
104
  # Given a list of tasks, pull a Hash of tasks with section name -> task list
100
105
  def by_section(tasks, project_gid)
101
106
  by_section = {}
102
- tasks.each do |task|
103
- file_task_by_section(by_section, task, project_gid)
104
- end
107
+ sections = client.sections.get_sections_for_project(project_gid: project_gid)
108
+ sections.each { |section| by_section[section_key(section.name)] = [] }
109
+ tasks.each { |task| file_task_by_section(by_section, task, project_gid) }
105
110
  by_section
106
111
  end
107
112
  cache_method :by_section, LONG_CACHE_TIME
@@ -110,11 +115,9 @@ module Checkoff
110
115
  membership = task.memberships.find { |m| m['project']['gid'] == project_gid }
111
116
  raise "Could not find task in project_gid #{project_gid}: #{task}" if membership.nil?
112
117
 
113
- current_section = membership['section']['name']
114
- inbox_section_names = ['(no section)', 'Untitled section', 'Inbox']
115
- current_section = nil if inbox_section_names.include?(current_section)
116
- by_section[current_section] ||= []
117
- by_section[current_section] << task
118
+ current_section = section_key(membership['section']['name'])
119
+
120
+ by_section.fetch(current_section) << task
118
121
  end
119
122
 
120
123
  def project_or_raise(workspace_name, project_name)
@@ -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.31.0'
6
+ VERSION = '0.32.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.31.0
4
+ version: 0.32.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: 2023-02-27 00:00:00.000000000 Z
11
+ date: 2023-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport