google_drive 3.0.3 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71bd4c5beb1dca6adac8ac731350adc287a14d2866617babe69af781ed037267
4
- data.tar.gz: 6b96ced61bff53274b89298e13f44b3b404780481131ed4cb263e7fc0f19a191
3
+ metadata.gz: 4058c1344a508194fb0dd57e58206b54469318b13139d9cdc8bd708afb4595b4
4
+ data.tar.gz: 304898bca40cd8022a002e25335c6dc22fb333c7e67d4ba8d62ffe0817fbde75
5
5
  SHA512:
6
- metadata.gz: 3c4853d7bea90aa49aa0e5027aba824a230755f01fd99e00007a52942372386515ee3e31db6fa41e8cc157f2393877bb37efc088a70efbfa6d576aad9661ab9a
7
- data.tar.gz: c87ea759783a8ca5cdb62bb31a66eb1472d9c936f87ef98e5e9083dc29dd0d45ff6834e7d03d4e32fc1cdf69979c0fd25f1c59a5670f82bb9d3d8b6f303d7280
6
+ metadata.gz: 0a8bf859d820a2b4d12ea1017b69ef733b99f3ed5530271d4694170decd7e3132a938870317eb40bbbe9c6a2aa41877ab6e82ceb73b0861d9dd327f8e96f71b0
7
+ data.tar.gz: b8dbadd5a9703ed7cd2f90a357393c81883a6304d40b5ae574f6149adb2cb9452ff6fe6613f339144431535c55a07afd5e22025affe952c57c46debe2aeb5b74
@@ -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
 
@@ -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.4
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-01-29 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: 0.37.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: 0.37.0
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: googleauth
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -168,8 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  - !ruby/object:Gem::Version
169
169
  version: '0'
170
170
  requirements: []
171
- rubyforge_project:
172
- rubygems_version: 2.7.7
171
+ rubygems_version: 3.0.6
173
172
  signing_key:
174
173
  specification_version: 4
175
174
  summary: A library to read/write files/spreadsheets in Google Drive/Docs.