google_calendar 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0abc20ca5bb465a9042cad4e9941fbaa0397888
4
- data.tar.gz: 21d702bee56ff9ae28582efc993f9765015b6ee7
3
+ metadata.gz: cb6ee8f97c1f4f064a5915428a3b5259a5f0d050
4
+ data.tar.gz: 01915a98a647b36bd2f22121db9f162196d6e952
5
5
  SHA512:
6
- metadata.gz: 1c881f0d97bab2f853c863f7e58b1d1385001b2b1b2bd101cb91f113d3ef5d599dc80b5bc53fd453b566e147ba24b14681364c405fe9a927e3fa25cc052dac68
7
- data.tar.gz: 4c56297fdd70294df8b274651ad3bc28b3cf9e1025ccbb5fab8dfd3a046f7707797a44a94be0ef08fad496c2ebc3da80490d841a208057f80b0d2ed1e93a01c1
6
+ metadata.gz: 97dba08c8fcc7e2c9e25917992c5a5830325412dbbd0bace74eb9c147fe08d02f0e04b353f234e4ed571d8a87b75693636d096d5fa61792648fe137745807d92
7
+ data.tar.gz: 4b024ebb4f6b049afe2df43bcb4c08a869660781a36a60c73566912b4da471a0b834db06815ef3aa63a61404d1a535ff1f608a29edc3333584a74bb902589470
data/Gemfile CHANGED
@@ -2,3 +2,4 @@ source "http://rubygems.org"
2
2
 
3
3
  # Using google_calendar to manage dependencies
4
4
  gemspec
5
+ gem "codeclimate-test-reporter", group: :test, require: nil
data/Gemfile.lock CHANGED
@@ -2,7 +2,6 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  google_calendar (0.4.0)
5
- addressable (>= 2.2.2)
6
5
  signet (>= 0.5.1)
7
6
 
8
7
  GEM
@@ -13,6 +12,8 @@ GEM
13
12
  builder (3.2.2)
14
13
  celluloid (0.16.0)
15
14
  timers (~> 4.0.0)
15
+ codeclimate-test-reporter (0.4.1)
16
+ simplecov (>= 0.7.1, < 1.0.0)
16
17
  coderay (1.1.0)
17
18
  docile (1.1.5)
18
19
  faraday (0.9.0)
@@ -81,6 +82,7 @@ PLATFORMS
81
82
 
82
83
  DEPENDENCIES
83
84
  bundler (>= 1.0.0)
85
+ codeclimate-test-reporter
84
86
  google_calendar!
85
87
  guard-minitest
86
88
  minitest (~> 5.1)
@@ -90,5 +92,4 @@ DEPENDENCIES
90
92
  rb-fsevent
91
93
  rdoc (>= 3)
92
94
  shoulda-context
93
- simplecov (~> 0.9.0)
94
95
  terminal-notifier-guard
data/README.rdoc CHANGED
@@ -1,45 +1,41 @@
1
1
 
2
2
  = Google Calendar
3
3
 
