google_calendar 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = "google_calendar"
8
- s.version = "0.2.0"
7
+ s.name = %q{google_calendar}
8
+ s.version = "0.2.1"
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 = "2011-11-07"
13
- s.description = "A minimal wrapper around the google calendar API, which uses nokogiri for fast parsing."
14
- s.email = "steve.zich@gmail.com"
12
+ s.date = %q{2011-11-10}
13
+ s.description = %q{A minimal wrapper around the google calendar API, which uses nokogiri for fast parsing.}
14
+ s.email = %q{steve.zich@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
17
  "README.rdoc"
@@ -41,11 +41,11 @@ Gem::Specification.new do |s|
41
41
  "test/mocks/successful_login.txt",
42
42
  "test/test_google_calendar.rb"
43
43
  ]
44
- s.homepage = "http://github.com/northworld/google_calendar"
44
+ s.homepage = %q{http://github.com/northworld/google_calendar}
45
45
  s.licenses = ["MIT"]
46
46
  s.require_paths = ["lib"]
47
- s.rubygems_version = "1.8.10"
48
- s.summary = "A lightweight google calendar API wrapper"
47
+ s.rubygems_version = %q{1.4.2}
48
+ s.summary = %q{A lightweight google calendar API wrapper}
49
49
  s.test_files = [
50
50
  "test/helper.rb",
51
51
  "test/test_google_calendar.rb"
@@ -27,14 +27,18 @@ module Google
27
27
  # # Specify the app_name
28
28
  # Calendar.new(:username => 'some.guy@gmail.com', :password => 'ilovepie!', :app_name => 'mycompany.com-googlecalendar-integration')
29
29
  #
30
+
31
+ # Calendar attributes
32
+ attr_accessor :username, :password, :app_name, :auth_url, :connection, :calendar
33
+
30
34
  def initialize(params)
31
- username = params[:username]
32
- password = params[:password]
33
- @calendar = params[:calendar]
34
- app_name = params[:app_name]
35
- auth_url = params[:auth_url]
35
+ self.username = params[:username]
36
+ self.password = params[:password]
37
+ self.calendar = params[:calendar]
38
+ self.app_name = params[:app_name]
39
+ self.auth_url = params[:auth_url]
36
40
 
37
- @connection = Connection.new(:username => username,
41
+ self.connection = Connection.new(:username => username,
38
42
  :password => password,
39
43
  :app_name => app_name,
40
44
  :auth_url => auth_url)
@@ -134,6 +138,27 @@ module Google
134
138
  @connection.send(Addressable::URI.parse(events_url + "/#{event.id}"), :delete)
135
139
  end
136
140
 
141
+ # Explicitly reload the connection to google calendar
142
+ #
143
+ # Examples
144
+ # class User
145
+ # def calendar
146
+ # @calendar ||= Google::Calendar.new :username => "foo@gmail.com", :password => "bar"
147
+ # end
148
+ # end
149
+ # user = User.new
150
+ # 2.times { user.calendar } #only one HTTP authentication request to google
151
+ # user.calendar.reload #new HTTP authentication request to google
152
+ #
153
+ # Returns Google::Calendar instance
154
+ def reload
155
+ self.connection = Connection.new(:username => username,
156
+ :password => password,
157
+ :app_name => app_name,
158
+ :auth_url => auth_url)
159
+ self
160
+ end
161
+
137
162
  protected
138
163
 
139
164
  def event_lookup(query_string = '') #:nodoc:
@@ -179,7 +204,6 @@ module Google
179
204
  event.save
180
205
  event
181
206
  end
182
-
183
207
  end
184
208
 
185
209
  end
@@ -31,76 +31,76 @@ 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
34
+
35
+ should "login properly with an app_name" do
36
36
  assert_nothing_thrown do
37
- Calendar.new(:username => 'some.one@gmail.com', :password => 'super-secret',
38
- :app_name => 'northworld.com-googlecalendar-integration'
37
+ Calendar.new(:username => 'some.one@gmail.com', :password => 'super-secret',
38
+ :app_name => 'northworld.com-googlecalendar-integration'
39
39
  )
40
40
  end
41
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
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
+ )
59
50
  end
51
+ end
60
52
 
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
70
-
71
- should "login properly with a calendar" do
72
- assert_nothing_thrown do
73
- cal = Calendar.new(:username => 'some.one@gmail.com', :password => 'super-secret',
74
- :calendar => "Little Giants")
75
-
76
- #mock calendar list request
77
- calendar_uri = mock("get calendar uri")
78
- Addressable::URI.expects(:parse).with("https://www.google.com/calendar/feeds/default/allcalendars/full").once.returns(calendar_uri)
79
- Connection.any_instance.expects(:send).with(calendar_uri, :get).once.returns(mock("response", :body => get_mock_body('list_calendars.xml')))
80
-
81
- #mock events list request
82
- events_uri = mock("get events uri")
83
- Addressable::URI.expects(:parse).with("https://www.google.com/calendar/feeds/rf1c66uld6dgk2t5lh43svev6g%40group.calendar.google.com/private/full").once.returns(events_uri)
84
- Connection.any_instance.expects(:send).with(events_uri, :get).once.returns(mock("response", :body => get_mock_body('events.xml')))
85
-
86
- cal.events
87
- end
88
- end
89
-
90
- should "catch login with invalid calendar" do
91
-
92
- assert_raise(InvalidCalendar) do
93
- cal = Calendar.new(:username => 'some.one@gmail.com', :password => 'super-secret',
94
- :calendar => "invalid calendar")
95
-
96
- #mock calendar list request
97
- calendar_uri = mock("get calendar uri")
98
- Addressable::URI.expects(:parse).with("https://www.google.com/calendar/feeds/default/allcalendars/full").once.returns(calendar_uri)
99
- Connection.any_instance.expects(:send).with(calendar_uri, :get).once.returns(mock("response", :body => get_mock_body('list_calendars.xml')))
100
-
101
- cal.events
102
- end
103
- end
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
70
+
71
+ should "login properly with a calendar" do
72
+ assert_nothing_thrown do
73
+ cal = Calendar.new(:username => 'some.one@gmail.com', :password => 'super-secret',
74
+ :calendar => "Little Giants")
75
+
76
+ #mock calendar list request
77
+ calendar_uri = mock("get calendar uri")
78
+ Addressable::URI.expects(:parse).with("https://www.google.com/calendar/feeds/default/allcalendars/full").once.returns(calendar_uri)
79
+ Connection.any_instance.expects(:send).with(calendar_uri, :get).once.returns(mock("response", :body => get_mock_body('list_calendars.xml')))
80
+
81
+ #mock events list request
82
+ events_uri = mock("get events uri")
83
+ Addressable::URI.expects(:parse).with("https://www.google.com/calendar/feeds/rf1c66uld6dgk2t5lh43svev6g%40group.calendar.google.com/private/full").once.returns(events_uri)
84
+ Connection.any_instance.expects(:send).with(events_uri, :get).once.returns(mock("response", :body => get_mock_body('events.xml')))
85
+
86
+ cal.events
87
+ end
88
+ end
89
+
90
+ should "catch login with invalid calendar" do
91
+
92
+ assert_raise(InvalidCalendar) do
93
+ cal = Calendar.new(:username => 'some.one@gmail.com', :password => 'super-secret',
94
+ :calendar => "invalid calendar")
95
+
96
+ #mock calendar list request
97
+ calendar_uri = mock("get calendar uri")
98
+ Addressable::URI.expects(:parse).with("https://www.google.com/calendar/feeds/default/allcalendars/full").once.returns(calendar_uri)
99
+ Connection.any_instance.expects(:send).with(calendar_uri, :get).once.returns(mock("response", :body => get_mock_body('list_calendars.xml')))
100
+
101
+ cal.events
102
+ end
103
+ end
104
104
 
105
105
  end # login context
106
106
 
@@ -109,6 +109,11 @@ class TestGoogleCalendar < Test::Unit::TestCase
109
109
  @calendar = Calendar.new(:username => 'some.one@gmail.com', :password => 'super-secret')
110
110
  end
111
111
 
112
+ should "reload connection" do
113
+ old_connection = @calendar.connection
114
+ assert_not_equal old_connection, @calendar.reload.connection
115
+ end
116
+
112
117
  should "find all events" do
113
118
  @http_mock.stubs(:body).returns( get_mock_body("events.xml") )
114
119
  assert_equal @calendar.events.length, 3
metadata CHANGED
@@ -1,102 +1,139 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: google_calendar
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.0
3
+ version: !ruby/object:Gem::Version
4
+ hash: 21
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 1
10
+ version: 0.2.1
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Steve Zich
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2011-11-07 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: nokogiri
16
- requirement: &70109869359520 !ruby/object:Gem::Requirement
17
+
18
+ date: 2011-11-10 00:00:00 -08:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ type: :runtime
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
17
24
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 15
29
+ segments:
30
+ - 1
31
+ - 4
32
+ - 4
21
33
  version: 1.4.4
34
+ requirement: *id001
35
+ prerelease: false
36
+ name: nokogiri
37
+ - !ruby/object:Gem::Dependency
22
38
  type: :runtime
39
+ version_requirements: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 2
47
+ - 2
48
+ - 2
49
+ version: 2.2.2
50
+ requirement: *id002
23
51
  prerelease: false
24
- version_requirements: *70109869359520
25
- - !ruby/object:Gem::Dependency
26
52
  name: addressable
27
- requirement: &70109869358300 !ruby/object:Gem::Requirement
53
+ - !ruby/object:Gem::Dependency
54
+ type: :development
55
+ version_requirements: &id003 !ruby/object:Gem::Requirement
28
56
  none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: 2.2.2
33
- type: :runtime
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ requirement: *id003
34
65
  prerelease: false
35
- version_requirements: *70109869358300
36
- - !ruby/object:Gem::Dependency
37
66
  name: shoulda
38
- requirement: &70109869357620 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
67
+ - !ruby/object:Gem::Dependency
44
68
  type: :development
45
- prerelease: false
46
- version_requirements: *70109869357620
47
- - !ruby/object:Gem::Dependency
48
- name: bundler
49
- requirement: &70109869346740 !ruby/object:Gem::Requirement
69
+ version_requirements: &id004 !ruby/object:Gem::Requirement
50
70
  none: false
51
- requirements:
71
+ requirements:
52
72
  - - ~>
53
- - !ruby/object:Gem::Version
73
+ - !ruby/object:Gem::Version
74
+ hash: 23
75
+ segments:
76
+ - 1
77
+ - 0
78
+ - 0
54
79
  version: 1.0.0
55
- type: :development
80
+ requirement: *id004
56
81
  prerelease: false
57
- version_requirements: *70109869346740
58
- - !ruby/object:Gem::Dependency
59
- name: jeweler
60
- requirement: &70109869345680 !ruby/object:Gem::Requirement
82
+ name: bundler
83
+ - !ruby/object:Gem::Dependency
84
+ type: :development
85
+ version_requirements: &id005 !ruby/object:Gem::Requirement
61
86
  none: false
62
- requirements:
87
+ requirements:
63
88
  - - ~>
64
- - !ruby/object:Gem::Version
89
+ - !ruby/object:Gem::Version
90
+ hash: 1
91
+ segments:
92
+ - 1
93
+ - 5
94
+ - 1
65
95
  version: 1.5.1
96
+ requirement: *id005
97
+ prerelease: false
98
+ name: jeweler
99
+ - !ruby/object:Gem::Dependency
66
100
  type: :development
101
+ version_requirements: &id006 !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ requirement: *id006
67
111
  prerelease: false
68
- version_requirements: *70109869345680
69
- - !ruby/object:Gem::Dependency
70
112
  name: rcov
71
- requirement: &70109869343760 !ruby/object:Gem::Requirement
72
- none: false
73
- requirements:
74
- - - ! '>='
75
- - !ruby/object:Gem::Version
76
- version: '0'
113
+ - !ruby/object:Gem::Dependency
77
114
  type: :development
78
- prerelease: false
79
- version_requirements: *70109869343760
80
- - !ruby/object:Gem::Dependency
81
- name: mocha
82
- requirement: &70109869342600 !ruby/object:Gem::Requirement
115
+ version_requirements: &id007 !ruby/object:Gem::Requirement
83
116
  none: false
84
- requirements:
85
- - - ! '>='
86
- - !ruby/object:Gem::Version
87
- version: '0'
88
- type: :development
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ hash: 3
121
+ segments:
122
+ - 0
123
+ version: "0"
124
+ requirement: *id007
89
125
  prerelease: false
90
- version_requirements: *70109869342600
91
- description: A minimal wrapper around the google calendar API, which uses nokogiri
92
- for fast parsing.
126
+ name: mocha
127
+ description: A minimal wrapper around the google calendar API, which uses nokogiri for fast parsing.
93
128
  email: steve.zich@gmail.com
94
129
  executables: []
130
+
95
131
  extensions: []
96
- extra_rdoc_files:
132
+
133
+ extra_rdoc_files:
97
134
  - LICENSE.txt
98
135
  - README.rdoc
99
- files:
136
+ files:
100
137
  - .document
101
138
  - Gemfile
102
139
  - Gemfile.lock
@@ -120,34 +157,40 @@ files:
120
157
  - test/mocks/query_events.xml
121
158
  - test/mocks/successful_login.txt
122
159
  - test/test_google_calendar.rb
160
+ has_rdoc: true
123
161
  homepage: http://github.com/northworld/google_calendar
124
- licenses:
162
+ licenses:
125
163
  - MIT
126
164
  post_install_message:
127
165
  rdoc_options: []
128
- require_paths:
166
+
167
+ require_paths:
129
168
  - lib
130
- required_ruby_version: !ruby/object:Gem::Requirement
169
+ required_ruby_version: !ruby/object:Gem::Requirement
131
170
  none: false
132
- requirements:
133
- - - ! '>='
134
- - !ruby/object:Gem::Version
135
- version: '0'
136
- segments:
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ hash: 3
175
+ segments:
137
176
  - 0
138
- hash: 3242428222687686780
139
- required_rubygems_version: !ruby/object:Gem::Requirement
177
+ version: "0"
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
179
  none: false
141
- requirements:
142
- - - ! '>='
143
- - !ruby/object:Gem::Version
144
- version: '0'
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ hash: 3
184
+ segments:
185
+ - 0
186
+ version: "0"
145
187
  requirements: []
188
+
146
189
  rubyforge_project:
147
- rubygems_version: 1.8.10
190
+ rubygems_version: 1.4.2
148
191
  signing_key:
149
192
  specification_version: 3
150
193
  summary: A lightweight google calendar API wrapper
151
- test_files:
194
+ test_files:
152
195
  - test/helper.rb
153
196
  - test/test_google_calendar.rb