google_calendar 0.6.0 → 0.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8db07fd559abd732624c1e225ba002a2c3a4f679
4
- data.tar.gz: 1471f5e7c39a8b599dab84d8bc42a66f340115e1
3
+ metadata.gz: 2c17b12f3368a1500b481e98511d25a58e8822c5
4
+ data.tar.gz: 1deb46615f678e7e445765895cca36af94f284f4
5
5
  SHA512:
6
- metadata.gz: 7257873946c722bb4edfa3f937bb03e5fbe12ca58ac62a15f947f2134bafac2a8e1e08bedf445dc52c25705ae3dc00e95acecb10e8775f118ef59d6d06b1d53b
7
- data.tar.gz: 42c07bb8b693b51da005df9fd66e754e0d7ff7d72f37b47e63f4ad636932d7942c6415c440373fd25fc4c35297a60d55e7fd6e8bbef82cf282ec4d62bc491757
6
+ metadata.gz: de0d7043457f15f227a5ce37e5394fa26ca494329c9da4e83e9ddd4d6d314ab5a7a2c38adbe95b75e34b98ff6cc6bac06520ee5264db98ed4da26aa8b7662460
7
+ data.tar.gz: 3034d06715304ca240b9849565231ce08ca263443cb8ada17546a2a3ea2b4ffecb3f7995e656a7e6de5db10f1986c3adf840eaba68f9d506d10734b69ae2170d
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- google_calendar (0.6.0)
4
+ google_calendar (0.6.1)
5
5
  TimezoneParser (~> 0.2.0)
6
- json (~> 2.0)
6
+ json (>= 1.8.3, < 2.1)
7
7
  signet (~> 0.7)
8
8
 
9
9
  GEM
@@ -21,11 +21,11 @@ GEM
21
21
  faraday (0.9.2)
22
22
  multipart-post (>= 1.2, < 3)
23
23
  insensitive_hash (0.3.3)
24
- json (2.0.1)
25
- jwt (1.5.4)
24
+ json (1.8.3)
25
+ jwt (1.5.6)
26
26
  metaclass (0.0.4)
27
- minitest (5.9.0)
28
- minitest-reporters (1.1.10)
27
+ minitest (5.9.1)
28
+ minitest-reporters (1.1.11)
29
29
  ansi
30
30
  builder
31
31
  minitest (>= 5.0)
@@ -34,9 +34,10 @@ GEM
34
34
  metaclass (~> 0.0.1)
35
35
  multi_json (1.12.1)
36
36
  multipart-post (2.0.0)
37
- rake (11.2.2)
37
+ rake (11.3.0)
38
38
  rb-fsevent (0.9.7)
39
- rdoc (4.1.0)
39
+ rdoc (4.2.2)
40
+ json (~> 1.4)
40
41
  ruby-progressbar (1.8.1)
41
42
  shoulda-context (1.2.1)
42
43
  signet (0.7.3)
@@ -71,4 +72,4 @@ DEPENDENCIES
71
72
  terminal-notifier-guard (~> 1.6)
72
73
 
73
74
  BUNDLED WITH
74
- 1.12.4
75
+ 1.13.2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.6.1
@@ -2,8 +2,8 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "google_calendar"
5
- s.version = "0.6.0"
6
- s.date = "2016-07-15"
5
+ s.version = "0.6.1"
6
+ s.date = "2016-09-30"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
 
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.rubygems_version = "2.2.2"
28
28
 
29
29
  s.add_runtime_dependency(%q<signet>, ["~> 0.7"])
30
- s.add_runtime_dependency(%q<json>, ["~> 2.0"])
30
+ s.add_runtime_dependency(%q<json>, [">= 1.8.3", "< 2.1"])
31
31
  s.add_runtime_dependency(%q<TimezoneParser>, ["~> 0.2.0"])
32
32
 
33
33
  s.add_development_dependency(%q<terminal-notifier-guard>, ["~> 1.6"])
@@ -259,69 +259,92 @@ module Google
259
259
  # Google JSON representation of an event object.
260
260
  #
261
261
  def to_json
262
- "{
263
- \"summary\": \"#{title}\",
264
- \"visibility\": \"#{visibility}\",
265
- \"description\": \"#{description}\",
266
- \"location\": \"#{location}\",
267
- \"start\": {
268
- \"dateTime\": \"#{start_time}\"
269
- #{timezone_needed? ? local_timezone_json : ''}
270
- },
271
- \"end\": {
272
- \"dateTime\": \"#{end_time}\"
273
- #{timezone_needed? ? local_timezone_json : ''}
262
+
263
+ attributes = {
264
+ "summary" => title,
265
+ "visibility" => visibility,
266
+ "transparency" => transparency,
267
+ "description" => description,
268
+ "location" => location,
269
+ "start" => {
270
+ "dateTime" => start_time
274
271
  },
275
- #{recurrence_json}
276
- #{color_json}
277
- #{attendees_json}
278
- #{extended_properties_json}
279
- \"reminders\": {
280
- #{reminders_json}
272
+ "end" => {
273
+ "dateTime" => end_time
281
274
  },
282
- \"guestsCanInviteOthers\": #{guests_can_invite_others.to_json},
283
- \"guestsCanSeeOtherGuests\": #{guests_can_see_other_guests.to_json}
284
- }"
275
+ "reminders" => reminders_attributes,
276
+ "guestsCanInviteOthers" => guests_can_invite_others,
277
+ "guestsCanSeeOtherGuests" => guests_can_see_other_guests
278
+ }
279
+
280
+ if timezone_needed?
281
+ attributes['start'].merge!(local_timezone_attributes)
282
+ attributes['end'].merge!(local_timezone_attributes)
283
+ end
284
+
285
+
286
+ attributes.merge!(recurrence_attributes)
287
+ attributes.merge!(color_attributes)
288
+ attributes.merge!(attendees_attributes)
289
+ attributes.merge!(extended_properties_attributes)
290
+
291
+ JSON.generate attributes
292
+ end
293
+
294
+ #
295
+ # Hash representation of colors
296
+ #
297
+ def color_attributes
298
+ return {} unless color_id
299
+ { "colorId" => "#{color_id}" }
285
300
  end
286
301
 
302
+ #
303
+ # JSON representation of colors
304
+ #
287
305
  def color_json
288
- return unless color_id
289
- "\"colorId\": \"#{color_id}\","
306
+ color_attributes.to_json
290
307
  end
308
+
291
309
  #
292
- # JSON representation of attendees
310
+ # Hash representation of attendees
293
311
  #
294
- def attendees_json
295
- return unless @attendees
312
+ def attendees_attributes
313
+ return {} unless @attendees
296
314
 
297
315
  attendees = @attendees.map do |attendee|
298
- "{
299
- \"displayName\": \"#{attendee['displayName']}\",
300
- \"email\": \"#{attendee['email']}\",
301
- \"responseStatus\": \"#{attendee['responseStatus']}\"
302
- }"
303
- end.join(",\n")
316
+ attendee.select { |k,v| ['displayName', 'email', 'responseStatus'].include?(k) }
317
+ end
304
318
 
305
- "\"attendees\": [\n#{attendees}],"
319
+ { "attendees" => attendees }
306
320
  end
307
321
 
308
322
  #
309
- # JSON representation of a reminder
323
+ # JSON representation of attendees
310
324
  #
311
- def reminders_json
325
+ def attendees_json
326
+ attendees_attributes.to_json
327
+ end
328
+
329
+ #
330
+ # Hash representation of a reminder
331
+ #
332
+ def reminders_attributes
312
333
  if reminders && reminders.is_a?(Hash) && reminders['overrides']
313
- overrides = reminders['overrides'].map do |reminder|
314
- "{
315
- \"method\": \"#{reminder['method']}\",
316
- \"minutes\": #{reminder['minutes']}
317
- }"
318
- end.join(",\n")
319
- "\n\"useDefault\": false,\n\"overrides\": [\n#{overrides}]"
334
+
335
+ { "useDefault" => false, "overrides" => reminders['overrides'] }
320
336
  else
321
- "\"useDefault\": true"
337
+ { "useDefault" => true}
322
338
  end
323
339
  end
324
340
 
341
+ #
342
+ # JSON representation of a reminder
343
+ #
344
+ def reminders_json
345
+ reminders_attributes.to_json
346
+ end
347
+
325
348
  #
326
349
  # Timezone info is needed only at recurring events
327
350
  #
@@ -330,25 +353,49 @@ module Google
330
353
  end
331
354
 
332
355
  #
333
- # JSON representation of local timezone
356
+ # Hash representation of local timezone
334
357
  #
335
- def local_timezone_json
358
+ def local_timezone_attributes
336
359
  tz = Time.now.getlocal.zone
337
360
  tz_name = TimezoneParser::getTimezones(tz).last
338
- ",\"timeZone\" : \"#{tz_name}\""
361
+ { "timeZone" => tz_name }
339
362
  end
340
363
 
341
364
  #
342
- # JSON representation of recurrence rules for repeating events
365
+ # JSON representation of local timezone
343
366
  #
344
- def recurrence_json
345
- return unless is_recurring_event?
367
+ def local_timezone_json
368
+ local_timezone_attributes.to_json
369
+ end
370
+
371
+ #
372
+ # Hash representation of recurrence rules for repeating events
373
+ #
374
+ def recurrence_attributes
375
+ return {} unless is_recurring_event?
346
376
 
347
377
  @recurrence[:until] = @recurrence[:until].strftime('%Y%m%dT%H%M%SZ') if @recurrence[:until]
348
378
  rrule = "RRULE:" + @recurrence.collect { |k,v| "#{k}=#{v}" }.join(';').upcase
349
379
  @recurrence[:until] = Time.parse(@recurrence[:until]) if @recurrence[:until]
350
380
 
351
- "\"recurrence\": [\n\"#{rrule}\"],"
381
+ { "recurrence" => [rrule] }
382
+ end
383
+
384
+ #
385
+ # JSON representation of recurrence rules for repeating events
386
+ #
387
+ def recurrence_json
388
+ recurrence_attributes.to_json
389
+ end
390
+
391
+ #
392
+ # Hash representation of extended properties
393
+ # shared : whether this should handle shared or public properties
394
+ #
395
+ def extended_properties_attributes
396
+ return {} unless @extended_properties && (@extended_properties['shared'] || @extended_properties['private'])
397
+
398
+ { "extendedProperties" => @extended_properties.select {|k,v| ['shared', 'private'].include?(k) } }
352
399
  end
353
400
 
354
401
  #
@@ -356,21 +403,7 @@ module Google
356
403
  # shared : whether this should handle shared or public properties
357
404
  #
358
405
  def extended_properties_json
359
- return unless @extended_properties && (@extended_properties['shared'] || @extended_properties['private'])
360
- json_extended_properties = []
361
- ['shared', 'private'].each do |prop_type|
362
- if @extended_properties[prop_type]
363
- props_json = @extended_properties[prop_type].map do |key, value|
364
- "\"#{key}\": \"#{value}\""
365
- end.join(",\n")
366
- json_extended_properties << "\"#{prop_type}\": {\n
367
- #{props_json}
368
- }\n"
369
- end
370
- end
371
- "\n\"extendedProperties\": {\n
372
- #{json_extended_properties.join(',')}\n
373
- },\n"
406
+ extended_properties_attributes.to_json
374
407
  end
375
408
 
376
409
  #
@@ -419,7 +452,7 @@ module Google
419
452
  #
420
453
  def self.new_from_feed(e, calendar) #:nodoc:
421
454
  params = {}
422
- %w(id status description location creator transparency updated reminders attendees visibility).each do |p|
455
+ %w(id status description location creator transparency updated reminders attendees visibility).each do |p|
423
456
  params[p.to_sym] = e[p]
424
457
  end
425
458
 
@@ -431,7 +464,7 @@ module Google
431
464
  params[:guests_can_invite_others] = e['guestsCanInviteOthers']
432
465
  params[:guests_can_see_other_guests] = e['guestsCanSeeOtherGuests']
433
466
  params[:html_link] = e['htmlLink']
434
- params[:start_time] = Event.parse_json_time(e['start'])
467
+ params[:start_time] = Event.parse_json_time(e['start'])
435
468
  params[:end_time] = Event.parse_json_time(e['end'])
436
469
  params[:recurrence] = Event.parse_recurrence_rule(e['recurrence'])
437
470
 
@@ -365,6 +365,7 @@ class TestGoogleCalendar < Minitest::Test
365
365
  expected_structure = {
366
366
  "summary" => "Go Swimming",
367
367
  "visibility"=>"default",
368
+ "transparency"=>"opaque",
368
369
  "description" => "The polar bear plunge",
369
370
  "location" => "In the arctic ocean",
370
371
  "start" => {"dateTime" => "#{@event.start_time}"},
@@ -424,7 +425,8 @@ class TestGoogleCalendar < Minitest::Test
424
425
  require 'timezone_parser'
425
426
  expected_structure = {
426
427
  "summary" => "Go Swimming",
427
- "visibility"=>"default",
428
+ "visibility"=>"default",
429
+ "transparency"=>"opaque",
428
430
  "description" => "The polar bear plunge",
429
431
  "location" => "In the arctic ocean",
430
432
  "start" => {"dateTime" => "#{@event.start_time}", "timeZone" => "#{TimezoneParser::getTimezones(Time.now.getlocal.zone).last}"},
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_calendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Zich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-15 00:00:00.000000000 Z
11
+ date: 2016-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: signet
@@ -28,16 +28,22 @@ dependencies:
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.8.3
34
+ - - "<"
32
35
  - !ruby/object:Gem::Version
33
- version: '2.0'
36
+ version: '2.1'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.8.3
44
+ - - "<"
39
45
  - !ruby/object:Gem::Version
40
- version: '2.0'
46
+ version: '2.1'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: TimezoneParser
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -247,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
247
253
  version: '0'
248
254
  requirements: []
249
255
  rubyforge_project:
250
- rubygems_version: 2.6.4
256
+ rubygems_version: 2.4.8
251
257
  signing_key:
252
258
  specification_version: 4
253
259
  summary: A lightweight Google Calendar API wrapper