bfs-s3 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 37e10fdc93aa067bed7a72b5bcbccbc8b05bebad755e1bdd5091f6ed03b78206
4
- data.tar.gz: 6db5a4abb0b6b6825785eff4a18ca74e5bf6083c2a6ce3f0344e3ea28b7e0446
3
+ metadata.gz: cbc8a8c0a41de684e3d77bc2593f75aff0f438154779dfce05199ab5898bdd60
4
+ data.tar.gz: 25369f70e61e235bc3dc18a4e5d1a7d6d1f05fc3897cc6070dd56794300b2f9a
5
5
  SHA512:
6
- metadata.gz: 37ddc5cd5672316032a45fe30e99ee1a29b8e17b83c770542fd7998c2bf4c3f6046acb374e3440ae4ea646c88437dc7cf065b8d6f40b6456d81d56fa2d8786f4
7
- data.tar.gz: c3744960bc91b119af9fe51c52429662b6d7e13aee85c4d373efc579e11492df599ddd0fbd35e1a5dd107cd870c2937add208db43ce9d6a96a8068b82e27f1f8
6
+ metadata.gz: 2f9f61852c8eeb4437aa15c17a27f9b367c60076a68f520ee54f607acd1f6f006281912470bfb7807df9d226db8272fbe9b70fa02080b185eb85030f215a0685
7
+ data.tar.gz: 7ca097e4764bda327018ddb7ce01f87ec9df8aa47f24dfe0ffb62138557151d4ed17b498961e62c5f8a5842d99363a5efbdebdb4f8dcd3aedee635b9779cbbff
data/lib/bfs/bucket/s3.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'bfs'
2
2
  require 'aws-sdk-s3'
3
- require 'cgi'
4
3
 
5
4
  module BFS
6
5
  module Bucket
@@ -21,7 +20,6 @@ module BFS
21
20
  # @option opts [Symbol] :acl canned ACL
22
21
  # @option opts [String] :storage_class storage class
23
22
  # @option opts [Aws::S3::Client] :client custom client, uses default_client by default
24
- # @option opts [String] :encoding Custom encoding.
25
23
  def initialize(name, **opts)
26
24
  super(**opts)
27
25
 
@@ -74,9 +72,8 @@ module BFS
74
72
  # @option opts [String] :acl custom ACL override
75
73
  # @option opts [String] :server_side_encryption SSE override
76
74
  # @option opts [String] :storage_class storage class override
77
- def create(path, encoding: nil, perm: nil, **opts, &block)
75
+ def create(path, encoding: self.encoding, perm: self.perm, **opts, &block)
78
76
  path = full_path(path)
79
- enc = encoding || @encoding
80
77
  opts = opts.merge(
81
78
  bucket: name,
82
79
  key: path,
@@ -85,8 +82,8 @@ module BFS
85
82
  opts[:server_side_encryption] ||= @sse if @sse
86
83
  opts[:storage_class] ||= @storage_class if @storage_class
87
84
 
88
- temp = BFS::TempWriter.new(path, encoding: enc, perm: perm) do |t|
89
- File.open(t, encoding: enc) do |file|
85
+ temp = BFS::TempWriter.new(path, encoding: encoding, perm: perm) do |t|
86
+ File.open(t, encoding: encoding) do |file|
90
87
  @client.put_object(opts.merge(body: file))
91
88
  end
92
89
  end
@@ -104,10 +101,9 @@ module BFS
104
101
  # @param [Hash] opts options
105
102
  # @option opts [String] :encoding Custom encoding.
106
103
  # @option opts [String] :tempdir Custom temp dir.
107
- def open(path, encoding: nil, tempdir: nil, **opts, &block)
104
+ def open(path, encoding: self.encoding, tempdir: nil, **opts, &block)
108
105
  path = full_path(path)
109
- enc = encoding || @encoding
110
- temp = Tempfile.new(File.basename(path), tempdir, encoding: enc)
106
+ temp = Tempfile.new(File.basename(path), tempdir, encoding: encoding)
111
107
  temp.close
112
108
 
113
109
  opts = opts.merge(
@@ -117,7 +113,7 @@ module BFS
117
113
  )
118
114
  @client.get_object(**opts)
119
115
 
120
- File.open(temp.path, encoding: enc, &block)
116
+ File.open(temp.path, encoding: encoding, &block)
121
117
  rescue Aws::S3::Errors::NoSuchKey, Aws::S3::Errors::NoSuchBucket, Aws::S3::Errors::NotFound
122
118
  raise BFS::FileNotFound, trim_prefix(path)
123
119
  end
@@ -162,17 +158,9 @@ module BFS
162
158
  end
163
159
  end
164
160
 
165
- BFS.register('s3') do |url|
166
- params = CGI.parse(url.query.to_s)
167
- prefix = BFS.norm_path(params.key?('prefix') ? params['prefix'].first : url.path)
168
- prefix = nil if prefix.empty?
169
-
170
- BFS::Bucket::S3.new url.host,
171
- prefix: prefix,
172
- region: params.key?('region') ? params['region'].first : nil,
173
- sse: params.key?('sse') ? params['sse'].first : nil,
174
- access_key_id: params.key?('access_key_id') ? params['access_key_id'].first : nil,
175
- secret_access_key: params.key?('secret_access_key') ? params['secret_access_key'].first : nil,
176
- acl: params.key?('acl') ? params['acl'].first : nil,
177
- storage_class: params.key?('storage_class') ? params['storage_class'].first : nil
161
+ BFS.register('s3') do |url, opts|
162
+ prefix = BFS.norm_path(opts[:prefix] || url.path)
163
+ opts[:prefix] = prefix.empty? ? nil : prefix
164
+
165
+ BFS::Bucket::S3.new url.host, **opts.slice(:prefix, :region, :sse, :access_key_id, :secret_access_key, :acl, :storage_class, :encoding)
178
166
  end
@@ -25,10 +25,11 @@ RSpec.describe BFS::Bucket::S3, if: run_spec do
25
25
  it_behaves_like 'a bucket'
26
26
 
27
27
  it 'should resolve from URL' do
28
- bucket = BFS.resolve("s3://#{sandbox[:bucket]}/?acl=private")
28
+ bucket = BFS.resolve("s3://#{sandbox[:bucket]}/?acl=private&encoding=binary")
29
29
  expect(bucket).to be_instance_of(described_class)
30
30
  expect(bucket.name).to eq(sandbox[:bucket])
31
31
  expect(bucket.acl).to eq(:private)
32
+ expect(bucket.encoding).to eq('binary')
32
33
  expect(bucket.instance_variable_get(:@prefix)).to be_nil
33
34
 
34
35
  bucket = BFS.resolve("s3://#{sandbox[:bucket]}/a/b/")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bfs-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitrij Denissenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-12 00:00:00.000000000 Z
11
+ date: 2020-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.6.2
33
+ version: 0.6.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.6.2
40
+ version: 0.6.3
41
41
  description: https://github.com/bsm/bfs.rb
42
42
  email: dimitrij@blacksquaremedia.com
43
43
  executables: []
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  requirements: []
70
- rubygems_version: 3.0.6
70
+ rubygems_version: 3.1.2
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: S3 bucket adapter for bfs