gslide 0.1.2 → 0.1.3

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: c60628d84c354c773b26428a27bf090324f9d480e7fbaa21f61b9eff373afcfd
4
- data.tar.gz: 35dfbc790360627c4829f6747e9e25532ab0342d8044c61259e77bf050e85f2c
3
+ metadata.gz: 8fe444ca4bdef588c1e0aadf54db33d2024612b4d3450c4da243bd7ea3538055
4
+ data.tar.gz: 5416cb52420d81d5c5f8e4f99a13d2745e405a372c780314debb67c64e4c1b61
5
5
  SHA512:
6
- metadata.gz: 3998d8e6e183a9a7f1bc4164284a26fa4296c11187dcbf848f8dbe0f75ba6fdc5bb6b9e4407007d1cd7a11d6fd3f5c46b023b7fcda9000a23f3c2fdf0c88eddf
7
- data.tar.gz: '086712b43b87c1a09ee7563c028af143282dc22f3fd74762c0e0dd2d99c81f8d78268affa80be92b1f3eb6e5fe98700356132d8d7f97f6d59ed9e50535333228'
6
+ metadata.gz: 5477601ab8d237e62853bf974c1e3961fbd60e5197822754cdfe1d903a2bc37983395c412b674b27c8405fa3883d6b48291b384c49a619c7c4334f7bab719256
7
+ data.tar.gz: 518e86e5a3ececa73d696c737f3d0672f21fae300f5e57b2aa53c1de8fde8a9d925e1cadbbfd3c2048d9af90d41a3cd0765cd61f445bd9a78bc39c1183aafccd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.1.3] - 2026-08-19
2
+
3
+ - Add `Gslide::Presentation::PRESENTATION_ID_PATTERN` and `Gslide::Presentation.file_id_in`, so callers can validate a presentation id without repeating the pattern
4
+
1
5
  ## [0.1.2] - 2025-05-09
2
6
 
3
7
  - Add `Gslide::HTTPError`, `Gslide::UnauthorizedError` and `Gslide::QuotaExceededError` #10
@@ -1,6 +1,8 @@
1
1
  require "net/http"
2
2
 
3
3
  module Gslide
4
+
5
+ # @private
4
6
  module Concerns
5
7
  module Requests
6
8
  def get_request(uri, auth_token: "")
@@ -7,10 +7,17 @@ module Gslide
7
7
 
8
8
  attr_reader :id
9
9
 
10
- PRESENTATION_PATTERN = %r[/presentation/d/([a-zA-Z0-9\-_]+)?]
10
+ PRESENTATION_ID_PATTERN = /[a-zA-Z0-9\-_]+/
11
+ PRESENTATION_PATTERN = %r[/presentation/d/(#{PRESENTATION_ID_PATTERN})?]
12
+
13
+ # @param [String] id_or_url a presentation id, or a sharing url holding one.
14
+ # @return [String] the presentation id, or the argument when it is not a url.
15
+ def self.file_id_in(id_or_url)
16
+ (url_id = id_or_url.match(PRESENTATION_PATTERN)) ? url_id[1] : id_or_url
17
+ end
11
18
 
12
19
  def initialize(id_or_url, auth: nil)
13
- @id = (url_id = id_or_url.match(PRESENTATION_PATTERN)) ? url_id[1] : id_or_url
20
+ @id = self.class.file_id_in(id_or_url)
14
21
  @auth = auth
15
22
  end
16
23
 
@@ -40,6 +40,23 @@ module Gslide
40
40
  parsed_body = get
41
41
  parsed_body[:sheets].collect { |h| Sheet.new(h) }
42
42
  end
43
+
44
+ # @param [Hash] options the request body.
45
+ # @see https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets.values/append
46
+ def values_append(notation, options = {})
47
+ uri = url_escape_uri(GOOGLE_SHEETS + "/#{@id}/values/'#{notation}':append?valueInputOption=USER_ENTERED")
48
+ request_body = options.convert_keys { |k| k.to_s.lower_camel_case }.to_json
49
+
50
+ response_body = post_request(uri, auth_token: @auth.token, body: request_body)
51
+ response_body
52
+ end
53
+
54
+ private
55
+
56
+ def url_escape_uri(uri_string)
57
+ parser = URI::Parser.new
58
+ URI parser.escape(uri_string)
59
+ end
43
60
  end
44
61
 
45
62
  class SpreadsheetDraft
@@ -61,10 +78,11 @@ module Gslide
61
78
  end
62
79
 
63
80
  class Sheet
64
- attr_reader :id, :charts
81
+ attr_reader :id, :title, :charts
65
82
 
66
83
  def initialize(options = {})
67
84
  @id = options[:properties][:sheet_id]
85
+ @title = options[:properties][:title]
68
86
  @charts = options[:charts].collect { |h| Chart.new(h) } if options[:charts]
69
87
  end
70
88
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gslide
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gslide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kang-Kyu Lee
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  requirements: []
55
- rubygems_version: 3.6.7
55
+ rubygems_version: 4.0.6
56
56
  specification_version: 4
57
57
  summary: Google Slides API client.
58
58
  test_files: []