r2store.rb 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b97625de127487dcfefd8fafeda4cc9ef4d25baaabceab605f125a32b0a6a238
4
- data.tar.gz: d675b5461d2be041dbddab00cecda1fca934ca705569ba2e67747084aa5d1459
3
+ metadata.gz: 2ac7b1310d2ee967d839ca1639d2c47d1f096206bffdb7d40da82e2926423bba
4
+ data.tar.gz: ce5de61fa0c2c3a36a05c88736024d913f8263c769b13ad5f55bc354e479b9d9
5
5
  SHA512:
6
- metadata.gz: 0a23dca220a9883a0c4477716bfb1a399a90ab362574ce0f44851533c416ee299ab92ad9e5c1937257bf885dab5f4a250cd28008e4b0d5f7ccd74bdf31bd3088
7
- data.tar.gz: f08d8a2c80e20bcec42bdca9504389cffd325be1e75ca1899e97a36632f78d25a50a1175cea43b6715fc6f43abee2026aea9a0d9b8ddd9462e8fb32dd4c0f266
6
+ metadata.gz: 27a0d2cb5123e55417a14164ca69aa5f6efc5eaa5adfdcac3ae208b842ef9213a8560d14e15b957fd17483d397939b817d5fc014ab24bd010d6e9f13e2bfab4d
7
+ data.tar.gz: 2ce6db1e267074d07c6a051ca09d66fc5f10013529b01f486981e03894a1a731080847f680ae9c09ccacfe6b0db5d9e2f7a06aa222ad10c97895f339fd679906
@@ -1,8 +1,8 @@
1
1
  module R2Store
2
2
  module Storage
3
3
  class << self
4
- def presigned_put(seller:, path:, content_type:, max_size:, expires_in: 3600)
5
- key = scoped_key(seller, path)
4
+ def presigned_put(tenant:, path:, content_type:, max_size:, expires_in: 3600)
5
+ key = scoped_key(tenant, path)
6
6
  presigner.presigned_url(:put_object,
7
7
  bucket: config.bucket,
8
8
  key: key,
@@ -12,8 +12,8 @@ module R2Store
12
12
  )
13
13
  end
14
14
 
15
- def presigned_get(seller:, path:, expires_in: 3600)
16
- key = scoped_key(seller, path)
15
+ def presigned_get(tenant:, path:, expires_in: 3600)
16
+ key = scoped_key(tenant, path)
17
17
  presigner.presigned_url(:get_object,
18
18
  bucket: config.bucket,
19
19
  key: key,
@@ -21,8 +21,8 @@ module R2Store
21
21
  )
22
22
  end
23
23
 
24
- def head(seller:, path:)
25
- key = scoped_key(seller, path)
24
+ def head(tenant:, path:)
25
+ key = scoped_key(tenant, path)
26
26
  resp = client.head_object(bucket: config.bucket, key: key)
27
27
  {
28
28
  size: resp.content_length,
@@ -33,19 +33,19 @@ module R2Store
33
33
  nil
34
34
  end
35
35
 
36
- def fetch(seller:, path:)
37
- key = scoped_key(seller, path)
36
+ def fetch(tenant:, path:)
37
+ key = scoped_key(tenant, path)
38
38
  resp = client.get_object(bucket: config.bucket, key: key)
39
39
  resp.body.read
40
40
  end
41
41
 
42
- def delete(seller:, path:)
43
- key = scoped_key(seller, path)
42
+ def delete(tenant:, path:)
43
+ key = scoped_key(tenant, path)
44
44
  client.delete_object(bucket: config.bucket, key: key)
45
45
  end
46
46
 
47
- def list(seller:, prefix: nil)
48
- full_prefix = "sellers/#{seller}/"
47
+ def list(tenant:, prefix: nil)
48
+ full_prefix = "tenants/#{tenant}/"
49
49
  full_prefix += prefix if prefix
50
50
  validate_path!(full_prefix)
51
51
 
@@ -57,9 +57,9 @@ module R2Store
57
57
 
58
58
  private
59
59
 
60
- def scoped_key(seller, path)
60
+ def scoped_key(tenant, path)
61
61
  validate_path!(path)
62
- "sellers/#{seller}/#{path}"
62
+ "tenants/#{tenant}/#{path}"
63
63
  end
64
64
 
65
65
  def validate_path!(path)
@@ -1,14 +1,14 @@
1
1
  module R2Store
2
2
  module Webhook
3
3
  Event = Struct.new(:type, :key, :size, :etag, :bucket, keyword_init: true) do
4
- def seller
4
+ def tenant
5
5
  parts = key.split("/")
6
- return parts[1] if parts[0] == "sellers" && parts.length >= 3
6
+ return parts[1] if parts[0] == "tenants" && parts.length >= 3
7
7
  end
8
8
 
9
9
  def path
10
10
  parts = key.split("/")
11
- return parts[2..].join("/") if parts[0] == "sellers" && parts.length >= 3
11
+ return parts[2..].join("/") if parts[0] == "tenants" && parts.length >= 3
12
12
  end
13
13
 
14
14
  def product_manifest?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r2store.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Filippo