net-ftp 0.2.0 → 0.3.8

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: cf9d2560e8bb495195915b83e2fa701ff039c328b06934515ac50f1309025769
4
- data.tar.gz: 2231a3b5311f57b6fee02282e8cb41fd717b79cc1f2186d76483db8fd873ff47
3
+ metadata.gz: e481d7fa04c36757bf0f4a60bc8821b56d37d20343f3ffee84f863a351bab45b
4
+ data.tar.gz: 27dfd640949af2161f80d5899a426fecd2a2d979ee08158cc5c4300cb3c98ae9
5
5
  SHA512:
6
- metadata.gz: 52f5676aecc77cc97286bbbe6c6649ff9a966e7e161674643593db4cdb1aacdd6080fa25d8f8e3e379b9649125a5dd1167b3292401268141f0924bf618e4e0ad
7
- data.tar.gz: 19212687975c12da4fee59c30e620ead52ad0e5a8beccf178de4c74809e43fc662c6cf5a5e084d3b222c19d5bacc4c352bdebb7b2d18939f9762600f9c43b60d
6
+ metadata.gz: 84a90b945499fce5fc21da0b67a8776c0a6aa814670d8d1cbcd40dd5eb3f5d788834991bf4b15c3db4f91e57bba5588c1d1d091ac0b885e40bb878426e1de336
7
+ data.tar.gz: 04454bccbb3088db4510b2805f8a4c38aac2feca903d5a25dd5e7eeb51bb25a89a9c66c336fe1e112ffe063094aac3c1e939fdf8a54add77dde3a3577ee2aa36
@@ -0,0 +1,48 @@
1
+ name: Publish gem to rubygems.org
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ push:
13
+ if: github.repository == 'ruby/net-ftp'
14
+ runs-on: ubuntu-latest
15
+
16
+ environment:
17
+ name: rubygems.org
18
+ url: https://rubygems.org/gems/net-ftp
19
+
20
+ permissions:
21
+ contents: write
22
+ id-token: write
23
+
24
+ steps:
25
+ # Set up
26
+ - name: Harden Runner
27
+ uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
28
+ with:
29
+ egress-policy: audit
30
+
31
+ - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
32
+
33
+ - name: Set up Ruby
34
+ uses: ruby/setup-ruby@cacc9f1c0b3f4eb8a16a6bb0ed10897b43b9de49 # v1.176.0
35
+ with:
36
+ bundler-cache: true
37
+ ruby-version: ruby
38
+
39
+ # Release
40
+ - name: Publish to RubyGems
41
+ uses: rubygems/release-gem@612653d273a73bdae1df8453e090060bb4db5f31 # v1
42
+
43
+ - name: Create GitHub release
44
+ run: |
45
+ tag_name="$(git describe --tags --abbrev=0)"
46
+ gh release create "${tag_name}" --verify-tag --draft --generate-notes
47
+ env:
48
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -3,15 +3,22 @@ name: ubuntu
3
3
  on: [push, pull_request]
4
4
 
5
5
  jobs:
6
+ ruby-versions:
7
+ uses: ruby/actions/.github/workflows/ruby_versions.yml@master
8
+ with:
9
+ engine: cruby
10
+ min_version: 2.6
11
+
6
12
  build:
13
+ needs: ruby-versions
7
14
  name: build (${{ matrix.ruby }} / ${{ matrix.os }})
8
15
  strategy:
9
16
  matrix:
10
- ruby: [ head, '3.1', '3.0', '2.7', '2.6' ]
11
- os: [ ubuntu-latest, macos-latest ]
17
+ ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
18
+ os: [ ubuntu-latest, macos-latest, windows-latest ]
12
19
  runs-on: ${{ matrix.os }}
13
20
  steps:
14
- - uses: actions/checkout@v3
21
+ - uses: actions/checkout@v4
15
22
  - name: Set up Ruby
16
23
  uses: ruby/setup-ruby@v1
17
24
  with:
