bfs-gs 0.7.0 → 0.7.5
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/lib/bfs/bucket/gs.rb +12 -16
- data/spec/bfs/bucket/gs_spec.rb +5 -10
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '068f4b652ec2ef87b680e2ababa9de943b87807626a662fc645813d8fe038eca'
|
4
|
+
data.tar.gz: de6b4d78c33dee9c85929031cf29f5b3fc19c9a0d0d28ae8735609f5f5f00b1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d15bb556314fa4e06c24742890a47427b4b7af5e946120c7e24079e613dd236384146af23e67349e5625e7bcd283a5900394a1fb75144cff885bb7020231b76
|
7
|
+
data.tar.gz: 22bd175fecc3c3e75d3a60154a760c1c87c5e773f5ec6e1dd90af001b4ef91a799595d9942c3a5128542a0cd58a16a0f4a48e52e6a6b850657cacb66bc089bcd
|
data/lib/bfs/bucket/gs.rb
CHANGED
@@ -33,7 +33,7 @@ module BFS
|
|
33
33
|
|
34
34
|
# Lists the contents of a bucket using a glob pattern
|
35
35
|
def ls(pattern = '**/*', **opts)
|
36
|
-
prefix = pattern[%r{^[
|
36
|
+
prefix = pattern[%r{^[^*?\{\}\[\]]+/}]
|
37
37
|
prefix = File.join(*[@prefix, prefix].compact) if @prefix
|
38
38
|
opts = opts.merge(prefix: prefix) if prefix
|
39
39
|
|
@@ -59,18 +59,11 @@ module BFS
|
|
59
59
|
def create(path, encoding: self.encoding, perm: self.perm, **opts, &block)
|
60
60
|
opts[:metadata] = norm_meta(opts[:metadata])
|
61
61
|
path = full_path(path)
|
62
|
-
|
62
|
+
BFS::TempWriter.new(path, encoding: encoding, perm: perm) do |t|
|
63
63
|
File.open(t, encoding: encoding) do |file|
|
64
64
|
@bucket.create_file(file, path, **opts)
|
65
65
|
end
|
66
|
-
end
|
67
|
-
return temp unless block
|
68
|
-
|
69
|
-
begin
|
70
|
-
yield temp
|
71
|
-
ensure
|
72
|
-
temp.close
|
73
|
-
end
|
66
|
+
end.perform(&block)
|
74
67
|
end
|
75
68
|
|
76
69
|
# Opens an existing file for reading
|
@@ -105,12 +98,15 @@ module BFS
|
|
105
98
|
end
|
106
99
|
end
|
107
100
|
|
108
|
-
BFS.register('gs') do |url, opts|
|
101
|
+
BFS.register('gs') do |url, opts, block|
|
109
102
|
prefix = BFS.norm_path(opts.key?(:prefix) ? opts[:prefix] : url.path)
|
110
103
|
prefix = nil if prefix.empty?
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
104
|
+
opts = opts.slice(:project_id, :credentials, :acl)
|
105
|
+
extra = {
|
106
|
+
prefix: prefix,
|
107
|
+
timeout: opts.key?(:timeout) ? opts[:timeout].to_i : nil,
|
108
|
+
retries: opts.key?(:retries) ? opts[:retries].to_i : nil,
|
109
|
+
}
|
110
|
+
|
111
|
+
BFS::Bucket::GS.open url.host, **opts, **extra, &block
|
116
112
|
end
|
data/spec/bfs/bucket/gs_spec.rb
CHANGED
@@ -6,17 +6,9 @@ module Google::Auth::CredentialsLoader
|
|
6
6
|
module_function :warn_if_cloud_sdk_credentials # rubocop:disable Style/AccessModifierDeclarations
|
7
7
|
end
|
8
8
|
|
9
|
-
sandbox
|
10
|
-
run_spec = \
|
11
|
-
begin
|
12
|
-
s = Google::Cloud::Storage.new(project_id: sandbox[:project])
|
13
|
-
!s.bucket(sandbox[:bucket]).nil?
|
14
|
-
rescue Signet::AuthorizationError => e
|
15
|
-
warn "WARNING: unable to run #{File.basename __FILE__}: #{e.message}"
|
16
|
-
false
|
17
|
-
end
|
9
|
+
sandbox = { project: 'bogus', bucket: 'bsm-bfs-unittest' }.freeze
|
18
10
|
|
19
|
-
RSpec.describe BFS::Bucket::GS,
|
11
|
+
RSpec.describe BFS::Bucket::GS, gs: true do
|
20
12
|
let(:prefix) { "x/#{SecureRandom.uuid}/" }
|
21
13
|
|
22
14
|
subject do
|
@@ -34,15 +26,18 @@ RSpec.describe BFS::Bucket::GS, if: run_spec do
|
|
34
26
|
expect(bucket).to be_instance_of(described_class)
|
35
27
|
expect(bucket.name).to eq(sandbox[:bucket])
|
36
28
|
expect(bucket.instance_variable_get(:@prefix)).to be_nil
|
29
|
+
bucket.close
|
37
30
|
|
38
31
|
bucket = BFS.resolve("gs://#{sandbox[:bucket]}/a/b/")
|
39
32
|
expect(bucket).to be_instance_of(described_class)
|
40
33
|
expect(bucket.name).to eq(sandbox[:bucket])
|
41
34
|
expect(bucket.instance_variable_get(:@prefix)).to eq('a/b')
|
35
|
+
bucket.close
|
42
36
|
end
|
43
37
|
|
44
38
|
it 'should enumerate over a large number of files' do
|
45
39
|
bucket = described_class.new sandbox[:bucket], project_id: sandbox[:project], prefix: 'm/'
|
46
40
|
expect(bucket.ls('**/*').count).to eq(2121)
|
41
|
+
bucket.close
|
47
42
|
end
|
48
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bfs-gs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.5
|
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-
|
11
|
+
date: 2020-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bfs
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.7.
|
19
|
+
version: 0.7.5
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.7.
|
26
|
+
version: 0.7.5
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: google-cloud-storage
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|