bucket_store 0.4.0 → 0.5.0
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 +9 -0
- data/lib/bucket_store/disk.rb +1 -1
- data/lib/bucket_store/key_context.rb +22 -5
- data/lib/bucket_store/key_storage.rb +1 -1
- data/lib/bucket_store/version.rb +1 -1
- data/lib/bucket_store.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14fe28facb1db7af27414a3d1ce64ad24974c79e72c5b9faca796860f679c3d8
|
4
|
+
data.tar.gz: 4b6a4fe4e68bb81b4e7df6d76d2f8e14dc6210508955263fe579b067c7b1af61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60b864052d68196fd7bda4a67a67bb66a82ef9bb828f01fb9364ce8aeca67ea414f8f2c34259982fd3dd76a3545b9c72172400e3acbb277fe3cc907d5d449e36
|
7
|
+
data.tar.gz: 5aab2c949368e330f73470f5a9c705c681662ec7209d8e8600c3ea971f852c79d2ce6f6af52350760c9f585cc25ab94f51431001cbb4ff053276333515bf8fd1
|
data/README.md
CHANGED
@@ -159,6 +159,15 @@ BucketStore.for("inmemory://bucket/path/file.xml").delete!
|
|
159
159
|
=> true
|
160
160
|
```
|
161
161
|
|
162
|
+
## Development
|
163
|
+
|
164
|
+
### Running tests
|
165
|
+
BucketStore comes with both unit and integration tests. While unit tests can be run by simply
|
166
|
+
executing `bundle exec rspec`, integration tests require running minio locally. We provide an
|
167
|
+
helper script (`scripts/run-minio.sh`) that spins up a pre-configured docker container with
|
168
|
+
a single test bucket. Once minio has started, integration tests can be executed with
|
169
|
+
`bundle exec rspec --tag integration`.
|
170
|
+
|
162
171
|
## License & Contributing
|
163
172
|
|
164
173
|
* BucketStore is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/lib/bucket_store/disk.rb
CHANGED
@@ -19,18 +19,35 @@ module BucketStore
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.parse(raw_key)
|
22
|
-
uri = URI(raw_key)
|
22
|
+
uri = URI(escape(raw_key))
|
23
|
+
|
24
|
+
scheme = unescape(uri.scheme)
|
25
|
+
bucket = unescape(uri.host)
|
23
26
|
|
24
27
|
# A key should never be `nil` but can be empty. Depending on the operation, this may
|
25
28
|
# or may not be a valid configuration (e.g. an empty key is likely valid on a
|
26
29
|
# `list`, but not during a `download`).
|
27
|
-
key = uri.path.sub!(%r{/}, "") || ""
|
30
|
+
key = unescape(uri.path).sub!(%r{/}, "") || ""
|
28
31
|
|
29
|
-
raise KeyParseException if [
|
32
|
+
raise KeyParseException if [scheme, bucket, key].map(&:nil?).any?
|
30
33
|
|
31
|
-
KeyContext.new(adapter:
|
32
|
-
bucket:
|
34
|
+
KeyContext.new(adapter: scheme,
|
35
|
+
bucket: bucket,
|
33
36
|
key: key)
|
34
37
|
end
|
38
|
+
|
39
|
+
def self.escape(key)
|
40
|
+
return key if key.nil?
|
41
|
+
|
42
|
+
URI::DEFAULT_PARSER.escape(key)
|
43
|
+
end
|
44
|
+
private_class_method :escape
|
45
|
+
|
46
|
+
def self.unescape(key)
|
47
|
+
return key if key.nil?
|
48
|
+
|
49
|
+
URI::DEFAULT_PARSER.unescape(key)
|
50
|
+
end
|
51
|
+
private_class_method :unescape
|
35
52
|
end
|
36
53
|
end
|
@@ -153,7 +153,7 @@ module BucketStore
|
|
153
153
|
#
|
154
154
|
# @return [bool] `true` if the given key exists, `false` if not
|
155
155
|
def exists?
|
156
|
-
list.first == "#{adapter_type}://#{bucket}/#{key}"
|
156
|
+
list(page_size: 1).first == "#{adapter_type}://#{bucket}/#{key}"
|
157
157
|
end
|
158
158
|
|
159
159
|
private
|
data/lib/bucket_store/version.rb
CHANGED
data/lib/bucket_store.rb
CHANGED
@@ -4,6 +4,7 @@ require "bucket_store/version"
|
|
4
4
|
require "bucket_store/configuration"
|
5
5
|
require "bucket_store/key_context"
|
6
6
|
require "bucket_store/key_storage"
|
7
|
+
require "bucket_store/uri_builder"
|
7
8
|
|
8
9
|
# An abstraction layer on the top of file cloud storage systems such as Google Cloud
|
9
10
|
# Storage or S3. This module exposes a generic interface that allows interoperability
|
@@ -41,8 +42,8 @@ module BucketStore
|
|
41
42
|
# Given a `key` in the format of `adapter://bucket/key` returns the corresponding
|
42
43
|
# adapter that will allow to manipulate (e.g. download, upload or list) such key.
|
43
44
|
#
|
44
|
-
# Currently supported adapters are `gs` (Google Cloud Storage), `
|
45
|
-
# in-memory key-value storage) and `disk` (a disk-backed key-value store).
|
45
|
+
# Currently supported adapters are `gs` (Google Cloud Storage), `s3` (AWS S3),
|
46
|
+
# `inmemory` (an in-memory key-value storage) and `disk` (a disk-backed key-value store).
|
46
47
|
#
|
47
48
|
# @param [String] key The reference key
|
48
49
|
# @return [KeyStorage] An interface to the adapter that can handle requests on the given key
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bucket_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GoCardless Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|