checkoff 0.52.0 → 0.53.1

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: c150952f6929705defdcfb0d506308ca1d5e285e732eb6715fcb9c03a78e8ad4
4
- data.tar.gz: ac88caf643edccda95c7fcf345e601bcee87f6f1e59b0af83136fe7194420766
3
+ metadata.gz: 234864e30843bb30b598e38ef8e2571a6b5f6bbf37f07db7af5d4249ffe8ada2
4
+ data.tar.gz: 4e2eef390cc3fca5a3022a816811acadfc710983ec96f288567d6892f7d08e22
5
5
  SHA512:
6
- metadata.gz: 3d4a6454075c4e2332b3c59ca3f93b3358b77f77f8bf43e2c7e28f9a615d73b204edc3b1ac00b51acbe109355ae3b6a16b30944bd13ea6be653dc28e2e45d857
7
- data.tar.gz: 774fb7f8311cc540f762f36d30f79b59de16897105ae8a34496585a5c1c6e19353b37736b691b98b3bc447a88685bdd73db297dbaa23f2bde1b3d70f0ef47ab2
6
+ metadata.gz: b035b186ac2b3fd74507020d165aa4b50c1c95d1a5848cbae0f579013dbf4fd6c6b0a3f648b00901544c525924ea7596009446777bb91db3ca5412fad6448136
7
+ data.tar.gz: c35c867d9aaac72f54355fb371ea298afb55ccf9502d6baca0f2bc928ca4a0896a3bd5c784c052a6f566852933fbac88dd51a2d0764e4940edd132b5d21f5c8d
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.52.0)
15
+ checkoff (0.53.1)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -22,7 +22,7 @@ PATH
22
22
  GEM
23
23
  remote: https://rubygems.org/
24
24
  specs:
25
- activesupport (7.0.7.2)
25
+ activesupport (7.0.8)
26
26
  concurrent-ruby (~> 1.0, >= 1.0.2)
27
27
  i18n (>= 1.6, < 2)
28
28
  minitest (>= 5.1)
@@ -36,7 +36,10 @@ module Checkoff
36
36
  validate_unit_not_provided!
37
37
 
38
38
  # Example value: 1702857600000
39
- after = Time.at(due_date_after.to_i / 1000).to_date
39
+ # +1 is because API seems to operate on inclusive ranges
40
+ # @type [Date]
41
+ # @sg-ignore
42
+ after = Time.at(due_date_after.to_i / 1000).to_date + 1
40
43
  [{ 'due_on.after' => after.to_s }, []]
41
44
  end
42
45
 
@@ -497,6 +497,47 @@ module Checkoff
497
497
  task_selector
498
498
  end
499
499
  end
500
+
501
+ # :estimate_exceeds_duration
502
+ class EstimateExceedsDurationFunctionEvaluator < FunctionEvaluator
503
+ FUNCTION_NAME = :estimate_exceeds_duration
504
+
505
+ def matches?
506
+ fn?(task_selector, FUNCTION_NAME)
507
+ end
508
+
509
+ # @param task [Asana::Resources::Task]
510
+ # @return [Float]
511
+ def calculate_allocated_hours(task)
512
+ due_on = nil
513
+ start_on = nil
514
+ start_on = Date.parse(task.start_on) unless task.start_on.nil?
515
+ due_on = Date.parse(task.due_on) unless task.due_on.nil?
516
+ allocated_hours = 8.0
517
+ # @sg-ignore
518
+ allocated_hours = (due_on - start_on + 1).to_i * 8.0 if start_on && due_on
519
+ allocated_hours
520
+ end
521
+
522
+ # @param task [Asana::Resources::Task]
523
+ # @return [Boolean]
524
+ def evaluate(task)
525
+ custom_field = pull_custom_field_by_name_or_raise(task, 'Estimated time')
526
+
527
+ # @sg-ignore
528
+ # @type [Integer, nil]
529
+ estimate_minutes = custom_field.fetch('number_value')
530
+
531
+ # no estimate set
532
+ return false if estimate_minutes.nil?
533
+
534
+ estimate_hours = estimate_minutes / 60.0
535
+
536
+ allocated_hours = calculate_allocated_hours(task)
537
+
538
+ estimate_hours > allocated_hours
539
+ end
540
+ end
500
541
  end
501
542
 
502
543
  # Evaluator task selectors against a task
@@ -527,6 +568,7 @@ module Checkoff
527
568
  Checkoff::TaskSelectorClasses::CustomFieldLessThanNDaysFromNowFunctionEvaluator,
528
569
  Checkoff::TaskSelectorClasses::CustomFieldGreaterThanOrEqualToNDaysFromNowFunctionEvaluator,
529
570
  Checkoff::TaskSelectorClasses::StringLiteralEvaluator,
571
+ Checkoff::TaskSelectorClasses::EstimateExceedsDurationFunctionEvaluator,
530
572
  ].freeze
531
573
 
532
574
  # @param task_selector [Array]
@@ -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.52.0'
6
+ VERSION = '0.53.1'
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.52.0
4
+ version: 0.53.1
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-09-04 00:00:00.000000000 Z
11
+ date: 2023-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport