bfs-gs 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bfs/bucket/gs.rb +29 -8
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 361c56113182e489c7373029e15e134fe2f65a0cdec35b00f97a72ed8b8b94b7
|
4
|
+
data.tar.gz: 8f969343d8848f1ba073ce0948836290591fd1096995ed0456a7715c89e7cc70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '04359b81560d94527826da03a81d00b2f399a7e2d77e8d5c563aa6f1587d8163aa863f69288aaecdc5213b07e1d26e579c129958d7d761a797ddf11bc013de84'
|
7
|
+
data.tar.gz: b3656acbcfaf1074bdcebabb4c6df76801bb913bceb37bb5be5a68e4099543d0a31e0953f7606af280faa2368aa415e4d36bce375e0ab6b87241d39b05158165
|
data/lib/bfs/bucket/gs.rb
CHANGED
@@ -33,14 +33,18 @@ module BFS
|
|
33
33
|
|
34
34
|
# Lists the contents of a bucket using a glob pattern
|
35
35
|
def ls(pattern = '**/*', **opts)
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
Enumerator.new do |acc|
|
37
|
+
walk(pattern, **opts) do |name, _|
|
38
|
+
acc << name
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
39
42
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
43
|
+
# Iterates over the contents of a bucket using a glob pattern
|
44
|
+
def glob(pattern = '**/*', **opts)
|
45
|
+
Enumerator.new do |acc|
|
46
|
+
walk(pattern, **opts) do |name, file|
|
47
|
+
acc << file_info(name, file)
|
44
48
|
end
|
45
49
|
end
|
46
50
|
end
|
@@ -52,7 +56,7 @@ module BFS
|
|
52
56
|
raise BFS::FileNotFound, trim_prefix(path) unless file
|
53
57
|
|
54
58
|
name = trim_prefix(file.name)
|
55
|
-
|
59
|
+
file_info(name, file)
|
56
60
|
end
|
57
61
|
|
58
62
|
# Creates a new file and opens it for writing
|
@@ -94,6 +98,23 @@ module BFS
|
|
94
98
|
|
95
99
|
file.copy(full_path(dst), **opts)
|
96
100
|
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def walk(pattern, **opts)
|
105
|
+
prefix = pattern[%r{^[^*?\{\}\[\]]+/}]
|
106
|
+
prefix = File.join(*[@prefix, prefix].compact) if @prefix
|
107
|
+
opts = opts.merge(prefix: prefix) if prefix
|
108
|
+
|
109
|
+
@bucket.files(**opts).all do |file|
|
110
|
+
name = trim_prefix(file.name)
|
111
|
+
yield(name, file) if File.fnmatch?(pattern, name, File::FNM_PATHNAME)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def file_info(name, file)
|
116
|
+
BFS::FileInfo.new(path: name, size: file.size, mtime: file.updated_at.to_time, content_type: file.content_type, metadata: norm_meta(file.metadata))
|
117
|
+
end
|
97
118
|
end
|
98
119
|
end
|
99
120
|
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.8.
|
4
|
+
version: 0.8.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: 2021-05-
|
11
|
+
date: 2021-05-27 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.8.
|
19
|
+
version: 0.8.3
|
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.8.
|
26
|
+
version: 0.8.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: google-cloud-storage
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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.
|
70
|
+
rubygems_version: 3.2.15
|
71
71
|
signing_key:
|
72
72
|
specification_version: 4
|
73
73
|
summary: GS bucket adapter for bfs
|