data/BSDL ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions
5
+ are met:
6
+ 1. Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ 2. Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22
+ SUCH DAMAGE.
data/COPYING ADDED
@@ -0,0 +1,56 @@
1
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
2
+ You can redistribute it and/or modify it under either the terms of the
3
+ 2-clause BSDL (see the file BSDL), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a. place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b. use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c. give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
22
+
23
+ d. make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or binary form,
26
+ provided that you do at least ONE of the following:
27
+
28
+ a. distribute the binaries and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b. accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c. give non-standard binaries non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d. make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under these terms.
43
+
44
+ For the list of those files and their copying conditions, see the
45
+ file LEGAL.
46
+
47
+ 5. The scripts and library files supplied as input to or produced as
48
+ output from the software do not automatically fall under the
49
+ copyright of the software, but belong to whomever generated them,
50
+ and may be sold commercially, and may be aggregated with this
51
+ software.
52
+
53
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
+ PURPOSE.
data/LICENSE.txt CHANGED
@@ -1,22 +1,2 @@
1
- Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
2
-
3
- Redistribution and use in source and binary forms, with or without
4
- modification, are permitted provided that the following conditions
5
- are met:
6
- 1. Redistributions of source code must retain the above copyright
7
- notice, this list of conditions and the following disclaimer.
8
- 2. Redistributions in binary form must reproduce the above copyright
9
- notice, this list of conditions and the following disclaimer in the
10
- documentation and/or other materials provided with the distribution.
11
-
12
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18
- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22
- SUCH DAMAGE.
1
+ All the files in this distribution are covered under either the Ruby license or
2
+ the BSD-2-Clause license (see the file COPYING).
data/lib/net/ftp.rb CHANGED
@@ -77,6 +77,10 @@ module Net
77
77
  # - #rename
78
78
  # - #delete
79
79
  #
80
+ # == Mainframe User Support
81
+ # - #literal
82
+ # - #quote
83
+ #
80
84
  class FTP < Protocol
81
85
  include MonitorMixin
82
86
  if defined?(OpenSSL::SSL)
@@ -85,7 +89,7 @@ module Net
85
89
  end
86
90
 
87
91
  # :stopdoc:
88
- VERSION = "0.2.0"
92
+ VERSION = "0.3.8"
89
93
  FTP_PORT = 21
90
94
  CRLF = "\r\n"
91
95
  DEFAULT_BLOCKSIZE = BufferedIO::BUFSIZE
@@ -245,10 +249,15 @@ module Net
245
249
  if defined?(VerifyCallbackProc)
246
250
  @ssl_context.verify_callback = VerifyCallbackProc
247
251
  end
248
- @ssl_context.session_cache_mode =
249
- OpenSSL::SSL::SSLContext::SESSION_CACHE_CLIENT |
250
- OpenSSL::SSL::SSLContext::SESSION_CACHE_NO_INTERNAL_STORE
251
- @ssl_context.session_new_cb = proc {|sock, sess| @ssl_session = sess }
252
+
253
+ # jruby-openssl does not support session caching
254
+ unless RUBY_ENGINE == "jruby"
255
+ @ssl_context.session_cache_mode =
256
+ OpenSSL::SSL::SSLContext::SESSION_CACHE_CLIENT |
257
+ OpenSSL::SSL::SSLContext::SESSION_CACHE_NO_INTERNAL_STORE
258
+ @ssl_context.session_new_cb = proc {|sock, sess| @ssl_session = sess }
259
+ end
260
+
252
261
  @ssl_session = nil
253
262
  if options[:private_data_connection].nil?
254
263
  @private_data_connection = true
@@ -356,19 +365,14 @@ module Net
356
365
  # SOCKS_SERVER, then a SOCKSSocket is returned, else a Socket is
357
366
  # returned.
358
367
  def open_socket(host, port) # :nodoc:
359
- if defined? SOCKSSocket and ENV["SOCKS_SERVER"]
360
- @passive = true
361
- Timeout.timeout(@open_timeout, OpenTimeout) do
368
+ return Timeout.timeout(@open_timeout, OpenTimeout) {
369
+ if defined? SOCKSSocket and ENV["SOCKS_SERVER"]
370
+ @passive = true
362
371
  SOCKSSocket.open(host, port)
372
+ else
373
+ Socket.tcp(host, port)
363
374
  end
364
- else
365
- begin
366
- Socket.tcp host, port, nil, nil, connect_timeout: @open_timeout
367
- rescue Errno::ETIMEDOUT #raise Net:OpenTimeout instead for compatibility with previous versions
368
- raise Net::OpenTimeout, "Timeout to open TCP connection to "\
369
- "#{host}:#{port} (exceeds #{@open_timeout} seconds)"
370
- end
371
- end
375
+ }
372
376
  end
373
377
  private :open_socket
374
378
 
@@ -568,6 +572,7 @@ module Net
568
572
  def transfercmd(cmd, rest_offset = nil) # :nodoc:
569
573
  if @passive
570
574
  host, port = makepasv
575
+ succeeded = false
571
576
  begin
572
577
  conn = open_socket(host, port)
573
578
  if @resume and rest_offset
@@ -582,8 +587,9 @@ module Net
582
587
  if !resp.start_with?("1")
583
588
  raise FTPReplyError, resp
584
589
  end
590
+ succeeded = true
585
591
  ensure
586
- conn.close if conn && $!
592
+ conn&.close if !succeeded
587
593
  end
588
594
  else
589
595
  sock = makeport
@@ -761,7 +767,7 @@ module Net
761
767
  ensure
762
768
  conn.close if conn
763
769
  end
764
- voidresp
770
+ getresp # The response might be important when connected to a mainframe
765
771
  end
766
772
  end
767
773
  rescue Errno::EPIPE
@@ -883,13 +889,18 @@ module Net
883
889
  # in +remotefile+. If callback or an associated block is supplied, calls it,
884
890
  # passing in the transmitted data one line at a time.
885
891
  #
892
+ # Returns the response which will contain a job number if the user was communicating with a mainframe in ASCII mode
893
+ # after issuing 'quote site filetype=jes'
894
+ #
886
895
  def puttextfile(localfile, remotefile = File.basename(localfile), &block) # :yield: line
887
896
  f = File.open(localfile)
897
+ response = ''
888
898
  begin
889
- storlines("STOR #{remotefile}", f, &block)
899
+ response = storlines("STOR #{remotefile}", f, &block)
890
900
  ensure
891
901
  f.close
892
902
  end
903
+ response
893
904
  end
894
905
 
895
906
  #
@@ -1229,6 +1240,16 @@ module Net
1229
1240
  return parse257(resp)
1230
1241
  end
1231
1242
 
1243
+ #
1244
+ # The "quote" subcommand sends arguments verbatim to the remote ftp server.
1245
+ # The "literal" subcommand is an alias for "quote".
1246
+ # @param arguments Array[String] to be sent verbatim to the remote ftp server
1247
+ #
1248
+ def quote(arguments)
1249
+ sendcmd(arguments)
1250
+ end
1251
+ alias literal quote
1252
+
1232
1253
  #
1233
1254
  # Removes a remote directory.
1234
1255
  #
@@ -1346,7 +1367,7 @@ module Net
1346
1367
  end
1347
1368
 
1348
1369
  feats = []
1349
- resp.split("\n").each do |line|
1370
+ resp.each_line do |line|
1350
1371
  next if !line.start_with?(' ') # skip status lines
1351
1372
 
1352
1373
  feats << line.strip
@@ -1401,7 +1422,7 @@ module Net
1401
1422
  if !resp.start_with?("227")
1402
1423
  raise FTPReplyError, resp
1403
1424
  end
1404
- if m = /\((?<host>\d+(?:,\d+){3}),(?<port>\d+,\d+)\)/.match(resp)
1425
+ if m = /(?<host>\d+(?:,\d+){3}),(?<port>\d+,\d+)/.match(resp)
1405
1426
  if @use_pasv_ip
1406
1427
  host = parse_pasv_ipv4_host(m["host"])
1407
1428
  else
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-ftp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-10-07 00:00:00.000000000 Z
10
+ date: 2024-10-03 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: net-protocol
@@ -46,8 +45,11 @@ extensions: []
46
45
  extra_rdoc_files: []
47
46
  files:
48
47
  - ".github/dependabot.yml"
48
+ - ".github/workflows/push_gem.yml"
49
49
  - ".github/workflows/test.yml"
50
50
  - ".gitignore"
51
+ - BSDL
52
+ - COPYING
51
53
  - Gemfile
52
54
  - LICENSE.txt
53
55
  - README.md
@@ -61,7 +63,6 @@ licenses:
61
63
  metadata:
62
64
  homepage_uri: https://github.com/ruby/net-ftp
63
65
  source_code_uri: https://github.com/ruby/net-ftp
64
- post_install_message:
65
66
  rdoc_options: []
66
67
  require_paths:
67
68
  - lib
@@ -76,8 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
77
  - !ruby/object:Gem::Version
77
78
  version: '0'
78
79
  requirements: []
79
- rubygems_version: 3.4.0.dev
80
- signing_key:
80
+ rubygems_version: 3.6.0.dev
81
81
  specification_version: 4
82
82
  summary: Support for the File Transfer Protocol.
83
83
  test_files: []