checkoff 0.28.0 → 0.29.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: bc77ff8291abdf8396b00f06b6a264aced462d4017962f22b12be600ca0838e7
4
- data.tar.gz: 04cd04ace148582a064b9eb52fa46e738e8621effe5316f8e9dc75909564d3b2
3
+ metadata.gz: 20a21200031442f158e3d48a5a51cd9cbe58265c421a0463bbf4642655a35ec2
4
+ data.tar.gz: 04dc7d610ee4366d2f4df09cd7be9f65d369f62bb09e24b7f1193ac5b717291c
5
5
  SHA512:
6
- metadata.gz: 1aa7f83850fd0b422d1c9d2e9f0634da82bc16bfd9a84a0116b839921c64448de06b49a7c8af009bfce2c282d5c7b6f65b2cf7e5dc4fdef31724613984010c31
7
- data.tar.gz: 9317f20ab81c07d64ae5c955ffe345a2849ba966d5faf9de03d73e8712ddac3ad0d1d90ac70dc7af3af54dcf6a12ae48bb80aa8e4ec43eed4368942fae206b32
6
+ metadata.gz: 1ad9ef6eadc4292f4b8e9adf1f834cec57b83957eaf2b2adc1dd3577034a3799b7a4d0cf1b66150e838d8376b29b54837b94b1facfb9ce505ff3f32f56129169
7
+ data.tar.gz: efe36f401cf154c5a3f98873a9c3cff908963806ce87db080da81be702de2c2452d26599b994c6722889c7ffbc2d58a9009cba6c68f8780a71edb5c71342cc25
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.28.0)
15
+ checkoff (0.29.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -43,7 +43,7 @@ GEM
43
43
  concurrent-ruby (1.1.10)
44
44
  crack (0.4.5)
45
45
  rexml
46
- dalli (3.2.3)
46
+ dalli (3.2.4)
47
47
  diff-lcs (1.5.0)
48
48
  docile (1.4.0)
49
49
  fakeweb (1.3.0)
@@ -3,8 +3,10 @@
3
3
  module Checkoff
4
4
  # Base class to evaluate a task selector function given fully evaluated arguments
5
5
  class FunctionEvaluator
6
- def initialize(task_selector:)
6
+ def initialize(task_selector:,
7
+ tasks:)
7
8
  @task_selector = task_selector
9
+ @tasks = tasks
8
10
  end
9
11
 
10
12
  def evaluate_arg?(_index)
@@ -83,6 +85,17 @@ module Checkoff
83
85
  end
84
86
  end
85
87
 
88
+ # :due function
89
+ class DuePFunctionEvaluator < FunctionEvaluator
90
+ def matches?
91
+ fn?(task_selector, :due)
92
+ end
93
+
94
+ def evaluate(task)
95
+ @tasks.task_ready?(task)
96
+ end
97
+ end
98
+
86
99
  # :custom_field_value function
87
100
  class CustomFieldValueFunctionEvaluator < FunctionEvaluator
88
101
  def matches?
@@ -174,8 +187,10 @@ module Checkoff
174
187
 
175
188
  # Evaluator task selectors against a task
176
189
  class TaskSelectorEvaluator
177
- def initialize(task:)
190
+ def initialize(task:,
191
+ tasks: Checkoff::Tasks.new)
178
192
  @task = task
193
+ @tasks = tasks
179
194
  end
180
195
 
181
196
  FUNCTION_EVALUTORS = [
@@ -186,13 +201,15 @@ module Checkoff
186
201
  CustomFieldGidValueFunctionEvaluator,
187
202
  CustomFieldGidValueContainsAnyGidFunctionEvaluator,
188
203
  AndFunctionEvaluator,
204
+ DuePFunctionEvaluator,
189
205
  ].freeze
190
206
 
191
207
  def evaluate(task_selector)
192
208
  return true if task_selector == []
193
209
 
194
210
  FUNCTION_EVALUTORS.each do |evaluator_class|
195
- evaluator = evaluator_class.new(task_selector: task_selector)
211
+ evaluator = evaluator_class.new(task_selector: task_selector,
212
+ tasks: tasks)
196
213
 
197
214
  next unless evaluator.matches?
198
215
 
@@ -216,6 +233,6 @@ module Checkoff
216
233
  evaluator.evaluate(task, *evaluated_args)
217
234
  end
218
235
 
219
- attr_reader :task, :task_selector
236
+ attr_reader :task, :tasks, :task_selector
220
237
  end
221
238
  end
@@ -20,17 +20,23 @@ module Checkoff
20
20
  LONG_CACHE_TIME = MINUTE * 15
21
21
  SHORT_CACHE_TIME = MINUTE
22
22
 
23
- def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana))
23
+ def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
24
+ tasks: Checkoff::Tasks.new)
24
25
  @config = config
26
+ @tasks = tasks
25
27
  end
26
28
 
27
29
  # @param [Hash<Symbol, Object>] task_selector Filter based on
28
30
  # description. Examples: {tag: 'foo'} {:not {tag: 'foo'} (:tag 'foo')
29
31
  def filter_via_task_selector(task, task_selector)
30
- evaluator = TaskSelectorEvaluator.new(task: task)
32
+ evaluator = TaskSelectorEvaluator.new(task: task, tasks: tasks)
31
33
  evaluator.evaluate(task_selector)
32
34
  end
33
35
 
36
+ private
37
+
38
+ attr_reader :tasks
39
+
34
40
  # bundle exec ./task_selectors.rb
35
41
  # :nocov:
36
42
  class << self
@@ -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.28.0'
6
+ VERSION = '0.29.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.28.0
4
+ version: 0.29.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-02-06 00:00:00.000000000 Z
11
+ date: 2023-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport