google_drive 3.0.3 → 3.0.5

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
- SHA256:
3
- metadata.gz: 71bd4c5beb1dca6adac8ac731350adc287a14d2866617babe69af781ed037267
4
- data.tar.gz: 6b96ced61bff53274b89298e13f44b3b404780481131ed4cb263e7fc0f19a191
2
+ SHA1:
3
+ metadata.gz: 71fe69bd1f6f33fc7bc16f567e044bd7e36411c4
4
+ data.tar.gz: c94e5ec66d46f6354e73a2a2a2fbad4bb62828a5
5
5
  SHA512:
6
- metadata.gz: 3c4853d7bea90aa49aa0e5027aba824a230755f01fd99e00007a52942372386515ee3e31db6fa41e8cc157f2393877bb37efc088a70efbfa6d576aad9661ab9a
7
- data.tar.gz: c87ea759783a8ca5cdb62bb31a66eb1472d9c936f87ef98e5e9083dc29dd0d45ff6834e7d03d4e32fc1cdf69979c0fd25f1c59a5670f82bb9d3d8b6f303d7280
6
+ metadata.gz: d1cd95cecdecc769b3f0842540c1565581918f3aa69188d7f3a01c5116b35a3bebf5541f26709f24cd2dbc018862c3661d96d08ffc717ddc933cb1577c171c32
7
+ data.tar.gz: cd9b0137b9412501b43e402caf596103f36e76b4b2a17664e2e43582dbfee88269165d7c5942f1f6e0ac2ef43644199c08afd03f5e8702895e24c6381dac315d
@@ -22,7 +22,7 @@ module GoogleDrive
22
22
  @session = session
23
23
  @file = file
24
24
  api_permissions = @session.drive_service.list_permissions(
25
- @file.id, fields: '*', supports_team_drives: true
25
+ @file.id, fields: '*', supports_all_drives: true
26
26
  )
27
27
  @entries =
28
28
  api_permissions.permissions.map { |perm| AclEntry.new(perm, self) }
@@ -73,7 +73,7 @@ module GoogleDrive
73
73
  api_permission = @session.drive_service.create_permission(
74
74
  @file.id,
75
75
  entry.params,
76
- { fields: '*', supports_team_drives: true }.merge(options)
76
+ { fields: '*', supports_all_drives: true }.merge(options)
77
77
  )
78
78
  new_entry = AclEntry.new(api_permission, self)
79
79
  @entries.push(new_entry)
@@ -86,7 +86,7 @@ module GoogleDrive
86
86
  # spreadsheet.acl.delete(spreadsheet.acl[1])
87
87
  def delete(entry)
88
88
  @session.drive_service.delete_permission(
89
- @file.id, entry.id, supports_team_drives: true
89
+ @file.id, entry.id, supports_all_drives: true
90
90
  )
91
91
  @entries.delete(entry)
92
92
  end
@@ -98,7 +98,7 @@ module GoogleDrive
98
98
  entry.id,
99
99
  { role: entry.role },
100
100
  fields: '*',
101
- supports_team_drives: true
101
+ supports_all_drives: true
102
102
  )
103
103
  entry.api_permission = api_permission
104
104
  entry
@@ -20,7 +20,7 @@ module GoogleDrive
20
20
  # Adds the given GoogleDrive::File to the folder.
21
21
  def add(file)
22
22
  @session.drive_service.update_file(
23
- file.id, add_parents: id, fields: '', supports_team_drives: true
23
+ file.id, add_parents: id, fields: '', supports_all_drives: true
24
24
  )
25
25
  nil
26
26
  end
@@ -28,7 +28,7 @@ module GoogleDrive
28
28
  # Removes the given GoogleDrive::File from the folder.
29
29
  def remove(file)
30
30
  @session.drive_service.update_file(
31
- file.id, remove_parents: id, fields: '', supports_team_drives: true
31
+ file.id, remove_parents: id, fields: '', supports_all_drives: true
32
32
  )
33
33
  end
34
34
 
@@ -62,7 +62,7 @@ module GoogleDrive
62
62
  }.merge(file_properties)
63
63
 
64
64
  file = @session.drive_service.create_file(
65
- file_metadata, fields: '*', supports_team_drives: true
65
+ file_metadata, fields: '*', supports_all_drives: true
66
66
  )
67
67
 
68
68
  @session.wrap_api_file(file)
@@ -39,7 +39,7 @@ module GoogleDrive
39
39
  # Reloads file metadata such as title and acl.
40
40
  def reload_metadata
41
41
  @api_file = @session.drive_service.get_file(
42
- id, fields: '*', supports_team_drives: true
42
+ id, fields: '*', supports_all_drives: true
43
43
  )
44
44
  @acl = Acl.new(@session, self) if @acl
45
45
  end
@@ -96,7 +96,7 @@ module GoogleDrive
96
96
  def download_to_file(path, params = {})
97
97
  @session.drive_service.get_file(
98
98
  id,
99
- { download_dest: path, supports_team_drives: true }.merge(params)
99
+ { download_dest: path, supports_all_drives: true }.merge(params)
100
100
  )
101
101
  end
102
102
 
@@ -115,7 +115,7 @@ module GoogleDrive
115
115
  def download_to_io(io, params = {})
116
116
  @session.drive_service.get_file(
117
117
  id,
118
- { download_dest: io, supports_team_drives: true }.merge(params)
118
+ { download_dest: io, supports_all_drives: true }.merge(params)
119
119
  )
120
120
  end
121
121
 
@@ -184,7 +184,7 @@ module GoogleDrive
184
184
 
185
185
  # Reads content from +io+ and updates the file with the content.
186
186
  def update_from_io(io, params = {})
187
- params = { upload_source: io, supports_team_drives: true }.merge(params)
187
+ params = { upload_source: io, supports_all_drives: true }.merge(params)
188
188
  @session.drive_service.update_file(id, nil, params)
189
189
  nil
190
190
  end
@@ -193,10 +193,10 @@ module GoogleDrive
193
193
  # If +permanent+ is +true+, deletes the file permanently.
194
194
  def delete(permanent = false)
195
195
  if permanent
196
- @session.drive_service.delete_file(id, supports_team_drives: true)
196
+ @session.drive_service.delete_file(id, supports_all_drives: true)
197
197
  else
198
198
  @session.drive_service.update_file(
199
- id, { trashed: true }, supports_team_drives: true
199
+ id, { trashed: true }, supports_all_drives: true
200
200
  )
201
201
  end
202
202
  nil
@@ -205,7 +205,7 @@ module GoogleDrive
205
205
  # Renames title of the file.
206
206
  def rename(title)
207
207
  @session.drive_service.update_file(
208
- id, { name: title }, supports_team_drives: true
208
+ id, { name: title }, supports_all_drives: true
209
209
  )
210
210
  nil
211
211
  end
@@ -215,7 +215,7 @@ module GoogleDrive
215
215
  # Creates copy of this file with the given title.
216
216
  def copy(title, file_properties = {})
217
217
  api_file = @session.drive_service.copy_file(
218
- id, { name: title }.merge(file_properties), fields: '*', supports_team_drives: true
218
+ id, { name: title }.merge(file_properties), fields: '*', supports_all_drives: true
219
219
  )
220
220
  @session.wrap_api_file(api_file)
221
221
  end
@@ -141,15 +141,13 @@ module GoogleDrive
141
141
  config.client_id = options[:client_id]
142
142
  config.client_secret = options[:client_secret]
143
143
  end
144
- if !config.client_id && !config.client_secret
145
- config.client_id =
146
- '452925651630-egr1f18o96acjjvphpbbd1qlsevkho1d.' \
147
- 'apps.googleusercontent.com'
148
- config.client_secret = '1U3-Krii5x1oLPrwD5zgn-ry'
149
- elsif !config.client_id || !config.client_secret
144
+ if !config.client_id || !config.client_secret
150
145
  raise(
151
146
  ArgumentError,
152
- 'client_id and client_secret must be both specified or both omitted'
147
+ 'client_id or client_secret is missing in the config. Follow ' \
148
+ 'https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md ' \
149
+ 'to provide a valid config. google_drive library no longer provides ' \
150
+ 'the default credential due to a limitation of Google API.'
153
151
  )
154
152
  end
155
153
 
@@ -255,7 +253,7 @@ module GoogleDrive
255
253
  params = convert_params(params)
256
254
  execute_paged!(
257
255
  method: drive_service.method(:list_files),
258
- parameters: { fields: '*', supports_team_drives: true }.merge(params),
256
+ parameters: { fields: '*', supports_all_drives: true, include_items_from_all_drives: true }.merge(params),
259
257
  items_method_name: :files,
260
258
  converter: proc { |af| wrap_api_file(af) },
261
259
  &block
@@ -287,7 +285,7 @@ module GoogleDrive
287
285
  # Returns an instance of GoogleDrive::File or its subclass
288
286
  # (GoogleDrive::Spreadsheet, GoogleDrive::Collection).
289
287
  def file_by_id(id)
290
- api_file = drive_service.get_file(id, fields: '*', supports_team_drives: true)
288
+ api_file = drive_service.get_file(id, fields: '*', supports_all_drives: true)
291
289
  wrap_api_file(api_file)
292
290
  end
293
291
 
@@ -510,7 +508,7 @@ module GoogleDrive
510
508
  }.merge(file_properties)
511
509
 
512
510
  file = drive_service.create_file(
513
- file_metadata, fields: '*', supports_team_drives: true
511
+ file_metadata, fields: '*', supports_all_drives: true
514
512
  )
515
513
 
516
514
  wrap_api_file(file)
@@ -656,7 +654,7 @@ module GoogleDrive
656
654
  upload_source: source,
657
655
  content_type: 'application/octet-stream',
658
656
  fields: '*',
659
- supports_team_drives: true
657
+ supports_all_drives: true
660
658
  }
661
659
  for k, v in params
662
660
  unless %i[convert convert_mime_type parents].include?(k)
@@ -73,13 +73,16 @@ module GoogleDrive
73
73
  def worksheet_feed_entry
74
74
  @worksheet_feed_entry ||= @session.request(:get, worksheet_feed_url).root
