gslide 0.1.0 → 0.1.1

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: 3b59859f25a2ec7a2e3477e43f1fd9130c2f39cac573da00949db781721e0c00
4
- data.tar.gz: 3931e3260c7230dc6661baab6b5411c372aef15732a336738dc829f5fa27794f
3
+ metadata.gz: 52da391c6d99b7a6c04b766ec32349d41409af6a568f6b3dad3bc300f9e362b4
4
+ data.tar.gz: 0adf949984afb45f782c8a4bef5d516b68550bd499b382dfa2e993b008b7402c
5
5
  SHA512:
6
- metadata.gz: 7c04e204a3469bbaf902cc32f631476ca8af0d20138f38cfcf146d21ecb0491831333a262418b0eb3e5d95b1d3ab498f1de037d45b7fb34e6bf6360e08b9e5ba
7
- data.tar.gz: d79224b147b6f6f6dabbfedd9e3f1ab2d49093b2e7622e9333edbe1c41a1d2b59e16b099230ceeee5ff4be11467fc4343971ec444b611c9fe800d30839e39e80
6
+ metadata.gz: 788294f12da41010e96ecb1576983e51cbd57de78970971b7940a60a325563685a2a494395925998c936ea2b862467d8971c6dbcfa62dd21442bafd81d7b83be
7
+ data.tar.gz: 5c18a8c54b79bdff0da9c8f896d7aa31a2388cc7a86b9ad6e5a6c4a4425236a6915cde046dfee446e1a80ec5d8966b487e59c9356dbc4b5e54c8052f66f4736e
data/CHANGELOG.md CHANGED
@@ -1,4 +1,7 @@
1
- ## [Unreleased]
1
+ ## [0.1.1] - 2025-04-14
2
+
3
+ - Use a regular expression for finding a presentation id from url #8
4
+ - Add retry logic for slide batch_update #7
2
5
 
3
6
  ## [0.1.0] - 2025-03-31
4
7
 
data/README.md CHANGED
@@ -1,10 +1,24 @@
1
+ [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/gems/gslide)
2
+ [![Gem](https://img.shields.io/gem/v/gslide)](https://rubygems.org/gems/gslide)
3
+
1
4
  # Gslide
2
5
 
3
6
  Welcome to Gslide! This is an approach to build a Google Slides file for practical use.
4
7
 
5
8
  ## Installation
6
9
 
7
- > Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+ ```sh
11
+ gem install gslide
12
+ ```
13
+
14
+ - Use [bundler](https://bundler.io/)
15
+
16
+ ```bash
17
+ bundle add gslide
18
+ bundle install
19
+ ```
20
+
21
+ - From Github
8
22
 
9
23
  Install the gem and add to the application's Gemfile by executing:
10
24
 
@@ -7,8 +7,10 @@ module Gslide
7
7
 
8
8
  attr_reader :id
9
9
 
10
- def initialize(id, auth: nil)
11
- @id = id
10
+ PRESENTATION_PATTERN = %r[/presentation/d/([a-zA-Z0-9\-_]+)?]
11
+
12
+ def initialize(id_or_url, auth: nil)
13
+ @id = (url_id = id_or_url.match(PRESENTATION_PATTERN)) ? url_id[1] : id_or_url
12
14
  @auth = auth
13
15
  end
14
16
 
@@ -29,6 +31,8 @@ module Gslide
29
31
  # @return True when update successful.
30
32
  # @see https://developers.google.com/slides/api/reference/rest/v1/presentations/batchUpdate#request-body
31
33
  def batch_update(options = {})
34
+ retries ||= 0
35
+
32
36
  uri = URI(GOOGLE_SLIDES + "/#{@id}:batchUpdate")
33
37
  request_body = options.convert_keys { |k| k.to_s.lower_camel_case }.to_json
34
38
 
@@ -39,6 +43,16 @@ module Gslide
39
43
  raise Gslide::Error.new(response_body["error"]["message"])
40
44
  end
41
45
  response_body["presentationId"] == @id
46
+
47
+ rescue Gslide::Error => e
48
+ if e.message =~ /Quota exceeded/ && (retries += 1) < 3
49
+ # "Quota exceeded for quota metric 'Write requests' and limit 'Write requests per minute per user' of service 'slides.googleapis.com' for consumer 'project_number:012345678901'."
50
+ sleep 10 + retries * retries * 10
51
+
52
+ retry
53
+ end
54
+ # all retries failed, re-raise exception
55
+ raise e
42
56
  end
43
57
 
44
58
  def get_slide_ids
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gslide
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gslide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kang-Kyu Lee
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-03-31 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: Allows to modify a Google Slides file by API requests.
13
13
  email:
@@ -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.6
55
+ rubygems_version: 3.6.7
56
56
  specification_version: 4
57
57
  summary: Google Slides API client.
58
58
  test_files: []