bfs-gs 0.4.3 → 0.6.1

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: b4159d1f71708e97bbc8305a18e671cd8c875908b23b907009d2e23ad3da2c14
4
- data.tar.gz: 8700ac725661a73623efea456c0ed3c41cf452352c06edc93855daa21586d046
3
+ metadata.gz: 9a2d8c79d6fb88844a374b8f776967c20fcd7477815e4868fb2cb0534886a142
4
+ data.tar.gz: 65c9d7dbeecc7be84d77423a6fdfc40848511809af145315b6bf21de3807a9d6
5
5
  SHA512:
6
- metadata.gz: 3150b437e030322aa18f9ec5eeaa5365658a9e15ad854c7e38b0a8b3ca8cbe0621251343cf3d920b1e4f5933cc6e4e19b90df0fe1003b585e63172e417ef4064
7
- data.tar.gz: fc84d5ac79ae6999e25361ac208945aae929704c2401a7d6bf322c5c1110d0baf199061e155e6bf97ee3e88cfcadd9d45b59cbada9ed327fd3bbd092c8716d74
6
+ metadata.gz: 57b26012045b16b2dade58bd711c44dfd75cfede1bcba4a534386aab11ef2e44a9d3951e6f7f553594e7d0f3d0e44c05ee55d6243d632c1afe5f18e6eb2ac27e
7
+ data.tar.gz: 2e2eec782845273aebe39753d4424943b42519e70d39973ebd50969a5ddb4d320eca49fc70e241f37891deac5eb90ff8be50de19de7a3b654c1ff1758c61c922
data/bfs-gs.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = `git ls-files -- spec/*`.split("\n")
17
17
  s.require_paths = ['lib']
18
- s.required_ruby_version = '>= 2.4.0'
18
+ s.required_ruby_version = '>= 2.5.0'
19
19
 
20
20
  s.add_dependency 'bfs', s.version
21
21
  s.add_dependency 'google-cloud-storage', '~> 1.18'
data/lib/bfs/bucket/gs.rb CHANGED
@@ -20,18 +20,18 @@ module BFS
20
20
  # @option opts [Integer] :timeout request timeout, in seconds.
21
21
  # @option opts [String] :acl set the default ACL.
22
22
  # @option opts [Google::Cloud::Storage] :client custom client.
23
- # @option opts [String] :encoding default encoding to use, default: 'binary'
24
- def initialize(name, opts={})
23
+ # @option opts [String] :encoding Custom encoding.
24
+ def initialize(name, **opts)
25
25
  opts = opts.dup
26
26
  opts.keys.each do |key|
27
27
  val = opts.delete(key)
28
28
  opts[key.to_sym] = val unless val.nil?
29
29
  end
30
- super(opts)
30
+ super(**opts)
31
31
 
32
32
  @prefix = opts.delete(:prefix)
33
33
  acl = opts.delete(:acl)
34
- client = opts.delete(:client) || Google::Cloud::Storage.new(opts)
34
+ client = opts.delete(:client) || Google::Cloud::Storage.new(**opts)
35
35
 
36
36
  @name = name.to_s
37
37
  @bucket = client.bucket(@name)
@@ -39,13 +39,13 @@ module BFS
39
39
  end
40
40
 
41
41
  # Lists the contents of a bucket using a glob pattern
42
- def ls(pattern='**/*', opts={})
42
+ def ls(pattern = '**/*', **opts)
43
43
  prefix = pattern[%r{^[^\*\?\{\}\[\]]+/}]
44
44
  prefix = File.join(*[@prefix, prefix].compact) if @prefix
45
45
  opts = opts.merge(prefix: prefix) if prefix
46
46
 
47
47
  Enumerator.new do |y|
48
- @bucket.files(opts).all do |file|
48
+ @bucket.files(**opts).all do |file|
49
49
  name = trim_prefix(file.name)
50
50
  y << name if File.fnmatch?(pattern, name, File::FNM_PATHNAME)
51
51
  end
@@ -53,22 +53,23 @@ module BFS
53
53
  end
54
54
 
55
55
  # Info returns the object info
56
- def info(path, _opts={})
56
+ def info(path, **_opts)
57
57
  path = full_path(path)
58
58
  file = @bucket.file(path)
59
59
  raise BFS::FileNotFound, trim_prefix(path) unless file
60
60
 
61
61
  name = trim_prefix(file.name)
