google_drive 1.0.6 → 2.0.0.pre1

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: 63bf6efd4050300790543c7ed135632f86e61432
4
- data.tar.gz: 481431da22d9bbebbf0a44067eaef26e7b05dc57
3
+ metadata.gz: 55c7313948e140230848e220a36ab07648790d38
4
+ data.tar.gz: aea2dafd3efb8cce5911a5a0475a51276bdef75f
5
5
  SHA512:
6
- metadata.gz: ff5e59d1b8b1a3bfcc59a6bda70d03b71f179d896e9dcb7c7cac836ce674569929a06dcfc5e792f19fac1d23398c4b043a64951b3597544acaae42a351a652d9
7
- data.tar.gz: 77f7e1b096e71e4cfe7f3c4cb745f0efa9ce202fd41bfbbb38fb52a341ac7d4d1b3af55927d9cef7ec3eadf79ac41d7b5cef9a7a269af83554c2707308625835
6
+ metadata.gz: b4866bc23c4cad36082f3487ad90f9b15cca81fb789c19a869770eb9d40b10651b1e40e4a10833f39a802884dba4f8a0b9855c57d4160ca9aa56ddd3621bc1fd
7
+ data.tar.gz: cf998e7d7ed9073c7f5f3bb3d10a29ea45fc79c99f9f1fa3c2d23d306c17e2e2e38a6d6a289db115ee678ff66179c76f2484db5d3dd42349ebccf1c27cc9b2fc
data/README.rdoc CHANGED
@@ -3,11 +3,9 @@ This is a Ruby library to read/write files/spreadsheets in Google Drive/Docs.
3
3
  NOTE: This is NOT a library to create Google Drive App.
4
4
 
5
5
 
6
- = Migration from 0.3.x or before to ver. 1.0.x
6
+ = Migration from ver. 0.x.x / 1.x.x to to ver. 2.x.x
7
7
 
