calendar-assistant 0.9.0 → 0.10.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 +4 -4
- data/Gemfile +2 -1
- data/README.md +43 -22
- data/Rakefile +33 -6
- data/bin/calendar-assistant +2 -1
- data/lib/calendar_assistant.rb +14 -14
- data/lib/calendar_assistant/available_block.rb +1 -1
- data/lib/calendar_assistant/calendar_assistant.rb +21 -25
- data/lib/calendar_assistant/cli.rb +10 -10
- data/lib/calendar_assistant/cli/authorizer.rb +14 -14
- data/lib/calendar_assistant/cli/command_service.rb +2 -2
- data/lib/calendar_assistant/cli/commands.rb +47 -40
- data/lib/calendar_assistant/cli/config.rb +16 -17
- data/lib/calendar_assistant/cli/event_presenter.rb +2 -2
- data/lib/calendar_assistant/cli/event_set_presenter.rb +3 -3
- data/lib/calendar_assistant/cli/helpers.rb +7 -8
- data/lib/calendar_assistant/cli/linter_event_presenter.rb +3 -3
- data/lib/calendar_assistant/cli/linter_event_set_presenter.rb +4 -4
- data/lib/calendar_assistant/cli/printer.rb +15 -15
- data/lib/calendar_assistant/config.rb +11 -11
- data/lib/calendar_assistant/config/token_store.rb +4 -4
- data/lib/calendar_assistant/date_helpers.rb +1 -2
- data/lib/calendar_assistant/event.rb +50 -50
- data/lib/calendar_assistant/event_repository.rb +12 -13
- data/lib/calendar_assistant/event_repository_factory.rb +1 -1
- data/lib/calendar_assistant/event_set.rb +14 -14
- data/lib/calendar_assistant/extensions/google_apis_extensions.rb +1 -1
- data/lib/calendar_assistant/extensions/launchy_extensions.rb +2 -2
- data/lib/calendar_assistant/has_duration.rb +4 -5
- data/lib/calendar_assistant/lint_event_repository.rb +3 -3
- data/lib/calendar_assistant/location_config_validator.rb +3 -3
- data/lib/calendar_assistant/location_event_repository.rb +7 -8
- data/lib/calendar_assistant/predicate_collection.rb +1 -2
- data/lib/calendar_assistant/scheduler.rb +4 -5
- data/lib/calendar_assistant/string_helpers.rb +1 -1
- data/lib/calendar_assistant/version.rb +1 -1
- metadata +18 -4
@@ -1,13 +1,12 @@
|
|
1
1
|
class CalendarAssistant
|
2
2
|
module HasDuration
|
3
|
-
def self.duration_in_seconds
|
3
|
+
def self.duration_in_seconds(start_time, end_time)
|
4
4
|
(end_time.to_datetime - start_time.to_datetime).days.to_i
|
5
|
-
|
6
5
|
end
|
7
6
|
|
8
7
|
def self.cast_datetime(datetime, time_zone = Time.zone.name)
|
9
|
-
|
10
|
-
|
8
|
+
return datetime if datetime.is_a?(Google::Apis::CalendarV3::EventDateTime)
|
9
|
+
Google::Apis::CalendarV3::EventDateTime.new(date_time: datetime.in_time_zone(time_zone).to_datetime)
|
11
10
|
end
|
12
11
|
|
13
12
|
def all_day?
|
@@ -95,7 +94,7 @@ class CalendarAssistant
|
|
95
94
|
HasDuration.duration_in_seconds start_time, end_time
|
96
95
|
end
|
97
96
|
|
98
|
-
def contains?
|
97
|
+
def contains?(time)
|
99
98
|
start_time <= time && time < end_time
|
100
99
|
end
|
101
100
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class CalendarAssistant
|
2
2
|
class LintEventRepository < EventRepository
|
3
|
-
def find
|
4
|
-
super(time,
|
3
|
+
def find(time, predicates: {})
|
4
|
+
super(time, predicates: predicates.merge({ needs_action?: true }))
|
5
5
|
end
|
6
6
|
end
|
7
|
-
end
|
7
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
class CalendarAssistant
|
3
3
|
class LocationConfigValidator
|
4
|
-
class LocationConfigValidationException < CalendarAssistant::BaseException
|
4
|
+
class LocationConfigValidationException < CalendarAssistant::BaseException
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.valid?(config)
|
8
|
-
return if (config.calendar_ids - [
|
8
|
+
return if (config.calendar_ids - [Config::DEFAULT_CALENDAR_ID]).empty?
|
9
9
|
return if !!config[CalendarAssistant::Config::Keys::Settings::NICKNAME]
|
10
10
|
return if !!config[CalendarAssistant::Config::Keys::Options::FORCE]
|
11
11
|
|
12
12
|
raise LocationConfigValidationException, "Managing location across multiple calendars when a nickname is not set is not recommended, use --force to override"
|
13
13
|
end
|
14
14
|
end
|
15
|
-
end
|
15
|
+
end
|
@@ -1,22 +1,21 @@
|
|
1
1
|
class CalendarAssistant
|
2
2
|
class LocationEventRepository < EventRepository
|
3
|
-
def find
|
3
|
+
def find(time, predicates: {})
|
4
4
|
event_set = super time, predicates: predicates
|
5
5
|
event_set.new event_set.events.select { |e| e.location_event? }
|
6
6
|
end
|
7
7
|
|
8
|
-
def create
|
8
|
+
def create(time, location, predicates: {})
|
9
9
|
# find pre-existing events that overlap
|
10
10
|
existing_event_set = find time, predicates: predicates
|
11
11
|
|
12
12
|
# augment event end date appropriately
|
13
13
|
range = CalendarAssistant.date_range_cast time
|
14
14
|
|
15
|
-
|
16
15
|
event = super(
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
transparency: CalendarAssistant::Event::Transparency::TRANSPARENT,
|
17
|
+
start: range.first, end: range.last,
|
18
|
+
summary: "#{Event.location_event_prefix(@config)}#{location}",
|
20
19
|
)
|
21
20
|
|
22
21
|
modify_location_events(event, existing_event_set)
|
@@ -25,13 +24,13 @@ class CalendarAssistant
|
|
25
24
|
private
|
26
25
|
|
27
26
|
def modify_location_events(event, existing_event_set)
|
28
|
-
response = existing_event_set.new({created: [event]})
|
27
|
+
response = existing_event_set.new({ created: [event] })
|
29
28
|
|
30
29
|
existing_event_set.events.each do |existing_event|
|
31
30
|
if event.cover?(existing_event)
|
32
31
|
response[:deleted] << delete(existing_event)
|
33
32
|
elsif event.overlaps_start_of?(existing_event)
|
34
|
-
|
33
|
+
response[:modified] << update(existing_event, start: event.end_date)
|
35
34
|
elsif event.overlaps_end_of?(existing_event)
|
36
35
|
response[:modified] << update(existing_event, end: event.start_date)
|
37
36
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
class CalendarAssistant
|
2
2
|
module PredicateCollection
|
3
|
-
|
4
3
|
def self.build(must_be, must_not_be)
|
5
4
|
predicates = {}
|
6
5
|
Array(must_be).each do |predicate|
|
@@ -18,4 +17,4 @@ class CalendarAssistant
|
|
18
17
|
str.to_s.gsub(/(.*[^?])$/, "\\1?").to_sym
|
19
18
|
end
|
20
19
|
end
|
21
|
-
end
|
20
|
+
end
|
@@ -5,7 +5,7 @@ class CalendarAssistant
|
|
5
5
|
#
|
6
6
|
# class methods
|
7
7
|
#
|
8
|
-
def self.select_busy_events
|
8
|
+
def self.select_busy_events(event_set)
|
9
9
|
dates_events = Hash.new
|
10
10
|
event_set.events.each do |event|
|
11
11
|
if event.private? || event.accepted? || event.self? || (event.all_day? && event.busy?)
|
@@ -17,21 +17,20 @@ class CalendarAssistant
|
|
17
17
|
event_set.new dates_events
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
20
|
#
|
22
21
|
# instance methods
|
23
22
|
#
|
24
|
-
def initialize
|
23
|
+
def initialize(calendar_assistant, event_repositories)
|
25
24
|
@ca = calendar_assistant
|
26
25
|
@ers = Array(event_repositories)
|
27
26
|
end
|
28
27
|
|
29
|
-
def available_blocks
|
28
|
+
def available_blocks(time_range, predicates: {})
|
30
29
|
avail = nil
|
31
30
|
ers.each do |er|
|
32
31
|
event_set = er.find time_range, predicates: predicates # array
|
33
32
|
event_set = Scheduler.select_busy_events event_set # hash
|
34
|
-
event_set.ensure_keys time_range.first.to_date
|
33
|
+
event_set.ensure_keys time_range.first.to_date..time_range.last.to_date, only: true
|
35
34
|
|
36
35
|
length = ChronicDuration.parse(ca.config.setting(Config::Keys::Settings::MEETING_LENGTH))
|
37
36
|
ca.in_env do
|
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.10.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: 2019-02-
|
12
|
+
date: 2019-02-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -143,6 +143,20 @@ dependencies:
|
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: 0.2.0
|
146
|
+
- !ruby/object:Gem::Dependency
|
147
|
+
name: thor_repl
|
148
|
+
requirement: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.1.1
|
153
|
+
type: :runtime
|
154
|
+
prerelease: false
|
155
|
+
version_requirements: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.1.1
|
146
160
|
- !ruby/object:Gem::Dependency
|
147
161
|
name: aruba
|
148
162
|
requirement: !ruby/object:Gem::Requirement
|
@@ -163,14 +177,14 @@ dependencies:
|
|
163
177
|
requirements:
|
164
178
|
- - "~>"
|
165
179
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
180
|
+
version: 2.0.0
|
167
181
|
type: :development
|
168
182
|
prerelease: false
|
169
183
|
version_requirements: !ruby/object:Gem::Requirement
|
170
184
|
requirements:
|
171
185
|
- - "~>"
|
172
186
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
187
|
+
version: 2.0.0
|
174
188
|
- !ruby/object:Gem::Dependency
|
175
189
|
name: concourse
|
176
190
|
requirement: !ruby/object:Gem::Requirement
|