checkoff 0.112.0 → 0.114.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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/checkoff/internal/create-class.sh +0 -2
- data/lib/checkoff/internal/project_hashes.rb +35 -0
- data/lib/checkoff/internal/task_timing.rb +1 -1
- data/lib/checkoff/portfolios.rb +16 -2
- data/lib/checkoff/projects.rb +16 -1
- data/lib/checkoff/tasks.rb +20 -0
- data/lib/checkoff/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a87ae5e25697c0daa4fd48bb9eb16d79e2b253ab886b535bd41fc460e3b1d2a9
|
4
|
+
data.tar.gz: 3ae9f56d8e53390c87c0f1560d85f8f9c6ad37d3fb1236ce23bbafe2cdb6125c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b227e5768678060e3ce4c3992937ff0e7bb0c6a9099b828fc577da123b48a6d070d75c3aa6c383509fe78b98777bc8e0ee246a54a254dbd7b1ea0de2abf411cc
|
7
|
+
data.tar.gz: b999dd5ab7a0d58c010c43231664bbe30efe617f4836a572ae146dde1cbe9f8d6bddf46598ec490327e6a8f7f86a6f4ff5c34d909bb06ddcd6a003336607e29c
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Checkoff
|
4
|
+
module Internal
|
5
|
+
# Builds on the standard API representation of an Asana project with some
|
6
|
+
# convenience keys.
|
7
|
+
class ProjectHashes
|
8
|
+
# @param _deps [Hash]
|
9
|
+
def initialize(_deps = {}); end
|
10
|
+
|
11
|
+
# @param project_obj [Asana::Resources::Project]
|
12
|
+
# @param project [String, Symbol<:not_specified, :my_tasks>]
|
13
|
+
#
|
14
|
+
# @return [Hash]
|
15
|
+
def project_to_h(project_obj, project: :not_specified)
|
16
|
+
project = project_obj.name if project == :not_specified
|
17
|
+
project_hash = { **project_obj.to_h, 'project' => project }
|
18
|
+
project_hash['unwrapped'] = {}
|
19
|
+
unwrap_custom_fields(project_hash)
|
20
|
+
project_hash
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# @param project_hash [Hash]
|
26
|
+
# @return [void]
|
27
|
+
def unwrap_custom_fields(project_hash)
|
28
|
+
unwrapped_custom_fields = project_hash.fetch('custom_fields', []).group_by do |cf|
|
29
|
+
cf['name']
|
30
|
+
end.transform_values(&:first)
|
31
|
+
project_hash['unwrapped']['custom_fields'] = unwrapped_custom_fields
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/checkoff/portfolios.rb
CHANGED
@@ -80,14 +80,28 @@ module Checkoff
|
|
80
80
|
|
81
81
|
# @param workspace_name [String]
|
82
82
|
# @param portfolio_name [String]
|
83
|
+
# @param extra_project_fields [Array<String>]
|
83
84
|
#
|
84
85
|
# @return [Enumerable<Asana::Resources::Project>]
|
85
|
-
def projects_in_portfolio(workspace_name, portfolio_name
|
86
|
+
def projects_in_portfolio(workspace_name, portfolio_name,
|
87
|
+
extra_project_fields: [])
|
86
88
|
portfolio = portfolio_or_raise(workspace_name, portfolio_name)
|
87
|
-
portfolio
|
89
|
+
projects_in_portfolio_obj(portfolio)
|
88
90
|
end
|
89
91
|
cache_method :projects_in_portfolio, LONG_CACHE_TIME
|
90
92
|
|
93
|
+
# @param portfolio [Asana::Resources::Portfolio]
|
94
|
+
# @param extra_project_fields [Array<String>]
|
95
|
+
#
|
96
|
+
# @return [Enumerable<Asana::Resources::Project>]
|
97
|
+
def projects_in_portfolio_obj(portfolio, extra_project_fields: [])
|
98
|
+
options = {
|
99
|
+
fields: ['name'],
|
100
|
+
}
|
101
|
+
options[:fields] += extra_project_fields
|
102
|
+
portfolio.get_items(options: options)
|
103
|
+
end
|
104
|
+
|
91
105
|
private
|
92
106
|
|
93
107
|
# @return [Checkoff::Workspaces]
|
data/lib/checkoff/projects.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'internal/config_loader'
|
4
|
+
require_relative 'internal/project_hashes'
|
4
5
|
require_relative 'workspaces'
|
5
6
|
require_relative 'clients'
|
6
7
|
require 'cache_method'
|
@@ -30,13 +31,16 @@ module Checkoff
|
|
30
31
|
# @param config [Hash<Symbol, Object>]
|
31
32
|
# @param client [Asana::Client]
|
32
33
|
# @param workspaces [Checkoff::Workspaces]
|
34
|
+
# @param project_hashes [Checkoff::Internal::ProjectHashes]
|
33
35
|
def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
|
34
36
|
client: Checkoff::Clients.new(config: config).client,
|
35
37
|
workspaces: Checkoff::Workspaces.new(config: config,
|
36
|
-
client: client)
|
38
|
+
client: client),
|
39
|
+
project_hashes: Checkoff::Internal::ProjectHashes.new)
|
37
40
|
@config = config
|
38
41
|
@workspaces = workspaces
|
39
42
|
@client = client
|
43
|
+
@project_hashes = project_hashes
|
40
44
|
end
|
41
45
|
|
42
46
|
# Default options used in Asana API to pull tasks
|
@@ -115,8 +119,19 @@ module Checkoff
|
|
115
119
|
# 15 minute cache resulted in 'Your pagination token has expired'
|
116
120
|
cache_method :projects_by_workspace_name, MEDIUM_CACHE_TIME
|
117
121
|
|
122
|
+
# @param project_obj [Asana::Resources::Project]
|
123
|
+
# @param project [String, Symbol<:not_specified, :my_tasks>]
|
124
|
+
#
|
125
|
+
# @return [Hash]
|
126
|
+
def project_to_h(project_obj, project: :not_specified)
|
127
|
+
project_hashes.project_to_h(project_obj, project: project)
|
128
|
+
end
|
129
|
+
|
118
130
|
private
|
119
131
|
|
132
|
+
# @return [Checkoff::Internal::ProjectHashes]
|
133
|
+
attr_reader :project_hashes
|
134
|
+
|
120
135
|
# @return [Asana::Client]
|
121
136
|
attr_reader :client
|
122
137
|
|
data/lib/checkoff/tasks.rb
CHANGED
@@ -86,6 +86,19 @@ module Checkoff
|
|
86
86
|
timing.in_period?(task_date_or_time, period)
|
87
87
|
end
|
88
88
|
|
89
|
+
# @param task [Asana::Resources::Task]
|
90
|
+
# @param field_name [Symbol,Array]
|
91
|
+
# :start - start_at or start_on (first set)
|
92
|
+
# :due - due_at or due_on (first set)
|
93
|
+
# :ready - start_at or start_on or due_at or due_on (first set)
|
94
|
+
# :modified - modified_at
|
95
|
+
# [:custom_field, "foo"] - 'Date' custom field type named 'foo'
|
96
|
+
#
|
97
|
+
# @return [Date, Time, nil]
|
98
|
+
def date_or_time_field_by_name(task, field_name)
|
99
|
+
task_timing.date_or_time_field_by_name(task, field_name)
|
100
|
+
end
|
101
|
+
|
89
102
|
# Pull a specific task by name
|
90
103
|
#
|
91
104
|
# @param workspace_name [String]
|
@@ -193,6 +206,13 @@ module Checkoff
|
|
193
206
|
task_hashes.task_to_h(task)
|
194
207
|
end
|
195
208
|
|
209
|
+
# @param task_data [Hash]
|
210
|
+
#
|
211
|
+
# @return [Asana::Resources::Task]
|
212
|
+
def h_to_task(task_data)
|
213
|
+
Asana::Resources::Task.new(task_data, client: client)
|
214
|
+
end
|
215
|
+
|
196
216
|
# True if the task is in a project which is in the given portfolio
|
197
217
|
#
|
198
218
|
# @param task [Asana::Resources::Task]
|
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.
|
4
|
+
version: 0.114.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-10-
|
11
|
+
date: 2023-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- lib/checkoff/custom_fields.rb
|
134
134
|
- lib/checkoff/internal/config_loader.rb
|
135
135
|
- lib/checkoff/internal/create-class.sh
|
136
|
+
- lib/checkoff/internal/project_hashes.rb
|
136
137
|
- lib/checkoff/internal/project_selector_evaluator.rb
|
137
138
|
- lib/checkoff/internal/search_url.rb
|
138
139
|
- lib/checkoff/internal/search_url/custom_field_param_converter.rb
|