checkoff 0.115.0 → 0.117.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40629a566b19445480126d856c41e4e409b52ae136c67360ee802cbe75c05b75
4
- data.tar.gz: bb76d2037eb04e1a0d4b14fc37796140f2392a5be87942033187d59c97b377e7
3
+ metadata.gz: 45425d3f07cc0fc1bf0e39a56a2f26c8777622953a3a75ae9d32ed758d0301ce
4
+ data.tar.gz: 456407b377fe6286909c23a0728f0d6954982c53b714610b7bd393a812dd4bfc
5
5
  SHA512:
6
- metadata.gz: 6cca167c8be76f96df2a87686398d9668883ecfb83bba2065b7729305e497bf116df281ce1f84c37dc90cfc7d366e94ad7ba83c2be1316591e2a4c2664cd0667
7
- data.tar.gz: 24eb191deaa41c2190a3dcd8f986e85d3f1e664fd17d560e0777c0242f930058dfbc5e2d51dcaa2daffa685a6f859987a15ea3e69f62b307dd38ff76a6120c88
6
+ metadata.gz: 622c7e1b6bb0d0f18f104c8b6b3d94240242a0528f73fceadd592e546a38b4bf2e0c36726729ba4d4d558068a2d9b200cdd0e1b8e79c25710bd471f445936b20
7
+ data.tar.gz: 258d4c6fca76db0bdbd3a1acdb8280c536c7ae788b77c9dcd7b0c2002b78b270b61237cc2a99c503354eff6816e58fc3b4ffbd179ec17d6aa179db6f84eb0d89
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.115.0)
15
+ checkoff (0.117.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -256,6 +256,22 @@ module Checkoff
256
256
  @tasks.in_portfolio_named?(task, portfolio_name)
257
257
  end
258
258
  end
259
+
260
+ # :last_task_milestone_does_not_depend_on_this_task? function
261
+ class LastTaskMilestoneDoesNotDependOnThisTaskPFunctionEvaluator < FunctionEvaluator
262
+ FUNCTION_NAME = :last_task_milestone_does_not_depend_on_this_task?
263
+
264
+ def matches?
265
+ fn?(selector, FUNCTION_NAME)
266
+ end
267
+
268
+ # @param task [Asana::Resources::Task]
269
+ #
270
+ # @return [Boolean]
271
+ def evaluate(task)
272
+ !@timelines.last_task_milestone_depends_on_this_task?(task)
273
+ end
274
+ end
259
275
  end
260
276
  end
261
277
  end
@@ -188,6 +188,18 @@ module Checkoff
188
188
  end
189
189
  end
190
190
 
191
+ # @param task [Asana::Resources::Task]
192
+ #
193
+ # @return [Array<Asana::Resources::Task>]
194
+ def all_dependent_tasks(task)
195
+ dependent_tasks = []
196
+ task.dependents.each do |dependent_task|
197
+ dependent_tasks << dependent_task
198
+ dependent_tasks += all_dependent_tasks(dependent_task)
199
+ end
200
+ dependent_tasks
201
+ end
202
+
191
203
  # Builds on the standard API representation of an Asana task with some
192
204
  # convenience keys:
193
205
  #
@@ -58,12 +58,32 @@ module Checkoff
58
58
  end
59
59
  end
60
60
 
61
+ # @param task [Asana::Resources::Task]
62
+ def last_task_milestone_depends_on_this_task?(task)
63
+ all_dependent_task_gids = @tasks.all_dependent_tasks(task).map(&:gid)
64
+ task.memberships.all? do |membership_data|
65
+ # @type [Hash{String => String}]
66
+ section_data = membership_data.fetch('section')
67
+ # @type [String]
68
+ section_gid = section_data.fetch('gid')
69
+
70
+ last_milestone = last_milestone_in_section(section_gid)
71
+
72
+ next false if last_milestone.nil?
73
+
74
+ next true if last_milestone.gid == task.gid
75
+
76
+ all_dependent_task_gids.include? last_milestone.gid
77
+ end
78
+ end
79
+
61
80
  # @param section_gid [String]
62
81
  #
63
82
  # @return [Asana::Resources::Task,nil]
64
83
  def last_milestone_in_section(section_gid)
65
84
  # @type [Array<Asana::Resources::Task>]
66
- task_list = @sections.tasks_by_section_gid(section_gid).to_a
85
+ task_list = @sections.tasks_by_section_gid(section_gid,
86
+ extra_fields: ['resource_subtype']).to_a
67
87
  last_task = task_list.last
68
88
  last_task&.resource_subtype == 'milestone' ? last_task : nil
69
89
  end
@@ -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.115.0'
6
+ VERSION = '0.117.0'
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: checkoff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.115.0
4
+ version: 0.117.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz