bfs-ftp 0.7.0 → 0.7.5

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: 38b05322f90198412292ff3521d4d59b82b32bc3d9f10b8799a8dff4b29a8fe3
4
- data.tar.gz: 0db611782568ba9ea4b58f92bc706d755dc5cb19a5ca5ed9f347e832378bcaf4
3
+ metadata.gz: e82797725ebe072d7a7d384baaf2409ad28c14a12e01e5dcf93fc43f611db082
4
+ data.tar.gz: fa949c1d80de980559ac17cd05d103a7b226e02b650a64b81a949fc7bc83fbad
5
5
  SHA512:
6
- metadata.gz: b46c593f7f2c31b2e1284091f3aefd9557c5c807538e7bebb3cbacc89814e23be126f8699472ac7f6e5e7b612374d4425e75caafd79f1eb00ffcece69ace155b
7
- data.tar.gz: f98a8d56a8d41bcc500e61167feedf3bb51b0fca9a5c146e3d78ead1e564932062eaf4b5bfcae1de43544c5a8d224be0a3b0ee891406e681711b425a47a343f8
6
+ metadata.gz: 07a83b8967eb478a2b81a13bf369e6be61b8c921baa1a773e2a4132a0e73968ec2c21be07be0acce6d7cf04c1140ba9ca00e0073de9823faebb3c7a0ab074d5b
7
+ data.tar.gz: fe4f046c10dcf18e2f657d1b6b780e555b99e9fc6db252bd158547ca6fb43f490180184a729d25365d8df769ad7c63d090b9c590a38f9c9609e5934b6e2d75fa
@@ -31,7 +31,7 @@ module BFS
31
31
 
32
32
  # Lists the contents of a bucket using a glob pattern
33
33
  def ls(pattern = '**/*', **_opts)
34
- dir = pattern[%r{^[^\*\?\{\}\[\]]+/}]
34
+ dir = pattern[%r{^[^*?\{\}\[\]]+/}]
35
35
  dir&.chomp!('/')
36
36
 
37
37
  Enumerator.new do |y|
@@ -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
@@ -81,7 +74,7 @@ module BFS
81
74
  def rm(path, **_opts)
82
75
  path = norm_path(path)
83
76
  @client.delete(path)
84
- rescue Net::FTPPermError
77
+ rescue Net::FTPPermError # rubocop:disable Lint/SuppressedException
85
78
  end
86
79
 
87
80
  # Closes the underlying connection
@@ -114,10 +107,15 @@ module BFS
114
107
  end
115
108
  end
116
109
 
117
- BFS.register('ftp', 'sftp') do |url, opts|
118
- BFS::Bucket::FTP.new url.host, **opts,
119
- username: url.user ? CGI.unescape(url.user) : nil,
120
- password: url.password ? CGI.unescape(url.password) : nil,
121
- port: url.port,
122
- ssl: opts.key?(:ssl) || url.scheme == 'sftp'
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
+
114
+ extra = {
115
+ username: url.user ? CGI.unescape(url.user) : nil,
116
+ password: url.password ? CGI.unescape(url.password) : nil,
117
+ port: url.port,
118
+ ssl: opts.key?(:ssl) || url.scheme == 'sftp',
119
+ }
120
+ BFS::Bucket::FTP.open url.host, **opts, **extra, &block
123
121
  end
@@ -1,17 +1,8 @@
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
+ sandbox = { host: '127.0.0.1', port: 7021, username: 'ftpuser', password: 'ftppass' }.freeze
13
4
 
14
- RSpec.describe BFS::Bucket::FTP, if: run_spec do
5
+ RSpec.describe BFS::Bucket::FTP, ftp: true do
15
6
  subject { described_class.new sandbox[:host], **sandbox.merge(prefix: SecureRandom.uuid) }
16
7
  after { subject.close }
17
8
 
@@ -22,5 +13,12 @@ RSpec.describe BFS::Bucket::FTP, if: run_spec do
22
13
  it 'should resolve from URL' do
23
14
  bucket = BFS.resolve('ftp://ftpuser:ftppass@127.0.0.1:7021')
24
15
  expect(bucket).to be_instance_of(described_class)
16
+ expect(bucket.instance_variable_get(:@client).pwd).to eq('/ftp/ftpuser')
17
+ bucket.close
18
+
19
+ bucket = BFS.resolve('ftp://ftpuser:ftppass@127.0.0.1:7021/a/b/')
20
+ expect(bucket).to be_instance_of(described_class)
21
+ expect(bucket.instance_variable_get(:@client).pwd).to eq('/ftp/ftpuser/a/b')
22
+ bucket.close
25
23
  end
26
24
  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.0
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-05-28 00:00:00.000000000 Z
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.0
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.0
26
+ version: 0.7.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: net-ftp-list
29
29
  requirement: !ruby/object:Gem::Requirement