checkoff 0.113.0 → 0.115.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/portfolios.rb +16 -2
- data/lib/checkoff/projects.rb +16 -1
- 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: 40629a566b19445480126d856c41e4e409b52ae136c67360ee802cbe75c05b75
|
4
|
+
data.tar.gz: bb76d2037eb04e1a0d4b14fc37796140f2392a5be87942033187d59c97b377e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cca167c8be76f96df2a87686398d9668883ecfb83bba2065b7729305e497bf116df281ce1f84c37dc90cfc7d366e94ad7ba83c2be1316591e2a4c2664cd0667
|
7
|
+
data.tar.gz: 24eb191deaa41c2190a3dcd8f986e85d3f1e664fd17d560e0777c0242f930058dfbc5e2d51dcaa2daffa685a6f859987a15ea3e69f62b307dd38ff76a6120c88
|
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/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.115.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
|