checkoff 0.39.1 → 0.39.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/config/definitions.rb +18 -0
- data/lib/checkoff/sections.rb +46 -5
- data/lib/checkoff/tasks.rb +4 -4
- data/lib/checkoff/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e76d0cf72eb0426c6c69b27837d486f9cbe6de2f0782b10acc157f1b305941b1
|
4
|
+
data.tar.gz: effbabaaccae53bf8e3e843f509bba7477a24a34be44542906bf33e39a6a1f91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0d0e684e7811ab1ba2637117969e114b1c2c01e8e495f5dd2aa42255ff9d8ee1b67cf6368dcb2908ce1e70000b51c537492a5e812632b2c134ff0b632602510
|
7
|
+
data.tar.gz: b24402a8cbf03684397dddea78ba3d778cd96fbb9408a828853e737c65b787b7bb1170f14ff5f28d1efb7b599766e944df8f1e2ce27eff93f03e5b02736ccd86
|
data/Gemfile.lock
CHANGED
@@ -12,7 +12,7 @@ GIT
|
|
12
12
|
PATH
|
13
13
|
remote: .
|
14
14
|
specs:
|
15
|
-
checkoff (0.39.
|
15
|
+
checkoff (0.39.2)
|
16
16
|
activesupport
|
17
17
|
asana (> 0.10.0)
|
18
18
|
cache_method
|
@@ -74,7 +74,7 @@ GEM
|
|
74
74
|
multi_json
|
75
75
|
gli (2.21.0)
|
76
76
|
hashdiff (1.0.1)
|
77
|
-
i18n (1.14.
|
77
|
+
i18n (1.14.1)
|
78
78
|
concurrent-ruby (~> 1.0)
|
79
79
|
imagen (0.1.8)
|
80
80
|
parser (>= 2.5, != 2.5.1.1)
|
data/config/definitions.rb
CHANGED
@@ -14,6 +14,8 @@
|
|
14
14
|
# def tasks; end
|
15
15
|
# # @return [Asana::ProxiedResourceClasses::Workspace]
|
16
16
|
# def workspaces; end
|
17
|
+
# # @return [Asana::ProxiedResourceClasses::Section]
|
18
|
+
# def sections; end
|
17
19
|
# end
|
18
20
|
# module Resources
|
19
21
|
# class Task
|
@@ -43,10 +45,26 @@
|
|
43
45
|
# # @param options [Hash] the request I/O options.
|
44
46
|
# # @return [Asana::Resources::Task]
|
45
47
|
# def find_by_id(id, options: {}); end
|
48
|
+
# # @param section [Asana::Resources::section]
|
49
|
+
# # @param options [Hash] the request I/O options.
|
50
|
+
# # @return [Array<Asana::Resources::Task>]
|
51
|
+
# def get_tasks(assignee: nil,
|
52
|
+
# project: nil,
|
53
|
+
# section: nil,
|
54
|
+
# workspace: nil,
|
55
|
+
# completed_since: nil,
|
56
|
+
# per_page: 20,
|
57
|
+
# modified_since: nil,
|
58
|
+
# options: {}); end
|
46
59
|
# end
|
47
60
|
# class Workspace
|
48
61
|
# # @return [Array<Asana::Resources::Workspace>]
|
49
62
|
# def find_all; end
|
50
63
|
# end
|
64
|
+
# class Section
|
65
|
+
# # @param project_gid [String]
|
66
|
+
# # @return [Array<Asana::Resources::Section>]
|
67
|
+
# def get_sections_for_project(client, project_gid:, options: {}); end
|
68
|
+
# end
|
51
69
|
# end
|
52
70
|
# end
|
data/lib/checkoff/sections.rb
CHANGED
@@ -9,14 +9,23 @@ require_relative 'my_tasks'
|
|
9
9
|
module Checkoff
|
10
10
|
# Query different sections of Asana projects
|
11
11
|
class Sections
|
12
|
+
# @!parse
|
13
|
+
# extend CacheMethod::ClassMethods
|
14
|
+
|
12
15
|
MINUTE = 60
|
16
|
+
# @sg-ignore
|
13
17
|
LONG_CACHE_TIME = MINUTE * 15
|
18
|
+
# @sg-ignore
|
14
19
|
SHORT_CACHE_TIME = MINUTE * 5
|
15
20
|
|
16
21
|
extend Forwardable
|
17
22
|
|
18
23
|
attr_reader :projects, :workspaces, :time, :my_tasks
|
19
24
|
|
25
|
+
# @param client [Asana::Client]
|
26
|
+
# @param projects [Checkoff::Projects]
|
27
|
+
# @param workspaces [Checkoff::Workspaces]
|
28
|
+
# @param time [Class<Time>]
|
20
29
|
def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
|
21
30
|
client: Checkoff::Clients.new(config: config).client,
|
22
31
|
projects: Checkoff::Projects.new(config: config,
|
@@ -32,8 +41,13 @@ module Checkoff
|
|
32
41
|
end
|
33
42
|
|
34
43
|
# Returns a list of Asana API section objects for a given project
|
44
|
+
# @param workspace_name [String]
|
45
|
+
# @param project_name [String, Symbol]
|
46
|
+
#
|
47
|
+
# @return [Array<Asana::Resources::Section>]
|
35
48
|
def sections_or_raise(workspace_name, project_name)
|
36
49
|
project = project_or_raise(workspace_name, project_name)
|
50
|
+
# @sg-ignore
|
37
51
|
client.sections.get_sections_for_project(project_gid: project.gid)
|
38
52
|
end
|
39
53
|
|
@@ -55,6 +69,14 @@ module Checkoff
|
|
55
69
|
# XXX: Rename to section_tasks
|
56
70
|
#
|
57
71
|
# Pulls task objects from a specified section
|
72
|
+
#
|
73
|
+
# @param workspace_name [String]
|
74
|
+
# @param project_name [String, Symbol]
|
75
|
+
# @param section_name [String, nil]
|
76
|
+
# @param only_uncompleted [Boolean]
|
77
|
+
# @param extra_fields [Array<String>]
|
78
|
+
#
|
79
|
+
# @return [Array<Asana::Resources::Task>]
|
58
80
|
def tasks(workspace_name, project_name, section_name,
|
59
81
|
only_uncompleted: true,
|
60
82
|
extra_fields: [])
|
@@ -71,27 +93,35 @@ module Checkoff
|
|
71
93
|
# @param workspace_name [String]
|
72
94
|
# @param project_name [String, Symbol]
|
73
95
|
# @param section_name [String, nil]
|
96
|
+
#
|
74
97
|
# @return [Array<String>]
|
75
98
|
def section_task_names(workspace_name, project_name, section_name)
|
76
|
-
|
77
|
-
|
99
|
+
task_array = tasks(workspace_name, project_name, section_name)
|
100
|
+
task_array.map(&:name)
|
78
101
|
end
|
79
102
|
cache_method :section_task_names, SHORT_CACHE_TIME
|
80
103
|
|
104
|
+
# @param workspace_name [String]
|
105
|
+
# @param project_name [String, Symbol]
|
106
|
+
# @param section_name [String, nil]
|
107
|
+
#
|
108
|
+
# @return [Asana::Resources::Section]
|
81
109
|
def section_or_raise(workspace_name, project_name, section_name)
|
82
|
-
|
83
|
-
if
|
110
|
+
s = section(workspace_name, project_name, section_name)
|
111
|
+
if s.nil?
|
84
112
|
valid_sections = sections_or_raise(workspace_name, project_name).map(&:name)
|
85
113
|
|
86
114
|
raise "Could not find section #{section_name} under project #{project_name} " \
|
87
115
|
"under workspace #{workspace_name}. Valid sections: #{valid_sections}"
|
88
116
|
end
|
89
|
-
|
117
|
+
s
|
90
118
|
end
|
91
119
|
cache_method :section_or_raise, LONG_CACHE_TIME
|
92
120
|
|
93
121
|
private
|
94
122
|
|
123
|
+
# @!attribute [r] client
|
124
|
+
# @return [Asana::Client]
|
95
125
|
attr_reader :client
|
96
126
|
|
97
127
|
# Given a project object, pull all tasks, then provide a Hash of
|
@@ -117,6 +147,7 @@ module Checkoff
|
|
117
147
|
# @return [Hash<[String,nil], Array<Asana::Resources::Task>>]
|
118
148
|
def by_section(tasks, project_gid)
|
119
149
|
by_section = {}
|
150
|
+
# @sg-ignore
|
120
151
|
sections = client.sections.get_sections_for_project(project_gid: project_gid)
|
121
152
|
sections.each { |section| by_section[section_key(section.name)] = [] }
|
122
153
|
tasks.each { |task| file_task_by_section(by_section, task, project_gid) }
|
@@ -124,15 +155,25 @@ module Checkoff
|
|
124
155
|
end
|
125
156
|
cache_method :by_section, LONG_CACHE_TIME
|
126
157
|
|
158
|
+
# @param by_section [Hash{[String, nil] => Array<Asana::Resources::Task>}]
|
159
|
+
# @param task [Asana::Resources::Task]
|
160
|
+
# @param project_gid [String]
|
161
|
+
# @return [void]
|
127
162
|
def file_task_by_section(by_section, task, project_gid)
|
163
|
+
# @type [Array<Hash>]
|
128
164
|
membership = task.memberships.find { |m| m['project']['gid'] == project_gid }
|
129
165
|
raise "Could not find task in project_gid #{project_gid}: #{task}" if membership.nil?
|
130
166
|
|
167
|
+
# @type [String, nil]
|
131
168
|
current_section = section_key(membership['section']['name'])
|
132
169
|
|
170
|
+
# @sg-ignore
|
133
171
|
by_section.fetch(current_section) << task
|
134
172
|
end
|
135
173
|
|
174
|
+
# @param workspace_name [String]
|
175
|
+
# @param project_name [String, Symbol]
|
176
|
+
# @return [Asana::Resources::Project]
|
136
177
|
def project_or_raise(workspace_name, project_name)
|
137
178
|
project = projects.project(workspace_name, project_name)
|
138
179
|
if project.nil?
|
data/lib/checkoff/tasks.rb
CHANGED
@@ -64,13 +64,13 @@ module Checkoff
|
|
64
64
|
end
|
65
65
|
|
66
66
|
# Pull a specific task by name
|
67
|
+
# @param task_gid [String]
|
68
|
+
# @param extra_fields [Array<String>]
|
67
69
|
# @return [Asana::Resources::Task, nil]
|
68
70
|
def task_by_gid(task_gid,
|
69
|
-
only_uncompleted: true,
|
70
71
|
extra_fields: [])
|
71
|
-
options = projects.task_options
|
72
|
-
options[:
|
73
|
-
options[:completed_since] = '9999-12-01' if only_uncompleted
|
72
|
+
options = projects.task_options.fetch(:options, {})
|
73
|
+
options[:fields] += extra_fields
|
74
74
|
client.tasks.find_by_id(task_gid, options: options)
|
75
75
|
end
|
76
76
|
|
data/lib/checkoff/version.rb
CHANGED
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.39.
|
4
|
+
version: 0.39.2
|
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-06-
|
11
|
+
date: 2023-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|