checkoff 0.104.0 → 0.106.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: b6d308b4ca05ee88bf3b380772496d9c621cc7b9f521b4cf19eb1351395ed2b2
4
- data.tar.gz: eb14bb0c6f4dabd72e083ce67a5c3c821be931ac268f3202445714da9ae713aa
3
+ metadata.gz: d1113a5ffbcd7bbe80ffd702559e8be32741468c788b26b976d8bb33ce50c06b
4
+ data.tar.gz: 91fb42cdc5620a932033d43eab190c46191c11794004b358a92bc6e40f97818d
5
5
  SHA512:
6
- metadata.gz: 28983082df6a4c00e31fb3f458a6bafc0241920d4f1b5657e6ce3613d86127b0df6561defde8669a9ead845e2ef7d77c10ec1d45603c55d17fe735c5d3d5e716
7
- data.tar.gz: dc877bc157ed76157327c2e094ff69ff4074275eaa9df93ec9d3fdf8bc67969c4402503ee9435bcf1305f489f0d7ab22f0b43129e69b0abe9e06064b4683f8e7
6
+ metadata.gz: 18746c467511ea53db664dd7194ce8b9aeb432ae4fac74911db3d775a921fb7abb9ee8e1ce16e83c2ad1e31b4baf9cf79efb180b827579f040007729f7a6fc20
7
+ data.tar.gz: 81645f19b209186e1e27d8d07bb5e9792eb9127462fa12af8518f71ee5baf2a8b721a2fe2060fb24ab4dc5291b817b27c8370e6b452e9c49a52b7cae3226567a
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.104.0)
15
+ checkoff (0.106.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:ensable Style/OptionalBooleanParameter
88
98
  end
89
99
 
90
100
  # :unassigned function
@@ -50,6 +50,7 @@ module Checkoff
50
50
  @client = client
51
51
  @portfolios = portfolios
52
52
  @workspaces = workspaces
53
+ @timing = Timing.new(today_getter: date_class, now_getter: time_class)
53
54
  end
54
55
 
55
56
  # Indicates a task is ready for a person to work on it. This is
@@ -63,16 +64,16 @@ module Checkoff
63
64
  # * start at is before now
64
65
  #
65
66
  # @param task [Asana::Resources::Task]
67
+ # @param period [Symbol<:now_or_before,:this_week>]
66
68
  # @param ignore_dependencies [Boolean]
67
- def task_ready?(task, ignore_dependencies: false)
69
+ def task_ready?(task, period: :now_or_before, ignore_dependencies: false)
70
+ field_name = :ready
68
71
  return false if !ignore_dependencies && incomplete_dependencies?(task)
69
72
 
70
- start = task_timing.start_time(task)
71
- due = task_timing.due_time(task)
73
+ # @type [Date,Time,nil]
74
+ task_date_or_time = task_timing.date_or_time_field_by_name(task, field_name)
72
75
 
73
- return true if start.nil? && due.nil?
74
-
75
- (start || due) < @time_class.now
76
+ timing.in_period?(task_date_or_time, period)
76
77
  end
77
78
 
78
79
  # Pull a specific task by name
@@ -236,6 +237,9 @@ module Checkoff
236
237
  # @return [Asana::Client]
237
238
  attr_reader :client
238
239
 
240
+ # @return [Checkoff::Timing]
241
+ attr_reader :timing
242
+
239
243
  # @return [Checkoff::Projects]
240
244
  def projects
241
245
  @projects ||= @sections.projects
@@ -23,24 +23,38 @@ module Checkoff
23
23
  SHORT_CACHE_TIME = MINUTE
24
24
 
25
25
  # @param today_getter [Class<Date>]
26
- def initialize(today_getter: Date)
26
+ # @param now_getter [Class<Time>]
27
+ def initialize(today_getter: Date,
28
+ now_getter: Time)
27
29
  @today_getter = today_getter
30
+ @now_getter = now_getter
28
31
  end
29
32
 
30
- # @param date [Date]
33
+ # @param date_or_time [Date,Time,nil]
34
+ def now_or_before?(date_or_time)
35
+ return true if date_or_time.nil?
36
+
37
+ date_or_time.to_time < @now_getter.now
38
+ end
39
+
40
+ # @param date_or_time [Date,Time,nil]
31
41
  # @param period [Symbol<:indefinite>]
32
- def in_period?(date, period)
33
- return this_week?(date) if period == :this_week
42
+ def in_period?(date_or_time, period)
43
+ return this_week?(date_or_time) if period == :this_week
34
44
 
35
45
  return true if period == :indefinite
36
46
 
47
+ return now_or_before?(date_or_time) if period == :now_or_before
48
+
37
49
  raise "Teach me how to handle period #{period.inspect}"
38
50
  end
39
51
 
40
52
  private
41
53
 
42
- # @param date [Date]
43
- def this_week?(date)
54
+ # @param date_or_time [Date,Time,nil]
55
+ def this_week?(date_or_time)
56
+ return true if date_or_time.nil?
57
+
44
58
  today = @today_getter.today
45
59
 
46
60
  # Beginning of this week (assuming week starts on Sunday)
@@ -49,6 +63,8 @@ module Checkoff
49
63
  # End of this week (assuming week ends on Saturday)
50
64
  end_of_week = beginning_of_week + 6
51
65
 
66
+ date = date_or_time.to_date
67
+
52
68
  date >= beginning_of_week && date <= end_of_week
53
69
  end
54
70
 
@@ -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.104.0'
6
+ VERSION = '0.106.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.104.0
4
+ version: 0.106.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz