checkoff 0.99.0 → 0.100.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: f0aa9c88e96e1094d284c59a9c7146ff72f393f2e16442c8e320b3253ab0221d
4
- data.tar.gz: 7f6021289d7fb0e331cb6b993b10307287c365d9a00d5fbe789e5b6c13972dad
3
+ metadata.gz: c1944705f29ddc4dab95bb2c056b55c3aa6417cab26ca036a5493612663a4614
4
+ data.tar.gz: 299262b20e9331ee86755c8fced359e62889e34f1fb714c694535167356c2793
5
5
  SHA512:
6
- metadata.gz: ab4476c149bf918e5d138f71a5d1c5df78192f3fa3fa13e8ef0e8a2d7c7198b34268a78ab14e6009237d3cf0113316f3ff91222d22893606c5ecc1ab31830d55
7
- data.tar.gz: 4f804bcfc9548b7106fcd80c5764da4250bf024e9dc7f1c2b95460078b89de3a238ba2b28f6d44188cd3fee074a0d348925ef780b751534a0f801f08b74fab24
6
+ metadata.gz: f84b26f7790beb97d9f2467b00bead09cd59f60c57e448442892304bbbf7acd6c72c299ee2c890762d9682df76efcf203d5ff3b4442d88d8871b117006a18a83
7
+ data.tar.gz: b1478b9ac625f873fa32ab444facf710ac7246b118927fd3347ed0867ca182cb757ec8b12cbb83a29e4d00882647b6df45a93c2758fb2e4c1ebad5983b13b724
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.99.0)
15
+ checkoff (0.100.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -114,7 +114,7 @@ module Checkoff
114
114
  end
115
115
  end
116
116
 
117
- # :ready_between_n_days function
117
+ # :ready_between_relative function
118
118
  class ReadyBetweenRelativePFunctionEvaluator < FunctionEvaluator
119
119
  FUNCTION_NAME = :ready_between_relative
120
120
 
@@ -134,24 +134,34 @@ module Checkoff
134
134
  #
135
135
  # @return [Boolean]
136
136
  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)
137
154
  beginning_n_days_from_now_time = (Time.now + (beginning_num_days_from_now * 24 * 60 * 60))
138
155
  end_n_days_from_now_time = (Time.now + (end_num_days_from_now * 24 * 60 * 60))
139
156
 
140
157
  # @type [Date, Time, nil]
141
- task_date_or_time = @task_timing.date_or_time_field_by_name(task, :start) ||
142
- @task_timing.date_or_time_field_by_name(task, :due)
158
+ ready_date_or_time = @task_timing.date_or_time_field_by_name(task, :ready)
143
159
 
144
- return false if task_date_or_time.nil?
160
+ return false if ready_date_or_time.nil?
145
161
 
146
- # if time
147
- in_range = if task_date_or_time.is_a?(Time)
148
- task_date_or_time > beginning_n_days_from_now_time &&
149
- task_date_or_time <= end_n_days_from_now_time
150
- else
151
- # if date
152
- task_date_or_time > beginning_n_days_from_now_time.to_date &&
153
- task_date_or_time <= end_n_days_from_now_time.to_date
154
- end
162
+ in_range = ready_in_range?(ready_date_or_time,
163
+ beginning_n_days_from_now_time,
164
+ end_n_days_from_now_time)
155
165
 
156
166
  return false unless in_range
157
167
 
@@ -159,6 +169,17 @@ module Checkoff
159
169
 
160
170
  true
161
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
182
+ end
162
183
  end
163
184
 
164
185
  # :field_less_than_n_days_ago
@@ -59,6 +59,8 @@ module Checkoff
59
59
 
60
60
  return start_date_or_time(task) if field_name == :start
61
61
 
62
+ return start_date_or_time(task) || due_date_or_time(task) if field_name == :ready
63
+
62
64
  raise "Teach me how to handle field #{field_name}"
63
65
  end
64
66
  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.99.0'
6
+ VERSION = '0.100.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.99.0
4
+ version: 0.100.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz