bfs-ftp 0.7.2 → 0.8.0
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/ftp.rb +5 -9
- data/spec/bfs/bucket/ftp_spec.rb +11 -12
- 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: 3fc095ce10f0585ef7c4ece472b54d4b6543017f47b0b49f267b0bdd199aa493
|
4
|
+
data.tar.gz: e366f5a503feb6bf5843f8459823052ca939952aa3bd94288813a1ac58835bee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60d25fde695df0aa25eb4f3ced184a87692211b64982d33c1a9ec1bc8ca42f6eeb89a0ce343c9230a385e2ed622033982e0ce4e5ad89a1648cf6a9be2b24ab82
|
7
|
+
data.tar.gz: 2539e624485bf2ddf7b171dbc981a51a5f5e4c60e378e78b5caa5c8286f1a11ae0ffb6c24246ac3b8737b6ab89a408fe81a1994cb63e20a8c4c1e5b280cccb55
|
data/lib/bfs/bucket/ftp.rb
CHANGED
@@ -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
|
-
|
55
|
+
BFS::Writer.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,
|
data/spec/bfs/bucket/ftp_spec.rb
CHANGED
@@ -1,18 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
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.
|
4
|
+
version: 0.8.0
|
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-12-01 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.
|
19
|
+
version: 0.8.0
|
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.
|
26
|
+
version: 0.8.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: net-ftp-list
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|