checkoff 0.52.0 → 0.53.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: c150952f6929705defdcfb0d506308ca1d5e285e732eb6715fcb9c03a78e8ad4
4
- data.tar.gz: ac88caf643edccda95c7fcf345e601bcee87f6f1e59b0af83136fe7194420766
3
+ metadata.gz: 70e5f767656e34b2431a2920a57ade34d64480f53d95855818bd607400ae9e60
4
+ data.tar.gz: 42b5dc27c71e1f0bb5772f00d8ae74947286f13e7bb319d9ae8ab2c8dbb06722
5
5
  SHA512:
6
- metadata.gz: 3d4a6454075c4e2332b3c59ca3f93b3358b77f77f8bf43e2c7e28f9a615d73b204edc3b1ac00b51acbe109355ae3b6a16b30944bd13ea6be653dc28e2e45d857
7
- data.tar.gz: 774fb7f8311cc540f762f36d30f79b59de16897105ae8a34496585a5c1c6e19353b37736b691b98b3bc447a88685bdd73db297dbaa23f2bde1b3d70f0ef47ab2
6
+ metadata.gz: 8327942085367d3501b77563121dab0935696550a46036da89f4662d59d5dd7acc9fa49930db08f3901a1468b05c5ab63a2f813ab56415c9f627887b585d8386
7
+ data.tar.gz: 6046d32bfd28b7805771be9854843821d0d84c2da3e49eac3df3f44d839169b073117870a38e67659e4f3ca0356151bcbfc4eb2feabbb7a6ffc88efe7917673b
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.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -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.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.52.0
4
+ version: 0.53.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz