google_calendar 0.1.2 → 0.1.3
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.
- data/README.rdoc +4 -2
- data/VERSION +1 -1
- data/google_calendar.gemspec +3 -3
- data/lib/google/calendar.rb +11 -1
- data/lib/google/connection.rb +5 -6
- data/test/test_google_calendar.rb +36 -0
- metadata +12 -12
data/README.rdoc
CHANGED
@@ -5,13 +5,15 @@ A fast lightweight and minimalist wrapper around the google calendar api.
|
|
5
5
|
== Install
|
6
6
|
[sudo] gem install 'google_calendar'
|
7
7
|
|
8
|
-
Note:
|
8
|
+
Note: Google requests that you set the name of your application so they can better monitor the use of their services.
|
9
9
|
|
10
10
|
== Usage
|
11
11
|
require 'rubygems'
|
12
12
|
require 'google_calendar'
|
13
13
|
|
14
|
-
cal = Google::Calendar.new(:username => 'some.person@gmail.com',
|
14
|
+
cal = Google::Calendar.new(:username => 'some.person@gmail.com',
|
15
|
+
:password => 'super-secret',
|
16
|
+
:app_name => 'mycompany.com-googlecalendar-integration')
|
15
17
|
|
16
18
|
event = cal.create_event do |e|
|
17
19
|
e.title = 'A Cool Event'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/google_calendar.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{google_calendar}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Steve Zich"]
|
12
|
-
s.date = %q{2011-01-
|
12
|
+
s.date = %q{2011-01-28}
|
13
13
|
s.description = %q{A minimal wrapper around the google calendar API, which uses nokogiri for fast parsing.}
|
14
14
|
s.email = %q{steve.zich@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -42,7 +42,7 @@ Gem::Specification.new do |s|
|
|
42
42
|
s.homepage = %q{http://github.com/northworld/google_calendar}
|
43
43
|
s.licenses = ["MIT"]
|
44
44
|
s.require_paths = ["lib"]
|
45
|
-
s.rubygems_version = %q{1.4.
|
45
|
+
s.rubygems_version = %q{1.4.2}
|
46
46
|
s.summary = %q{A lightweight google calendar API wrapper}
|
47
47
|
s.test_files = [
|
48
48
|
"test/helper.rb",
|
data/lib/google/calendar.rb
CHANGED
@@ -10,6 +10,8 @@ module Google
|
|
10
10
|
# * :username => the username of the specified calendar (i.e. some.guy@gmail.com)
|
11
11
|
# * :password => the password for the specified user (i.e. super-secret)
|
12
12
|
# * :calendar => the name of the calendar you would like to work with (optional, defaults to the calendar the user setup as their default one.)
|
13
|
+
# * :app_name => the name of your application (defaults to 'northworld.com-googlecalendar-integration')
|
14
|
+
# * :auth_url => the base url that is used to connect to google (defaults to 'https://www.google.com/accounts/ClientLogin')
|
13
15
|
#
|
14
16
|
# After creating an instace you are immediatly logged on and ready to go.
|
15
17
|
#
|
@@ -20,12 +22,20 @@ module Google
|
|
20
22
|
# # Specify the calendar
|
21
23
|
# Calendar.new(username: => 'some.guy@gmail.com', :password => 'ilovepie!', :calendar => 'my.company@gmail.com')
|
22
24
|
#
|
25
|
+
# # Specify the app_name
|
26
|
+
# Calendar.new(username: => 'some.guy@gmail.com', :password => 'ilovepie!', :app_name => 'mycompany.com-googlecalendar-integration')
|
27
|
+
#
|
23
28
|
def initialize(params)
|
24
29
|
username = params[:username]
|
25
30
|
password = params[:password]
|
26
31
|
@calendar = params[:calendar]
|
32
|
+
app_name = params[:app_name]
|
33
|
+
auth_url = params[:auth_url]
|
27
34
|
|
28
|
-
@connection = Connection.new(:username => username,
|
35
|
+
@connection = Connection.new(:username => username,
|
36
|
+
:password => password,
|
37
|
+
:app_name => app_name,
|
38
|
+
:auth_url => auth_url)
|
29
39
|
end
|
30
40
|
|
31
41
|
# Find all of the events associated with this calendar.
|
data/lib/google/connection.rb
CHANGED
@@ -7,14 +7,13 @@ module Google
|
|
7
7
|
# communication with the google calendar api.
|
8
8
|
#
|
9
9
|
class Connection
|
10
|
-
|
11
|
-
APP_NAME = "northworld.com-googlecalendar-integration"
|
12
|
-
|
13
|
-
# set the username and password and login.
|
10
|
+
# set the username, password, auth_url, app_name, and login.
|
14
11
|
#
|
15
12
|
def initialize(params)
|
16
13
|
@username = params[:username]
|
17
14
|
@password = params[:password]
|
15
|
+
@auth_url = params[:auth_url] || "https://www.google.com/accounts/ClientLogin"
|
16
|
+
@app_name = params[:app_name] || "northworld.com-googlecalendar-integration"
|
18
17
|
|
19
18
|
login()
|
20
19
|
end
|
@@ -25,11 +24,11 @@ module Google
|
|
25
24
|
content = {
|
26
25
|
'Email' => @username,
|
27
26
|
'Passwd' => @password,
|
28
|
-
'source' =>
|
27
|
+
'source' => @app_name,
|
29
28
|
'accountType' => 'HOSTED_OR_GOOGLE',
|
30
29
|
'service' => 'cl'}
|
31
30
|
|
32
|
-
response = send(Addressable::URI.parse(
|
31
|
+
response = send(Addressable::URI.parse(@auth_url), :post_form, content)
|
33
32
|
|
34
33
|
raise HTTPRequestFailed unless response.kind_of? Net::HTTPSuccess
|
35
34
|
|
@@ -31,6 +31,42 @@ class TestGoogleCalendar < Test::Unit::TestCase
|
|
31
31
|
Calendar.new(:username => 'some.one@gmail.com', :password => 'wrong-password')
|
32
32
|
end
|
33
33
|
end
|
34
|
+
|
35
|
+
should "login properly with an app_name" do
|
36
|
+
assert_nothing_thrown do
|
37
|
+
Calendar.new(:username => 'some.one@gmail.com', :password => 'super-secret',
|
38
|
+
:app_name => 'northworld.com-googlecalendar-integration'
|
39
|
+
)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
should "catch login with invalid app_name" do
|
44
|
+
@http_mock.stubs(:kind_of?).with(Net::HTTPForbidden).returns(true)
|
45
|
+
@http_mock.stubs(:body).returns('Error=BadAuthentication')
|
46
|
+
assert_raise(HTTPAuthorizationFailed) do
|
47
|
+
Calendar.new(:username => 'some.one@gmail.com', :password => 'super-secret',
|
48
|
+
:app_name => 'northworld.com-silly-cal'
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
should "login properly with an auth_url" do
|
54
|
+
assert_nothing_thrown do
|
55
|
+
Calendar.new(:username => 'some.one@gmail.com', :password => 'super-secret',
|
56
|
+
:auth_url => "https://www.google.com/accounts/ClientLogin"
|
57
|
+
)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
should "catch login with invalid auth_url" do
|
62
|
+
@http_mock.stubs(:kind_of?).with(Net::HTTPForbidden).returns(true)
|
63
|
+
@http_mock.stubs(:body).returns('Error=BadAuthentication')
|
64
|
+
assert_raise(HTTPAuthorizationFailed) do
|
65
|
+
Calendar.new(:username => 'some.one@gmail.com', :password => 'super-secret',
|
66
|
+
:auth_url => "https://www.google.com/accounts/ClientLogin/waffles"
|
67
|
+
)
|
68
|
+
end
|
69
|
+
end
|
34
70
|
|
35
71
|
end # login context
|
36
72
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_calendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Steve Zich
|
@@ -15,10 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-28 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
+
type: :runtime
|
22
23
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
24
|
none: false
|
24
25
|
requirements:
|
@@ -33,8 +34,8 @@ dependencies:
|
|
33
34
|
requirement: *id001
|
34
35
|
prerelease: false
|
35
36
|
name: nokogiri
|
36
|
-
type: :runtime
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
+
type: :runtime
|
38
39
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
40
|
none: false
|
40
41
|
requirements:
|
@@ -49,8 +50,8 @@ dependencies:
|
|
49
50
|
requirement: *id002
|
50
51
|
prerelease: false
|
51
52
|
name: addressable
|
52
|
-
type: :runtime
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
|
+
type: :development
|
54
55
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
55
56
|
none: false
|
56
57
|
requirements:
|
@@ -63,8 +64,8 @@ dependencies:
|
|
63
64
|
requirement: *id003
|
64
65
|
prerelease: false
|
65
66
|
name: shoulda
|
66
|
-
type: :development
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
|
+
type: :development
|
68
69
|
version_requirements: &id004 !ruby/object:Gem::Requirement
|
69
70
|
none: false
|
70
71
|
requirements:
|
@@ -79,8 +80,8 @@ dependencies:
|
|
79
80
|
requirement: *id004
|
80
81
|
prerelease: false
|
81
82
|
name: bundler
|
82
|
-
type: :development
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
+
type: :development
|
84
85
|
version_requirements: &id005 !ruby/object:Gem::Requirement
|
85
86
|
none: false
|
86
87
|
requirements:
|
@@ -95,8 +96,8 @@ dependencies:
|
|
95
96
|
requirement: *id005
|
96
97
|
prerelease: false
|
97
98
|
name: jeweler
|
98
|
-
type: :development
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
|
+
type: :development
|
100
101
|
version_requirements: &id006 !ruby/object:Gem::Requirement
|
101
102
|
none: false
|
102
103
|
requirements:
|
@@ -109,8 +110,8 @@ dependencies:
|
|
109
110
|
requirement: *id006
|
110
111
|
prerelease: false
|
111
112
|
name: rcov
|
112
|
-
type: :development
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
|
+
type: :development
|
114
115
|
version_requirements: &id007 !ruby/object:Gem::Requirement
|
115
116
|
none: false
|
116
117
|
requirements:
|
@@ -123,7 +124,6 @@ dependencies:
|
|
123
124
|
requirement: *id007
|
124
125
|
prerelease: false
|
125
126
|
name: mocha
|
126
|
-
type: :development
|
127
127
|
description: A minimal wrapper around the google calendar API, which uses nokogiri for fast parsing.
|
128
128
|
email: steve.zich@gmail.com
|
129
129
|
executables: []
|
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
requirements: []
|
186
186
|
|
187
187
|
rubyforge_project:
|
188
|
-
rubygems_version: 1.4.
|
188
|
+
rubygems_version: 1.4.2
|
189
189
|
signing_key:
|
190
190
|
specification_version: 3
|
191
191
|
summary: A lightweight google calendar API wrapper
|