google_calendar_api_v2 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,10 +2,15 @@ module GoogleCalendarApiV2
2
2
  module Base
3
3
  attr_reader :connection
4
4
 
5
+
6
+ private
7
+
5
8
  def success?(response)
6
9
  case response.code.to_i
7
10
  when 200, 201
8
11
  true
12
+ when 401
13
+ raise GoogleCalendarApiV2::AuthenticationError.new response
9
14
  else
10
15
  false
11
16
  end
@@ -0,0 +1,8 @@
1
+ module GoogleCalendarApiV2
2
+ class AuthenticationError < StandardError
3
+ attr_reader :response
4
+ def initialize(response)
5
+ @response = response
6
+ end
7
+ end
8
+ end
@@ -30,7 +30,7 @@ module GoogleCalendarApiV2
30
30
  if success? response
31
31
  Response::Calendar.new(response, @connection)
32
32
  else
33
- response
33
+ false
34
34
  end
35
35
  end
36
36
 
@@ -3,7 +3,7 @@ require 'json'
3
3
  module GoogleCalendarApiV2
4
4
  module Response
5
5
  module Base
6
- attr_reader :response, :connection, :attributes
6
+ attr_reader :response, :attributes
7
7
 
8
8
  def initialize(response, connection, parent = nil)
9
9
  @response, @connection = response, connection
@@ -53,17 +53,6 @@ module GoogleCalendarApiV2
53
53
  @attributes['id'].split('/').last
54
54
  end
55
55
 
56
- private
57
-
58
- def success?(response)
59
- case response.code.to_i
60
- when 200, 201
61
- true
62
- else
63
- false
64
- end
65
- end
66
-
67
56
  end
68
57
  end
69
58
  end
@@ -1,6 +1,7 @@
1
1
  module GoogleCalendarApiV2
2
2
  module Response
3
3
  class Calendar
4
+ include GoogleCalendarApiV2::Base
4
5
  include Base
5
6
 
6
7
  attr_reader :events
@@ -1,6 +1,7 @@
1
1
  module GoogleCalendarApiV2
2
2
  module Response
3
3
  class Event
4
+ include GoogleCalendarApiV2::Base
4
5
  include Base
5
6
 
6
7
  attr_reader :calendar
@@ -4,6 +4,8 @@ module GoogleCalendarApiV2
4
4
  autoload :Calendar, 'google_calendar_api_v2/calendar'
5
5
  autoload :Event, 'google_calendar_api_v2/event'
6
6
 
7
+ autoload :AuthenticationError, 'google_calendar_api_v2/error/authentication'
8
+
7
9
  module Response
8
10
  autoload :Base, 'google_calendar_api_v2/response/base'
9
11
  autoload :Calendar, 'google_calendar_api_v2/response/calendar'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_calendar_api_v2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-10 00:00:00.000000000 Z
12
+ date: 2012-02-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth
16
- requirement: &70155641661760 !ruby/object:Gem::Requirement
16
+ requirement: &70104510747640 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70155641661760
24
+ version_requirements: *70104510747640
25
25
  description:
26
26
  email: unixcharles@gmail.com
27
27
  executables: []
@@ -35,6 +35,7 @@ files:
35
35
  - lib/google_calendar_api_v2/client.rb
36
36
  - lib/google_calendar_api_v2/calendar.rb
37
37
  - lib/google_calendar_api_v2/event.rb
38
+ - lib/google_calendar_api_v2/error/authentication.rb
38
39
  - lib/google_calendar_api_v2/response/base.rb
39
40
  - lib/google_calendar_api_v2/response/calendar.rb
40
41
  - lib/google_calendar_api_v2/response/event.rb