gcalapi 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +13 -0
- data/Rakefile +82 -0
- data/VERSION +1 -0
- data/example/mail2gcal.rb +101 -0
- data/example/ol2gcal.rb +55 -0
- data/html/classes/GoogleCalendar.html +281 -0
- data/html/classes/GoogleCalendar/AuthenticationFailed.html +111 -0
- data/html/classes/GoogleCalendar/Calendar.html +204 -0
- data/html/classes/GoogleCalendar/Event.html +511 -0
- data/html/classes/GoogleCalendar/EventDeleteFailed.html +111 -0
- data/html/classes/GoogleCalendar/EventInsertFailed.html +111 -0
- data/html/classes/GoogleCalendar/EventUpdateFailed.html +111 -0
- data/html/classes/GoogleCalendar/InvalidCalendarURL.html +111 -0
- data/html/classes/GoogleCalendar/Service.html +472 -0
- data/html/created.rid +1 -0
- data/html/files/README.html +117 -0
- data/html/files/lib/googlecalendar/calendar_rb.html +110 -0
- data/html/files/lib/googlecalendar/event_rb.html +110 -0
- data/html/files/lib/googlecalendar/service_rb.html +114 -0
- data/html/fr_class_index.html +35 -0
- data/html/fr_file_index.html +30 -0
- data/html/fr_method_index.html +49 -0
- data/html/index.html +24 -0
- data/html/rdoc-style.css +208 -0
- data/lib/googlecalendar/calendar.rb +117 -0
- data/lib/googlecalendar/event.rb +283 -0
- data/lib/googlecalendar/service.rb +193 -0
- data/test/00_service_test.rb +169 -0
- data/test/01_calendar_test.rb +52 -0
- data/test/02_event_test.rb +60 -0
- data/test/all.sh +2 -0
- data/test/base_unit.rb +54 -0
- data/test/each.sh +2 -0
- metadata +85 -0
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'rake/gempackagetask'
|
2
|
+
require "rake/contrib/rubyforgepublisher"
|
3
|
+
|
4
|
+
require 'rbconfig'
|
5
|
+
include Config
|
6
|
+
|
7
|
+
PKG_NAME = 'gcalapi'
|
8
|
+
PKG_VERSION = File.read('VERSION').chomp
|
9
|
+
PKG_FILES = FileList["**/*"].exclude(".svn").exclude("pkg").exclude("test/temp_*.rb").exclude("test/parameters.rb")
|
10
|
+
|
11
|
+
desc "Installing library"
|
12
|
+
task :install do
|
13
|
+
ruby 'install.rb'
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Testing library"
|
17
|
+
task :test do
|
18
|
+
sh '(cd test; sh all.sh)'
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Removing generated files"
|
22
|
+
task :clean do
|
23
|
+
rm_rf 'html'
|
24
|
+
end
|
25
|
+
|
26
|
+
# Create RDOC documentation.
|
27
|
+
task :rdoc do
|
28
|
+
sh "rdoc -S -o html README lib/googlecalendar/*.rb"
|
29
|
+
end
|
30
|
+
|
31
|
+
spec = Gem::Specification.new do |s|
|
32
|
+
#### Basic information.
|
33
|
+
|
34
|
+
s.name = PKG_NAME
|
35
|
+
s.version = PKG_VERSION
|
36
|
+
s.summary = "Google Calendar API"
|
37
|
+
s.description = ""
|
38
|
+
|
39
|
+
#### Dependencies and requirements.
|
40
|
+
|
41
|
+
s.files = PKG_FILES
|
42
|
+
|
43
|
+
#### C code extensions.
|
44
|
+
|
45
|
+
#s.extensions << "ext/extconf.rb"
|
46
|
+
|
47
|
+
#### Load-time details: library and application (you will need one or both).
|
48
|
+
|
49
|
+
s.require_path = 'lib' # Use these for libraries.
|
50
|
+
s.autorequire = "googlecalendar/calendar"
|
51
|
+
|
52
|
+
#### Documentation and testing.
|
53
|
+
|
54
|
+
s.has_rdoc = true
|
55
|
+
#s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
|
56
|
+
s.extra_rdoc_files = 'README'
|
57
|
+
s.rdoc_options << '--line-numbers' << '--inline-source'
|
58
|
+
#s.rdoc_options <<
|
59
|
+
# '--title' << 'Rake -- Ruby Make' <<
|
60
|
+
# '--main' << 'README' <<
|
61
|
+
# '--line-numbers'
|
62
|
+
s.test_files = Dir.glob('test/*_test.rb')
|
63
|
+
|
64
|
+
#### Author and project details.
|
65
|
+
|
66
|
+
s.author = "zorio"
|
67
|
+
s.email = "zoriorz@gmail.com"
|
68
|
+
s.homepage = "http://gcalapi.rubyforge.net"
|
69
|
+
s.rubyforge_project = "gcalapi"
|
70
|
+
end
|
71
|
+
|
72
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
73
|
+
pkg.need_tar = true
|
74
|
+
pkg.package_files += PKG_FILES
|
75
|
+
end
|
76
|
+
|
77
|
+
task :release => [ :clean, :package ]
|
78
|
+
|
79
|
+
desc "Publish to RubyForge"
|
80
|
+
task :rubyforge => [:rdoc, :package] do
|
81
|
+
Rake::RubyForgePublisher.new(PKG_NAME, "zorio").upload
|
82
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.3
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require "kconv"
|
2
|
+
require "yaml"
|
3
|
+
require "net/pop"
|
4
|
+
require "googlecalendar/calendar"
|
5
|
+
|
6
|
+
#
|
7
|
+
# This example shows how to create an event for Google Calendar from an e-mail.
|
8
|
+
#
|
9
|
+
# 1. the subject of the email must be 'gcal'.
|
10
|
+
#
|
11
|
+
# 2. write the mail body in yaml format. here is an example.
|
12
|
+
# st: 2006-09-26 09:30:00
|
13
|
+
# en: 2006-09-26 11:00:00
|
14
|
+
# title: title of an event
|
15
|
+
# desc: description of an event
|
16
|
+
# where: location of an event
|
17
|
+
#
|
18
|
+
# 3. send the mail to your mail account.
|
19
|
+
#
|
20
|
+
# 4. execute this sample script.
|
21
|
+
#
|
22
|
+
|
23
|
+
POP_SERVER = "your pop server"
|
24
|
+
POP_PORT = 110
|
25
|
+
POP_ACCOUNT = "your account"
|
26
|
+
POP_PASSWORD = "your password"
|
27
|
+
|
28
|
+
GCAL_ACCOUNT = "your gmail account"
|
29
|
+
GCAL_PASSWORD = "your gmail password"
|
30
|
+
GCAL_FEED = "http://www.google.com/calendar/feeds/XXXXXXXXXXX@group.calendar.google.com/private/full"
|
31
|
+
|
32
|
+
TARGET_SUBJECT = "gcal"
|
33
|
+
|
34
|
+
# very simple e-mail parser.
|
35
|
+
class Mail
|
36
|
+
attr_accessor :subject, :body
|
37
|
+
def initialize(cont)
|
38
|
+
self.subject = nil
|
39
|
+
self.body = nil
|
40
|
+
parse(cont)
|
41
|
+
end
|
42
|
+
|
43
|
+
SUBJECT = /^Subject: (.*)$/
|
44
|
+
|
45
|
+
def parse(cont)
|
46
|
+
head = true
|
47
|
+
bd = []
|
48
|
+
cont.each_line do |line|
|
49
|
+
if head
|
50
|
+
line.chomp!
|
51
|
+
if line =~ SUBJECT
|
52
|
+
self.subject = $1
|
53
|
+
elsif line == ""
|
54
|
+
head = false
|
55
|
+
end
|
56
|
+
else
|
57
|
+
bd << line
|
58
|
+
end
|
59
|
+
end
|
60
|
+
self.body = bd.join("")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
server = GoogleCalendar::Service.new(GCAL_ACCOUNT, GCAL_PASSWORD)
|
65
|
+
calendar = GoogleCalendar::Calendar.new(server, GCAL_FEED)
|
66
|
+
|
67
|
+
#
|
68
|
+
# * make an event of the calendar
|
69
|
+
# * set attributes of the event from email content.
|
70
|
+
# * update the event to the calendar.
|
71
|
+
#
|
72
|
+
def calendar.from_mail(mail)
|
73
|
+
event = self.create_event
|
74
|
+
yaml = YAML::load(mail.body)
|
75
|
+
event.st = Time.parse(yaml["st"].to_s) if yaml.has_key?("st")
|
76
|
+
event.en = Time.parse(yaml["en"].to_s) if yaml.has_key?("en")
|
77
|
+
event.title = yaml["title"].toutf8 if yaml.has_key?("title")
|
78
|
+
event.desc = yaml["desc"].toutf8 if yaml.has_key?("desc")
|
79
|
+
event.where = yaml["where"].toutf8 if yaml.has_key?("where")
|
80
|
+
event.allday = yaml["allday"] if yaml.has_key?("allday")
|
81
|
+
event.save!
|
82
|
+
end
|
83
|
+
|
84
|
+
pop = Net::POP3.APOP(true).new(POP_SERVER, POP_PORT)
|
85
|
+
pop.start(POP_ACCOUNT, POP_PASSWORD)
|
86
|
+
|
87
|
+
if pop.mails.empty? then
|
88
|
+
puts 'no mail.'
|
89
|
+
else
|
90
|
+
i = 0
|
91
|
+
pop.each_mail do |m|
|
92
|
+
mail = Mail.new(m.pop)
|
93
|
+
if mail.subject == TARGET_SUBJECT
|
94
|
+
calendar.from_mail(mail)
|
95
|
+
m.delete
|
96
|
+
i += 1
|
97
|
+
end
|
98
|
+
end
|
99
|
+
puts "#{i} mail(s) processed."
|
100
|
+
end
|
101
|
+
pop.finish
|
data/example/ol2gcal.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require "googlecalendar/calendar"
|
2
|
+
require "win32ole"
|
3
|
+
require "nkf"
|
4
|
+
|
5
|
+
|
6
|
+
# google calendar Feed URL
|
7
|
+
FEED_URL = "http://www.google.com/calendar/feeds/XXXXXXXXXXXXXXXX@group.calendar.google.com/private/full"
|
8
|
+
# email address
|
9
|
+
EMAIL = "XXXXXXXXXX@gmail.com"
|
10
|
+
# password
|
11
|
+
PASS = "XXXXXXX"
|
12
|
+
|
13
|
+
def each_event
|
14
|
+
created = false
|
15
|
+
ol = nil
|
16
|
+
begin
|
17
|
+
ol = WIN32OLE.connect("Outlook.Application")
|
18
|
+
rescue
|
19
|
+
created = true
|
20
|
+
ol = WIN32OLE.new("Outlook.Application")
|
21
|
+
end
|
22
|
+
ns = ol.GetNameSpace("MAPI")
|
23
|
+
folder = ns.GetDefaultFolder(9) #olFolderCalendar
|
24
|
+
folder.Items.each do |event|
|
25
|
+
GC.start
|
26
|
+
yield event
|
27
|
+
end
|
28
|
+
ol.Quit if created
|
29
|
+
end
|
30
|
+
|
31
|
+
#proxy setting
|
32
|
+
GoogleCalendar::Service.proxy_addr="192.168.0.1"
|
33
|
+
GoogleCalendar::Service.proxy_port="8080"
|
34
|
+
|
35
|
+
@srv = GoogleCalendar::Service.new(EMAIL, PASS)
|
36
|
+
@cal = GoogleCalendar::Calendar.new(@srv, FEED_URL)
|
37
|
+
|
38
|
+
# Delete All Future Data Of Google Calendar
|
39
|
+
now = Time.now
|
40
|
+
@cal.events(now, nil).each do |ev| ev.destroy! end
|
41
|
+
|
42
|
+
# Insert All Future Data Of Outlook
|
43
|
+
@nstr = now.strftime("%Y/%m/%d %H:%M:%S")
|
44
|
+
each_event do |oev|
|
45
|
+
if oev.Start > @nstr
|
46
|
+
gev = @cal.create_event
|
47
|
+
#NKF is used for japanese charcter code conversion
|
48
|
+
gev.title = NKF.nkf("-w", oev.Subject)
|
49
|
+
gev.where = NKF.nkf("-w", oev.Location)
|
50
|
+
gev.st = Time.parse(oev.Start)
|
51
|
+
gev.en = Time.parse(oev.End)
|
52
|
+
gev.allday = oev.AllDayEvent
|
53
|
+
gev.save!
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,281 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Module: GoogleCalendar</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Module</strong></td>
|
53
|
+
<td class="class-name-in-header">GoogleCalendar</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../files/lib/googlecalendar/calendar_rb.html">
|
59
|
+
lib/googlecalendar/calendar.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
<a href="../files/lib/googlecalendar/event_rb.html">
|
63
|
+
lib/googlecalendar/event.rb
|
64
|
+
</a>
|
65
|
+
<br />
|
66
|
+
<a href="../files/lib/googlecalendar/service_rb.html">
|
67
|
+
lib/googlecalendar/service.rb
|
68
|
+
</a>
|
69
|
+
<br />
|
70
|
+
</td>
|
71
|
+
</tr>
|
72
|
+
|
73
|
+
</table>
|
74
|
+
</div>
|
75
|
+
<!-- banner header -->
|
76
|
+
|
77
|
+
<div id="bodyContent">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<div id="contextContent">
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
</div>
|
86
|
+
|
87
|
+
<div id="method-list">
|
88
|
+
<h3 class="section-bar">Methods</h3>
|
89
|
+
|
90
|
+
<div class="name-list">
|
91
|
+
<a href="#M000004">create_event</a>
|
92
|
+
<a href="#M000003">events</a>
|
93
|
+
<a href="#M000001">new</a>
|
94
|
+
<a href="#M000002">source</a>
|
95
|
+
</div>
|
96
|
+
</div>
|
97
|
+
|
98
|
+
</div>
|
99
|
+
|
100
|
+
|
101
|
+
<!-- if includes -->
|
102
|
+
|
103
|
+
<div id="section">
|
104
|
+
|
105
|
+
<div id="class-list">
|
106
|
+
<h3 class="section-bar">Classes and Modules</h3>
|
107
|
+
|
108
|
+
Class <a href="GoogleCalendar/AuthenticationFailed.html" class="link">GoogleCalendar::AuthenticationFailed</a><br />
|
109
|
+
Class <a href="GoogleCalendar/Calendar.html" class="link">GoogleCalendar::Calendar</a><br />
|
110
|
+
Class <a href="GoogleCalendar/Event.html" class="link">GoogleCalendar::Event</a><br />
|
111
|
+
Class <a href="GoogleCalendar/EventDeleteFailed.html" class="link">GoogleCalendar::EventDeleteFailed</a><br />
|
112
|
+
Class <a href="GoogleCalendar/EventInsertFailed.html" class="link">GoogleCalendar::EventInsertFailed</a><br />
|
113
|
+
Class <a href="GoogleCalendar/EventUpdateFailed.html" class="link">GoogleCalendar::EventUpdateFailed</a><br />
|
114
|
+
Class <a href="GoogleCalendar/InvalidCalendarURL.html" class="link">GoogleCalendar::InvalidCalendarURL</a><br />
|
115
|
+
Class <a href="GoogleCalendar/Service.html" class="link">GoogleCalendar::Service</a><br />
|
116
|
+
|
117
|
+
</div>
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
<div id="attribute-list">
|
123
|
+
<h3 class="section-bar">Attributes</h3>
|
124
|
+
|
125
|
+
<div class="name-list">
|
126
|
+
<table>
|
127
|
+
<tr class="top-aligned-row context-row">
|
128
|
+
<td class="context-item-name">feed</td>
|
129
|
+
<td class="context-item-value"> [R] </td>
|
130
|
+
<td class="context-item-desc"></td>
|
131
|
+
</tr>
|
132
|
+
</table>
|
133
|
+
</div>
|
134
|
+
</div>
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
<!-- if method_list -->
|
139
|
+
<div id="methods">
|
140
|
+
<h3 class="section-bar">Public Class methods</h3>
|
141
|
+
|
142
|
+
<div id="method-M000001" class="method-detail">
|
143
|
+
<a name="M000001"></a>
|
144
|
+
|
145
|
+
<div class="method-heading">
|
146
|
+
<a href="#M000001" class="method-signature">
|
147
|
+
<span class="method-name">new</span><span class="method-args">(srv, feed)</span>
|
148
|
+
</a>
|
149
|
+
</div>
|
150
|
+
|
151
|
+
<div class="method-description">
|
152
|
+
<p>
|
153
|
+
srv: <a href="GoogleCalendar/Service.html">GoogleCalendar::Service</a>
|
154
|
+
object feed: <a href="GoogleCalendar/Calendar.html">Calendar</a>’s
|
155
|
+
editable feed url
|
156
|
+
</p>
|
157
|
+
<p><a class="source-toggle" href="#"
|
158
|
+
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
159
|
+
<div class="method-source-code" id="M000001-source">
|
160
|
+
<pre>
|
161
|
+
<span class="ruby-comment cmt"># File lib/googlecalendar/calendar.rb, line 65</span>
|
162
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">srv</span>, <span class="ruby-identifier">feed</span>)
|
163
|
+
<span class="ruby-ivar">@srv</span> = <span class="ruby-identifier">srv</span>
|
164
|
+
<span class="ruby-ivar">@feed</span> = <span class="ruby-identifier">feed</span>
|
165
|
+
<span class="ruby-ivar">@source</span> = <span class="ruby-keyword kw">nil</span>
|
166
|
+
<span class="ruby-keyword kw">end</span>
|
167
|
+
</pre>
|
168
|
+
</div>
|
169
|
+
</div>
|
170
|
+
</div>
|
171
|
+
|
172
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
173
|
+
|
174
|
+
<div id="method-M000004" class="method-detail">
|
175
|
+
<a name="M000004"></a>
|
176
|
+
|
177
|
+
<div class="method-heading">
|
178
|
+
<a href="#M000004" class="method-signature">
|
179
|
+
<span class="method-name">create_event</span><span class="method-args">()</span>
|
180
|
+
</a>
|
181
|
+
</div>
|
182
|
+
|
183
|
+
<div class="method-description">
|
184
|
+
<p>
|
185
|
+
creates a new <a href="GoogleCalendar/Event.html">Event</a> instance which
|
186
|
+
belongs to this clandar instance.
|
187
|
+
</p>
|
188
|
+
<p><a class="source-toggle" href="#"
|
189
|
+
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
190
|
+
<div class="method-source-code" id="M000004-source">
|
191
|
+
<pre>
|
192
|
+
<span class="ruby-comment cmt"># File lib/googlecalendar/calendar.rb, line 100</span>
|
193
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_event</span>
|
194
|
+
<span class="ruby-identifier">ev</span> = <span class="ruby-constant">Event</span>.<span class="ruby-identifier">new</span>
|
195
|
+
<span class="ruby-identifier">ev</span>.<span class="ruby-identifier">srv</span> = <span class="ruby-ivar">@srv</span>
|
196
|
+
<span class="ruby-identifier">ev</span>.<span class="ruby-identifier">feed</span> = <span class="ruby-ivar">@feed</span>
|
197
|
+
<span class="ruby-identifier">ev</span>
|
198
|
+
<span class="ruby-keyword kw">end</span>
|
199
|
+
</pre>
|
200
|
+
</div>
|
201
|
+
</div>
|
202
|
+
</div>
|
203
|
+
|
204
|
+
<div id="method-M000003" class="method-detail">
|
205
|
+
<a name="M000003"></a>
|
206
|
+
|
207
|
+
<div class="method-heading">
|
208
|
+
<a href="#M000003" class="method-signature">
|
209
|
+
<span class="method-name">events</span><span class="method-args">(conditions = {})</span>
|
210
|
+
</a>
|
211
|
+
</div>
|
212
|
+
|
213
|
+
<div class="method-description">
|
214
|
+
<p>
|
215
|
+
send query to get events and returns an array of <a
|
216
|
+
href="GoogleCalendar/Event.html">Event</a> objects. if any conditions are
|
217
|
+
given, recent 25 entries are retrieved. For detail, see <a
|
218
|
+
href="GoogleCalendar/Service.html#M000020">Service#query</a>
|
219
|
+
</p>
|
220
|
+
<p><a class="source-toggle" href="#"
|
221
|
+
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
222
|
+
<div class="method-source-code" id="M000003-source">
|
223
|
+
<pre>
|
224
|
+
<span class="ruby-comment cmt"># File lib/googlecalendar/calendar.rb, line 84</span>
|
225
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">events</span>(<span class="ruby-identifier">conditions</span> = {})
|
226
|
+
<span class="ruby-identifier">ret</span> = <span class="ruby-ivar">@srv</span>.<span class="ruby-identifier">query</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">feed</span>, <span class="ruby-identifier">conditions</span>)
|
227
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidCalendarURL</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">ret</span>.<span class="ruby-identifier">code</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"200"</span>
|
228
|
+
<span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ret</span>.<span class="ruby-identifier">body</span>).<span class="ruby-identifier">root</span>.<span class="ruby-identifier">elements</span>.<span class="ruby-identifier">each</span>(<span class="ruby-value str">"entry"</span>){}.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">elem</span><span class="ruby-operator">|</span>
|
229
|
+
<span class="ruby-identifier">elem</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">"xmlns:gCal"</span>] = <span class="ruby-value str">"http://schemas.google.com/gCal/2005"</span>
|
230
|
+
<span class="ruby-identifier">elem</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">"xmlns:gd"</span>] = <span class="ruby-value str">"http://schemas.google.com/g/2005"</span>
|
231
|
+
<span class="ruby-identifier">elem</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">"xmlns"</span>] = <span class="ruby-value str">"http://www.w3.org/2005/Atom"</span>
|
232
|
+
<span class="ruby-identifier">entry</span> = <span class="ruby-constant">Event</span>.<span class="ruby-identifier">new</span>
|
233
|
+
<span class="ruby-identifier">entry</span>.<span class="ruby-identifier">srv</span> = <span class="ruby-ivar">@srv</span>
|
234
|
+
<span class="ruby-identifier">entry</span>.<span class="ruby-identifier">load_xml</span>(<span class="ruby-node">"<?xml version='1.0' encoding='UTF-8'?>#{elem.to_s}"</span>)
|
235
|
+
<span class="ruby-keyword kw">end</span>
|
236
|
+
<span class="ruby-keyword kw">end</span>
|
237
|
+
</pre>
|
238
|
+
</div>
|
239
|
+
</div>
|
240
|
+
</div>
|
241
|
+
|
242
|
+
<div id="method-M000002" class="method-detail">
|
243
|
+
<a name="M000002"></a>
|
244
|
+
|
245
|
+
<div class="method-heading">
|
246
|
+
<a href="#M000002" class="method-signature">
|
247
|
+
<span class="method-name">source</span><span class="method-args">()</span>
|
248
|
+
</a>
|
249
|
+
</div>
|
250
|
+
|
251
|
+
<div class="method-description">
|
252
|
+
<p>
|
253
|
+
REXML::Document object which represents calendar object
|
254
|
+
</p>
|
255
|
+
<p><a class="source-toggle" href="#"
|
256
|
+
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
257
|
+
<div class="method-source-code" id="M000002-source">
|
258
|
+
<pre>
|
259
|
+
<span class="ruby-comment cmt"># File lib/googlecalendar/calendar.rb, line 74</span>
|
260
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">source</span>
|
261
|
+
<span class="ruby-ivar">@source</span> = <span class="ruby-identifier">get_data</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@source</span>
|
262
|
+
<span class="ruby-ivar">@source</span>
|
263
|
+
<span class="ruby-keyword kw">end</span>
|
264
|
+
</pre>
|
265
|
+
</div>
|
266
|
+
</div>
|
267
|
+
</div>
|
268
|
+
|
269
|
+
|
270
|
+
</div>
|
271
|
+
|
272
|
+
|
273
|
+
</div>
|
274
|
+
|
275
|
+
|
276
|
+
<div id="validator-badges">
|
277
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
278
|
+
</div>
|
279
|
+
|
280
|
+
</body>
|
281
|
+
</html>
|