bfs-ftp 0.7.1 → 0.7.6

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: 82596b06db1568d9f633733e9ee00a0473d3597c96b4ea755f7c67f1e0b150e2
4
- data.tar.gz: ea4dfedb77af9e9a77167aac97745deb9fca9e598eab058d53e9270f0ef709c8
3
+ metadata.gz: 0d38185964804e9e5a66c247e02217133fc179dd56572ce1f31796e327be2b80
4
+ data.tar.gz: 2880cb28f4a001c41bc374ed41bc74fd84923bec89aa70adfc3d2fe4256928fe
5
5
  SHA512:
6
- metadata.gz: 6bc46e356ba7c382e7b7614f4770dafc3019796b212873f41fecbf6ab571ec5961e109cfd008120cf5fd7b3549be8d09b5a4a3d6c719b1dd6b93d8ff5464c9ec
7
- data.tar.gz: cdb89ae7e48ca49e02a051c595ea021a69e8106d2427b615a5073152279dcdf0c3473dd64183838120765aeb879299ddbaf1cbbe514cb13256e77c26d6c24ca9
6
+ metadata.gz: b50533901599636d409e2f188e7ad79815488db581df8b9e8f89c9fd32e2ca0347216f75c8230f17370e9179ab2ffd99810f27dfb8ba19fa832a497538ffb635
7
+ data.tar.gz: 19f7c1630ea6e047d63de8c87d2c07f6fe795f0b23be627454d3414845380d4d0fdf0e044c8b505e21d9ebd8afebb219025c3a3ace6b5e377f0c904b309ae9bf
@@ -52,17 +52,10 @@ module BFS
52
52
  # Creates a new file and opens it for writing
53
53
  def create(path, encoding: self.encoding, perm: self.perm, **_opts, &block)
54
54
  path = norm_path(path)
55
- temp = BFS::TempWriter.new(path, encoding: encoding, perm: perm) do |t|
55
+ BFS::TempWriter.new(path, encoding: encoding, perm: perm) do |t|
56
56
  mkdir_p File.dirname(path)
57
57
  @client.put(t, path)
58
- end
59
- return temp unless block
60
-
61
- begin
62
- yield temp
63
- ensure
64
- temp.close
65
- end
58
+ end.perform(&block)
66
59
  end
67
60
 
68
61
  # Opens an existing file for reading
@@ -115,6 +108,9 @@ module BFS
115
108
  end
116
109
 
117
110
  BFS.register('ftp', 'sftp') do |url, opts, block|
111
+ prefix = BFS.norm_path(opts[:prefix] || url.path)
112
+ opts[:prefix] = prefix unless prefix.empty?
113
+
118
114
  extra = {
119
115
  username: url.user ? CGI.unescape(url.user) : nil,
120
116
  password: url.password ? CGI.unescape(url.password) : nil,
@@ -1,18 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- sandbox = { host: '127.0.0.1', port: 7021, username: 'ftpuser', password: 'ftppass' }.freeze
4
- run_spec = \
5
- begin
6
- ftp = Net::FTP.new sandbox[:host], sandbox
7
- ftp.list
8
- ftp.close
9
- rescue Errno::ECONNREFUSED, Net::FTPError => e
10
- warn "WARNING: unable to run #{File.basename __FILE__}: #{e.message}"
11
- false
12
- end
3
+ RSpec.describe BFS::Bucket::FTP, ftp: true do
4
+ let(:hostname) { '127.0.0.1' }
5
+ let(:conn_opts) { { port: 7021, username: 'ftpuser', password: 'ftppass', prefix: SecureRandom.uuid } }
13
6
 
14
- RSpec.describe BFS::Bucket::FTP, if: run_spec do
15
- subject { described_class.new sandbox[:host], **sandbox.merge(prefix: SecureRandom.uuid) }
7
+ subject { described_class.new hostname, **conn_opts }
16
8
  after { subject.close }
17
9
 
18
10
  it_behaves_like 'a bucket',
@@ -22,5 +14,12 @@ RSpec.describe BFS::Bucket::FTP, if: run_spec do
22
14
  it 'should resolve from URL' do
23
15
  bucket = BFS.resolve('ftp://ftpuser:ftppass@127.0.0.1:7021')
24
16
  expect(bucket).to be_instance_of(described_class)
17
+ expect(bucket.instance_variable_get(:@client).pwd).to eq('/ftp/ftpuser')
18
+ bucket.close
19
+
20
+ bucket = BFS.resolve('ftp://ftpuser:ftppass@127.0.0.1:7021/a/b/')
21
+ expect(bucket).to be_instance_of(described_class)
22
+ expect(bucket.instance_variable_get(:@client).pwd).to eq('/ftp/ftpuser/a/b')
23
+ bucket.close
25
24
  end
26
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bfs-ftp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.6
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-07-02 00:00:00.000000000 Z
11
+ date: 2020-11-10 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.1
19
+ version: 0.7.6
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.1
26
+ version: 0.7.6
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: net-ftp-list
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.1.4
70
+ rubygems_version: 3.1.2
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: FTP adapter for bfs