bfs-scp 0.6.1 → 0.6.2

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: 806a4a94596c4967bf51c5017c05cc60444a65ef67c8f76e9eb13448d8989428
4
- data.tar.gz: 465ff7c8af4987f2ac97311cfb8039d584193a60e5837dfca2ba7759986d87cb
3
+ metadata.gz: 2d2a1d8aa79faab191a46b8719628bc1b92fa2528be1e9b95d1e0c88e34e5131
4
+ data.tar.gz: 3b8ed648fc045c535b360c9541028655a18748c4421cdec5f6ac23b3ca04681a
5
5
  SHA512:
6
- metadata.gz: 459ec003bfbd273b9aee278f8fd81533b5d0493d573eefa8c6f9303b9e8d1bb444216ab9bd9d1785b3c92ac0e3e60fce8233535374b9be59658b82c85c7ebe4a
7
- data.tar.gz: 5b54beb2bd9b9bcfdd40e621adabbb71d34421eee4cddfbae59c0b6c2a32f5fe1156a0657db539880766c33d437d28d2adb458213f7d4eb50e25ffc240ac617a
6
+ metadata.gz: 375ed1a9efc068961df091335dd6950e934d3f9363d7c79b6e8428c4d04febe368569189caf8b941ca74b3b1c964229cc7df6ed1399e6cdb783e16a2e71c1814
7
+ data.tar.gz: faaccfff6e02b43e0e41374596dd89f169c827916ca1902d3504de4cdbafb6fcc53594055170a68a7b76715783d82217e55200bdb233c379392446d4853888aa
@@ -28,15 +28,10 @@ module BFS
28
28
  # @option opts [Integer] :keepalive_interval interval if keepalive enabled. Default: 300.
29
29
  # @option opts [Array<String>] :keys an array of file names of private keys to use for publickey and hostbased authentication.
30
30
  # @option opts [Boolean|Symbol] :verify_host_key specifying how strict host-key verification should be, either false, true, :very, or :secure.
31
- def initialize(host, **opts)
32
- opts = opts.dup
33
- opts.keys.each do |key|
34
- val = opts.delete(key)
35
- opts[key.to_sym] = val unless val.nil?
36
- end
31
+ def initialize(host, prefix: nil, **opts)
37
32
  super(**opts)
38
33
 
39
- @prefix = opts.delete(:prefix)
34
+ @prefix = prefix
40
35
  @client = Net::SCP.start(host, nil, **opts)
41
36
 
42
37
  if @prefix # rubocop:disable Style/GuardClause
@@ -62,10 +57,10 @@ module BFS
62
57
  def info(path, **_opts)
63
58
  full = full_path(path)
64
59
  path = norm_path(path)
65
- out = sh! 'stat', '-c', '%s;%Z', full
60
+ out = sh! 'stat', '-c', '%s;%Z;%a', full
66
61
 
67
- size, epoch = out.strip.split(';', 2).map(&:to_i)
68
- BFS::FileInfo.new(path, size, Time.at(epoch))
62
+ size, epoch, mode = out.strip.split(';', 3)
63
+ BFS::FileInfo.new(path: path, size: size.to_i, mtime: Time.at(epoch.to_i), mode: BFS.norm_mode(mode))
69
64
  rescue CommandError => e
70
65
  e.status == 1 ? raise(BFS::FileNotFound, path) : raise
71
66
  end
@@ -73,13 +68,14 @@ module BFS
73
68
  # Creates a new file and opens it for writing
74
69
  # @option opts [String|Encoding] :encoding Custom file encoding.
75
70
  # @option opts [Integer] :perm Custom file permission, default: 0600.
76
- def create(path, **opts, &block)
71
+ def create(path, encoding: nil, perm: nil, **opts, &block)
77
72
  full = full_path(path)
78
- perm = opts[:perm]
79
- enc = opts.delete(:encoding) || @encoding
80
- temp = BFS::TempWriter.new(path, perm: perm, encoding: enc) do |temp_path|
73
+
74
+ opts[:preserve] = true if perm && !opts.key?(:preserve)
75
+ enc = encoding || @encoding
76
+ temp = BFS::TempWriter.new(path, encoding: enc, perm: perm) do |temp_path|
81
77
  mkdir_p File.dirname(full)
82
- @client.upload!(temp_path, full, preserve: true)
78
+ @client.upload!(temp_path, full, **opts)
83
79
  end
84
80
  return temp unless block
85
81
 
@@ -91,10 +87,10 @@ module BFS
91
87
  end
92
88
 
93
89
  # Opens an existing file for reading
94
- def open(path, **opts, &block)
90
+ def open(path, encoding: nil, tempdir: nil, **_opts, &block)
95
91
  full = full_path(path)
96
- enc = opts.delete(:encoding) || @encoding
97
- temp = Tempfile.new(File.basename(path), encoding: enc)
92
+ enc = encoding || @encoding
93
+ temp = Tempfile.new(File.basename(path), tempdir, encoding: enc)
98
94
  temp.close
99
95
 
100
96
  @client.download!(full, temp.path)
@@ -45,4 +45,11 @@ RSpec.describe BFS::Bucket::SCP, if: run_spec do
45
45
  abs.close
46
46
  rel.close
47
47
  end
48
+
49
+ it 'should support custom perms' do
50
+ blob = BFS::Blob.new("scp://root:root@127.0.0.1:7022/#{SecureRandom.uuid}/file.txt")
51
+ blob.create(perm: 0o666) {|w| w.write 'foo' }
52
+ expect(blob.info.mode).to eq(0o666)
53
+ blob.close
54
+ end
48
55
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bfs-scp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
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-02-12 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.6.2
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.6.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: net-scp
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.2
70
+ rubygems_version: 3.0.6
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: SCP/SSH adapter for bfs