checkoff 0.106.0 → 0.107.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: d1113a5ffbcd7bbe80ffd702559e8be32741468c788b26b976d8bb33ce50c06b
4
- data.tar.gz: 91fb42cdc5620a932033d43eab190c46191c11794004b358a92bc6e40f97818d
3
+ metadata.gz: 9a3f9bd1bb8698f7f5a318fefbf79cc09cf17998177dfbbae762fb3be82e33d7
4
+ data.tar.gz: 634e833fdb5f54c9f8a5e56411b4affb1a2d7384a1231a068bf77a8e37951088
5
5
  SHA512:
6
- metadata.gz: 18746c467511ea53db664dd7194ce8b9aeb432ae4fac74911db3d775a921fb7abb9ee8e1ce16e83c2ad1e31b4baf9cf79efb180b827579f040007729f7a6fc20
7
- data.tar.gz: 81645f19b209186e1e27d8d07bb5e9792eb9127462fa12af8518f71ee5baf2a8b721a2fe2060fb24ab4dc5291b817b27c8370e6b452e9c49a52b7cae3226567a
6
+ metadata.gz: 950738387e7ecfe3652763452bca3dd79b39e3e8b8ca2618decacb77c04e6deb2d5b5680a272aacac5b46d97a75b53409a483bc339b13f8fd910c55d8ea0105a
7
+ data.tar.gz: 176ac1780573b9fe89f97a75c9bddf4cc74b69833ee31ec60e0f684ef88a7ca4dafa5e5661e5c5aec78ce8e5392dc23e7b9f3022e7ef77c2e94b1cc5efd45300
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.106.0)
15
+ checkoff (0.107.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -94,7 +94,7 @@ module Checkoff
94
94
  def evaluate(task, period = :now_or_before, ignore_dependencies = false)
95
95
  @tasks.task_ready?(task, period: period, ignore_dependencies: ignore_dependencies)
96
96
  end
97
- # rubocop:ensable Style/OptionalBooleanParameter
97
+ # rubocop:enable Style/OptionalBooleanParameter
98
98
  end
99
99
 
100
100
  # :unassigned function
@@ -171,16 +171,7 @@ module Checkoff
171
171
  #
172
172
  # @return [Boolean]
173
173
  def evaluate(task, field_name, num_days)
174
- task_timing = Checkoff::Internal::TaskTiming.new
175
-
176
- date = task_timing.date_or_time_field_by_name(task, field_name)&.to_date
177
-
178
- return false if date.nil?
179
-
180
- # @sg-ignore
181
- n_days_ago = Date.today - num_days
182
- # @sg-ignore
183
- date < n_days_ago
174
+ @tasks.in_period?(task, field_name, [:less_than_n_days_ago, num_days])
184
175
  end
185
176
  end
186
177
 
@@ -28,9 +28,9 @@ module Checkoff
28
28
  # @param clients [Checkoff::Clients]
29
29
  # @param client [Asana::Client]
30
30
  def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
31
- workspaces: Checkoff::Workspaces.new(config: config),
32
31
  clients: Checkoff::Clients.new(config: config),
33
- client: clients.client)
32
+ client: clients.client,
33
+ workspaces: Checkoff::Workspaces.new(config: config, client: client))
34
34
  @workspaces = workspaces
35
35
  @client = client
36
36
  end
@@ -67,9 +67,15 @@ module Checkoff
67
67
  # @param period [Symbol<:now_or_before,:this_week>]
68
68
  # @param ignore_dependencies [Boolean]
69
69
  def task_ready?(task, period: :now_or_before, ignore_dependencies: false)
70
- field_name = :ready
71
70
  return false if !ignore_dependencies && incomplete_dependencies?(task)
72
71
 
72
+ in_period?(task, :ready, period)
73
+ end
74
+
75
+ # @param task [Asana::Resources::Task]
76
+ # @param field_name [Symbol]
77
+ # @param period [Symbol<:now_or_before,:this_week>,Array] See Checkoff::Timing#in_period?_
78
+ def in_period?(task, field_name, period)
73
79
  # @type [Date,Time,nil]
74
80
  task_date_or_time = task_timing.date_or_time_field_by_name(task, field_name)
75
81
 
@@ -38,7 +38,9 @@ module Checkoff
38
38
  end
39
39
 
40
40
  # @param date_or_time [Date,Time,nil]
41
- # @param period [Symbol<:indefinite>]
41
+ # @param period [Symbol,Array<(Symbol,Integer)>]
42
+ #
43
+ # Valid values: :this_week, :now_or_before, :indefinite, [:less_than_n_days_ago, Integer]
42
44
  def in_period?(date_or_time, period)
43
45
  return this_week?(date_or_time) if period == :this_week
44
46
 
@@ -46,11 +48,34 @@ module Checkoff
46
48
 
47
49
  return now_or_before?(date_or_time) if period == :now_or_before
48
50
 
51
+ if period.is_a?(Array)
52
+ # @sg-ignore
53
+ # @type [Symbol]
54
+ period_name = period.first
55
+ args = period[1..]
56
+
57
+ # @sg-ignore
58
+ return less_than_n_days_ago?(date_or_time, *args) if period_name == :less_than_n_days_ago
59
+ end
60
+
49
61
  raise "Teach me how to handle period #{period.inspect}"
50
62
  end
51
63
 
52
64
  private
53
65
 
66
+ # @param date_or_time [Date,Time,nil]
67
+ # @param num_days [Integer]
68
+ def less_than_n_days_ago?(date_or_time, num_days)
69
+ return false if date_or_time.nil?
70
+
71
+ date = date_or_time.to_date
72
+
73
+ # @sg-ignore
74
+ n_days_ago = @today_getter.today - num_days
75
+ # @sg-ignore
76
+ date < n_days_ago
77
+ end
78
+
54
79
  # @param date_or_time [Date,Time,nil]
55
80
  def this_week?(date_or_time)
56
81
  return true if date_or_time.nil?
@@ -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.106.0'
6
+ VERSION = '0.107.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.106.0
4
+ version: 0.107.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz