checkoff 0.100.0 → 0.102.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: c1944705f29ddc4dab95bb2c056b55c3aa6417cab26ca036a5493612663a4614
4
- data.tar.gz: 299262b20e9331ee86755c8fced359e62889e34f1fb714c694535167356c2793
3
+ metadata.gz: 4d8549d02934007d479b28d83262a32e060e6ada2033f5d5c9743210bf599e68
4
+ data.tar.gz: 86f5d4ba266d1d60af237d428c50b0065e80ce233d8ed964e7af9cc2396e6ae3
5
5
  SHA512:
6
- metadata.gz: f84b26f7790beb97d9f2467b00bead09cd59f60c57e448442892304bbbf7acd6c72c299ee2c890762d9682df76efcf203d5ff3b4442d88d8871b117006a18a83
7
- data.tar.gz: b1478b9ac625f873fa32ab444facf710ac7246b118927fd3347ed0867ca182cb757ec8b12cbb83a29e4d00882647b6df45a93c2758fb2e4c1ebad5983b13b724
6
+ metadata.gz: 6e7d47b7d64ee0008783db1a0a460bc0a1865f361920ff136c85e95df6f1d4cf36f88fda44ce50cb0f7f81e5117800feef82874320d6453e4b525f734721fc2d
7
+ data.tar.gz: 9c376fe5b386897f379f0b575423078fa0d4495ae953f05a5aeab6d794e3be6eac36a235f4d44d7e80313824de8110e246e7069abf3399f88c0a931eb709b60f
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.100.0)
15
+ checkoff (0.102.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -63,6 +63,10 @@
63
63
  # # @return [String,nil]
64
64
  # def due_date; end
65
65
  # end
66
+ # class Portfolio
67
+ # # @return [Enumerable<Asana::Resources::Project>]
68
+ # def get_items(options = {}); end
69
+ # end
66
70
  # end
67
71
  # module Resources
68
72
  # class Workspace
@@ -394,6 +394,23 @@ module Checkoff
394
394
  limit_to_portfolio_gid: limit_to_portfolio_gid)
395
395
  end
396
396
  end
397
+
398
+ # :in_portfolio_named? function
399
+ class InPortfolioNamedFunctionEvaluator < FunctionEvaluator
400
+ FUNCTION_NAME = :in_portfolio_named?
401
+
402
+ def matches?
403
+ fn?(selector, FUNCTION_NAME)
404
+ end
405
+
406
+ # @param task [Asana::Resources::Task]
407
+ # @param portfolio_name [String]
408
+ #
409
+ # @return [Boolean]
410
+ def evaluate(task, portfolio_name)
411
+ @tasks.in_portfolio_named?(task, portfolio_name)
412
+ end
413
+ end
397
414
  end
398
415
  end
399
416
  end
@@ -78,6 +78,16 @@ module Checkoff
78
78
  end
79
79
  cache_method :portfolio_by_gid, SHORT_CACHE_TIME
80
80
 
81
+ # @param workspace_name [String]
82
+ # @param portfolio_name [String]
83
+ #
84
+ # @return [Enumerable<Asana::Resources::Project>]
85
+ def projects_in_portfolio(workspace_name, portfolio_name)
86
+ portfolio = portfolio_or_raise(workspace_name, portfolio_name)
87
+ portfolio.get_items
88
+ end
89
+ cache_method :projects_in_portfolio, LONG_CACHE_TIME
90
+
81
91
  private
82
92
 
83
93
  # @return [Checkoff::Workspaces]
@@ -3,6 +3,7 @@
3
3
  # frozen_string_literal: true
4
4
 
5
5
  require_relative 'sections'
6
+ require_relative 'portfolios'
6
7
  require_relative 'workspaces'
7
8
  require_relative 'internal/config_loader'
8
9
  require_relative 'internal/task_timing'
@@ -26,6 +27,7 @@ module Checkoff
26
27
  # @param client [Asana::Client]
27
28
  # @param workspaces [Checkoff::Workspaces]
28
29
  # @param sections [Checkoff::Sections]
30
+ # @param portfolios [Checkoff::Portfolios]
29
31
  # @param time_class [Class<Time>]
