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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -1
  3. data/README.md +43 -22
  4. data/Rakefile +33 -6
  5. data/bin/calendar-assistant +2 -1
  6. data/lib/calendar_assistant.rb +14 -14
  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 +50 -50
  24. data/lib/calendar_assistant/event_repository.rb +12 -13
  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 +2 -2
  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 +18 -4
@@ -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.10.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.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-11 00:00:00.000000000 Z
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: '1.16'
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: '1.16'
187
+ version: 2.0.0
174
188
  - !ruby/object:Gem::Dependency
175
189
  name: concourse
176
190
  requirement: !ruby/object:Gem::Requirement