4
- A fast lightweight and minimalist wrapper around the google calendar api.
4
+ A fast lightweight and minimalist wrapper around the {Google Calendar}[https://www.google.com/calendar/] api.
5
5
 
6
- {<img src="https://travis-ci.org/northworld/google_calendar.png?branch=master" alt="Build Status" />}[https://travis-ci.org/northworld/google_calendar] {<img src="https://gemnasium.com/northworld/google_calendar.png" alt="Dependency Status" />}[https://gemnasium.com/northworld/google_calendar] {<img src="https://codeclimate.com/github/northworld/google_calendar/badges/gpa.svg" />}[https://codeclimate.com/github/northworld/google_calendar]
6
+ {<img src="https://badge.fury.io/rb/google_calendar.svg" alt="Gem Version" />}[http://badge.fury.io/rb/google_calendar] {<img src="https://travis-ci.org/northworld/google_calendar.png?branch=master" alt="Build Status" />}[https://travis-ci.org/northworld/google_calendar] {<img src="https://gemnasium.com/northworld/google_calendar.png" alt="Dependency Status" />}[https://gemnasium.com/northworld/google_calendar] {<img src="https://codeclimate.com/github/northworld/google_calendar/badges/gpa.svg" />}[https://codeclimate.com/github/northworld/google_calendar] {<img src="https://codeclimate.com/github/northworld/google_calendar/badges/coverage.svg" />}[https://codeclimate.com/github/northworld/google_calendar]
7
7
  == Install
8
8
  [sudo] gem install 'google_calendar'
9
9
 
10
10
  == Setup
11
11
 
12
- Obtain a Client ID and Secret from Google
12
+ <b>Obtain a Client ID and Secret</b>
13
13
 
14
- Go to the {Google Developers Console}[https://console.developers.google.com/].
15
- Select a project, or create a new one.
16
- In the sidebar on the left, expand APIs & auth. Next, click APIs. In the list of APIs, make sure the status is ON for the Calendar API.
17
- In the sidebar on the left, select Credentials.
18
- In either case, you end up on the Credentials page and can create your project's credentials from here.
14
+ 1. Go to the {Google Developers Console}[https://console.developers.google.com/].
15
+ 1. Select a project, or create a new one.
16
+ 1. In the sidebar on the left, expand APIs & auth. Next, click APIs. In the list of APIs, make sure the status is ON for the Calendar API.
17
+ 1. In the sidebar on the left, select Credentials.
18
+ 1. In either case, you end up on the Credentials page and can create your project's credentials from here.
19
+ 1. If you haven't done so already, create your OAuth 2.0 credentials by clicking Create new Client ID under the OAuth heading. Next, look for your application's client ID and client secret in the relevant table. You may also create and edit redirect URIs from this page.
19
20
 
20
- If you haven't done so already, create your OAuth 2.0 credentials by clicking Create new Client ID under the OAuth heading. Next, look for your application's client ID and client secret in the relevant table. You may also create and edit redirect URIs from this page.
21
+ <em>Take note of the Client ID as you'll need to add it to your code later.</em>
21
22
 
22
- Take note of the Client ID as you'll need to add it to your code later.
23
+ <b>Find your calendar ID</b>
23
24
 
24
- === How to find your calendar ID
25
- Visit Google calendar in your web browser.
26
- In the calendar list on the left, click the down-arrow button next to the appropriate calendar, then select Calendar settings.
27
- In the Calendar Address section, locate the Calendar ID listed next to the XML, ICAL and HTML buttons.
28
- Copy the Calendar ID.
25
+ 1. Visit {Google Calendar}[https://www.google.com/calendar/] in your web browser.
26
+ 1. In the calendar list on the left, click the down-arrow button next to the appropriate calendar, then select Calendar settings.
27
+ 1. In the Calendar Address section, locate the Calendar ID listed next to the XML, ICAL and HTML buttons.
28
+ 1. Copy the Calendar ID.
29
29
 
30
30
  == Usage
31
31
  require 'rubygems'
32
32
  require 'google_calendar'
33
33
 
34
- YOUR_CLIENT_ID = ""
35
- YOUR_SECRET = ""
36
- YOUR_CALENDAR_ID = ""
37
-
38
34
  # Create an instance of the calendar.
39
- cal = Google::Calendar.new(:client_id => YOUR_CLIENT_ID,
35
+ cal = Google::Calendar.new(:client_id => YOUR_CLIENT_ID,
40
36
  :client_secret => YOUR_SECRET,
41
- :calendar => YOUR_CALENDAR_ID,
42
- :redirect_url => "urn:ietf:wg:oauth:2.0:oob" # this is what Google uses for 'applications'
37
+ :calendar => YOUR_CALENDAR_ID,
38
+ :redirect_url => "urn:ietf:wg:oauth:2.0:oob" # this is what Google uses for 'applications'
43
39
  )
44
40
 
45
41
  puts "Do you already have a refresh token? (y/n)"
@@ -61,6 +57,7 @@ A fast lightweight and minimalist wrapper around the google calendar api.
61
57
  $stdin.gets.chomp
62
58
 
63
59
  else
60
+
64
61
  puts "Enter your refresh token"
65
62
  refresh_token = $stdin.gets.chomp
66
63
  cal.login_with_refresh_token(refresh_token)
@@ -106,4 +103,4 @@ Note: This is not a complete implementation of the calendar api, it just include
106
103
 
107
104
  == Copyright
108
105
 
109
- Copyright (c) 2010 Steve Zich. See LICENSE.txt for further details.
106
+ Copyright (c) 2010-2014 Steve Zich. See LICENSE.txt for further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "google_calendar"
5
- s.version = "0.4.0"
6
- s.date = "2014-11-17"
5
+ s.version = "0.4.1"
6
+ s.date = "2014-11-21"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
 
10
10
  s.authors = ["Steve Zich"]
11
11
  s.email = "steve.zich@gmail.com"
12
12
 
13
- s.summary = "A lightweight google calendar API wrapper"
13
+ s.summary = "A lightweight Google Calendar API wrapper"
14
14
  s.description = "A minimal wrapper around the google calendar API"
15
- s.homepage = "http://github.com/northworld/google_calendar"
15
+ s.homepage = "http://northworld.github.io/google_calendar/"
16
16
  s.licenses = ["MIT"]
17
17
 
18
18
  s.extra_rdoc_files = [
@@ -27,7 +27,6 @@ Gem::Specification.new do |s|
27
27
  s.rubygems_version = "1.8.24"
28
28
 
29
29
  s.add_runtime_dependency(%q<signet>, [">= 0.5.1"])
30
- s.add_runtime_dependency(%q<addressable>, [">= 2.2.2"])
31
30
 
32
31
  s.add_development_dependency(%q<terminal-notifier-guard>, [">= 0"])
33
32
  s.add_development_dependency(%q<rb-fsevent>, [">= 0"])
@@ -39,6 +38,5 @@ Gem::Specification.new do |s|
39
38
  s.add_development_dependency(%q<mocha>, [">= 0"])
40
39
  s.add_development_dependency(%q<rake>, ["> 10"])
41
40
  s.add_development_dependency(%q<rdoc>, [">= 3"])
42
- s.add_development_dependency(%q<simplecov>, ["~> 0.9.0"])
43
41
 
44
42
  end
@@ -142,7 +142,7 @@ module Google
142
142
  # an array of events if many found.
143
143
  #
144
144
  def find_future_events(options={})
145
- formatted_start_min = encode_time(DateTime.now)
145
+ formatted_start_min = encode_time(Time.now)
146
146
  query = "?timeMin=#{formatted_start_min}#{parse_options(options)}"
147
147
  event_lookup(query)
148
148
  end
@@ -199,7 +199,7 @@ module Google
199
199
  body = event.use_quickadd? ? nil : event.to_json
200
200
 
201
201
  query_string = if event.use_quickadd?
202
- "/quickAdd?text=#{ Addressable::URI.encode_component(event.quickadd)}"
202
+ "/quickAdd?text=#{event.title}"
203
203
  elsif event.new_event?
204
204
  ''
205
205
  else # update existing event.
@@ -233,7 +233,7 @@ module Google
233
233
  # Utility method to centralize time encoding.
234
234
  #
235
235
  def encode_time(time) #:nodoc:
236
- Addressable::URI.encode_component(time.strftime("%FT%T%:z"), Addressable::URI::CharacterClasses::UNRESERVED)
236
+ time.strftime("%FT%T%z")
237
237
  end
238
238
 
239
239
  #
@@ -1,5 +1,4 @@
1
1
  require 'signet/oauth_2/client'
2
- require "addressable/uri"
3
2
 
4
3
  module Google
5
4
 
@@ -78,6 +77,7 @@ module Google
78
77
 
79
78
  #
80
79
  # Convenience method used to streamline the process of logging in with a auth code.
80
+ # Returns the refresh token.
81
81
  #
82
82
  def login_with_auth_code(auth_code)
83
83
  @client.code = auth_code
@@ -115,7 +115,7 @@ module Google
115
115
  # Wraps the `send` method. Send an event related request to Google.
116
116
  #
117
117
  def send_events_request(path_and_query_string, method, content = '')
118
- send(Addressable::URI.parse(@events_url + path_and_query_string), method, content)
118
+ send(@events_url + path_and_query_string, method, content)
119
119
  end
120
120
 
121
121
  protected
@@ -144,7 +144,7 @@ module Google
144
144
  private
145
145
 
146
146
  #
147
- #
147
+ # Utility method to centralize credential validation.
148
148
  #
149
149
  def self.credentials_provided?(params) #:nodoc:
150
150
  blank = /[^[:space:]]/
data/readme_code.rb CHANGED
@@ -5,22 +5,14 @@
5
5
  # $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
6
6
  # $LOAD_PATH.unshift(File.dirname(__FILE__))
7
7
 
8
- #
9
- # Comment out the require lines out if you want to run against
10
- # the local version of the gem.
11
- #
12
8
  require 'rubygems'
13
9
  require 'google_calendar'
14
10
 
15
- YOUR_CLIENT_ID = ""
16
- YOUR_SECRET = ""
17
- YOUR_CALENDAR_ID = ""
18
-
19
11
  # Create an instance of the calendar.
20
- cal = Google::Calendar.new(:client_id => YOUR_CLIENT_ID,
12
+ cal = Google::Calendar.new(:client_id => YOUR_CLIENT_ID,
21
13
  :client_secret => YOUR_SECRET,
22
- :calendar => YOUR_CALENDAR_ID,
23
- :redirect_url => "urn:ietf:wg:oauth:2.0:oob" # this is what Google uses for 'applications'
14
+ :calendar => YOUR_CALENDAR_ID,
15
+ :redirect_url => "urn:ietf:wg:oauth:2.0:oob" # this is what Google uses for 'applications'
24
16
  )
25
17
 
26
18
  puts "Do you already have a refresh token? (y/n)"
@@ -42,6 +34,7 @@ if has_token.downcase != 'y'
42
34
  $stdin.gets.chomp
43
35
 
44
36
  else
37
+
45
38
  puts "Enter your refresh token"
46
39
  refresh_token = $stdin.gets.chomp
47
40
  cal.login_with_refresh_token(refresh_token)
data/test/helper.rb CHANGED
@@ -1,5 +1,7 @@
1
- require 'simplecov'
2
- SimpleCov.start
1
+ #require 'simplecov'
2
+ #SimpleCov.start
3
+ require "codeclimate-test-reporter"
4
+ CodeClimate::TestReporter.start
3
5
 
4
6
  require 'rubygems'
5
7
  require 'bundler'
@@ -81,14 +81,14 @@ class TestGoogleCalendar < Minitest::Test
81
81
  should "find events in range" do
82
82
  start_min = DateTime.new(2011, 2, 1, 11, 1, 1)
83
83
  start_max = DateTime.new(2011, 2, 28, 23, 59, 59)
84
- @calendar.expects(:event_lookup).with('?timeMin=2011-02-01T11%3A01%3A01%2B00%3A00&timeMax=2011-02-28T23%3A59%3A59%2B00%3A00&orderBy=startTime&maxResults=25&singleEvents=true')
84
+ @calendar.expects(:event_lookup).with('?timeMin=2011-02-01T11:01:01+0000&timeMax=2011-02-28T23:59:59+0000&orderBy=startTime&maxResults=25&singleEvents=true')
85
85
  events = @calendar.find_events_in_range(start_min, start_max)
86
86
  end
87
87
 
88
88
  should "find future events" do
89
89
  now = DateTime.now
90
90
  DateTime.stubs(:now).returns(now)
91
- formatted_time = Addressable::URI.encode_component(now.strftime("%FT%T%:z"), Addressable::URI::CharacterClasses::UNRESERVED)
91
+ formatted_time = now.strftime("%FT%T%z")
92
92
  @calendar.expects(:event_lookup).with("?timeMin=#{formatted_time}&orderBy=startTime&maxResults=25&singleEvents=true")
93
93
  events = @calendar.find_future_events()
94
94
  end
@@ -289,27 +289,21 @@ class TestGoogleCalendar < Minitest::Test
289
289
  end
290
290
 
291
291
  context "reminders" do
292
- context "reminders array" do
292
+ context "reminders hash" do
293
293
  should "set reminder time" do
294
- @event = Event.new :reminders => [minutes: 6]
295
- assert_equal @event.reminders.first[:minutes], 6
294
+ @event = Event.new(:reminders => { 'useDefault' => false, 'overrides' => ['minutes' => 6, 'method' => "popup"]})
295
+ assert_equal @event.reminders['overrides'].first['minutes'], 6
296
296
  end
297
297
 
298
298
  should "use different time scales" do
299
- @event = Event.new :reminders => [hours: 5]
300
- assert_equal @event.reminders.first[:hours], 5
299
+ @event = Event.new(:reminders => { 'useDefault' => false, 'overrides' => ['hours' => 6, 'method' => "popup"]})
300
+ assert_equal @event.reminders['overrides'].first['hours'], 6
301
301
  end
302
302
 
303
303
  should "set reminder method" do
304
- @event = Event.new :reminders => [minutes: 6, method: "sms"]
305
- assert_equal @event.reminders.first[:minutes], 6
306
- assert_equal @event.reminders.first[:method], "sms"
307
- end
308
-
309
- should "default to minutes -> hours -> days" do
310
- @event = Event.new :reminders => [minutes: 6, hours: 8]
311
- assert_equal @event.reminders.first[:minutes], 6
312
- assert_equal @event.reminders.first[:hours], 8
304
+ @event = Event.new(:reminders => { 'useDefault' => false, 'overrides' => ['minutes' => 6, 'method' => "sms"]})
305
+ assert_equal @event.reminders['overrides'].first['minutes'], 6
306
+ assert_equal @event.reminders['overrides'].first['method'], 'sms'
313
307
  end
314
308
  end
315
309
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_calendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Zich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-17 00:00:00.000000000 Z
11
+ date: 2014-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: signet
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.5.1
27
- - !ruby/object:Gem::Dependency
28
- name: addressable
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 2.2.2
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 2.2.2
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: terminal-notifier-guard
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -178,20 +164,6 @@ dependencies:
178
164
  - - ">="
179
165
  - !ruby/object:Gem::Version
180
166
  version: '3'
181
- - !ruby/object:Gem::Dependency
182
- name: simplecov
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - "~>"
186
- - !ruby/object:Gem::Version
187
- version: 0.9.0
188
- type: :development
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - "~>"
193
- - !ruby/object:Gem::Version
194
- version: 0.9.0
195
167
  description: A minimal wrapper around the google calendar API
196
168
  email: steve.zich@gmail.com
197
169
  executables: []
@@ -233,7 +205,7 @@ files:
233
205
  - test/mocks/repeating_events.json
234
206
  - test/mocks/successful_login.json
235
207
  - test/test_google_calendar.rb
236
- homepage: http://github.com/northworld/google_calendar
208
+ homepage: http://northworld.github.io/google_calendar/
237
209
  licenses:
238
210
  - MIT
239
211
  metadata: {}
@@ -256,7 +228,7 @@ rubyforge_project:
256
228
  rubygems_version: 2.2.2
257
229
  signing_key:
258
230
  specification_version: 4
259
- summary: A lightweight google calendar API wrapper
231
+ summary: A lightweight Google Calendar API wrapper
260
232
  test_files:
261
233
  - test/helper.rb
262
234
  - test/mocks/401.json