checkoff 0.111.0 → 0.113.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: 6e758f72d1a6f7cd1c2dd5b6ebb4b52964e9fa2ee6e24f9e17aa613f6c6fe23b
4
- data.tar.gz: 9354f3874da0b13ec8662042475d60f67d0b67be9d22ddca07ee9938e81777f0
3
+ metadata.gz: 7d2b22635f5b5c89add793da4b37ed9bdf3a1c943476fac5d8b16825d06491a6
4
+ data.tar.gz: 1faf6e1ab7a7168cac91f888a62a03a638de20eb83e2f9c23ffce66828da44a4
5
5
  SHA512:
6
- metadata.gz: 6d5945f70f231c337708a252597ffb2623c9fdc7e96996ca1acfe6337ac1082f53fd3fcc2fc0ae8fcab75c3af4b0eed5e8e469eb8ef0537558d1dfb4e5e56d36
7
- data.tar.gz: e84eda5a4713bea660373ff2fc3829d861f61e4d88dd71b9127be5e077d0c9ca621fff32ec067e4890d37d1c65c67a47952f9e8478e129b3f2eae7a1c77443a6
6
+ metadata.gz: bec50f216ca19ca2820feffe1424de08ed95cdab7369e78971d42dbc9e69620e966b8a9e4b76d4a9e55e2cffd30b12cbf9579c4f1acc83cd99d7b9a95fa77248
7
+ data.tar.gz: db6380ac15afc8fce0aada0179b8ae3e9a4bf303c6df7086010c1aaab6d58af848ccba62563fcacff6884dc6dd1c2821e83d63a8a37188ab10a6e31dbe04a35b
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.111.0)
15
+ checkoff (0.113.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'task/function_evaluator'
4
- require 'checkoff/internal/ready_between_relative'
5
4
  require 'checkoff/internal/task_timing'
6
5
 
7
6
  module Checkoff
@@ -146,34 +145,6 @@ module Checkoff
146
145
  end
147
146
  end
148
147
 
149
- # :ready_between_relative function
150
- class ReadyBetweenRelativePFunctionEvaluator < FunctionEvaluator
151
- FUNCTION_NAME = :ready_between_relative
152
-
153
- def matches?
154
- fn?(selector, FUNCTION_NAME)
155
- end
156
-
157
- # @param _index [Integer]
158
- def evaluate_arg?(_index)
159
- false
160
- end
161
-
162
- # @param task [Asana::Resources::Task]
163
- # @param beginning_num_days_from_now [Integer]
164
- # @param end_num_days_from_now [Integer]
165
- # @param ignore_dependencies [Boolean]
166
- #
167
- # @return [Boolean]
168
- def evaluate(task, beginning_num_days_from_now, end_num_days_from_now, ignore_dependencies: false)
169
- ready_between_relative = Checkoff::Internal::ReadyBetweenRelative.new(tasks: @tasks,
170
- client: @client)
171
- ready_between_relative.ready_between_relative?(task,
172
- beginning_num_days_from_now, end_num_days_from_now,
173
- ignore_dependencies: ignore_dependencies)
174
- end
175
- end
176
-
177
148
  # :last_story_created_less_than_n_days_ago function
178
149
  class LastStoryCreatedLessThanNDaysAgoFunctionEvaluator < FunctionEvaluator
179
150
  FUNCTION_NAME = :last_story_created_less_than_n_days_ago
@@ -76,7 +76,7 @@ module Checkoff
76
76
  end
77
77
 
78
78
  # @param task [Asana::Resources::Task]
79
- # @param field_name [Symbol]
79
+ # @param field_name [Symbol,Array]
80
80
  #
81
81
  # @sg-ignore
82
82
  # @return [Date, Time, nil]
@@ -86,6 +86,19 @@ module Checkoff
86
86
  timing.in_period?(task_date_or_time, period)
87
87
  end
88
88
 
89
+ # @param task [Asana::Resources::Task]
90
+ # @param field_name [Symbol,Array]
91
+ # :start - start_at or start_on (first set)
92
+ # :due - due_at or due_on (first set)
93
+ # :ready - start_at or start_on or due_at or due_on (first set)
94
+ # :modified - modified_at
95
+ # [:custom_field, "foo"] - 'Date' custom field type named 'foo'
96
+ #
97
+ # @return [Date, Time, nil]
98
+ def date_or_time_field_by_name(task, field_name)
99
+ task_timing.date_or_time_field_by_name(task, field_name)
100
+ end
101
+
89
102
  # Pull a specific task by name
90
103
  #
91
104
  # @param workspace_name [String]
@@ -193,6 +206,13 @@ module Checkoff
193
206
  task_hashes.task_to_h(task)
194
207
  end
195
208
 
209
+ # @param task_data [Hash]
210
+ #
211
+ # @return [Asana::Resources::Task]
212
+ def h_to_task(task_data)
213
+ Asana::Resources::Task.new(task_data, client: client)
214
+ end
215
+
196
216
  # True if the task is in a project which is in the given portfolio
197
217
  #
198
218
  # @param task [Asana::Resources::Task]
@@ -73,8 +73,7 @@ module Checkoff
73
73
  def greater_than_or_equal_to_n_days_from_now?(date_or_time, num_days)
74
74
  return false if date_or_time.nil?
75
75
 
76
- n_days_from_now = (@now_getter.now + (num_days * 24 * 60 * 60))
77
- date_or_time >= n_days_from_now
76
+ date_or_time >= n_days_from_now(num_days)
78
77
  end
79
78
 
80
79
  # @param date_or_time [Date,Time,nil]
@@ -95,8 +94,7 @@ module Checkoff
95
94
  def less_than_n_days_from_now?(date_or_time, num_days)
96
95
  return false if date_or_time.nil?
97
96
 
98
- n_days_from_now = (@now_getter.now + (num_days * 24 * 60 * 60))
99
- date_or_time < n_days_from_now
97
+ date_or_time < n_days_from_now(num_days)
100
98
  end
101
99
 
102
100
  # @param date_or_time [Date,Time,nil]
@@ -123,6 +121,29 @@ module Checkoff
123
121
  date_or_time.to_time < @now_getter.now
124
122
  end
125
123
 
124
+ # @param num_days [Integer]
125
+ #
126
+ # @return [Time]
127
+ def n_days_from_now(num_days)
128
+ (@now_getter.now + (num_days * 24 * 60 * 60))
129
+ end
130
+
131
+ # @param date_or_time [Date,Time,nil]
132
+ # @param beginning_num_days_from_now [Integer,nil]
133
+ # @param end_num_days_from_now [Integer,nil]
134
+ def between_relative_days?(date_or_time, beginning_num_days_from_now, end_num_days_from_now)
135
+ start_time = n_days_from_now(beginning_num_days_from_now || -99_999)
136
+ end_time = n_days_from_now(end_num_days_from_now || 99_999)
137
+
138
+ return false if date_or_time.nil?
139
+
140
+ if date_or_time.is_a?(Time)
141
+ date_or_time > start_time && date_or_time <= end_time
142
+ else
143
+ date_or_time > start_time.to_date && date_or_time <= end_time.to_date
144
+ end
145
+ end
146
+
126
147
  # @param date_or_time [Date,Time,nil]
127
148
  # @param period_name [Symbol]
128
149
  # @param args [Object]
@@ -133,15 +154,17 @@ module Checkoff
133
154
  return less_than_n_days_from_now?(date_or_time, *args) if period_name == :less_than_n_days_from_now
134
155
 
135
156
  if period_name == :greater_than_or_equal_to_n_days_from_now
136
- return greater_than_or_equal_to_n_days_from_now?(date_or_time,
137
- *args)
157
+ return greater_than_or_equal_to_n_days_from_now?(date_or_time, *args)
138
158
  end
139
159
 
140
160
  if period_name == :greater_than_or_equal_to_n_days_from_today
141
161
  return greater_than_or_equal_to_n_days_from_today?(date_or_time, *args)
142
162
  end
143
163
 
144
- raise "Teach me how to handle period [#{period_name.inspect}, #{args.join(', ')}]"
164
+ # @sg-ignore
165
+ return between_relative_days?(date_or_time, *args) if period_name == :between_relative_days
166
+
167
+ raise "Teach me how to handle period [#{period_name.inspect}, #{args.map(&:inspect).join(', ')}]"
145
168
  end
146
169
 
147
170
  # bundle exec ./time.rb
@@ -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.111.0'
6
+ VERSION = '0.113.0'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: checkoff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.111.0
4
+ version: 0.113.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-29 00:00:00.000000000 Z
11
+ date: 2023-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -134,7 +134,6 @@ 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
138
137
  - lib/checkoff/internal/search_url.rb
139
138
  - lib/checkoff/internal/search_url/custom_field_param_converter.rb
140
139
  - lib/checkoff/internal/search_url/custom_field_variant.rb
@@ -1,63 +0,0 @@
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 client [Asana::Client]
9
- # @param task_timing [Checkoff::Internal::TaskTiming]
10
- # @param tasks [Checkoff::Tasks]
11
- def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
12
- client: Checkoff::Clients.new(config: config).client,
13
- task_timing: ::Checkoff::Internal::TaskTiming.new(client: client),
14
- tasks: ::Checkoff::Tasks.new(config: config,
15
- client: 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