bfs-ftp 0.7.6 → 0.8.4
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 +28 -10
- data/spec/bfs/bucket/ftp_spec.rb +4 -3
- 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: c5be3ed746fb7cb16a7370091447d6bfcb813c272d272e7a5a7c22eaef49eb4a
|
4
|
+
data.tar.gz: 6d70e82c8747aca2b0f6a6f2932b9c72c283506cac0598da2f5a9438f02b730c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b88b1f0dfc2c649bc606ac91e24e115091c8d79f6f59ba0828dd6ba95edf5cb2f5746f43582888410e9d447e84887614748e849f6e86600ce2bdd37a6a8de22b
|
7
|
+
data.tar.gz: 5c16e3e43dbce48a893e7e61731211f1d0bf6c234f1f5879dcde5de182e66a7beee21f0589a108401a7e4c77433dc9b083c6a39b304e106c3e125155b824d2f0
|
data/lib/bfs/bucket/ftp.rb
CHANGED
@@ -31,16 +31,22 @@ 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{^[^*?\{\}\[\]]+/}]
|
35
|
-
dir&.chomp!('/')
|
36
|
-
|
37
34
|
Enumerator.new do |y|
|
38
|
-
|
35
|
+
walk(pattern) do |path, _|
|
39
36
|
y << path if File.fnmatch?(pattern, path, File::FNM_PATHNAME)
|
40
37
|
end
|
41
38
|
end
|
42
39
|
end
|
43
40
|
|
41
|
+
# Iterates over the contents of a bucket using a glob pattern
|
42
|
+
def glob(pattern = '**/*', **_opts)
|
43
|
+
Enumerator.new do |y|
|
44
|
+
walk(pattern) do |path, entry|
|
45
|
+
y << file_info(path, entry) if File.fnmatch?(pattern, path, File::FNM_PATHNAME)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
44
50
|
# Info returns the object info
|
45
51
|
def info(path, **_opts)
|
46
52
|
path = norm_path(path)
|
@@ -52,7 +58,7 @@ module BFS
|
|
52
58
|
# Creates a new file and opens it for writing
|
53
59
|
def create(path, encoding: self.encoding, perm: self.perm, **_opts, &block)
|
54
60
|
path = norm_path(path)
|
55
|
-
BFS::
|
61
|
+
BFS::Writer.new(path, encoding: encoding, perm: perm) do |t|
|
56
62
|
mkdir_p File.dirname(path)
|
57
63
|
@client.put(t, path)
|
58
64
|
end.perform(&block)
|
@@ -84,14 +90,26 @@ module BFS
|
|
84
90
|
|
85
91
|
private
|
86
92
|
|
87
|
-
def
|
88
|
-
|
89
|
-
|
93
|
+
def file_info(path, entry)
|
94
|
+
BFS::FileInfo.new(path: path, size: entry.filesize, mtime: entry.mtime)
|
95
|
+
end
|
96
|
+
|
97
|
+
def walk(pattern, &block)
|
98
|
+
dir = pattern[%r{^[^*?\{\}\[\]]+/}]
|
99
|
+
dir&.chomp!('/')
|
100
|
+
walk_r(dir, &block)
|
101
|
+
end
|
102
|
+
|
103
|
+
def walk_r(dir, &block)
|
104
|
+
entries = @client.list(dir || '.')
|
105
|
+
entries.each do |ent|
|
106
|
+
entry = Net::FTP::List.parse(ent)
|
90
107
|
if entry.dir?
|
91
108
|
subdir = [dir, entry.basename].compact.join('/')
|
92
|
-
|
109
|
+
walk_r(subdir, &block)
|
93
110
|
elsif entry.file?
|
94
|
-
|
111
|
+
path = [dir, entry.basename].compact.join('/')
|
112
|
+
yield(path, entry)
|
95
113
|
end
|
96
114
|
end
|
97
115
|
end
|
data/spec/bfs/bucket/ftp_spec.rb
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe BFS::Bucket::FTP, ftp: true do
|
4
|
+
subject { described_class.new hostname, **conn_opts }
|
5
|
+
|
4
6
|
let(:hostname) { '127.0.0.1' }
|
5
7
|
let(:conn_opts) { { port: 7021, username: 'ftpuser', password: 'ftppass', prefix: SecureRandom.uuid } }
|
6
8
|
|
7
|
-
|
8
|
-
after { subject.close }
|
9
|
+
after { subject.close }
|
9
10
|
|
10
11
|
it_behaves_like 'a bucket',
|
11
12
|
content_type: false,
|
12
13
|
metadata: false
|
13
14
|
|
14
|
-
it '
|
15
|
+
it 'resolves from URL' do
|
15
16
|
bucket = BFS.resolve('ftp://ftpuser:ftppass@127.0.0.1:7021')
|
16
17
|
expect(bucket).to be_instance_of(described_class)
|
17
18
|
expect(bucket.instance_variable_get(:@client).pwd).to eq('/ftp/ftpuser')
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitrij Denissenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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.
|
19
|
+
version: 0.8.4
|
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.4
|
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.
|
70
|
+
rubygems_version: 3.2.15
|
71
71
|
signing_key:
|
72
72
|
specification_version: 4
|
73
73
|
summary: FTP adapter for bfs
|