checkoff 0.150.0 → 0.152.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: ff26e842716595b6b388bce568c5e65646535aa4ea7a88db6e375da53b0dd108
4
- data.tar.gz: c7195465fa94bea1970610c90314a966cea5523fcd285693a5f66c4906d1a818
3
+ metadata.gz: 84672143c6f2b9e08cd8be54cd4cf20d0bce2f56e72e9f2c98a7db3b48b690a3
4
+ data.tar.gz: 9e4cb2b6e73615e510cc169797d17f3d5552f5abb89be6a329b370219c79f647
5
5
  SHA512:
6
- metadata.gz: cd5fec3fc1dfe9e9237fb887fc069f783ed1d321c96e0ff5a031d9e377a7d34d27c06f385884062a0f11284f96d5b88e50c9ab9dc82e570805136a902f864120
7
- data.tar.gz: 24fbfffbf84845740afa19d6d4634d4deff06e86b9eadd23b1e978fb5a7be785c504e5cfab668903e0acfecb6454dc1d5c8c7fb75c604b3dfe3cb023746af0de
6
+ metadata.gz: f2b491d76c73456868a98511e2653842480cad9505fa844bdccfc75e71263305c1c68d7b5a178762fbfb25fedd55861249670e0ac273ccd1605cb47f6db78b36
7
+ data.tar.gz: e7acaa05c794fcf15e346eb95fb881fafa1f295e685687ec0425bc00561dc5c5d8d0eb9ebfad2c957af01d6ed387171c83f9f4c508e180d1e46ac2609e2ce2cc
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.150.0)
15
+ checkoff (0.152.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -52,6 +52,29 @@ module Checkoff
52
52
  end
53
53
  end
54
54
 
55
+ # :in_project_named? function
56
+ class InProjectNamedPFunctionEvaluator < FunctionEvaluator
57
+ def matches?
58
+ fn?(selector, :in_project_named?)
59
+ end
60
+
61
+ # @param _index [Integer]
62
+ def evaluate_arg?(_index)
63
+ false
64
+ end
65
+
66
+ # @sg-ignore
67
+ # @param task [Asana::Resources::Task]
68
+ # @param project_name [String]
69
+ # @return [Boolean]
70
+ def evaluate(task, project_name)
71
+ project_names = task.memberships.map do |membership|
72
+ membership.fetch('project').fetch('name')
73
+ end
74
+ project_names.include? project_name
75
+ end
76
+ end
77
+
55
78
  # :tag? function
56
79
  class TagPFunctionEvaluator < FunctionEvaluator
57
80
  def matches?
@@ -40,6 +40,9 @@ module Checkoff
40
40
  def in_period?(date_or_time, period)
41
41
  return this_week?(date_or_time) if period == :this_week
42
42
 
43
+ return day_of_week?(date_or_time, period) if %i[monday tuesday wednesday thursday friday saturday
44
+ sunday].include?(period)
45
+
43
46
  return true if period == :indefinite
44
47
 
45
48
  return now_or_before?(date_or_time) if period == :now_or_before
@@ -117,6 +120,28 @@ module Checkoff
117
120
  date >= beginning_of_week && date <= end_of_week
118
121
  end
119
122
 
123
+ # @type [Hash<Symbol,Integer>]
124
+ WDAY_FROM_DAY_OF_WEEK = {
125
+ monday: 1,
126
+ tuesday: 2,
127
+ wednesday: 3,
128
+ thursday: 4,
129
+ friday: 5,
130
+ saturday: 6,
131
+ sunday: 0,
132
+ }.freeze
133
+
134
+ # @param date_or_time [Date,Time,nil]
135
+ # @param day_of_week [Symbol]
136
+ def day_of_week?(date_or_time, day_of_week)
137
+ return false if date_or_time.nil?
138
+
139
+ wday = WDAY_FROM_DAY_OF_WEEK.fetch(day_of_week)
140
+ today = @today_getter.today
141
+ date = date_or_time.to_date
142
+ date_or_time.wday == wday && date >= today && date < today + 7
143
+ end
144
+
120
145
  # @param date_or_time [Date,Time,nil]
121
146
  def now_or_before?(date_or_time)
122
147
  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.150.0'
6
+ VERSION = '0.152.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.150.0
4
+ version: 0.152.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-12-06 00:00:00.000000000 Z
11
+ date: 2023-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport