Skip to content

Instantly share code, notes, and snippets.

@ecylmz
Created December 1, 2013 11:19
Show Gist options
  • Save ecylmz/7732263 to your computer and use it in GitHub Desktop.
Save ecylmz/7732263 to your computer and use it in GitHub Desktop.
# encoding: utf-8
require 'gcal4ruby'
include GCal4Ruby
@service = Service.new
@username = '[email protected]'
@password = 'p4ssw0rd'
p 'Yetkilendir'
unless @service.authenticate(@username, @password)
p 'Yetkilendirme Başarısız'
exit 1
end
p 'Takvim Oluştur'
cal = Calendar.new(@service)
cal.title = 'test takvim ' + Time.now.to_s
p 'Takvim Mevcut = ' + cal.exists?.to_s
if cal.save
p 'takvim oluşturuldu'
cal.to_xml
else
p 'takvim oluşturulamadı'
end
p 'Etkinlik Oluştur'
event = Event.new(@service)
event.calendar = @service.calendars[0]
event.title = 'Test Event'
event.content = 'Test event content'
event.start_time = Time.now + 1800
event.end_time = Time.now + 5400
if event.save
p 'Etkinlik Oluşturuldu'
p event.to_xml
else
p 'Etkinlik Oluşturulamadı'
end
p 'Etkinlik Düzenle'
event.title = 'Edited title'
if event.save
p 'Etkinlik Düzenlendi'
p event.to_xml
else
p 'Etkinlik Düzenlenemedi'
end
p 'Id ile Etkinlik Bul'
e = Event.find(@service, {:id => event.id})
if e.title == event.title
p 'Etkinlik Bulundu'
else
p 'Eşleşen Etkinlik Yok'
end
puts 'Etkinlik Sil'
if event.delete
p 'Etkinlik Silindi'
else
p 'Etkinlik Silinemedi'
end
p 'Tekrarlı Etkinlik Oluşturma'
@first_start = Time.now
@first_end = Time.now + 3600
@first_freq = {'weekly' => ['TU']}
@second_start = Time.now + 86000
@second_end = Time.now + 89600
@second_freq = {'weekly' => ['SA']}
puts 'Tekralı Etkinliği Oluştur'
event = Event.new(@service)
event.calendar = @service.calendars[0]
event.title = 'Test Recurring Event'
event.content = 'Test event content'
event.recurrence = Recurrence.new({:start_time => @first_start, :end_time => @first_end, :frequency => @first_freq})
if event.save
p 'Tekrarlı Etkinlik Oluşturuldu'
p event.to_xml
else
p 'Tekrarlı Etkinlik Olusturulamadı'
p 'recurrence = ' + event.recurrence.to_s
end
puts 'Tekrarlı Etkinliği Düzenle'
event.title = 'Edited recurring title'
event.recurrence = Recurrence.new({:start_time => @second_start, :end_time => @second_end, :frequency => @second_freq})
if event.save
p 'Tekrarlı Etkinlik Düzenlendi'
p event.to_xml
else
p 'Tekrarlı Etkinlik Düzenlenemedi'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment