google_drive_maintained 3.0.10 → 3.0.11
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 +4 -4
- data/README.md +1 -1
- data/lib/google_drive/{worksheet_formatting.rb → cell.rb} +14 -14
- data/lib/google_drive/util.rb +1 -0
- data/lib/google_drive/worksheet.rb +36 -11
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bc8471dadbc68ec2f2b2d4a27e44676fea447970d445b7e4554dd31183ec7a9
|
4
|
+
data.tar.gz: 6923ff6cda79e893cd884fa0271ca9617b0cfafae82d0117333f521b2551e86a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f61fb3b709779d9c9530b4a55fa33f6c962f094605f0188efff6dce304e728ea923d9b9d1f5147d7290daf8e7ed9b3a6adfe5f3f885635abd637e10b375d411
|
7
|
+
data.tar.gz: 625b06e7bc2c79e164aaaed1f1f4c48440e87a2f7a86edd89beacbeeef3445f4fc2dfeef69817c807b74b8934e6b3a2e51571ca0c54c4156b3037c4602ff6b8c
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# google-drive-ruby
|
2
2
|
|
3
3
|
[](https://rubygems.org/gems/google_drive_maintained)
|
4
|
-
[](https://github.com/y-bonfire/google-drive-ruby-maintained/actions/workflows/ci.yml)
|
5
5
|
|
6
6
|
This is a Ruby library to read/write files/spreadsheets in Google Drive/Docs.
|
7
7
|
|
@@ -5,16 +5,22 @@ module GoogleDrive
|
|
5
5
|
class Cell
|
6
6
|
attr_reader :row, :col, :value
|
7
7
|
|
8
|
-
|
8
|
+
# @!attribute [r] properties
|
9
|
+
# @return [Hash] properties
|
10
|
+
attr_reader :properties
|
11
|
+
|
12
|
+
# @!attribute [rw] worksheet
|
13
|
+
# @return [Worksheet] worksheet
|
14
|
+
attr_accessor :worksheet
|
15
|
+
|
16
|
+
def initialize(worksheet, row, col, value, properties = {})
|
9
17
|
@worksheet = worksheet
|
10
18
|
@row = row
|
11
19
|
@col = col
|
12
20
|
@value = value
|
21
|
+
@properties = properties || {}
|
13
22
|
end
|
14
23
|
|
15
|
-
#
|
16
|
-
# === 等価性
|
17
|
-
#
|
18
24
|
def ==(other)
|
19
25
|
case other
|
20
26
|
when GoogleDrive::Cell
|
@@ -36,18 +42,12 @@ module GoogleDrive
|
|
36
42
|
@worksheet.set_background_color(@row, @col, 1, 1, color)
|
37
43
|
end
|
38
44
|
|
39
|
-
|
40
|
-
|
41
|
-
module WorksheetFormatting
|
42
|
-
|
43
|
-
def set_background_color_at(row, col, color)
|
44
|
-
set_background_color(row, col, 1, 1, color)
|
45
|
+
def set_hyperlink_rich(text, hyperlink)
|
46
|
+
@worksheet.set_hyperlink_rich(@row, @col, 1, 1, text, hyperlink)
|
45
47
|
end
|
46
48
|
|
47
|
-
def
|
48
|
-
|
49
|
+
def hyperlink
|
50
|
+
@properties[:hyperlink]
|
49
51
|
end
|
50
|
-
|
51
|
-
# ... 他にも text_color, font_size など拡張しやすい
|
52
52
|
end
|
53
53
|
end
|
data/lib/google_drive/util.rb
CHANGED
@@ -5,10 +5,10 @@ require 'cgi'
|
|
5
5
|
require 'set'
|
6
6
|
require 'uri'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
require_relative "
|
8
|
+
require_relative 'util'
|
9
|
+
require_relative 'error'
|
10
|
+
require_relative 'list'
|
11
|
+
require_relative "cell"
|
12
12
|
|
13
13
|
module GoogleDrive
|
14
14
|
# A worksheet (i.e. a tab) in a spreadsheet.
|
@@ -16,7 +16,6 @@ module GoogleDrive
|
|
16
16
|
# object.
|
17
17
|
class Worksheet
|
18
18
|
include(Util)
|
19
|
-
include(WorksheetFormatting)
|
20
19
|
|
21
20
|
# A few default color instances that match the colors from the Google Sheets web UI.
|
22
21
|
#
|
@@ -63,6 +62,7 @@ module GoogleDrive
|
|
63
62
|
@cells = nil
|
64
63
|
@input_values = nil
|
65
64
|
@numeric_values = nil
|
65
|
+
@cell_properties = nil
|
66
66
|
@modified = Set.new
|
67
67
|
@list = nil
|
68
68
|
@v4_requests = []
|
@@ -171,7 +171,7 @@ module GoogleDrive
|
|
171
171
|
def [](*args)
|
172
172
|
(row, col) = parse_cell_args(args)
|
173
173
|
value = cells[[row, col]] || ''
|
174
|
-
Cell.new(self, row, col, value)
|
174
|
+
Cell.new(self, row, col, value, @cell_properties[[row, col]])
|
175
175
|
end
|
176
176
|
|
177
177
|
# Updates content of the cell.
|
@@ -192,6 +192,7 @@ module GoogleDrive
|
|
192
192
|
@cells[[row, col]] = value
|
193
193
|
@input_values[[row, col]] = value
|
194
194
|
@numeric_values[[row, col]] = nil
|
195
|
+
@cell_properties[[row, col]] = nil
|
195
196
|
@modified.add([row, col])
|
196
197
|
self.max_rows = row if row > @max_rows
|
197
198
|
self.max_cols = col if col > @max_cols
|
@@ -391,7 +392,7 @@ module GoogleDrive
|
|
391
392
|
ranges: "'%s'" % @title,
|
392
393
|
fields:
|
393
394
|
'sheets(properties,data.rowData.values' \
|
394
|
-
'(formattedValue,userEnteredValue,effectiveValue))'
|
395
|
+
'(formattedValue,userEnteredValue,effectiveValue,hyperlink))'
|
395
396
|
)
|
396
397
|
api_sheet = api_spreadsheet.sheets[0]
|
397
398
|
set_properties(api_sheet.properties)
|
@@ -419,7 +420,7 @@ module GoogleDrive
|
|
419
420
|
})
|
420
421
|
end
|
421
422
|
|
422
|
-
|
423
|
+
unless @v4_requests.empty?
|
423
424
|
self.spreadsheet.batch_update(@v4_requests)
|
424
425
|
@v4_requests = []
|
425
426
|
sent = true
|
@@ -588,6 +589,28 @@ module GoogleDrive
|
|
588
589
|
format_cells(top_row, left_col, num_rows, num_cols, format, fields)
|
589
590
|
end
|
590
591
|
|
592
|
+
def set_hyperlink_rich(top_row, left_col, num_rows, num_cols, text, uri)
|
593
|
+
cell = Google::Apis::SheetsV4::CellData.new(
|
594
|
+
user_entered_value: Google::Apis::SheetsV4::ExtendedValue.new(string_value: text),
|
595
|
+
text_format_runs: [
|
596
|
+
Google::Apis::SheetsV4::TextFormatRun.new(
|
597
|
+
start_index: 0,
|
598
|
+
format: Google::Apis::SheetsV4::TextFormat.new(
|
599
|
+
link: Google::Apis::SheetsV4::Link.new(uri: uri)
|
600
|
+
)
|
601
|
+
)
|
602
|
+
]
|
603
|
+
)
|
604
|
+
|
605
|
+
add_request(
|
606
|
+
repeat_cell: Google::Apis::SheetsV4::RepeatCellRequest.new(
|
607
|
+
range: v4_range_object(top_row, left_col, num_rows, num_cols),
|
608
|
+
cell: cell,
|
609
|
+
fields: 'userEnteredValue,textFormatRuns'
|
610
|
+
)
|
611
|
+
)
|
612
|
+
end
|
613
|
+
|
591
614
|
# Changes the background color on a range of cells. e.g.:
|
592
615
|
# worksheet.set_background_color(1, 1, 1, 1, GoogleDrive::Worksheet::Colors::DARK_YELLOW_1)
|
593
616
|
#
|
@@ -685,7 +708,7 @@ module GoogleDrive
|
|
685
708
|
@session.sheets_service.get_spreadsheet(
|
686
709
|
spreadsheet.id,
|
687
710
|
ranges: "'%s'" % @remote_title,
|
688
|
-
fields: 'sheets.data.rowData.values(formattedValue,userEnteredValue,effectiveValue)'
|
711
|
+
fields: 'sheets.data.rowData.values(formattedValue,userEnteredValue,effectiveValue,hyperlink)'
|
689
712
|
)
|
690
713
|
update_cells_from_api_sheet(response.sheets[0])
|
691
714
|
end
|
@@ -698,17 +721,19 @@ module GoogleDrive
|
|
698
721
|
@cells = {}
|
699
722
|
@input_values = {}
|
700
723
|
@numeric_values = {}
|
724
|
+
@cell_properties = {}
|
701
725
|
|
702
726
|
rows_data.each_with_index do |row_data, r|
|
703
|
-
next
|
727
|
+
next unless row_data.values
|
704
728
|
@num_cols = row_data.values.size if row_data.values.size > @num_cols
|
705
729
|
row_data.values.each_with_index do |cell_data, c|
|
706
730
|
k = [r + 1, c + 1]
|
707
731
|
@cells[k] = cell_data.formatted_value || ''
|
708
732
|
@input_values[k] = extended_value_to_str(cell_data.user_entered_value)
|
709
733
|
@numeric_values[k] =
|
710
|
-
|
734
|
+
cell_data.effective_value&.number_value ?
|
711
735
|
cell_data.effective_value.number_value.to_f : nil
|
736
|
+
@cell_properties[k] = { hyperlink: cell_data.hyperlink }
|
712
737
|
end
|
713
738
|
end
|
714
739
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_drive_maintained
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroshi Ichikawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- lib/google_drive/acl_entry.rb
|
144
144
|
- lib/google_drive/api_client_fetcher.rb
|
145
145
|
- lib/google_drive/authentication_error.rb
|
146
|
+
- lib/google_drive/cell.rb
|
146
147
|
- lib/google_drive/collection.rb
|
147
148
|
- lib/google_drive/config.rb
|
148
149
|
- lib/google_drive/error.rb
|
@@ -154,7 +155,6 @@ files:
|
|
154
155
|
- lib/google_drive/spreadsheet.rb
|
155
156
|
- lib/google_drive/util.rb
|
156
157
|
- lib/google_drive/worksheet.rb
|
157
|
-
- lib/google_drive/worksheet_formatting.rb
|
158
158
|
homepage: https://github.com/y-bonfire/google-drive-ruby-maintained
|
159
159
|
licenses:
|
160
160
|
- BSD-3-Clause
|