kagaribi 0.1.0 → 0.1.2

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: d7009cb11cae6982c8214c7de69349b851ac8b7475959801b48ebb309762a5e6
4
- data.tar.gz: 77887aa0a0f38a9cc1a83177505e78ec3bd4d20a6cf2f37eddae03ddb4f17539
3
+ metadata.gz: 07d15e73c256141678c50d117e26383372d2519def0de3591d29bce5ed9d7946
4
+ data.tar.gz: a36f76bd5dd57673fd45e9e5a22872dc3570ed3fcab4a430ba3a1f6a4ca89f7c
5
5
  SHA512:
6
- metadata.gz: f3849fcf52d60d06a23105f2318547bd9a14c49edaa9a9df6cdc28cd08ab1b91b78a533349c68935204a632e86b4b569600209f9cbfb14796f67df0e75fb351d
7
- data.tar.gz: 26c6ee337021f3c5d68a9d622db22cbc3c54e4052eb4e75e4af36d80c616b3f6af5c095cbc87e23ae8d6c8198dbd21171ade05196baec2bc9bcb850ef19c6f1b
6
+ metadata.gz: 6907b8361700413186ef5bd14884b504ad0987e755655d682e522f9af4d618056abb71273c7b1790bc3a4fde4f94aeb66eb92e8d7ddbfe421b1989a9510cb84d
7
+ data.tar.gz: 3d4c5a17519af0fdabda84b00321b24406b8656d843beb20ab7ab816feb3d5b13758979a34890507307fcb804e046e7dcfb567a1d59277ea14d389fd411a3916
data/CHANGELOG.md CHANGED
@@ -1,6 +1,18 @@
1
1
  ## [Unreleased]
2
- [full changelog](http://github.com/sue445/kagaribi/compare/v0.1.0...main)
2
+ [full changelog](http://github.com/sue445/kagaribi/compare/v0.1.2...main)
3
3
 
4
- ## [0.1.0] - 2024-05-11
4
+ ## [0.1.2](https://github.com/sue445/kagaribi/releases/tag/v0.1.2) - 2025-05-16
5
+ [full changelog](http://github.com/sue445/kagaribi/compare/v0.1.2...v0.1.2)
6
+
7
+ - Allow retries on `Google::Cloud::UnauthenticatedError`
8
+ - https://github.com/sue445/kagaribi/pull/40
9
+
10
+ ## [0.1.1](https://github.com/sue445/kagaribi/releases/tag/v0.1.1) - 2024-05-12
11
+ [full changelog](http://github.com/sue445/kagaribi/compare/v0.1.0...v0.1.1)
12
+
13
+ - Add missing rbs
14
+ - https://github.com/sue445/kagaribi/pull/18
15
+
16
+ ## [0.1.0](https://github.com/sue445/kagaribi/releases/tag/v0.1.0) - 2024-05-11
5
17
 
6
18
  - Initial release
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Kagaribi(篝火) :fire:
2
2
  Simple client for [Cloud Firestore](https://cloud.google.com/firestore)
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/kagaribi.svg)](https://badge.fury.io/rb/kagaribi)
4
5
  [![test](https://github.com/sue445/kagaribi/actions/workflows/test.yml/badge.svg)](https://github.com/sue445/kagaribi/actions/workflows/test.yml)
5
6
 
6
7
  ## Installation
@@ -22,13 +23,28 @@ Pass environment variables for Firestore authentication
22
23
 
23
24
  see https://cloud.google.com/ruby/docs/reference/google-cloud-firestore/latest/AUTHENTICATION
24
25
 
26
+ ### Requirements
27
+ Firestore CRUD(Create/Read/Update/Delete) requires at least the following IAM Role
28
+
29
+ * [Cloud Datastore User](https://cloud.google.com/iam/docs/understanding-roles#datastore.user) (`roles/datastore.user`)
30
+
25
31
  ### Simple usage
26
32
  ```ruby
27
33
  require "kagaribi"
28
34
 
29
35
  collection = Kagaribi.collection("users")
30
36
 
37
+ # or
38
+
39
+ class UsersCollection < Kagaribi::Collection
40
+ def initialize
41
+ super("users")
42
+ end
43
+ end
44
+ collection = UsersCollection.new
45
+
31
46
  collection.set("sue445", name: "sue445", url: "https://github.com/sue445")
47
+ #=> document is stored in a key named "users/sue445" to Firestore collection
32
48
 
33
49
  collection.get("sue445")
34
50
  #=> { name: "sue445", url: "https://github.com/sue445" }
@@ -38,6 +54,14 @@ All methods are followings
38
54
 
39
55
  https://sue445.github.io/kagaribi/Kagaribi/Collection
40
56
 
57
+ ## Features
58
+ ### Auto retry
59
+ The Cloud Firestore API is sometimes unstable.
60
+
61
+ Error, but retry the same operation and it may succeed.
62
+
63
+ Therefore, if an error occurs in some operations (e.g. [Kagaribi::Collection#get](https://sue445.github.io/kagaribi/Kagaribi/Collection.html#get-instance_method)), the retry will be performed automatically.
64
+
41
65
  ## Development
42
66
  At first, install [Firebase Local Emulator Suite](https://firebase.google.com/docs/emulator-suite/install_and_configure)
43
67
 
@@ -1,24 +1,45 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kagaribi
4
+ # Manage a Firestore collection
5
+ #
6
+ # @example
7
+ # require "kagaribi"
8
+ #
9
+ # collection = Kagaribi.collection("users")
10
+ #
11
+ # # or
12
+ #
13
+ # class UsersCollection < Kagaribi::Collection
14
+ # def initialize
15
+ # super("users")
16
+ # end
17
+ # end
18
+ # collection = UsersCollection.new
19
+ #
20
+ # collection.set("sue445", name: "sue445", url: "https://github.com/sue445")
21
+ # #=> document is stored in a key named "users/sue445" to Firestore collection
22
+ #
23
+ # collection.get("sue445")
24
+ # #=> { name: "sue445", url: "https://github.com/sue445" }
4
25
  class Collection
5
26
  MAX_RETRY_COUNT = 5
6
27
 
7
28
  # @!attribute [r] collection_name
8
- # @return [String]
29
+ # @return [String]
9
30
  attr_reader :collection_name
10
31
 
11
32
  # @!attribute [r] database_id
12
- # @return [String,nil]
33
+ # @return [String,nil]
13
34
  attr_reader :database_id
14
35
 
15
36
  # @!attribute [r] logger
16
- # @return [Logger]
37
+ # @return [Logger]
17
38
  attr_reader :logger
18
39
 
19
40
  # @param collection_name [String]
20
41
  # @param database_id [String,nil] Identifier for a Firestore database. If not present, the default database of the project is used.
21
- # @param logger [Logger] default is `STDOUT` Logger
42
+ # @param logger [Logger,nil] default is `STDOUT` Logger
22
43
  def initialize(collection_name, database_id: nil, logger: nil)
23
44
  @collection_name = collection_name
24
45
  @database_id = database_id
@@ -112,7 +133,7 @@ module Kagaribi
112
133
  # @yield
113
134
  def with_retry(label)
114
135
  yield
115
- rescue TypeError, GRPC::Unavailable, RuntimeError, Signet::AuthorizationError => error
136
+ rescue TypeError, GRPC::Unavailable, RuntimeError, Signet::AuthorizationError, Google::Cloud::UnauthenticatedError => error
116
137
  raise error unless retryable_error?(error)
117
138
 
118
139
  retry_count ||= 0
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kagaribi
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -1,18 +1,106 @@
1
1
  ---
2
2
  path: ".gem_rbs_collection"
3
3
  gems:
4
+ - name: addressable
5
+ version: '2.8'
6
+ source:
7
+ type: git
8
+ name: ruby/gem_rbs_collection
9
+ revision: 0ef449166f72c767f58f920cc36aca818fbf082f
10
+ remote: https://github.com/ruby/gem_rbs_collection.git
11
+ repo_dir: gems
12
+ - name: base64
13
+ version: '0.1'
14
+ source:
15
+ type: git
16
+ name: ruby/gem_rbs_collection
17
+ revision: 0ef449166f72c767f58f920cc36aca818fbf082f
18
+ remote: https://github.com/ruby/gem_rbs_collection.git
19
+ repo_dir: gems
20
+ - name: bigdecimal
21
+ version: '3.1'
22
+ source:
23
+ type: git
24
+ name: ruby/gem_rbs_collection
25
+ revision: 0ef449166f72c767f58f920cc36aca818fbf082f
26
+ remote: https://github.com/ruby/gem_rbs_collection.git
27
+ repo_dir: gems
28
+ - name: concurrent-ruby
29
+ version: '1.1'
30
+ source:
31
+ type: git
32
+ name: ruby/gem_rbs_collection
33
+ revision: 0ef449166f72c767f58f920cc36aca818fbf082f
34
+ remote: https://github.com/ruby/gem_rbs_collection.git
35
+ repo_dir: gems
4
36
  - name: diff-lcs
5
37
  version: '1.5'
6
38
  source:
7
39
  type: git
8
40
  name: ruby/gem_rbs_collection
9
- revision: 7a105f52053ce1c708b605dfa9c1ab8473424036
41
+ revision: 0ef449166f72c767f58f920cc36aca818fbf082f
42
+ remote: https://github.com/ruby/gem_rbs_collection.git
43
+ repo_dir: gems
44
+ - name: faraday
45
+ version: '2.7'
46
+ source:
47
+ type: git
48
+ name: ruby/gem_rbs_collection
49
+ revision: 0ef449166f72c767f58f920cc36aca818fbf082f
10
50
  remote: https://github.com/ruby/gem_rbs_collection.git
11
51
  repo_dir: gems
12
52
  - name: fileutils
13
53
  version: '0'
14
54
  source:
15
55
  type: stdlib
56
+ - name: forwardable
57
+ version: '0'
58
+ source:
59
+ type: stdlib
60
+ - name: google-cloud-firestore
61
+ version: '2.15'
62
+ source:
63
+ type: git
64
+ name: ruby/gem_rbs_collection
65
+ revision: 0ef449166f72c767f58f920cc36aca818fbf082f
66
+ remote: https://github.com/ruby/gem_rbs_collection.git
67
+ repo_dir: gems
68
+ - name: google-protobuf
69
+ version: '3.22'
70
+ source:
71
+ type: git
72
+ name: ruby/gem_rbs_collection
73
+ revision: 0ef449166f72c767f58f920cc36aca818fbf082f
74
+ remote: https://github.com/ruby/gem_rbs_collection.git
75
+ repo_dir: gems
76
+ - name: googleauth
77
+ version: '1.11'
78
+ source:
79
+ type: git
80
+ name: ruby/gem_rbs_collection
81
+ revision: 0ef449166f72c767f58f920cc36aca818fbf082f
82
+ remote: https://github.com/ruby/gem_rbs_collection.git
83
+ repo_dir: gems
84
+ - name: grpc
85
+ version: '1.63'
86
+ source:
87
+ type: git
88
+ name: ruby/gem_rbs_collection
89
+ revision: 0ef449166f72c767f58f920cc36aca818fbf082f
90
+ remote: https://github.com/ruby/gem_rbs_collection.git
91
+ repo_dir: gems
92
+ - name: json
93
+ version: '0'
94
+ source:
95
+ type: stdlib
96
+ - name: jwt
97
+ version: '2.5'
98
+ source:
99
+ type: git
100
+ name: ruby/gem_rbs_collection
101
+ revision: 0ef449166f72c767f58f920cc36aca818fbf082f
102
+ remote: https://github.com/ruby/gem_rbs_collection.git
103
+ repo_dir: gems
16
104
  - name: logger
17
105
  version: '0'
18
106
  source:
@@ -21,12 +109,40 @@ gems:
21
109
  version: '0'
22
110
  source:
23
111
  type: stdlib
112
+ - name: net-http
113
+ version: '0'
114
+ source:
115
+ type: stdlib
116
+ - name: net-protocol
117
+ version: '0'
118
+ source:
119
+ type: stdlib
24
120
  - name: rake
25
121
  version: '13.0'
26
122
  source:
27
123
  type: git
28
124
  name: ruby/gem_rbs_collection
29
- revision: 7a105f52053ce1c708b605dfa9c1ab8473424036
125
+ revision: 0ef449166f72c767f58f920cc36aca818fbf082f
126
+ remote: https://github.com/ruby/gem_rbs_collection.git
127
+ repo_dir: gems
128
+ - name: signet
129
+ version: '0.19'
130
+ source:
131
+ type: git
132
+ name: ruby/gem_rbs_collection
133
+ revision: 0ef449166f72c767f58f920cc36aca818fbf082f
30
134
  remote: https://github.com/ruby/gem_rbs_collection.git
31
135
  repo_dir: gems
136
+ - name: time
137
+ version: '0'
138
+ source:
139
+ type: stdlib
140
+ - name: timeout
141
+ version: '0'
142
+ source:
143
+ type: stdlib
144
+ - name: uri
145
+ version: '0'
146
+ source:
147
+ type: stdlib
32
148
  gemfile_lock_path: Gemfile.lock
data/rbs_collection.yaml CHANGED
@@ -24,3 +24,6 @@ gems:
24
24
  ignore: true
25
25
 
26
26
  - name: logger
27
+ - name: google-cloud-firestore
28
+ - name: grpc
29
+ - name: signet
@@ -13,6 +13,7 @@ module Kagaribi
13
13
 
14
14
  def initialize: (String collection_name, ?database_id: string?, ?logger: Logger?) -> void
15
15
  def set: (String doc_key, Hash[untyped, untyped] data) -> void
16
+ def update: (String doc_key, Hash[untyped, untyped] data) -> void
16
17
  def get: (String doc_key) -> Hash[Symbol, untyped]
17
18
  def exists?: (String doc_key) -> bool
18
19
  def delete: (String doc_key) -> void
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kagaribi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - sue445
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-05-11 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: google-cloud-firestore
@@ -110,7 +109,6 @@ metadata:
110
109
  changelog_uri: https://github.com/sue445/kagaribi/blob/main/CHANGELOG.md
111
110
  documentation_uri: https://sue445.github.io/kagaribi/
112
111
  rubygems_mfa_required: 'true'
113
- post_install_message:
114
112
  rdoc_options: []
115
113
  require_paths:
116
114
  - lib
@@ -125,8 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
123
  - !ruby/object:Gem::Version
126
124
  version: '0'
127
125
  requirements: []
128
- rubygems_version: 3.5.9
129
- signing_key:
126
+ rubygems_version: 3.6.7
130
127
  specification_version: 4
131
128
  summary: Simple client for Cloud Firestore
132
129
  test_files: []