checkoff 0.107.0 → 0.108.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: 9a3f9bd1bb8698f7f5a318fefbf79cc09cf17998177dfbbae762fb3be82e33d7
4
- data.tar.gz: 634e833fdb5f54c9f8a5e56411b4affb1a2d7384a1231a068bf77a8e37951088
3
+ metadata.gz: a6f58b9f4020d786886f43c7c3422b55b99143796be35fcccf7d46cc6d3369d8
4
+ data.tar.gz: 39b470be2c13d3e32d545f9914d935ee1fb8a8f2705e5cdb799a2ae2bab8bf71
5
5
  SHA512:
6
- metadata.gz: 950738387e7ecfe3652763452bca3dd79b39e3e8b8ca2618decacb77c04e6deb2d5b5680a272aacac5b46d97a75b53409a483bc339b13f8fd910c55d8ea0105a
7
- data.tar.gz: 176ac1780573b9fe89f97a75c9bddf4cc74b69833ee31ec60e0f684ef88a7ca4dafa5e5661e5c5aec78ce8e5392dc23e7b9f3022e7ef77c2e94b1cc5efd45300
6
+ metadata.gz: df03add2cd762e7e4ce70ec769d316d96b718f59eb418c340557822894f202d28b92796ae0d02e42b5e9e8d1f1ca607c294a4ce64ac92e71e1a6a556d4eeba72
7
+ data.tar.gz: 89ad98040c6ea65313d51206394f5af2ddcd2671a0b9ea403ecbf3466df564dbe7e09f64932838d7f8d06302d9abf9c29dd8f8dbaad28cf2342795269e5ec2f5
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.107.0)
15
+ checkoff (0.108.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -193,15 +193,7 @@ module Checkoff
193
193
  #
194
194
  # @return [Boolean]
195
195
  def evaluate(task, field_name, num_days)
196
- task_timing = Checkoff::Internal::TaskTiming.new
197
- date = task_timing.date_or_time_field_by_name(task, field_name)&.to_date
198
-
199
- return false if date.nil?
200
-
201
- # @sg-ignore
202
- n_days_from_today = Date.today + num_days
203
- # @sg-ignore
204
- date >= n_days_from_today
196
+ @tasks.in_period?(task, field_name, [:greater_than_or_equal_to_n_days_from_today, num_days])
205
197
  end
206
198
  end
207
199
 
@@ -30,13 +30,6 @@ module Checkoff
30
30
  @now_getter = now_getter
31
31
  end
32
32
 
33
- # @param date_or_time [Date,Time,nil]
34
- def now_or_before?(date_or_time)
35
- return true if date_or_time.nil?
36
-
37
- date_or_time.to_time < @now_getter.now
38
- end
39
-
40
33
  # @param date_or_time [Date,Time,nil]
41
34
  # @param period [Symbol,Array<(Symbol,Integer)>]
42
35
  #
@@ -54,8 +47,7 @@ module Checkoff
54
47
  period_name = period.first
55
48
  args = period[1..]
56
49
 
57
- # @sg-ignore
58
- return less_than_n_days_ago?(date_or_time, *args) if period_name == :less_than_n_days_ago
50
+ return compound_in_period?(date_or_time, period_name, *args)
59
51
  end
60
52
 
61
53
  raise "Teach me how to handle period #{period.inspect}"
@@ -63,6 +55,19 @@ module Checkoff
63
55
 
64
56
  private
65
57
 
58
+ # @param date_or_time [Date,Time,nil]
59
+ # @param num_days [Integer]
60
+ def greater_than_or_equal_to_n_days_from_today?(date_or_time, num_days)
61
+ return false if date_or_time.nil?
62
+
63
+ date = date_or_time.to_date
64
+
65
+ # @sg-ignore
66
+ n_days_from_today = @today_getter.today + num_days
67
+ # @sg-ignore
68
+ date >= n_days_from_today
69
+ end
70
+
66
71
  # @param date_or_time [Date,Time,nil]
67
72
  # @param num_days [Integer]
68
73
  def less_than_n_days_ago?(date_or_time, num_days)
@@ -93,6 +98,27 @@ module Checkoff
93
98
  date >= beginning_of_week && date <= end_of_week
94
99
  end
95
100
 
101
+ # @param date_or_time [Date,Time,nil]
102
+ def now_or_before?(date_or_time)
103
+ return true if date_or_time.nil?
104
+
105
+ date_or_time.to_time < @now_getter.now
106
+ end
107
+
108
+ # @param date_or_time [Date,Time,nil]
109
+ # @param period_name [Symbol]
110
+ # @param args [Object]
111
+ def compound_in_period?(date_or_time, period_name, *args)
112
+ # @sg-ignore
113
+ return less_than_n_days_ago?(date_or_time, *args) if period_name == :less_than_n_days_ago
114
+
115
+ if period_name == :greater_than_or_equal_to_n_days_from_today
116
+ return greater_than_or_equal_to_n_days_from_today?(date_or_time,
117
+ *args)
118
+ end
119
+ raise "Teach me how to handle period [#{period_name.inspect}, #{args.join(', ')}]"
120
+ end
121
+
96
122
  # bundle exec ./time.rb
97
123
  # :nocov:
98
124
  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.107.0'
6
+ VERSION = '0.108.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.107.0
4
+ version: 0.108.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz