google_drive_maintained 3.0.9 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1c15539fcc6168ea5c7dbec734c94b270e2d22ed189848caa74f2125bd4d8ad
4
- data.tar.gz: c9a287fb0fb0c1c905eb2e5c266baab65e4ce2e79e6380bbbd4699b4d185bcae
3
+ metadata.gz: 3bc8471dadbc68ec2f2b2d4a27e44676fea447970d445b7e4554dd31183ec7a9
4
+ data.tar.gz: 6923ff6cda79e893cd884fa0271ca9617b0cfafae82d0117333f521b2551e86a
5
5
  SHA512:
6
- metadata.gz: 1b9ff53cb67224d4a944c026ddab2f08d9dff247446eba5c9dac17a5b8a53aebc03d7cd5fac2296b7f940b782bd741670897b17d88a55fc490b50099145734e1
7
- data.tar.gz: 7401a746cfc823c070e4fbdaa3e3ee9eef322289d6cabd9b25dd3a70589d27b1586542a3665c2e75aaf424cc7aa6a3c73ff5bcb4001546e45476fd07ba628c20
6
+ metadata.gz: 6f61fb3b709779d9c9530b4a55fa33f6c962f094605f0188efff6dce304e728ea923d9b9d1f5147d7290daf8e7ed9b3a6adfe5f3f885635abd637e10b375d411
7
+ data.tar.gz: 625b06e7bc2c79e164aaaed1f1f4c48440e87a2f7a86edd89beacbeeef3445f4fc2dfeef69817c807b74b8934e6b3a2e51571ca0c54c4156b3037c4602ff6b8c
data/README.md CHANGED
@@ -1,13 +1,26 @@
1
- # google-drive-ruby [![CI](https://github.com/y-bonfire/google-drive-ruby-maintained/actions/workflows/test.yml/badge.svg)](https://github.com/y-bonfire/google-drive-ruby-maintained/actions/workflows/test.yml)
1
+ # google-drive-ruby
2
+
3
+ [![Gem](https://img.shields.io/gem/v/google_drive_maintained.svg)](https://rubygems.org/gems/google_drive_maintained)
4
+ [![GitHub Actions Workflow Status](https://github.com/y-bonfire/google-drive-ruby-maintained/actions/workflows/ci.yml/badge.svg)](https://github.com/y-bonfire/google-drive-ruby-maintained/actions/workflows/ci.yml)
2
5
 
3
6
  This is a Ruby library to read/write files/spreadsheets in Google Drive/Docs.
4
7
 
5
8
  NOTE: This is NOT a library to create Google Drive App.
6
9
 
7
- NOTE: ⚠️This is an unofficial maintained fork of google-drive-ruby, originally created by Hiroshi Ichikawa.
10
+ ## Introduction
11
+ ⚠️This is an unofficial maintained fork of [gimite/google-drive-ruby](https://github.com/gimite/google-drive-ruby), originally created by Hiroshi Ichikawa.
12
+
8
13
  We focus on preserving compatibility and fixing bugs, with minimal disruptive changes.
9
14
  New features may be added carefully when justified, but the core behavior will remain stable.
10
15
 
16
+ See [this issue](https://github.com/y-bonfire/google-drive-ruby-maintained/issues/7) for background and intent.
17
+
18
+ ## Contributing
19
+
20
+ We are actively working on improving the library, updating dependencies, and refining the development workflow.
21
+ If you'd like to contribute, please check [CONTRIBUTING.md](./CONTRIBUTING.md) for up-to-date contribution guidelines and technical notes (CI, testing, gem build, etc.).
22
+
23
+
11
24
  ✅ GitHub Actions Integration
12
25
  We've started testing this library with GitHub Actions:
13
26
  👉 [CI Workflow Link](https://github.com/y-bonfire/google-drive-ruby-maintained/actions)
@@ -15,6 +28,8 @@ We've started testing this library with GitHub Actions:
15
28
  This enables automated testing on every push and pull request, helping ensure long-term reliability.
16
29
  We welcome feedback and contributions to improve the CI process or test coverage. 🤗
17
30
 
31
+ ## table of contents
32
+
18
33
  * [Migration from ver. 2.x.x or before](#migration)
19
34
  * [How to install](#install)
20
35
  * [How to use](#use)
@@ -29,7 +44,7 @@ We welcome feedback and contributions to improve the CI process or test coverage
29
44
  ## <a name="migration">Migration from ver. 2.x.x or before</a>
30
45
 
31
46
  There are some incompatible API changes. See
32
- [MIGRATING.md](https://github.com/gimite/google-drive-ruby/blob/master/MIGRATING.md).
47
+ [MIGRATING.md](MIGRATING.md).
33
48
 
34
49
 
35
50
  ## <a name="install">How to install</a>
@@ -62,7 +77,7 @@ $ sudo gem install google_drive_maintained
62
77
 
63
78
  ### Authorization
64
79
 
65
- Follow one of the options in [Authorization](https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md) to construct a session object. The example code below assumes "On behalf of you" option.
80
+ Follow one of the options in [Authorization](doc/authorization.md) to construct a session object. The example code below assumes "On behalf of you" option.
66
81
 
67
82
  ### Example to read/write files in Google Drive
68
83
 
@@ -138,7 +153,7 @@ New BSD Licence.
138
153
 
139
154
  ## <a name="environments">Supported environments</a>
140
155
 
141
- Ruby 3.0.0 or later. Checked with Ruby 3.3.0.
156
+ Ruby 3.2.0 or later. Checked with Ruby 3.3.0.
142
157
 
143
158
 
144
159
  ## <a name="author">Author</a>
@@ -5,16 +5,22 @@ module GoogleDrive
5
5
  class Cell
6
6
  attr_reader :row, :col, :value
7
7
 
8
- def initialize(worksheet, row, col, value)
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
- end
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 set_bold(row, col, enable = true)
48
- # 太字設定
49
+ def hyperlink
50
+ @properties[:hyperlink]
49
51
  end
50
-
51
- # ... 他にも text_color, font_size など拡張しやすい
52
52
  end
53
53
  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_all_drives: true }.merge(params)
99
+ **{ download_dest: path, supports_all_drives: true }.merge(params)
100
100
  )
101
101
  end
102
102
 
@@ -77,6 +77,7 @@ module GoogleDrive
77
77
  # As with from_config, you can configure Google API client behavior with
78
78
  # +client_options+ and +request_options+. Unlike in from_config, these
79
79
  # are passed as positional arguments.
80
+ # @return [GoogleDrive::Session]
80
81
  def self.from_service_account_key(
81
82
  json_key_path_or_io, scope = DEFAULT_SCOPE, client_options = nil,
82
83
  request_options = nil
@@ -270,6 +271,19 @@ module GoogleDrive
270
271
  # If given an Array, traverses folders by title. e.g.:
271
272
  # session.file_by_title(
272
273
  # ["myfolder", "mysubfolder/even/w/slash", "myfile"])
274
+ # root
275
+ # └── myfolder
276
+ # └── mysubfolder/even/w/slash
277
+ # └── myfile
278
+ # In Google Drive,
279
+ #
280
+ # "mysubfolder/even/w/slash"
281
+ #
282
+ # is a folder with a single name that includes a slash.
283
+ # For example, you can create a folder named mysubfolder/even/w/slash directly
284
+ # This is not a UNIX-style "path."
285
+ #
286
+ # @return [GoogleDrive::File]
273
287
  def file_by_title(title)
274
288
  if title.is_a?(Array)
275
289
  root_collection.file_by_title(title)
@@ -329,6 +343,7 @@ module GoogleDrive
329
343
  # # https://docs.google.com/spreadsheets/d/1L3-kvwJblyW_TvjYD-7pE-AXxw5_bkb6S_MljuIPVL0/edit
330
344
  # session.spreadsheet_by_key(
331
345
  # "1L3-kvwJblyW_TvjYD-7pE-AXxw5_bkb6S_MljuIPVL0")
346
+ # @return [GoogleDrive::Spreadsheet]
332
347
  def spreadsheet_by_key(key)
333
348
  file = file_by_id(key)
334
349
  unless file.is_a?(Spreadsheet)
@@ -48,6 +48,7 @@ module GoogleDrive
48
48
  end
49
49
 
50
50
  # Returns worksheets of the spreadsheet as array of GoogleDrive::Worksheet.
51
+ # @return [Array<GoogleDrive::Worksheet>]
51
52
  def worksheets
52
53
  api_spreadsheet = @session.sheets_service.get_spreadsheet(id, fields: 'sheets.properties')
53
54
  api_spreadsheet.sheets.map{ |s| Worksheet.new(@session, self, s.properties) }
@@ -27,6 +27,7 @@ module GoogleDrive
27
27
  '.htm' => 'text/html',
28
28
  '.html' => 'text/html',
29
29
  '.zip' => 'application/zip',
30
+ '.epub' => 'application/epub+zip',
30
31
  '.swf' => 'application/x-shockwave-flash'
31
32
  }.freeze
32
33
 
@@ -5,10 +5,10 @@ require 'cgi'
5
5
  require 'set'
6
6
  require 'uri'
7
7
 
8
- require 'google_drive/util'
9
- require 'google_drive/error'
10
- require 'google_drive/list'
11
- require_relative "worksheet_formatting"
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
- if !@v4_requests.empty?
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
  #
@@ -635,7 +658,7 @@ module GoogleDrive
635
658
  # {bottom: Google::Apis::SheetsV4::Border.new(
636
659
  # style: "DOUBLE", color: GoogleDrive::Worksheet::Colors::BLACK)})
637
660
  def update_borders(top_row, left_col, num_rows, num_cols, borders)
638
- request = Google::Apis::SheetsV4::UpdateBordersRequest.new(borders)
661
+ request = Google::Apis::SheetsV4::UpdateBordersRequest.new(**borders)
639
662
  request.range = v4_range_object(top_row, left_col, num_rows, num_cols)
640
663
  add_request({update_borders: request})
641
664
  end
@@ -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 if !row_data.values
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
- cell_data.effective_value && cell_data.effective_value.number_value ?
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.9
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-07-26 00:00:00.000000000 Z
11
+ date: 2025-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.5.3
19
+ version: '1.18'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: 2.0.0
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 1.5.3
29
+ version: '1.18'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 2.0.0
@@ -36,42 +36,42 @@ dependencies:
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 0.5.0
39
+ version: 0.63.0
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 0.5.0
46
+ version: 0.63.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: google-apis-sheets_v4
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 0.4.0
53
+ version: 0.42.0
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: 0.4.0
60
+ version: 0.42.0
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: googleauth
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
- version: 0.5.0
67
+ version: '1.14'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: 0.5.0
74
+ version: '1.14'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: test-unit
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -98,14 +98,14 @@ dependencies:
98
98
  requirements:
99
99
  - - ">="
100
100
  - !ruby/object:Gem::Version
101
- version: 0.8.0
101
+ version: 13.0.3
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - ">="
107
107
  - !ruby/object:Gem::Version
108
- version: 0.8.0
108
+ version: 13.0.3
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: rspec-mocks
111
111
  requirement: !ruby/object:Gem::Requirement
@@ -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,11 +155,15 @@ 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
161
- metadata: {}
161
+ metadata:
162
+ homepage_uri: https://github.com/y-bonfire/google-drive-ruby-maintained
163
+ source_code_uri: https://github.com/y-bonfire/google-drive-ruby-maintained
164
+ changelog_uri: https://github.com/y-bonfire/google-drive-ruby-maintained/blob/main/CHANGELOG.md
165
+ bug_tracker_uri: https://github.com/y-bonfire/google-drive-ruby-maintained/issues
166
+ documentation_uri: https://rubydoc.info/gems/google_drive_ruby_maintained
162
167
  post_install_message:
163
168
  rdoc_options: []
164
169
  require_paths:
@@ -167,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
172
  requirements:
168
173
  - - ">="
169
174
  - !ruby/object:Gem::Version
170
- version: 3.0.0
175
+ version: '3.1'
171
176
  required_rubygems_version: !ruby/object:Gem::Requirement
172
177
  requirements:
173
178
  - - ">="