checkoff 0.113.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d2b22635f5b5c89add793da4b37ed9bdf3a1c943476fac5d8b16825d06491a6
4
- data.tar.gz: 1faf6e1ab7a7168cac91f888a62a03a638de20eb83e2f9c23ffce66828da44a4
3
+ metadata.gz: a87ae5e25697c0daa4fd48bb9eb16d79e2b253ab886b535bd41fc460e3b1d2a9
4
+ data.tar.gz: 3ae9f56d8e53390c87c0f1560d85f8f9c6ad37d3fb1236ce23bbafe2cdb6125c
5
5
  SHA512:
6
- metadata.gz: bec50f216ca19ca2820feffe1424de08ed95cdab7369e78971d42dbc9e69620e966b8a9e4b76d4a9e55e2cffd30b12cbf9579c4f1acc83cd99d7b9a95fa77248
7
- data.tar.gz: db6380ac15afc8fce0aada0179b8ae3e9a4bf303c6df7086010c1aaab6d58af848ccba62563fcacff6884dc6dd1c2821e83d63a8a37188ab10a6e31dbe04a35b
6
+ metadata.gz: b227e5768678060e3ce4c3992937ff0e7bb0c6a9099b828fc577da123b48a6d070d75c3aa6c383509fe78b98777bc8e0ee246a54a254dbd7b1ea0de2abf411cc
7
+ data.tar.gz: b999dd5ab7a0d58c010c43231664bbe30efe617f4836a572ae146dde1cbe9f8d6bddf46598ec490327e6a8f7f86a6f4ff5c34d909bb06ddcd6a003336607e29c
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.113.0)
15
+ checkoff (0.114.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -6,8 +6,6 @@ underscored_plural_name="${1:?underscored plural name of entities minus .rb}"
6
6
  class_name="${2:?class name without Checkoff:: prefix}"
7
7
 
8
8
  cat > "${underscored_plural_name}.rb" << EOF
9
- #!/usr/bin/env ruby
10
-
11
9
  # frozen_string_literal: true
12
10
 
13
11
  module Checkoff
@@ -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
@@ -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.get_items
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]
@@ -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
 
@@ -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.113.0'
6
+ VERSION = '0.114.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.113.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-30 00:00:00.000000000 Z
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