30
32
  # @param date_class [Class<Date>]
31
33
  # @param asana_task [Class<Asana::Resources::Task>]
@@ -35,6 +37,8 @@ module Checkoff
35
37
  client: client),
36
38
  sections: Checkoff::Sections.new(config: config,
37
39
  client: client),
40
+ portfolios: Checkoff::Portfolios.new(config: config,
41
+ client: client),
38
42
  time_class: Time,
39
43
  date_class: Date,
40
44
  asana_task: Asana::Resources::Task)
@@ -44,6 +48,7 @@ module Checkoff
44
48
  @date_class = date_class
45
49
  @asana_task = asana_task
46
50
  @client = client
51
+ @portfolios = portfolios
47
52
  @workspaces = workspaces
48
53
  end
49
54
 
@@ -71,6 +76,7 @@ module Checkoff
71
76
  end
72
77
 
73
78
  # Pull a specific task by name
79
+ #
74
80
  # @param workspace_name [String]
75
81
  # @param project_name [String, Symbol]
76
82
  # @param section_name [String, nil, Symbol]
@@ -93,7 +99,8 @@ module Checkoff
93
99
  end
94
100
  cache_method :task, SHORT_CACHE_TIME
95
101
 
96
- # Pull a specific task by name
102
+ # Pull a specific task by GID
103
+ #
97
104
  # @param task_gid [String]
98
105
  # @param extra_fields [Array<String>]
99
106
  # @return [Asana::Resources::Task, nil]
@@ -105,9 +112,12 @@ module Checkoff
105
112
  end
106
113
  cache_method :task_by_gid, SHORT_CACHE_TIME
107
114
 
115
+ # Add a task
116
+ #
108
117
  # @param name [String]
109
118
  # @param workspace_gid [String]
110
119
  # @param assignee_gid [String]
120
+ #
111
121
  # @return [Asana::Resources::Task]
112
122
  def add_task(name,
113
123
  workspace_gid: @workspaces.default_workspace_gid,
@@ -117,12 +127,17 @@ module Checkoff
117
127
  workspace: workspace_gid, name: name)
118
128
  end
119
129
 
130
+ # Return user-accessible URL for a task
131
+ #
120
132
  # @param task [Asana::Resources::Task]
133
+ #
121
134
  # @return [String] end-user URL to the task in question
122
135
  def url_of_task(task)
123
136
  "https://app.asana.com/0/0/#{task.gid}/f"
124
137
  end
125
138
 
139
+ # True if any of the task's dependencies are marked incomplete
140
+ #
126
141
  # @param task [Asana::Resources::Task]
127
142
  def incomplete_dependencies?(task)
128
143
  # Avoid a redundant fetch. Unfortunately, Ruby SDK allows
@@ -161,11 +176,29 @@ module Checkoff
161
176
  # task: String (name)
162
177
  #
163
178
  # @param task [Asana::Resources::Task]
179
+ #
164
180
  # @return [Hash]
165
181
  def task_to_h(task)
166
182
  task_hashes.task_to_h(task)
167
183
  end
168
184
 
185
+ # True if the task is in a project which is in the given portfolio
186
+ #
187
+ # @param task [Asana::Resources::Task]
188
+ # @param portfolio_name [String]
189
+ # @param workspace_name [String]
190
+ def in_portfolio_named?(task,
191
+ portfolio_name,
192
+ workspace_name: @workspaces.default_workspace.name)
193
+ portfolio_projects = @portfolios.projects_in_portfolio(workspace_name, portfolio_name)
194
+ task.memberships.any? do |membership|
195
+ project_gid = membership.fetch('project').fetch('gid')
196
+ portfolio_projects.any? do |portfolio_project|
197
+ portfolio_project.gid == project_gid
198
+ end
199
+ end
200
+ end
201
+
169
202
  private
170
203
 
171
204
  # @return [Checkoff::Internal::TaskTiming]
@@ -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.100.0'
6
+ VERSION = '0.102.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.100.0
4
+ version: 0.102.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-27 00:00:00.000000000 Z
11
+ date: 2023-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport