net-scp 4.2.0 → 4.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8d6b4ea9428a9cc3df98e388eb80ce0a6dd45021bad757992537f24dc954d38
4
- data.tar.gz: 72ada8e9dc44cf7d7ffad414ccf8dfa90f1f3f875e83400acc6293e9523d8b03
3
+ metadata.gz: ee8ac18a34abb6482265e9cef492d7a2988d821feeda9bd25b13158ae9676987
4
+ data.tar.gz: b35016e03ea18a6a707e6c9f0236930db49fe6ba33e2e675b910b6913f525419
5
5
  SHA512:
6
- metadata.gz: 76879f624878414b25e51abe5cfc88d078a99db6750b3b7c816454cae23c4d1d988201dd56af3ac3df21ac7b9c575a160c9eca44ccb731bfa332a6c3fe43651a
7
- data.tar.gz: 41880eab49fcce9ae5e1f251f2360843941598b96496d26b33770449d53bf1b2ea15ef706af37d5af83370c57e0c878815d523eca2b974274dce43288953e318
6
+ metadata.gz: d3a721c9a2310e338dc12f6f06bc712a3b0961f3236de4f69584541c04b2b4b83caf26954b104b8b4a834a93e8e5a4e50167057d7d9d238455d2012f6754ada6
7
+ data.tar.gz: aa7d1a69eeb9d67f622ca4af00576c91938bc39c68ce23e57a70b7ff2f156ec3337ecbc0c6fa4edf52780ce1a0ea95e8090e1fd53a23be42e46e86b675dcf8b2
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 4.2.1
2
+
3
+ * Add a `:limit` option to `upload`/`download` to cap bandwidth in Kbit/s, like `scp -l`. Based on #53 by @marcelrouw [#119, #53]
4
+
1
5
  === 4.2.0
2
6
 
3
7
  * BREAKING: Require Ruby 2.6 or later. Bundler on Ruby 2.3-2.5 resolves to 4.1.3. [#114]
data/README.md CHANGED
@@ -47,6 +47,11 @@ Net::SCP.download!("remote.host.com", "username",
47
47
  "/remote/path", "/local/path",
48
48
  :ssh => { :password => "password" })
49
49
 
50
+ # download with the bandwidth limited to 400 Kbit/s, like `scp -l 400`
51
+ Net::SCP.download!("remote.host.com", "username",
52
+ "/remote/path", "/local/path",
53
+ :ssh => { :password => "password" }, :limit => 400)
54
+
50
55
  # download a file to an in-memory buffer
51
56
  data = Net::SCP::download!("remote.host.com", "username", "/remote/path")
52
57
 
@@ -52,7 +52,7 @@ module Net
52
52
  MINOR = 2
53
53
 
54
54
  # The tiny component of this version of the Net::SSH library
55
- TINY = 0
55
+ TINY = 1
56
56
 
57
57
  # The prerelease component of this version of the Net::SSH library
58
58
  # nil allowed
data/lib/net/scp.rb CHANGED
@@ -94,6 +94,7 @@ module Net
94
94
  # be sent to indicate the modification and access times of each file.
95
95
  # * "-r" -- recursive transfers should be allowed. Without this, it is an
96
96
  # error to upload or download a directory.
97
+ # * "-l" -- limit the bandwidth used by the transfer, in Kbit/s.
97
98
  #
98
99
  # After those flags, the name of the remote file/directory should be passed
99
100
  # as the sole non-switch argument to scp.
@@ -267,6 +268,8 @@ module Net
267
268
  # * :chunk_size - the size of each "chunk" that should be sent. Defaults
268
269
  # to 2048. Changing this value may improve throughput at the expense
269
270
  # of decreasing interactivity.
271
+ # * :limit - the bandwidth limit in Kbit/s, a positive Integer, like
272
+ # <tt>scp -l</tt>. The remote scp enforces it.
270
273
  # * :quote - how +remote+ is quoted in the scp command run by the remote
271
274
  # shell. :posix (the default) escapes it for a POSIX shell, leaving a
272
275
  # leading "~" or "~/" unescaped so it expands to the remote home
@@ -309,6 +312,7 @@ module Net
309
312
  # * :preserve - the atime and mtime of the file should be preserved.
310
313
  # * :verbose - the process should result in verbose output on the server
311
314
  # end (useful for debugging).
315
+ # * :limit - the bandwidth limit in Kbit/s (see #upload).
312
316
  # * :quote - how +remote+ is quoted for the remote shell (see #upload).
313
317
  #
314
318
  # This method will return immediately, returning the Net::SSH::Connection::Channel
@@ -343,7 +347,7 @@ module Net
343
347
 
344
348
  # Constructs the scp command line needed to initiate and SCP session
345
349
  # for the given +mode+ (:upload or :download) and with the given options
346
- # (:verbose, :recursive, :preserve). Returns the command-line as a
350
+ # (:verbose, :recursive, :preserve, :limit). Returns the command-line as a
347
351
  # string, ready to execute.
348
352
  def scp_command(mode, options)
349
353
  command = +"scp "
@@ -351,6 +355,11 @@ module Net
351
355
  command << " -v" if options[:verbose]
352
356
  command << " -r" if options[:recursive]
353
357
  command << " -p" if options[:preserve]
358
+ limit = options[:limit]
359
+ unless limit.nil?
360
+ raise ArgumentError, ":limit must be a positive Integer" unless limit.is_a?(Integer) && limit > 0
361
+ command << " -l #{limit}"
362
+ end
354
363
  command
355
364
  end
356
365
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-scp
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamis Buck
@@ -32,7 +32,7 @@ cert_chain:
32
32
  vNiMFH5yLu/tlav4xh+HlYscWVdFQIvd7f/Uxa+Vip1Pi16wmhnrE15z/vDX921v
33
33
  hukBRIoCEAuUgNVBh+L/C8aETzbf/77WU3Si/w==
34
34
  -----END CERTIFICATE-----
35
- date: 2026-10-29 00:00:00.000000000 Z
35
+ date: 2026-11-02 00:00:00.000000000 Z
36
36
  dependencies:
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: net-ssh
metadata.gz.sig CHANGED
Binary file