checkoff 0.111.0 → 0.112.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: 6e758f72d1a6f7cd1c2dd5b6ebb4b52964e9fa2ee6e24f9e17aa613f6c6fe23b
4
- data.tar.gz: 9354f3874da0b13ec8662042475d60f67d0b67be9d22ddca07ee9938e81777f0
3
+ metadata.gz: 393a800af57dad5fa9edde789dbe166b09ad79b374c2f7dcab230ee0050c49e7
4
+ data.tar.gz: a2e852b005e952bacf694e0684c97db27a0e53e2e68d79b471d7a2a8d66939ce
5
5
  SHA512:
6
- metadata.gz: 6d5945f70f231c337708a252597ffb2623c9fdc7e96996ca1acfe6337ac1082f53fd3fcc2fc0ae8fcab75c3af4b0eed5e8e469eb8ef0537558d1dfb4e5e56d36
7
- data.tar.gz: e84eda5a4713bea660373ff2fc3829d861f61e4d88dd71b9127be5e077d0c9ca621fff32ec067e4890d37d1c65c67a47952f9e8478e129b3f2eae7a1c77443a6
6
+ metadata.gz: 12769031da94bd1a7afc9afeccededab8f19506201f14c29d97cbacba7b3c0574f73d1a2bf52e9d6e511249d8f946d42295a110f0ef59f575e8d26eb6337377f
7
+ data.tar.gz: 6395b5b368b7b74a0173d4a62b5e55188348b9c8293865cba02163f7d9a85ede6d6a139ab001f74eaf7acd13b431af341bac7eddc5cff87ec780c4e67f6a7207
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.112.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
@@ -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.112.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.111.0
4
+ version: 0.112.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz
@@ -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