checkoff 0.105.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: 4edf9b863abc88b80a990f28fa9a966eaff3d48b9ff267ff0f0c572ef20fda87
4
- data.tar.gz: e250e14a24ccc7463fc80dac424f9dc04eca6ff43522c8fc5795c4e8ea04390f
3
+ metadata.gz: 9a3f9bd1bb8698f7f5a318fefbf79cc09cf17998177dfbbae762fb3be82e33d7
4
+ data.tar.gz: 634e833fdb5f54c9f8a5e56411b4affb1a2d7384a1231a068bf77a8e37951088
5
5
  SHA512:
6
- metadata.gz: f9e5100c88fa3a02f678845db245ca271632015ba814c06c6d9cb795cbcf6f0988d7a57676163f66cdcc649c4542f628d91c467512e20531587d8e3391d2a20a
7
- data.tar.gz: 626ab57ad3597d651dfea7d41f2fd640286de88d2bfa79cc71c1dff2602db8ecb23536fb32b4e332d8e1f2130405e485f83a62e5e3638c4ced96ea67e1d464f0
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.105.0)
15
+ checkoff (0.107.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -74,17 +74,27 @@ module Checkoff
74
74
  end
75
75
 
76
76
  # :ready function
77
+ #
78
+ # See GLOSSARY.md and tasks.rb#task_ready? for more information.
77
79
  class ReadyFunctionEvaluator < FunctionEvaluator
78
80
  def matches?
79
81
  fn?(selector, :ready)
80
82
  end
81
83
 
84
+ # @param _index [Integer]
85
+ def evaluate_arg?(_index)
86
+ false
87
+ end
88
+
82
89
  # @param task [Asana::Resources::Task]
90
+ # @param period [Symbol<:now_or_before,:this_week>]
83
91
  # @param ignore_dependencies [Boolean]
84
92
  # @return [Boolean]
85
- def evaluate(task, ignore_dependencies: false)
86
- @tasks.task_ready?(task, ignore_dependencies: ignore_dependencies)
93
+ # rubocop:disable Style/OptionalBooleanParameter
94
+ def evaluate(task, period = :now_or_before, ignore_dependencies = false)
95
+ @tasks.task_ready?(task, period: period, ignore_dependencies: ignore_dependencies)
87
96
  end
97
+ # rubocop:enable Style/OptionalBooleanParameter
88
98
  end
89
99
 
90
100
  # :unassigned function
@@ -161,16 +171,7 @@ module Checkoff
161
171
  #
162
172
  # @return [Boolean]
163
173
  def evaluate(task, field_name, num_days)
164
- task_timing = Checkoff::Internal::TaskTiming.new
165
-
166
- date = task_timing.date_or_time_field_by_name(task, field_name)&.to_date
167
-
168
- return false if date.nil?
169
-
170
- # @sg-ignore
171
- n_days_ago = Date.today - num_days
172
- # @sg-ignore
173
- date < n_days_ago
174
+ @tasks.in_period?(task, field_name, [:less_than_n_days_ago, num_days])
174
175
  end
175
176
  end
176
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.105.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.105.0
4
+ version: 0.107.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz