bfs-ftp 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bfs/bucket/ftp.rb +27 -9
  3. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1a2274fa3727fd33cef1df0ab403e5db898294ad3e1ae48f580ece29dfa7900
4
- data.tar.gz: 1380a85411db753dbc2d4b273e8aba23a82b2831c914c3d9e8cc7a1ade14c909
3
+ metadata.gz: f926cbf5d1e11566b003f431781d2a7724619245d3cb6f65a35f74db0a1c1c86
4
+ data.tar.gz: a2db0fcadc0b559053dd92cfa48980ea94949a5aa2d1b66316042cbdadc10b40
5
5
  SHA512:
6
- metadata.gz: 1f0328f48f717639c9fd47ff20327e3828e8ab3a7e835936dec8bc49e9dd14da0bc24c6d9bcd285eaef1dd923039a9e36ca140f7f6da531c74617d0ce3c93e61
7
- data.tar.gz: e730fb80fa69bce311cff7a5508e4045fe24db1194e32e567f760f4231e4b0c907cb02155c5c108b83fcfab7fe12663cd22e772ae4aec124a59451f1da71b75b
6
+ metadata.gz: a14a4f793f59f403d7562301015c3d92505c06e7d76eb98d3a0bf661f8a8108d8aaacf7a0948f728c10366b57b57928f5029f06a09368734addd04f6f0881f5a
7
+ data.tar.gz: c769992cb97bcdac23ad2e2669eefab10e274f170fc666f34b4a5e3efc7bcb62fc3181cbd6eb520589bc652ac776cf70e7242b6a3af4eabfd59f177794e57f23
@@ -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
- glob(dir) do |path|
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)
@@ -84,14 +90,26 @@ module BFS
84
90
 
85
91
  private
86
92
 
87
- def glob(dir, &block)
88
- @client.ls(dir || '.') do |e|
89
- entry = Net::FTP::List.parse(e)
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
- glob subdir, &block
109
+ walk_r(subdir, &block)
93
110
  elsif entry.file?
94
- yield [dir, entry.basename].compact.join('/')
111
+ path = [dir, entry.basename].compact.join('/')
112
+ yield(path, entry)
95
113
  end
96
114
  end
97
115
  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.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitrij Denissenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-04 00:00:00.000000000 Z
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.8.2
19
+ version: 0.8.3
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.8.2
26
+ version: 0.8.3
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.2.15
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: FTP adapter for bfs