checkoff 0.134.0 → 0.136.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: 774ff63fdebd9187b4aedf1cad2ee5ba52c4d7f5d582747b0414e698c6c31d9d
4
- data.tar.gz: de61ee88dc1e575702bbe15df6fcd0e70738a3b0f5ffb10654633260831c9923
3
+ metadata.gz: 5e9b8a139f08b5a53da99f785ac0e57bed14e919e43cc56ecf929c3558e4b567
4
+ data.tar.gz: 524fd6f5a31e9737403610de5b5e6ae42671e8f157702feeeec79f1154b99c1a
5
5
  SHA512:
6
- metadata.gz: 767386a4cb59daf9085a545e1e6bb8b76d01ac374785c2c574a285142b0531ebf1c3c7f930b3d104262452bdb1975b8158a2906d157cc88b46bce0852fd357e9
7
- data.tar.gz: c3f95457b476ff66133dba010920db1feee0f27f98fa35ed92246b677dde95f17fd8347b91de6aa63f2777c2dcebef061a8d5aefaf85638e4c321009b68185d6
6
+ metadata.gz: df7a2327a7a1e63e15342dadcc6fded785de79c867bc4d9cf0de9b3d0c3c57d639c0908002162a188cd0fa261108b91a33788fd29f159f99f2f4139774f1a636
7
+ data.tar.gz: 55ffabad75909f3475ef78d702d6606be979dbce8ecbb3521133ec225651cdb53481ae4e5ddc571b587dbf88b63a1a7e78b3a7b271b43fa49169c15d80b26bad
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.134.0)
15
+ checkoff (0.136.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -127,11 +127,16 @@ module Checkoff
127
127
  #
128
128
  # @param task_gid [String]
129
129
  # @param extra_fields [Array<String>]
130
+ # @param only_uncompleted [Boolean]
131
+ #
130
132
  # @return [Asana::Resources::Task, nil]
131
133
  def task_by_gid(task_gid,
132
- extra_fields: [])
134
+ extra_fields: [],
135
+ only_uncompleted: false)
136
+ # @type [Hash]
133
137
  options = projects.task_options.fetch(:options, {})
134
138
  options[:fields] += extra_fields
139
+ options[:completed_since] = '9999-12-01' if only_uncompleted
135
140
  client.tasks.find_by_id(task_gid, options: options)
136
141
  end
137
142
  cache_method :task_by_gid, SHORT_CACHE_TIME
@@ -182,9 +187,10 @@ module Checkoff
182
187
  # the completion status of dependencies, so we need to do this
183
188
  # regardless:
184
189
  parent_task_gid = parent_task_info.fetch('gid')
185
- parent_task = @asana_task.find_by_id(client, parent_task_gid,
186
- options: { fields: ['completed'] })
187
- !parent_task.completed
190
+
191
+ parent_task = task_by_gid(parent_task_gid,
192
+ only_uncompleted: false)
193
+ parent_task.completed_at.nil?
188
194
  end
189
195
  end
190
196
 
@@ -9,6 +9,7 @@ require 'active_support'
9
9
  require 'forwardable'
10
10
  require 'cache_method'
11
11
  require_relative 'internal/config_loader'
12
+ require_relative 'internal/logging'
12
13
  require_relative 'workspaces'
13
14
  require_relative 'clients'
14
15
 
@@ -22,6 +23,8 @@ module Checkoff
22
23
  LONG_CACHE_TIME = MINUTE * 15
23
24
  SHORT_CACHE_TIME = MINUTE
24
25
 
26
+ include Logging
27
+
25
28
  # @param today_getter [Class<Date>]
26
29
  # @param now_getter [Class<Time>]
27
30
  def initialize(today_getter: Date,
@@ -128,20 +131,35 @@ module Checkoff
128
131
  (@now_getter.now + (num_days * 24 * 60 * 60))
129
132
  end
130
133
 
134
+ # @param num_days [Integer]
135
+ #
136
+ # @return [Date]
137
+ def n_days_from_today(num_days)
138
+ (@today_getter.today + num_days)
139
+ end
140
+
131
141
  # @param date_or_time [Date,Time,nil]
132
142
  # @param beginning_num_days_from_now [Integer,nil]
133
143
  # @param end_num_days_from_now [Integer,nil]
134
144
  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)
145
+ start_date = n_days_from_today(beginning_num_days_from_now || -99_999)
146
+ end_date = n_days_from_today(end_num_days_from_now || 99_999)
137
147
 
138
148
  return false if date_or_time.nil?
139
149
 
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
150
+ date = if date_or_time.is_a?(Time)
151
+ date_or_time.localtime.to_date
152
+ else
153
+ date_or_time
154
+ end
155
+ out = date > start_date && date <= end_date
156
+ logger.debug do
157
+ "Checkoff::Timing#between_relative_days?(#{date_or_time.inspect} " \
158
+ "(as date: #{date.inspect}) " \
159
+ "#{beginning_num_days_from_now.inspect}, #{end_num_days_from_now.inspect}) " \
160
+ "comparing with #{start_date} and #{end_date} = #{out.inspect}"
144
161
  end
162
+ out
145
163
  end
146
164
 
147
165
  # @param date_or_time [Date,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.134.0'
6
+ VERSION = '0.136.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.134.0
4
+ version: 0.136.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-11-23 00:00:00.000000000 Z
11
+ date: 2023-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport