bfs-ftp 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bfs-ftp.gemspec +1 -1
  3. data/lib/bfs/bucket/ftp.rb +13 -23
  4. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1382d2b94a93557fd39b9fa5a81a932836bb381e5eb96b4cf41551b8b7d1cfea
4
- data.tar.gz: c8152beba12ccc144e5b740bc768d5559be75ee0b79029c9bfdadbdc415975ed
3
+ metadata.gz: 38b05322f90198412292ff3521d4d59b82b32bc3d9f10b8799a8dff4b29a8fe3
4
+ data.tar.gz: 0db611782568ba9ea4b58f92bc706d755dc5cb19a5ca5ed9f347e832378bcaf4
5
5
  SHA512:
6
- metadata.gz: 5d12dedbf6a8ef0f96dccaf21c9104298739ed9deb821006ef10a3596d76ec1d2b3da1ec95e2f2e37ac9ad0af24afdf9638dff001bcc0e74e0f7c8ffdccc42ee
7
- data.tar.gz: afc2daba69cacdb914a474b2b1575e627eb6e72f026e1da34aa4759f46d328cab123211c2366885882e347e17bd19f021984c3d25449ea6a5c423b50f8aed316
6
+ metadata.gz: b46c593f7f2c31b2e1284091f3aefd9557c5c807538e7bebb3cbacc89814e23be126f8699472ac7f6e5e7b612374d4425e75caafd79f1eb00ffcece69ace155b
7
+ data.tar.gz: f98a8d56a8d41bcc500e61167feedf3bb51b0fca9a5c146e3d78ead1e564932062eaf4b5bfcae1de43544c5a8d224be0a3b0ee891406e681711b425a47a343f8
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = `git ls-files -- spec/*`.split("\n")
17
17
  s.require_paths = ['lib']
18
- s.required_ruby_version = '>= 2.5.0'
18
+ s.required_ruby_version = '>= 2.6.0'
19
19
 
20
20
  s.add_dependency 'bfs', s.version
21
21
  s.add_dependency 'net-ftp-list'
@@ -1,11 +1,12 @@
1
1
  require 'bfs'
2
2
  require 'net/ftp/list'
3
- require 'cgi'
4
3
 
5
4
  module BFS
6
5
  module Bucket
7
6
  # FTP buckets are operating on ftp servers
8
7
  class FTP < Abstract
8
+ attr_reader :perm
9
+
9
10
  # Initializes a new bucket
10
11
  # @param [String] host the host name
11
12
  # @param [Hash] opts options
@@ -15,15 +16,9 @@ module BFS
15
16
  # @option opts [String] :password password for login.
16
17
  # @option opts [String] :passive connect in passive mode. Default: true.
17
18
  # @option opts [String] :prefix optional prefix.
18
- def initialize(host, **opts)
19
- opts = opts.dup
20
- opts.keys.each do |key|
21
- val = opts.delete(key)
22
- opts[key.to_sym] = val unless val.nil?
23
- end
19
+ def initialize(host, prefix: nil, **opts)
24
20
  super(**opts)
25
21
 
26
- prefix = opts.delete(:prefix)
27
22
  @client = Net::FTP.new(host, **opts)
28
23
  @client.binary = true
29
24
 
@@ -49,16 +44,15 @@ module BFS
49
44
  # Info returns the object info
50
45
  def info(path, **_opts)
51
46
  path = norm_path(path)
52
- BFS::FileInfo.new(path, @client.size(path), @client.mtime(path))
47
+ BFS::FileInfo.new(path: path, size: @client.size(path), mtime: @client.mtime(path))
53
48
  rescue Net::FTPPermError
54
49
  raise BFS::FileNotFound, path
55
50
  end
56
51
 
57
52
  # Creates a new file and opens it for writing
58
- def create(path, **opts, &block)
53
+ def create(path, encoding: self.encoding, perm: self.perm, **_opts, &block)
59
54
  path = norm_path(path)
60
- enc = opts.delete(:encoding) || @encoding
61
- temp = BFS::TempWriter.new(path, encoding: enc) do |t|
55
+ temp = BFS::TempWriter.new(path, encoding: encoding, perm: perm) do |t|
62
56
  mkdir_p File.dirname(path)
63
57
  @client.put(t, path)
64
58
  end
@@ -72,14 +66,13 @@ module BFS
72
66
  end
73
67
 
74
68
  # Opens an existing file for reading
75
- def open(path, **opts, &block)
69
+ def open(path, encoding: self.encoding, perm: self.perm, tempdir: nil, **_opts, &block)
76
70
  path = norm_path(path)
77
- enc = opts.delete(:encoding) || @encoding
78
- temp = Tempfile.new(File.basename(path), encoding: enc)
71
+ temp = Tempfile.new(File.basename(path), tempdir, encoding: encoding, perm: perm)
79
72
  temp.close
80
73
 
81
74
  @client.get(path, temp.path)
82
- File.open(temp.path, encoding: enc, &block)
75
+ File.open(temp.path, encoding: encoding, &block)
83
76
  rescue Net::FTPPermError
84
77
  raise BFS::FileNotFound, path
85
78
  end
@@ -88,7 +81,7 @@ module BFS
88
81
  def rm(path, **_opts)
89
82
  path = norm_path(path)
90
83
  @client.delete(path)
91
- rescue Net::FTPPermError # rubocop:disable Lint/SuppressedException
84
+ rescue Net::FTPPermError
92
85
  end
93
86
 
94
87
  # Closes the underlying connection
@@ -121,13 +114,10 @@ module BFS
121
114
  end
122
115
  end
123
116
 
124
- BFS.register('ftp', 'sftp') do |url|
125
- params = CGI.parse(url.query.to_s)
126
-
127
- BFS::Bucket::FTP.new url.host,
117
+ BFS.register('ftp', 'sftp') do |url, opts|
118
+ BFS::Bucket::FTP.new url.host, **opts,
128
119
  username: url.user ? CGI.unescape(url.user) : nil,
129
120
  password: url.password ? CGI.unescape(url.password) : nil,
130
121
  port: url.port,
131
- ssl: params.key?('ssl') || url.scheme == 'sftp',
132
- prefix: params.key?('prefix') ? params['prefix'].first : nil
122
+ ssl: opts.key?(:ssl) || url.scheme == 'sftp'
133
123
  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.6.1
4
+ version: 0.7.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-02-11 00:00:00.000000000 Z
11
+ date: 2020-05-28 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.6.1
19
+ version: 0.7.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.6.1
26
+ version: 0.7.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: net-ftp-list
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -60,7 +60,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - ">="
62
62
  - !ruby/object:Gem::Version
63
- version: 2.5.0
63
+ version: 2.6.0
64
64
  required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="