calendar-assistant 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/calendar_assistant/cli_helpers.rb +1 -0
- data/lib/calendar_assistant/event.rb +18 -2
- data/lib/calendar_assistant/event_repository.rb +2 -2
- data/lib/calendar_assistant/event_set.rb +6 -4
- data/lib/calendar_assistant/scheduler.rb +1 -1
- data/lib/calendar_assistant/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39a771f697de78e8be9e8189021c20f33e73cabbd6df2266d9961b030fb37f23
|
4
|
+
data.tar.gz: 3237fc5462cc02428052aa17ade6b3e3d01b3e2f566583f2c1ad12ca0f47cce8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 769547047722afdd06a38385e2dba228879483bf4e77cff6beae29243d69ddf6b7c1c5195263a9570b5cc4c9992a228de228fb110580ae8f0745bdaaed110981
|
7
|
+
data.tar.gz: d14e5743b960ebebabdf10afbbba97b5f501351f961c6327ee8971ebea7990dc65c5fccf230cb818915d9325c7e6f0869279cf3fc105161abffe9d1ef3ca0e26
|
@@ -189,6 +189,7 @@ class CalendarAssistant
|
|
189
189
|
attributes << "self" if event.self? && !event.private?
|
190
190
|
attributes << "1:1" if event.one_on_one?
|
191
191
|
attributes << "awaiting" if event.awaiting?
|
192
|
+
attributes << "tentative" if event.tentative?
|
192
193
|
end
|
193
194
|
|
194
195
|
attributes << event.visibility if event.explicit_visibility?
|
@@ -33,7 +33,14 @@ class CalendarAssistant
|
|
33
33
|
LOCATION_EVENT_REGEX = /^#{CalendarAssistant::EMOJI_WORLDMAP}/
|
34
34
|
|
35
35
|
#
|
36
|
-
# methods
|
36
|
+
# class methods
|
37
|
+
#
|
38
|
+
def self.duration_in_seconds start_time, end_time
|
39
|
+
(end_time.to_datetime - start_time.to_datetime).days.to_i
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# instance methods
|
37
44
|
#
|
38
45
|
def update **args
|
39
46
|
update!(**args)
|
@@ -80,6 +87,10 @@ class CalendarAssistant
|
|
80
87
|
response_status == CalendarAssistant::Event::Response::NEEDS_ACTION
|
81
88
|
end
|
82
89
|
|
90
|
+
def tentative?
|
91
|
+
response_status == CalendarAssistant::Event::Response::TENTATIVE
|
92
|
+
end
|
93
|
+
|
83
94
|
def self?
|
84
95
|
response_status == CalendarAssistant::Event::Response::SELF
|
85
96
|
end
|
@@ -161,13 +172,18 @@ class CalendarAssistant
|
|
161
172
|
return "#{days}d"
|
162
173
|
end
|
163
174
|
|
164
|
-
p = ActiveSupport::Duration.build(
|
175
|
+
p = ActiveSupport::Duration.build(duration_in_seconds).parts
|
165
176
|
s = []
|
166
177
|
s << "#{p[:hours]}h" if p.has_key?(:hours)
|
167
178
|
s << "#{p[:minutes]}m" if p.has_key?(:minutes)
|
168
179
|
s.join(" ")
|
169
180
|
end
|
170
181
|
|
182
|
+
|
183
|
+
def duration_in_seconds
|
184
|
+
Event.duration_in_seconds start_time, end_time
|
185
|
+
end
|
186
|
+
|
171
187
|
def human_attendees
|
172
188
|
return nil if attendees.nil?
|
173
189
|
attendees.select { |a| ! a.resource }
|
@@ -51,8 +51,8 @@ class CalendarAssistant
|
|
51
51
|
|
52
52
|
def available_block start_time, end_time
|
53
53
|
e = Google::Apis::CalendarV3::Event.new(
|
54
|
-
start: Google::Apis::CalendarV3::EventDateTime.new(date_time: start_time.in_time_zone(calendar.time_zone)),
|
55
|
-
end: Google::Apis::CalendarV3::EventDateTime.new(date_time: end_time.in_time_zone(calendar.time_zone)),
|
54
|
+
start: Google::Apis::CalendarV3::EventDateTime.new(date_time: start_time.in_time_zone(calendar.time_zone).to_datetime),
|
55
|
+
end: Google::Apis::CalendarV3::EventDateTime.new(date_time: end_time.in_time_zone(calendar.time_zone).to_datetime),
|
56
56
|
summary: "available"
|
57
57
|
)
|
58
58
|
CalendarAssistant::Event.new e
|
@@ -76,14 +76,14 @@ class CalendarAssistant
|
|
76
76
|
next if Time.before_business_hours?(e.end_time.to_time)
|
77
77
|
next if Time.after_business_hours?(e.start_time.to_time)
|
78
78
|
|
79
|
-
if (e.start_time
|
79
|
+
if Event.duration_in_seconds(start_time, e.start_time) >= length
|
80
80
|
avail_time[date] << event_repository.available_block(start_time, e.start_time)
|
81
81
|
end
|
82
82
|
start_time = [e.end_time, start_time].max
|
83
83
|
break if ! start_time.during_business_hours?
|
84
84
|
end
|
85
85
|
|
86
|
-
if (end_time
|
86
|
+
if Event.duration_in_seconds(start_time, end_time) >= length
|
87
87
|
avail_time[date] << event_repository.available_block(start_time, end_time)
|
88
88
|
end
|
89
89
|
|
@@ -94,7 +94,7 @@ class CalendarAssistant
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
def intersection other
|
97
|
+
def intersection other, length: 1
|
98
98
|
set = new({})
|
99
99
|
set.ensure_keys(events.keys + other.events.keys)
|
100
100
|
set.events.keys.each do |date|
|
@@ -106,7 +106,9 @@ class CalendarAssistant
|
|
106
106
|
event_b.contains?(event_a.end_time-1)
|
107
107
|
start_time = [event_a.start_time, event_b.start_time].max
|
108
108
|
end_time = [event_a.end_time, event_b.end_time ].min
|
109
|
-
|
109
|
+
if Event.duration_in_seconds(start_time, end_time) >= length
|
110
|
+
set.events[date] << event_repository.available_block(start_time, end_time)
|
111
|
+
end
|
110
112
|
end
|
111
113
|
end
|
112
114
|
end
|
@@ -36,7 +36,7 @@ class CalendarAssistant
|
|
36
36
|
length = ChronicDuration.parse(ca.config.setting(Config::Keys::Settings::MEETING_LENGTH))
|
37
37
|
ca.in_env do
|
38
38
|
set_avail = event_set.available_blocks(length: length)
|
39
|
-
avail = avail ? avail.intersection(set_avail) : set_avail
|
39
|
+
avail = avail ? avail.intersection(set_avail, length: length) : set_avail
|
40
40
|
end
|
41
41
|
end
|
42
42
|
avail
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calendar-assistant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Dalessio
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-11-
|
12
|
+
date: 2018-11-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-api-client
|