checkoff 0.102.0 → 0.103.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: 4d8549d02934007d479b28d83262a32e060e6ada2033f5d5c9743210bf599e68
4
- data.tar.gz: 86f5d4ba266d1d60af237d428c50b0065e80ce233d8ed964e7af9cc2396e6ae3
3
+ metadata.gz: 18ab918128cd0d805829245306102209f7715f9dfa580a8861b4e97be7aa3b31
4
+ data.tar.gz: 0c40f9f30d1a0441de43140dcd442d783c7b6ae5e584e9b0ed23e13acbe5e35e
5
5
  SHA512:
6
- metadata.gz: 6e7d47b7d64ee0008783db1a0a460bc0a1865f361920ff136c85e95df6f1d4cf36f88fda44ce50cb0f7f81e5117800feef82874320d6453e4b525f734721fc2d
7
- data.tar.gz: 9c376fe5b386897f379f0b575423078fa0d4495ae953f05a5aeab6d794e3be6eac36a235f4d44d7e80313824de8110e246e7069abf3399f88c0a931eb709b60f
6
+ metadata.gz: 4b0ce332d7ee01af5680511dd1c7da6b7654f94b153b3240d344c64663ebc71ceaff79bc4ae2fb01846430904e167a36b81d55ac581f992524eef3dae50c6783
7
+ data.tar.gz: 738deef8848a424fe874711c874f83b70b14320b9df49a85da6b187da8e817887a3d3de9b63cc65411cf866e5813eb759d5c051eaf9b3c1d50726a98fa3dde33
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.102.0)
15
+ checkoff (0.103.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Checkoff
4
+ module Internal
5
+ # Determine whether a task is due within a relative date range
6
+ class ReadyBetweenRelative
7
+ # @param config [Hash<Symbol, Object>]
8
+ # @param clients [Checkoff::Clients]
9
+ # @param task_timing [Checkoff::Internal::TaskTiming]
10
+ # @param tasks [Checkoff::Tasks]
11
+ def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
12
+ clients: Checkoff::Clients.new(config: config),
13
+ task_timing: ::Checkoff::Internal::TaskTiming.new,
14
+ tasks: ::Checkoff::Tasks.new(config: config,
15
+ client: clients.client))
16
+ @task_timing = task_timing
17
+ @tasks = tasks
18
+ end
19
+
20
+ # @param task [Asana::Resources::Task]
21
+ # @param beginning_num_days_from_now [Integer]
22
+ # @param end_num_days_from_now [Integer]
23
+ # @param ignore_dependencies [Boolean]
24
+ #
25
+ # @return [Boolean]
26
+ def ready_between_relative?(task,
27
+ beginning_num_days_from_now,
28
+ end_num_days_from_now,
29
+ ignore_dependencies: false)
30
+ beginning_n_days_from_now_time = (Time.now + (beginning_num_days_from_now * 24 * 60 * 60))
31
+ end_n_days_from_now_time = (Time.now + (end_num_days_from_now * 24 * 60 * 60))
32
+
33
+ # @type [Date, Time, nil]
34
+ ready_date_or_time = @task_timing.date_or_time_field_by_name(task, :ready)
35
+
36
+ return false if ready_date_or_time.nil?
37
+
38
+ in_range = ready_in_range?(ready_date_or_time,
39
+ beginning_n_days_from_now_time,
40
+ end_n_days_from_now_time)
41
+
42
+ return false unless in_range
43
+
44
+ return false if !ignore_dependencies && @tasks.incomplete_dependencies?(task)
45
+
46
+ true
47
+ end
48
+
49
+ private
50
+
51
+ # @param ready_date_or_time [Date, Time]
52
+ # @param start_time [Time]
53
+ # @param end_time [Time]
54
+ def ready_in_range?(ready_date_or_time, start_time, end_time)
55
+ if ready_date_or_time.is_a?(Time)
56
+ ready_date_or_time > start_time && ready_date_or_time <= end_time
57
+ else
58
+ ready_date_or_time > start_time.to_date && ready_date_or_time <= end_time.to_date
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -17,7 +17,6 @@ module Checkoff
17
17
  @selector = selector
18
18
  @tasks = tasks
19
19
  @timelines = timelines
20
- @task_timing = ::Checkoff::Internal::TaskTiming.new
21
20
  super()
22
21
  end
23
22
 
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'task/function_evaluator'
4
+ require 'checkoff/internal/ready_between_relative'
4
5
 
5
6
  module Checkoff
6
7
  module SelectorClasses
@@ -134,51 +135,10 @@ module Checkoff
134
135
  #
135
136
  # @return [Boolean]
136
137
  def evaluate(task, beginning_num_days_from_now, end_num_days_from_now, ignore_dependencies: false)
137
- ready_between_relative?(task,
138
- beginning_num_days_from_now, end_num_days_from_now,
139
- ignore_dependencies: ignore_dependencies)
140
- end
141
-
142
- private
143
-
144
- # @param task [Asana::Resources::Task]
145
- # @param beginning_num_days_from_now [Integer]
146
- # @param end_num_days_from_now [Integer]
147
- # @param ignore_dependencies [Boolean]
148
- #
149
- # @return [Boolean]
150
- def ready_between_relative?(task,
151
- beginning_num_days_from_now,
152
- end_num_days_from_now,
153
- ignore_dependencies: false)
154
- beginning_n_days_from_now_time = (Time.now + (beginning_num_days_from_now * 24 * 60 * 60))
155
- end_n_days_from_now_time = (Time.now + (end_num_days_from_now * 24 * 60 * 60))
156
-
157
- # @type [Date, Time, nil]
158
- ready_date_or_time = @task_timing.date_or_time_field_by_name(task, :ready)
159
-
160
- return false if ready_date_or_time.nil?
161
-
162
- in_range = ready_in_range?(ready_date_or_time,
163
- beginning_n_days_from_now_time,
164
- end_n_days_from_now_time)
165
-
166
- return false unless in_range
167
-
168
- return false if !ignore_dependencies && @tasks.incomplete_dependencies?(task)
169
-
170
- true
171
- end
172
-
173
- # @param ready_date_or_time [Date, Time]
174
- # @param start_time [Time]
175
- # @param end_time [Time]
176
- def ready_in_range?(ready_date_or_time, start_time, end_time)
177
- if ready_date_or_time.is_a?(Time)
178
- ready_date_or_time > start_time && ready_date_or_time <= end_time
179
- else
180
- ready_date_or_time > start_time.to_date && ready_date_or_time <= end_time.to_date
181
- end
138
+ ready_between_relative = Checkoff::Internal::ReadyBetweenRelative.new(tasks: @tasks)
139
+ ready_between_relative.ready_between_relative?(task,
140
+ beginning_num_days_from_now, end_num_days_from_now,
141
+ ignore_dependencies: ignore_dependencies)
182
142
  end
183
143
  end
184
144
 
@@ -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.102.0'
6
+ VERSION = '0.103.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.102.0
4
+ version: 0.103.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz
@@ -134,6 +134,7 @@ files:
134
134
  - lib/checkoff/internal/config_loader.rb
135
135
  - lib/checkoff/internal/create-class.sh
136
136
  - lib/checkoff/internal/project_selector_evaluator.rb
137
+ - lib/checkoff/internal/ready_between_relative.rb
137
138
  - lib/checkoff/internal/search_url.rb
138
139
  - lib/checkoff/internal/search_url/custom_field_param_converter.rb
139
140
  - lib/checkoff/internal/search_url/custom_field_variant.rb