calendar-assistant 0.9.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -1
  3. data/README.md +44 -22
  4. data/Rakefile +37 -6
  5. data/bin/calendar-assistant +3 -1
  6. data/lib/calendar_assistant.rb +14 -16
  7. data/lib/calendar_assistant/available_block.rb +1 -1
  8. data/lib/calendar_assistant/calendar_assistant.rb +21 -25
  9. data/lib/calendar_assistant/cli.rb +10 -10
  10. data/lib/calendar_assistant/cli/authorizer.rb +14 -14
  11. data/lib/calendar_assistant/cli/command_service.rb +2 -2
  12. data/lib/calendar_assistant/cli/commands.rb +47 -40
  13. data/lib/calendar_assistant/cli/config.rb +16 -17
  14. data/lib/calendar_assistant/cli/event_presenter.rb +2 -2
  15. data/lib/calendar_assistant/cli/event_set_presenter.rb +3 -3
  16. data/lib/calendar_assistant/cli/helpers.rb +7 -8
  17. data/lib/calendar_assistant/cli/linter_event_presenter.rb +3 -3
  18. data/lib/calendar_assistant/cli/linter_event_set_presenter.rb +4 -4
  19. data/lib/calendar_assistant/cli/printer.rb +15 -15
  20. data/lib/calendar_assistant/config.rb +11 -11
  21. data/lib/calendar_assistant/config/token_store.rb +4 -4
  22. data/lib/calendar_assistant/date_helpers.rb +1 -2
  23. data/lib/calendar_assistant/event.rb +54 -50
  24. data/lib/calendar_assistant/event_repository.rb +14 -15
  25. data/lib/calendar_assistant/event_repository_factory.rb +1 -1
  26. data/lib/calendar_assistant/event_set.rb +14 -14
  27. data/lib/calendar_assistant/extensions/google_apis_extensions.rb +1 -1
  28. data/lib/calendar_assistant/extensions/launchy_extensions.rb +7 -4
  29. data/lib/calendar_assistant/has_duration.rb +4 -5
  30. data/lib/calendar_assistant/lint_event_repository.rb +3 -3
  31. data/lib/calendar_assistant/location_config_validator.rb +3 -3
  32. data/lib/calendar_assistant/location_event_repository.rb +7 -8
  33. data/lib/calendar_assistant/predicate_collection.rb +1 -2
  34. data/lib/calendar_assistant/scheduler.rb +4 -5
  35. data/lib/calendar_assistant/string_helpers.rb +1 -1
  36. data/lib/calendar_assistant/version.rb +1 -1
  37. metadata +38 -30
@@ -1,13 +1,12 @@
1
1
  class CalendarAssistant
2
2
  module HasDuration
3
- def self.duration_in_seconds start_time, end_time
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
- return datetime if datetime.is_a?(Google::Apis::CalendarV3::EventDateTime)
10
- Google::Apis::CalendarV3::EventDateTime.new(date_time: datetime.in_time_zone(time_zone).to_datetime)
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? time
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 time, predicates: {}
4
- super(time, predicates: predicates.merge({needs_action?: true}))
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 - [ Config::DEFAULT_CALENDAR_ID ]).empty?
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 time, predicates: {}
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 time, location, predicates: {}
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
- transparency: CalendarAssistant::Event::Transparency::TRANSPARENT,
18
- start: range.first, end: range.last,
19
- summary: "#{Event.location_event_prefix(@config)}#{location}"
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
- response[:modified] << update(existing_event, start: event.end_date)
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 event_set
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 calendar_assistant, event_repositories
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 time_range, predicates: {}
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 .. time_range.last.to_date, only: true
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
@@ -1,6 +1,6 @@
1
1
  class CalendarAssistant
2
2
  module StringHelpers
3
- def self.find_uri_for_domain string, domain
3
+ def self.find_uri_for_domain(string, domain)
4
4
  return unless string
5
5
  URI::Parser.new.extract(string).each do |uri_string|
6
6
  uri = URI.parse uri_string
@@ -1,3 +1,3 @@
1
1
  class CalendarAssistant
2
- VERSION = "0.9.0"
2
+ VERSION = "0.14.0"
3
3
  end
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.9.0
4
+ version: 0.14.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-11 00:00:00.000000000 Z
12
+ date: 2021-02-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -17,28 +17,28 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 5.2.1
20
+ version: '6.1'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 5.2.1
27
+ version: '6.1'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: business_time
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 0.9.0
34
+ version: '0.10'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 0.9.0
41
+ version: '0.10'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: chronic
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -68,25 +68,19 @@ dependencies:
68
68
  - !ruby/object:Gem::Version
69
69
  version: 0.10.0
70
70
  - !ruby/object:Gem::Dependency
71
- name: google-api-client
71
+ name: google-apis-calendar_v3
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ">="
75
75
  - !ruby/object:Gem::Version
76
- version: '0.24'
77
- - - "<"
78
- - !ruby/object:Gem::Version
79
- version: '0.29'
76
+ version: '0'
80
77
  type: :runtime
81
78
  prerelease: false
82
79
  version_requirements: !ruby/object:Gem::Requirement
83
80
  requirements:
84
81
  - - ">="
85
82
  - !ruby/object:Gem::Version
86
- version: '0.24'
87
- - - "<"
88
- - !ruby/object:Gem::Version
89
- version: '0.29'
83
+ version: '0'
90
84
  - !ruby/object:Gem::Dependency
91
85
  name: launchy
92
86
  requirement: !ruby/object:Gem::Requirement
@@ -121,14 +115,14 @@ dependencies:
121
115
  requirements:
122
116
  - - "~>"
123
117
  - !ruby/object:Gem::Version
124
- version: 0.20.0
118
+ version: 1.1.0
125
119
  type: :runtime
126
120
  prerelease: false
127
121
  version_requirements: !ruby/object:Gem::Requirement
128
122
  requirements:
129
123
  - - "~>"
130
124
  - !ruby/object:Gem::Version
131
- version: 0.20.0
125
+ version: 1.1.0
132
126
  - !ruby/object:Gem::Dependency
133
127
  name: toml
134
128
  requirement: !ruby/object:Gem::Requirement
@@ -143,34 +137,48 @@ dependencies:
143
137
  - - "~>"
144
138
  - !ruby/object:Gem::Version
145
139
  version: 0.2.0
140
+ - !ruby/object:Gem::Dependency
141
+ name: thor_repl
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - "~>"
145
+ - !ruby/object:Gem::Version
146
+ version: 0.1.4
147
+ type: :runtime
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: 0.1.4
146
154
  - !ruby/object:Gem::Dependency
147
155
  name: aruba
148
156
  requirement: !ruby/object:Gem::Requirement
149
157
  requirements:
150
158
  - - "~>"
151
159
  - !ruby/object:Gem::Version
152
- version: 0.14.8
160
+ version: 1.0.0
153
161
  type: :development
154
162
  prerelease: false
155
163
  version_requirements: !ruby/object:Gem::Requirement
156
164
  requirements:
157
165
  - - "~>"
158
166
  - !ruby/object:Gem::Version
159
- version: 0.14.8
167
+ version: 1.0.0
160
168
  - !ruby/object:Gem::Dependency
161
169
  name: bundler
162
170
  requirement: !ruby/object:Gem::Requirement
163
171
  requirements:
164
172
  - - "~>"
165
173
  - !ruby/object:Gem::Version
166
- version: '1.16'
174
+ version: '2.2'
167
175
  type: :development
168
176
  prerelease: false
169
177
  version_requirements: !ruby/object:Gem::Requirement
170
178
  requirements:
171
179
  - - "~>"
172
180
  - !ruby/object:Gem::Version
173
- version: '1.16'
181
+ version: '2.2'
174
182
  - !ruby/object:Gem::Dependency
175
183
  name: concourse
176
184
  requirement: !ruby/object:Gem::Requirement
@@ -191,42 +199,42 @@ dependencies:
191
199
  requirements:
192
200
  - - "~>"
193
201
  - !ruby/object:Gem::Version
194
- version: '1.9'
202
+ version: '2.1'
195
203
  type: :development
196
204
  prerelease: false
197
205
  version_requirements: !ruby/object:Gem::Requirement
198
206
  requirements:
199
207
  - - "~>"
200
208
  - !ruby/object:Gem::Version
201
- version: '1.9'
209
+ version: '2.1'
202
210
  - !ruby/object:Gem::Dependency
203
211
  name: license_finder
204
212
  requirement: !ruby/object:Gem::Requirement
205
213
  requirements:
206
214
  - - "~>"
207
215
  - !ruby/object:Gem::Version
208
- version: '5.5'
216
+ version: '6.0'
209
217
  type: :development
210
218
  prerelease: false
211
219
  version_requirements: !ruby/object:Gem::Requirement
212
220
  requirements:
213
221
  - - "~>"
214
222
  - !ruby/object:Gem::Version
215
- version: '5.5'
223
+ version: '6.0'
216
224
  - !ruby/object:Gem::Dependency
217
225
  name: rake
218
226
  requirement: !ruby/object:Gem::Requirement
219
227
  requirements:
220
228
  - - "~>"
221
229
  - !ruby/object:Gem::Version
222
- version: '12.3'
230
+ version: '13.0'
223
231
  type: :development
224
232
  prerelease: false
225
233
  version_requirements: !ruby/object:Gem::Requirement
226
234
  requirements:
227
235
  - - "~>"
228
236
  - !ruby/object:Gem::Version
229
- version: '12.3'
237
+ version: '13.0'
230
238
  - !ruby/object:Gem::Dependency
231
239
  name: rspec
232
240
  requirement: !ruby/object:Gem::Requirement
@@ -261,14 +269,14 @@ dependencies:
261
269
  requirements:
262
270
  - - "~>"
263
271
  - !ruby/object:Gem::Version
264
- version: '0.16'
272
+ version: '0.21'
265
273
  type: :development
266
274
  prerelease: false
267
275
  version_requirements: !ruby/object:Gem::Requirement
268
276
  requirements:
269
277
  - - "~>"
270
278
  - !ruby/object:Gem::Version
271
- version: '0.16'
279
+ version: '0.21'
272
280
  description: A command-line tool to help manage your Google Calendar.
273
281
  email:
274
282
  - mike.dalessio@gmail.com
@@ -336,7 +344,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
336
344
  - !ruby/object:Gem::Version
337
345
  version: '0'
338
346
  requirements: []
339
- rubygems_version: 3.0.1
347
+ rubygems_version: 3.2.3
340
348
  signing_key:
341
349
  specification_version: 4
342
350
  summary: A command-line tool to help manage your Google Calendar.