62
- BFS::FileInfo.new(name, file.size, file.updated_at.to_time, file.content_type, file.metadata)
62
+ BFS::FileInfo.new(name, file.size, file.updated_at.to_time, file.content_type, norm_meta(file.metadata))
63
63
  end
64
64
 
65
65
  # Creates a new file and opens it for writing
66
- def create(path, opts={}, &block)
66
+ def create(path, **opts, &block)
67
+ opts[:metadata] = norm_meta(opts[:metadata])
67
68
  path = full_path(path)
68
69
  enc = opts.delete(:encoding) || @encoding
69
70
  temp = BFS::TempWriter.new(path, encoding: enc) do |t|
70
71
  File.open(t, encoding: enc) do |file|
71
- @bucket.create_file(file, path, opts)
72
+ @bucket.create_file(file, path, **opts)
72
73
  end
73
74
  end
74
75
  return temp unless block
@@ -81,7 +82,7 @@ module BFS
81
82
  end
82
83
 
83
84
  # Opens an existing file for reading
84
- def open(path, opts={}, &block)
85
+ def open(path, **opts, &block)
85
86
  path = full_path(path)
86
87
  enc = opts.delete(:encoding) || @encoding
87
88
  file = @bucket.file(path)
@@ -95,19 +96,19 @@ module BFS
95
96
  end
96
97
 
97
98
  # Deletes a file.
98
- def rm(path, opts={})
99
+ def rm(path, **opts)
99
100
  path = full_path(path)
100
101
  file = @bucket.file(path)
101
- file&.delete(opts)
102
+ file&.delete(**opts)
102
103
  end
103
104
 
104
105
  # Copies a file.
105
- def cp(src, dst, opts={})
106
+ def cp(src, dst, **opts)
106
107
  src = full_path(src)
107
108
  file = @bucket.file(src)
108
109
  raise BFS::FileNotFound, trim_prefix(src) unless file
109
110
 
110
- file.copy(full_path(dst), opts)
111
+ file.copy(full_path(dst), **opts)
111
112
  end
112
113
  end
113
114
  end
@@ -119,10 +120,10 @@ BFS.register('gs') do |url|
119
120
  prefix = nil if prefix.empty?
120
121
 
121
122
  BFS::Bucket::GS.new url.host,
122
- prefix: prefix,
123
- project_id: params.key?('project_id') ? params['project_id'].first : nil,
124
- credentials: params.key?('credentials') ? params['credentials'].first : nil,
125
- acl: params.key?('acl') ? params['acl'].first : nil,
126
- timeout: params.key?('timeout') ? params['timeout'].first.to_i : nil,
127
- retries: params.key?('retries') ? params['retries'].first.to_i : nil
123
+ prefix: prefix,
124
+ project_id: params.key?('project_id') ? params['project_id'].first : nil,
125
+ credentials: params.key?('credentials') ? params['credentials'].first : nil,
126
+ acl: params.key?('acl') ? params['acl'].first : nil,
127
+ timeout: params.key?('timeout') ? params['timeout'].first.to_i : nil,
128
+ retries: params.key?('retries') ? params['retries'].first.to_i : nil
128
129
  end
@@ -30,7 +30,7 @@ RSpec.describe BFS::Bucket::GS, if: run_spec do
30
30
  it_behaves_like 'a bucket'
31
31
 
32
32
  it 'should resolve from URL' do
33
- bucket = BFS.resolve("gs://#{sandbox[:bucket]}/?acl=private&project_id=#{sandbox[:project]}")
33
+ bucket = BFS.resolve("gs://#{sandbox[:bucket]}/?project_id=#{sandbox[:project]}")
34
34
  expect(bucket).to be_instance_of(described_class)
35
35
  expect(bucket.name).to eq(sandbox[:bucket])
36
36
  expect(bucket.instance_variable_get(:@prefix)).to be_nil
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.4.3
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitrij Denissenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-19 00:00:00.000000000 Z
11
+ date: 2020-02-11 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.4.3
19
+ version: 0.6.1
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.4.3
26
+ version: 0.6.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: google-cloud-storage
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -60,14 +60,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - ">="
62
62
  - !ruby/object:Gem::Version
63
- version: 2.4.0
63
+ version: 2.5.0
64
64
  required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  requirements: []
70
- rubygems_version: 3.0.3
70
+ rubygems_version: 3.1.2
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: GS bucket adapter for bfs