8
- Ver. 0.3.x and the versions before no longer works, because the API used was deprecated and shut down. You need to migrate to ver. 1.0.x.
9
-
10
- Ver. 1.0.x is not 100% backward compatible with 0.3.x. Some methods have been removed. Especially, GoogleDrive.login has been removed, and you must use GoogleDrive.saved_session or GoogleDrive.login_with_oauth instead, as in the example code below.
8
+ There are some incompatible API changes. See {MIGRATING.md}[https://github.com/gimite/google-drive-ruby/blob/master/MIGRATING.md].
11
9
 
12
10
 
13
11
  = How to install
@@ -28,7 +26,6 @@ Next, create a file config.json which contains the client ID and crient secret y
28
26
 
29
27
  Example to read/write files in Google Drive:
30
28
 
31
- require "google/api_client"
32
29
  require "google_drive"
33
30
 
34
31
  # Creates a session. This will prompt the credential via command line for the
@@ -52,7 +49,6 @@ Example to read/write files in Google Drive:
52
49
 
53
50
  Example to read/write spreadsheets:
54
51
 
55
- require "google/api_client"
56
52
  require "google_drive"
57
53
 
58
54
  # Creates a session. This will prompt the credential via command line for the
@@ -97,7 +93,7 @@ The license of this source is "New BSD Licence"
97
93
 
98
94
  = Supported environments
99
95
 
100
- Ruby 1.9.x or later. Checked with Ruby 1.9.3 and 2.2.1.
96
+ Ruby 2.0.0 or later. Checked with Ruby 2.3.0.
101
97
 
102
98
 
103
99
  = Author
@@ -1,20 +1,16 @@
1
1
  module GoogleDrive
2
-
3
- class Acl
4
-
5
- # Returns the number of entries.
6
- def size
7
- end
8
-
9
- # Returns GoogleDrive::AclEntry object at +index+.
10
- def [](index)
11
- end
12
-
13
- # Iterates over GoogleDrive::AclEntry objects.
14
- def each(&block)
15
- yield(entry)
16
- end
17
-
2
+ class Acl
3
+ # Returns the number of entries.
4
+ def size
18
5
  end
19
-
6
+
7
+ # Returns GoogleDrive::AclEntry object at +index+.
8
+ def [](index)
9
+ end
10
+
11
+ # Iterates over GoogleDrive::AclEntry objects.
12
+ def each(&_block)
13
+ yield(entry)
14
+ end
15
+ end
20
16
  end
data/lib/google_drive.rb CHANGED
@@ -2,177 +2,147 @@
2
2
  # The license of this source is "New BSD Licence"
3
3
 
4
4
  require 'json'
5
- require 'google/api_client'
5
+ require 'googleauth'
6
6
 
7
7
  require 'google_drive/session'
8
8
 
9
9
  module GoogleDrive
10
- # Authenticates with given OAuth2 token.
11
- #
12
- # +access_token+ can be either OAuth2 access_token string, or OAuth2::AccessToken.
13
- #
14
- # OAuth2 code example for Web apps:
15
- #
16
- # require "rubygems"
17
- # require "google/api_client"
18
- # client = Google::APIClient.new
19
- # auth = client.authorization
20
- # # Follow Step 1 and 2 of “Authorizing requests with OAuth 2.0” in
21
- # # https://developers.google.com/drive/v3/web/about-auth to get a client ID and client secret.
22
- # auth.client_id = "YOUR CLIENT ID"
23
- # auth.client_secret = "YOUR CLIENT SECRET"
24
- # auth.scope =
25
- # "https://www.googleapis.com/auth/drive " +
26
- # "https://spreadsheets.google.com/feeds/"
27
- # auth.redirect_uri = "http://example.com/redirect"
28
- # auth_url = auth.authorization_uri
29
- # # Redirect the user to auth_url and get authorization code from redirect URL.
30
- # auth.code = authorization_code
31
- # auth.fetch_access_token!
32
- # session = GoogleDrive.login_with_oauth(auth.access_token)
33
- #
34
- # auth.access_token expires in 1 hour. If you want to restore a session afterwards, you can store
35
- # auth.refresh_token somewhere after auth.fetch_access_token! above, and use this code:
36
- #
37
- # require "rubygems"
38
- # require "google/api_client"
39
- # client = Google::APIClient.new
40
- # auth = client.authorization
41
- # # Follow "Create a client ID and client secret" in
42
- # # https://developers.google.com/drive/web/auth/web-server] to get a client ID and client secret.
43
- # auth.client_id = "YOUR CLIENT ID"
44
- # auth.client_secret = "YOUR CLIENT SECRET"
45
- # auth.scope =
46
- # "https://www.googleapis.com/auth/drive " +
47
- # "https://spreadsheets.google.com/feeds/"
48
- # auth.redirect_uri = "http://example.com/redirect"
49
- # auth.refresh_token = refresh_token
50
- # auth.fetch_access_token!
51
- # session = GoogleDrive.login_with_oauth(auth.access_token)
52
- #
53
- # OAuth2 code example for command-line apps:
54
- #
55
- # require "rubygems"
56
- # require "google/api_client"
57
- # client = Google::APIClient.new
58
- # auth = client.authorization
59
- # # Follow "Create a client ID and client secret" in
60
- # # https://developers.google.com/drive/web/auth/web-server] to get a client ID and client secret.
61
- # auth.client_id = "YOUR CLIENT ID"
62
- # auth.client_secret = "YOUR CLIENT SECRET"
63
- # auth.scope =
64
- # "https://www.googleapis.com/auth/drive " +
65
- # "https://spreadsheets.google.com/feeds/"
66
- # auth.redirect_uri = "urn:ietf:wg:oauth:2.0:oob"
67
- # print("1. Open this page:\n%s\n\n" % auth.authorization_uri)
68
- # print("2. Enter the authorization code shown in the page: ")
69
- # auth.code = $stdin.gets.chomp
70
- # auth.fetch_access_token!
71
- # session = GoogleDrive.login_with_oauth(auth.access_token)
72
- #
73
- # See this document for details:
74
- #
75
- # - https://developers.google.com/drive/web/about-auth
76
- def self.login_with_oauth(client_or_access_token, proxy = nil)
77
- return Session.new(client_or_access_token, proxy)
78
- end
79
-
80
- # Returns GoogleDrive::Session constructed from a config JSON file at +path+.
81
- #
82
- # Follow the following steps to use this method:
83
- #
84
- # First, follow "Create a client ID and client secret" in
85
- # {this page}[https://developers.google.com/drive/web/auth/web-server] to get a client ID
86
- # and client secret for OAuth. Set "Application type" to "Other" in the form to create a
87
- # client ID if you use GoogleDrive.saved_session method as in the example below.
88
- #
89
- # Next, create a file config.json which contains the client ID and client secret you got
90
- # above, which looks like:
91
- #
92
- # {
93
- # "client_id": "xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
94
- # "client_secret": "xxxxxxxxxxxxxxxxxxxxxxxx"
95
- # }
96
- #
97
- # Then you can construct a GoogleDrive::Session by:
98
- #
99
- # session = GoogleDrive.saved_session("config.json")
100
- #
101
- # This will prompt the credential via command line for the first time and save it to
102
- # config.json file for later usages.
103
- #
104
- # +path+ defaults to ENV["HOME"] + "/.ruby_google_drive.token".
105
- #
106
- # If the file doesn't exist or client ID/secret are not given in the file, the default client
107
- # ID/secret embedded in the library is used.
108
- #
109
- # You can also provide a config object that must respond to:
110
- # client_id
111
- # client_secret
112
- # refesh_token
113
- # refresh_token=
114
- # scope
115
- # scope=
116
- # save
117
- def self.saved_session(
118
- path_or_config = nil, proxy = nil, client_id = nil, client_secret = nil)
119
- config = case path_or_config
120
- when String
121
- Config.new(path_or_config)
122
- when nil
123
- Config.new(ENV['HOME'] + '/.ruby_google_drive.token')
124
- else
125
- path_or_config
126
- end
10
+ # Authenticates with given OAuth2 token.
11
+ #
12
+ # +access_token+ can be either OAuth2 access_token string, OAuth2::AccessToken
13
+ # or credentials generated by googleauth library.
14
+ #
15
+ # OAuth2 code example for Web apps:
16
+ #
17
+ # require "googleauth"
18
+ #
19
+ # credentials = Google::Auth::UserRefreshCredentials.new(
20
+ # client_id: "YOUR CLIENT ID",
21
+ # client_secret: "YOUR CLIENT SECRET",
22
+ # scope: [
23
+ # "https://www.googleapis.com/auth/drive",
24
+ # "https://spreadsheets.google.com/feeds/",
25
+ # ],
26
+ # redirect_uri: "http://example.com/redirect")
27
+ # auth_url = credentials.authorization_uri
28
+ # # Redirect the user to auth_url and get authorization code from redirect URL.
29
+ # credentials.code = authorization_code
30
+ # credentials.fetch_access_token!
31
+ # session = GoogleDrive.login_with_oauth(credentials)
32
+ #
33
+ # auth.access_token expires in 1 hour. If you want to restore a session afterwards, you can store
34
+ # auth.refresh_token somewhere after auth.fetch_access_token! above, and use this code:
35
+ #
36
+ # require "googleauth"
37
+ #
38
+ # credentials = Google::Auth::UserRefreshCredentials.new(
39
+ # client_id: "YOUR CLIENT ID",
40
+ # client_secret: "YOUR CLIENT SECRET",
41
+ # scope: [
42
+ # "https://www.googleapis.com/auth/drive",
43
+ # "https://spreadsheets.google.com/feeds/",
44
+ # ],
45
+ # redirect_uri: "http://example.com/redirect")
46
+ # auth.refresh_token = refresh_token
47
+ # auth.fetch_access_token!
48
+ # session = GoogleDrive.login_with_oauth(auth.access_token)
49
+ #
50
+ # For command-line apps, it would be easier to use saved_session method instead.
51
+ def self.login_with_oauth(client_or_access_token, proxy = nil)
52
+ Session.new(client_or_access_token, proxy)
53
+ end
127
54
 
128
- config.scope ||= [
129
- 'https://www.googleapis.com/auth/drive',
130
- 'https://spreadsheets.google.com/feeds/',
131
- ]
55
+ # Returns GoogleDrive::Session constructed from a config JSON file at +path+.
56
+ #
57
+ # Follow the following steps to use this method:
58
+ #
59
+ # First, follow "Create a client ID and client secret" in
60
+ # {this page}[https://developers.google.com/drive/web/auth/web-server] to get a client ID
61
+ # and client secret for OAuth. Set "Application type" to "Other" in the form to create a
62
+ # client ID if you use GoogleDrive.saved_session method as in the example below.
63
+ #
64
+ # Next, create a file config.json which contains the client ID and client secret you got
65
+ # above, which looks like:
66
+ #
67
+ # {
68
+ # "client_id": "xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
69
+ # "client_secret": "xxxxxxxxxxxxxxxxxxxxxxxx"
70
+ # }
71
+ #
72
+ # Then you can construct a GoogleDrive::Session by:
73
+ #
74
+ # session = GoogleDrive.saved_session("config.json")
75
+ #
76
+ # This will prompt the credential via command line for the first time and save it to
77
+ # config.json file for later usages.
78
+ #
79
+ # +path+ defaults to ENV["HOME"] + "/.ruby_google_drive.token".
80
+ #
81
+ # If the file doesn't exist or client ID/secret are not given in the file, the default client
82
+ # ID/secret embedded in the library is used.
83
+ #
84
+ # You can also provide a config object that must respond to:
85
+ # client_id
86
+ # client_secret
87
+ # refesh_token
88
+ # refresh_token=
89
+ # scope
90
+ # scope=
91
+ # save
92
+ def self.saved_session(
93
+ path_or_config = nil, proxy = nil, client_id = nil, client_secret = nil)
94
+ config = case path_or_config
95
+ when String
96
+ Config.new(path_or_config)
97
+ when nil
98
+ Config.new(ENV['HOME'] + '/.ruby_google_drive.token')
99
+ else
100
+ path_or_config
101
+ end
132
102
 
133
- if client_id && client_secret
134
- config.client_id = client_id
135
- config.client_secret = client_secret
136
- end
137
- if !config.client_id && !config.client_secret
138
- config.client_id = "452925651630-egr1f18o96acjjvphpbbd1qlsevkho1d.apps.googleusercontent.com"
139
- config.client_secret = "1U3-Krii5x1oLPrwD5zgn-ry"
140
- elsif !config.client_id || !config.client_secret
141
- raise(ArgumentError, "client_id and client_secret must be both specified or both omitted")
142
- end
103
+ config.scope ||= [
104
+ 'https://www.googleapis.com/auth/drive',
105
+ 'https://spreadsheets.google.com/feeds/'
106
+ ]
143
107
 
144
- if proxy
145
- raise(
146
- ArgumentError,
147
- 'Specifying a proxy object is no longer supported. Set ENV["http_proxy"] instead.')
148
- end
108
+ if client_id && client_secret
109
+ config.client_id = client_id
110
+ config.client_secret = client_secret
111
+ end
112
+ if !config.client_id && !config.client_secret
113
+ config.client_id = '452925651630-egr1f18o96acjjvphpbbd1qlsevkho1d.apps.googleusercontent.com'
114
+ config.client_secret = '1U3-Krii5x1oLPrwD5zgn-ry'
115
+ elsif !config.client_id || !config.client_secret
116
+ fail(ArgumentError, 'client_id and client_secret must be both specified or both omitted')
117
+ end
149
118
 
150
- refresh_token = config.refresh_token
119
+ if proxy
120
+ fail(
121
+ ArgumentError,
122
+ 'Specifying a proxy object is no longer supported. Set ENV["http_proxy"] instead.')
123
+ end
151
124
 
152
- client = Google::APIClient.new(
153
- :application_name => 'google_drive Ruby library',
154
- :application_version => '0.4.0'
155
- )
125
+ refresh_token = config.refresh_token
156
126
 
157
- auth = client.authorization
158
- auth.client_id = config.client_id
159
- auth.client_secret = config.client_secret
160
- auth.scope = config.scope
161
- auth.redirect_uri = 'urn:ietf:wg:oauth:2.0:oob'
127
+ credentials = Google::Auth::UserRefreshCredentials.new(
128
+ client_id: config.client_id,
129
+ client_secret: config.client_secret,
130
+ scope: config.scope,
131
+ redirect_uri: 'urn:ietf:wg:oauth:2.0:oob')
162
132
 
163
- if config.refresh_token
164
- auth.refresh_token = config.refresh_token
165
- auth.fetch_access_token!
166
- else
167
- $stderr.print("\n1. Open this page:\n%s\n\n" % auth.authorization_uri)
168
- $stderr.print('2. Enter the authorization code shown in the page: ')
169
- auth.code = $stdin.gets.chomp
170
- auth.fetch_access_token!
171
- config.refresh_token = auth.refresh_token
172
- end
133
+ if config.refresh_token
134
+ credentials.refresh_token = config.refresh_token
135
+ credentials.fetch_access_token!
136
+ else
137
+ $stderr.print("\n1. Open this page:\n%s\n\n" % credentials.authorization_uri)
138
+ $stderr.print('2. Enter the authorization code shown in the page: ')
139
+ credentials.code = $stdin.gets.chomp
140
+ credentials.fetch_access_token!
141
+ config.refresh_token = credentials.refresh_token
142
+ end
173
143
 
174
- config.save
144
+ config.save
175
145
 
176
- return GoogleDrive.login_with_oauth(client)
177
- end
146
+ GoogleDrive.login_with_oauth(credentials)
147
+ end
178
148
  end
@@ -3,106 +3,90 @@
3
3
  # Author: Hiroshi Ichikawa <http://gimite.net/>
4
4
  # The license of this source is "New BSD Licence"
5
5
 
6
- require "google_drive/acl_entry"
6
+ require 'google_drive/acl_entry'
7
7
 
8
8
  module GoogleDrive
9
+ # ACL (access control list) of a spreadsheet.
10
+ #
11
+ # Use GoogleDrive::Spreadsheet#acl to get GoogleDrive::Acl object.
12
+ # See GoogleDrive::Spreadsheet#acl for usage example.
13
+ #
14
+ # This code is based on https://github.com/guyboertje/gdata-spreadsheet-ruby .
15
+ class Acl
16
+ include(Util)
17
+ extend(Forwardable)
9
18
 
10
- # ACL (access control list) of a spreadsheet.
11
- #
12
- # Use GoogleDrive::Spreadsheet#acl to get GoogleDrive::Acl object.
13
- # See GoogleDrive::Spreadsheet#acl for usage example.
14
- #
15
- # This code is based on https://github.com/guyboertje/gdata-spreadsheet-ruby .
16
- class Acl
17
-
18
- include(Util)
19
- extend(Forwardable)
20
-
21
- def initialize(session, file) #:nodoc:
22
- @session = session
23
- @file = file
24
- api_result = @session.execute!(
25
- :api_method => @session.drive.permissions.list,
26
- :parameters => { "fileId" => @file.id })
27
- @entries = api_result.data.items.map(){ |i| AclEntry.new(i, self) }
28
- end
29
-
30
- def_delegators(:@entries, :size, :[], :each)
31
-
32
- # Adds a new entry. +entry+ is either a GoogleDrive::AclEntry or a Hash with keys
33
- # :scope_type, :scope and :role. See GoogleDrive::AclEntry#scope_type and
34
- # GoogleDrive::AclEntry#role for the document of the fields.
35
- #
36
- # Also you can pass the second hash argument +options+, which specifies
37
- # optional query parameters for the API.
38
- # Possible keys of +options+ are,
39
- # * :emailMessage -- A custom message to include in notification emails
40
- # * :sendNotificationEmails -- Whether to send notification emails
41
- # when sharing to users or groups.
42
- #
43
- # NOTE: This sends email to the new people.
44
- #
45
- # e.g.
46
- # # A specific user can read or write.
47
- # spreadsheet.acl.push(
48
- # {:type => "user", :value => "example2@gmail.com", :role => "reader"})
49
- # spreadsheet.acl.push(
50
- # {:type => "user", :value => "example3@gmail.com", :role => "writer"})
51
- # # Publish on the Web.
52
- # spreadsheet.acl.push(
53
- # {:type => "anyone", :role => "reader"})
54
- # # Anyone who knows the link can read.
55
- # spreadsheet.acl.push(
56
- # {:type => "anyone", :withLink => true, :role => "reader"})
57
- # # Set ACL without sending notification emails
58
- # spreadsheet.acl.push(
59
- # {:type => "user", :value => "example2@gmail.com", :role => "reader"},
60
- # {:sendNotificationEmails => false})
61
- #
62
- # See here for parameter detais:
63
- # https://developers.google.com/drive/v2/reference/permissions/insert
64
- def push(params_or_entry, options = {})
65
- entry = params_or_entry.is_a?(AclEntry) ? params_or_entry : AclEntry.new(params_or_entry)
66
- new_permission = @session.drive.permissions.insert.request_schema.new(entry.params)
67
- api_result = @session.execute!(
68
- :api_method => @session.drive.permissions.insert,
69
- :body_object => new_permission,
70
- :parameters => options.merge({ "fileId" => @file.id }))
71
- new_entry = AclEntry.new(api_result.data, self)
72
- @entries.push(new_entry)
73
- return new_entry
74
- end
19
+ def initialize(session, file) #:nodoc:
20
+ @session = session
21
+ @file = file
22
+ api_permissions = @session.drive.list_permissions(@file.id, fields: '*')
23
+ @entries = api_permissions.permissions.map { |perm| AclEntry.new(perm, self) }
24
+ end
75
25
 
76
- # Deletes an ACL entry.
77
- #
78
- # e.g.
79
- # spreadsheet.acl.delete(spreadsheet.acl[1])
80
- def delete(entry)
81
- @session.execute!(
82
- :api_method => @session.drive.permissions.delete,
83
- :parameters => {
84
- "fileId" => @file.id,
85
- "permissionId" => entry.id,
86
- })
87
- @entries.delete(entry)
88
- end
26
+ def_delegators(:@entries, :size, :[], :each)
89
27
 
90
- def update_role(entry) #:nodoc:
91
- api_result = @session.execute!(
92
- :api_method => @session.drive.permissions.update,
93
- :body_object => entry.api_permission,
94
- :parameters => {
95
- "fileId" => @file.id,
96
- "permissionId" => entry.id,
97
- })
98
- entry.api_permission = api_result.data
99
- return entry
100
- end
28
+ # Adds a new entry. +entry+ is either a GoogleDrive::AclEntry or a Hash with keys
29
+ # +:type+, +:email_address+, +:domain+, +:role+ and +:allow_file_discovery+.
30
+ # See GoogleDrive::AclEntry#type and
31
+ # GoogleDrive::AclEntry#role for the document of the fields.
32
+ #
33
+ # Also you can pass the second hash argument +options+, which specifies
34
+ # optional query parameters for the API.
35
+ # Possible keys of +options+ are,
36
+ # * :emailMessage -- A custom message to include in notification emails
37
+ # * :sendNotificationEmails -- Whether to send notification emails
38
+ # when sharing to users or groups.
39
+ #
40
+ # NOTE: This sends email to the new people.
41
+ #
42
+ # e.g.
43
+ # # A specific user can read or write.
44
+ # spreadsheet.acl.push(
45
+ # {type: "user", email_address: "example2@gmail.com", role: "reader"})
46
+ # spreadsheet.acl.push(
47
+ # {type: "user", email_address: "example3@gmail.com", role: "writer"})
48
+ # # Share with a Google Apps domain.
49
+ # spreadsheet.acl.push(
50
+ # {type: "domain", domain: "gimite.net", role: "reader"})
51
+ # # Publish on the Web.
52
+ # spreadsheet.acl.push(
53
+ # {type: "anyone", role: "reader"})
54
+ # # Anyone who knows the link can read.
55
+ # spreadsheet.acl.push(
56
+ # {type: "anyone", allow_file_discovery: false, role: "reader"})
57
+ # # Set ACL without sending notification emails
58
+ # spreadsheet.acl.push(
59
+ # {type: "user", email_address: "example2@gmail.com", role: "reader"},
60
+ # {sendNotificationEmails: false})
61
+ #
62
+ # See here for parameter detais:
63
+ # https://developers.google.com/drive/v3/reference/permissions/create
64
+ def push(params_or_entry, options = {})
65
+ entry = params_or_entry.is_a?(AclEntry) ? params_or_entry : AclEntry.new(params_or_entry)
66
+ api_permission = @session.drive.create_permission(@file.id, entry.params, fields: '*')
67
+ new_entry = AclEntry.new(api_permission, self)
68
+ @entries.push(new_entry)
69
+ new_entry
70
+ end
101
71
 
102
- def inspect
103
- return "\#<%p %p>" % [self.class, @entries]
104
- end
72
+ # Deletes an ACL entry.
73
+ #
74
+ # e.g.
75
+ # spreadsheet.acl.delete(spreadsheet.acl[1])
76
+ def delete(entry)
77
+ @session.drive.delete_permission(@file.id, entry.id)
78
+ @entries.delete(entry)
79
+ end
105
80
 
81
+ def update_role(entry) #:nodoc:
82
+ api_permission = @session.drive.update_permission(
83
+ @file.id, entry.id, {role: entry.role}, fields: '*')
84
+ entry.api_permission = api_permission
85
+ entry
106
86
  end
107
87
 
88
+ def inspect
89
+ "\#<%p %p>" % [self.class, @entries]
90
+ end
91
+ end
108
92
  end