75
75
  end
76
-
76
+
77
77
  # Google::Apis::SheetsV4::SheetProperties object for this worksheet.
78
78
  attr_reader :properties
79
79
 
80
80
  # Title of the worksheet (shown as tab label in Web interface).
81
81
  attr_reader :title
82
82
 
83
+ # Index of the worksheet (affects tab order in web interface).
84
+ attr_reader :index
85
+
83
86
  # GoogleDrive::Spreadsheet which this worksheet belongs to.
84
87
  attr_reader :spreadsheet
85
88
 
@@ -139,6 +142,24 @@ module GoogleDrive
139
142
  format("%s\#gid=%s", spreadsheet.human_url, gid)
140
143
  end
141
144
 
145
+ # Copy worksheet to specified spreadsheet.
146
+ # This method can take either instance of GoogleDrive::Spreadsheet or its id.
147
+ def copy_to(spreadsheet_or_id)
148
+ destination_spreadsheet_id =
149
+ spreadsheet_or_id.respond_to?(:id) ?
150
+ spreadsheet_or_id.id : spreadsheet_or_id
151
+ request = Google::Apis::SheetsV4::CopySheetToAnotherSpreadsheetRequest.new(
152
+ destination_spreadsheet_id: destination_spreadsheet_id,
153
+ )
154
+ @session.sheets_service.copy_spreadsheet(spreadsheet.id, sheet_id, request)
155
+ nil
156
+ end
157
+
158
+ # Copy worksheet to owner spreadsheet.
159
+ def duplicate
160
+ copy_to(spreadsheet)
161
+ end
162
+
142
163
  # Returns content of the cell as String. Arguments must be either
143
164
  # (row number, column number) or cell name. Top-left cell is [1, 1].
144
165
  #
@@ -280,6 +301,13 @@ module GoogleDrive
280
301
  @meta_modified = true
281
302
  end
282
303
 
304
+ # Updates index of the worksheet.
305
+ # Note that update is not sent to the server until you call save().
306
+ def index=(index)
307
+ @index = index
308
+ @meta_modified = true
309
+ end
310
+
283
311
  # @api private
284
312
  def cells
285
313
  reload_cells unless @cells
@@ -380,6 +408,7 @@ module GoogleDrive
380
408
  properties: {
381
409
  sheet_id: sheet_id,
382
410
  title: title,
411
+ index: index,
383
412
  grid_properties: {row_count: max_rows, column_count: max_cols},
384
413
  },
385
414
  fields: '*',
@@ -392,7 +421,7 @@ module GoogleDrive
392
421
  @v4_requests = []
393
422
  sent = true
394
423
  end
395
-
424
+
396
425
  @remote_title = @title
397
426
 
398
427
  unless @modified.empty?
@@ -406,7 +435,7 @@ module GoogleDrive
406
435
  min_modified_col = c if c < min_modified_col
407
436
  max_modified_col = c if c > max_modified_col
408
437
  end
409
-
438
+
410
439
  # Uses update_spreadsheet_value instead batch_update_spreadsheet with
411
440
  # update_cells. batch_update_spreadsheet has benefit that the request
412
441
  # can be batched with other requests. But it has drawback that the
@@ -570,8 +599,8 @@ module GoogleDrive
570
599
  # A1 to have red text that is bold and italic:
571
600
  # worksheet.set_text_format(
572
601
  # 1, 1, 1, 1,
573
- # bold: true,
574
- # italic: true,
602
+ # bold: true,
603
+ # italic: true,
575
604
  # foreground_color: GoogleDrive::Worksheet::Colors::RED_BERRY)
576
605
  #
577
606
  # foreground_color is an instance of Google::Apis::SheetsV4::Color.
@@ -638,6 +667,7 @@ module GoogleDrive
638
667
  def set_properties(properties)
639
668
  @properties = properties
640
669
  @title = @remote_title = properties.title
670
+ @index = properties.index
641
671
  if properties.grid_properties.nil?
642
672
  @max_rows = @max_cols = 0
643
673
  else
@@ -673,7 +703,7 @@ module GoogleDrive
673
703
  k = [r + 1, c + 1]
674
704
  @cells[k] = cell_data.formatted_value || ''
675
705
  @input_values[k] = extended_value_to_str(cell_data.user_entered_value)
676
- @numeric_values[k] =
706
+ @numeric_values[k] =
677
707
  cell_data.effective_value && cell_data.effective_value.number_value ?
678
708
  cell_data.effective_value.number_value.to_f : nil
679
709
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_drive
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Ichikawa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-09 00:00:00.000000000 Z
11
+ date: 2020-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: 0.11.0
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: 0.31.0
42
+ version: 1.0.0
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: 0.11.0
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: 0.31.0
52
+ version: 1.0.0
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: googleauth
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  version: '0'
170
170
  requirements: []
171
171
  rubyforge_project:
172
- rubygems_version: 2.7.7
172
+ rubygems_version: 2.6.14
173
173
  signing_key:
174
174
  specification_version: 4
175
175
  summary: A library to read/write files/spreadsheets in Google Drive/Docs.