google_client 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +43 -0
- data/app/controllers/google_client_controller.rb +8 -6
- data/lib/google_client/calendar.rb +2 -2
- data/lib/google_client/version.rb +1 -1
- data/scripts/script_config.rb +16 -0
- data/spec/google_client_spec.rb +6 -2
- metadata +13 -12
data/Rakefile
CHANGED
@@ -1,2 +1,45 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
require "bundler/gem_tasks"
|
3
|
+
|
4
|
+
Bundler::GemHelper.install_tasks
|
5
|
+
|
6
|
+
require 'rdoc/task'
|
7
|
+
|
8
|
+
task :default => [:spec]
|
9
|
+
|
10
|
+
require 'rspec/core/rake_task'
|
11
|
+
|
12
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
13
|
+
spec.skip_bundler = true
|
14
|
+
spec.pattern = ['spec/*_spec.rb']
|
15
|
+
spec.rspec_opts = '--color --format doc'
|
16
|
+
end
|
17
|
+
|
18
|
+
RDoc::Task.new do |rdoc|
|
19
|
+
rdoc.rdoc_dir = 'doc/rdoc'
|
20
|
+
rdoc.title = "google_client #{GoogleClient::VERSION} documentation"
|
21
|
+
|
22
|
+
rdoc.rdoc_files.include('README.md')
|
23
|
+
|
24
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
25
|
+
rdoc.options << '-c' << 'utf-8'
|
26
|
+
rdoc.options << '-m' << 'README.md'
|
27
|
+
end
|
28
|
+
|
29
|
+
# extracted from https://github.com/grosser/project_template
|
30
|
+
desc "Bump version"
|
31
|
+
rule /^version:bump:.*/ do |t|
|
32
|
+
sh "git status | grep 'nothing to commit'" # ensure we are not dirty
|
33
|
+
index = ['major', 'minor','patch'].index(t.name.split(':').last)
|
34
|
+
puts index
|
35
|
+
return
|
36
|
+
file = 'lib/google_client/version.rb'
|
37
|
+
|
38
|
+
version_file = File.read(file)
|
39
|
+
old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
|
40
|
+
version_parts[index] = version_parts[index].to_i + 1
|
41
|
+
new_version = version_parts * '.'
|
42
|
+
File.open(file,'w'){|f| f.write(version_file.sub(old_version, new_version)) }
|
43
|
+
|
44
|
+
sh "bundle && git add -f #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}'"
|
45
|
+
end
|
@@ -9,9 +9,11 @@ class GoogleClientController < ApplicationController
|
|
9
9
|
# OAuth step1: redirect to Google endpoint with the application idenfitifer and the redirect uri
|
10
10
|
def index
|
11
11
|
_params = {
|
12
|
-
:redirect_uri
|
13
|
-
:response_type
|
14
|
-
:scope
|
12
|
+
:redirect_uri => Rails.application.config.google_client.redirect_uri,
|
13
|
+
:response_type => "code",
|
14
|
+
:scope => Rails.application.config.google_client.scope,
|
15
|
+
:access_type => Rails.application.config.google_client.access_type.nil? ? "online" : Rails.application.config.google_client.access_type,
|
16
|
+
#:approval_prompt => Rails.application.config.google_client.approval_prompt.nil? ? "force" : Rails.application.config.google_client.approval_prompt
|
15
17
|
}
|
16
18
|
_params.merge!(DEFAULT_PARAMS)
|
17
19
|
|
@@ -24,10 +26,10 @@ class GoogleClientController < ApplicationController
|
|
24
26
|
# This code is retrieved from Google
|
25
27
|
|
26
28
|
_params = {
|
27
|
-
:redirect_uri
|
29
|
+
:redirect_uri => Rails.application.config.google_client.redirect_uri,
|
28
30
|
:client_secret => Rails.application.config.google_client.client_secret,
|
29
|
-
:grant_type
|
30
|
-
:code
|
31
|
+
:grant_type => "authorization_code",
|
32
|
+
:code => params[:code]
|
31
33
|
}
|
32
34
|
|
33
35
|
_params.merge!(DEFAULT_PARAMS)
|
@@ -24,7 +24,7 @@ module GoogleClient
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def to_s
|
27
|
-
"#{self.class.name} => { id: #{@id}, title: #{@title},
|
27
|
+
"#{self.class.name} => { id: #{@id}, title: #{@title}, timezone => #{@timezone}, location => #{@location} }"
|
28
28
|
end
|
29
29
|
|
30
30
|
def connection
|
@@ -97,7 +97,7 @@ module GoogleClient
|
|
97
97
|
end
|
98
98
|
|
99
99
|
##
|
100
|
-
# Fetch forthcoming events in the
|
100
|
+
# Fetch forthcoming events in the following *time* minutes
|
101
101
|
def forthcoming_events(time = 3600)
|
102
102
|
events({:from => Time.now.strftime("%Y-%m-%dT%k:%M:%S").concat(timezone).gsub(/ /,"0"),
|
103
103
|
:to => (Time.now + time).strftime("%Y-%m-%dT%k:%M:%S").concat(timezone).gsub(/ /,"0")})
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
# This value is used to refresh an user token
|
3
|
+
CLIENT_ID = "YOUR-APPLICATION-ID"
|
4
|
+
|
5
|
+
# This value is used to refresh an user token
|
6
|
+
CLIENT_SECRET = "YOUR-APPLICATION-SECRET"
|
7
|
+
|
8
|
+
# This value is used to refresh an user token
|
9
|
+
REFRESH_TOKEN = "USER-REFRESH-TOKEN"
|
10
|
+
|
11
|
+
# User authentication in any request (except refresh token)
|
12
|
+
AUTH_TOKEN = "USER-AUTH-TOKEN"
|
13
|
+
|
14
|
+
# Specific calendar id for calendar related operations
|
15
|
+
CALENDAR_ID = "CALENDAR-ID-TO-WORK-WITH"
|
16
|
+
|
data/spec/google_client_spec.rb
CHANGED
@@ -2,8 +2,12 @@ require 'google_client'
|
|
2
2
|
|
3
3
|
describe GoogleClient do
|
4
4
|
describe "while initializing" do
|
5
|
-
|
6
|
-
|
5
|
+
subject { GoogleClient.create_client("oauth_token") }
|
6
|
+
|
7
|
+
it "should return a GoogleClient::User instance" do
|
8
|
+
subject.should be_instance_of GoogleClient::User
|
7
9
|
end
|
10
|
+
|
11
|
+
its(:oauth_credentials) { should == "oauth_token" }
|
8
12
|
end
|
9
13
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.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: 2011-
|
12
|
+
date: 2011-12-14 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
16
|
-
requirement: &
|
16
|
+
requirement: &2156723480 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2156723480
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: addressable
|
27
|
-
requirement: &
|
27
|
+
requirement: &2156722860 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2156722860
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &2156722220 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2156722220
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &2156721580 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2156721580
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: webmock
|
60
|
-
requirement: &
|
60
|
+
requirement: &2156720920 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2156720920
|
69
69
|
description: This gem is a wrapper on top of the Google API that allows a developer
|
70
70
|
to handle calendars, events, contacts on behalf of the user.
|
71
71
|
email:
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- scripts/fetch_contacts.rb
|
103
103
|
- scripts/fetch_events.rb
|
104
104
|
- scripts/refresh_token.rb
|
105
|
+
- scripts/script_config.rb
|
105
106
|
- scripts/user_profile.rb
|
106
107
|
- spec/calendar_spec.rb
|
107
108
|
- spec/contact_spec.rb
|