net-ftp 0.1.1 → 0.1.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: ba4ad76088a26b22d04b1c904c98d47d064d69c9ec06cb1c29d5f81d604963b7
4
- data.tar.gz: 2416f84cfc9b309026a027af2f44629119fa19a1cd2fb45a306d8aeae1653115
3
+ metadata.gz: cb3a59b7b4a2153ab8e56bdf8dbad9402c9ae73aeb5dc765a990dc0fe491dd46
4
+ data.tar.gz: 0c5552bcd67be7ae0087d83345716a8b6014d2d5347348ca72a48c5e1c306a2b
5
5
  SHA512:
6
- metadata.gz: 59a15adc74781c2720af162360e9f05768b91d0a5b1937faf6ee2d04679feabdb1b9e892ea6c56f48fc06c2487506461935ee67163335b2700dd53c3c7f591c3
7
- data.tar.gz: 8b08d23da6ad3126d18c2efd7711d2b95a7df621399e73548596e27cd5e159ea3e195181ba83e3cedebd4dff4b43853ad74ed88fe644ea648dc44713cb6026a5
6
+ metadata.gz: 4a67c6f9918df76bfb390cbaa44216e5180ab8f28c703da4fbf2cc83dccd062d420eb180a7db489a37fdc8dfbb676dee78695b71082a622172e208fa220a4a2c
7
+ data.tar.gz: b501f9ee7c06712ed74eef5b5f414d9abb772d41f639a4bd71824e58cc62230715f5a23d139ccb0ff6c4cbf3033cb931c5921b9616e6f06c249fdcdcd8547af8
@@ -7,18 +7,16 @@ jobs:
7
7
  name: build (${{ matrix.ruby }} / ${{ matrix.os }})
8
8
  strategy:
9
9
  matrix:
10
- ruby: [ 2.7, 2.6, 2.5, 2.4, head ]
10
+ ruby: [ '3.0', 2.7, 2.6, 2.5, 2.4, head ]
11
11
  os: [ ubuntu-latest, macos-latest ]
12
12
  runs-on: ${{ matrix.os }}
13
13
  steps:
14
- - uses: actions/checkout@master
14
+ - uses: actions/checkout@v2
15
15
  - name: Set up Ruby
16
16
  uses: ruby/setup-ruby@v1
17
17
  with:
18
18
  ruby-version: ${{ matrix.ruby }}
19
19
  - name: Install dependencies
20
- run: |
21
- gem install bundler --no-document
22
- bundle install
20
+ run: bundle install
23
21
  - name: Run test
24
22
  run: rake test
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ Gemfile.lock
data/lib/net/ftp.rb CHANGED
@@ -85,7 +85,7 @@ module Net
85
85
  end
86
86
 
87
87
  # :stopdoc:
88
- VERSION = "0.1.1"
88
+ VERSION = "0.1.2"
89
89
  FTP_PORT = 21
90
90
  CRLF = "\r\n"
91
91
  DEFAULT_BLOCKSIZE = BufferedIO::BUFSIZE
@@ -330,14 +330,19 @@ module Net
330
330
  # SOCKS_SERVER, then a SOCKSSocket is returned, else a Socket is
331
331
  # returned.
332
332
  def open_socket(host, port) # :nodoc:
333
- return Timeout.timeout(@open_timeout, OpenTimeout) {
334
- if defined? SOCKSSocket and ENV["SOCKS_SERVER"]
335
- @passive = true
333
+ if defined? SOCKSSocket and ENV["SOCKS_SERVER"]
334
+ @passive = true
335
+ Timeout.timeout(@open_timeout, OpenTimeout) do
336
336
  SOCKSSocket.open(host, port)
337
- else
338
- Socket.tcp(host, port)
339
337
  end
340
- }
338
+ else
339
+ begin
340
+ Socket.tcp host, port, nil, nil, connect_timeout: @open_timeout
341
+ rescue Errno::ETIMEDOUT #raise Net:OpenTimeout instead for compatibility with previous versions
342
+ raise Net::OpenTimeout, "Timeout to open TCP connection to "\
343
+ "#{host}:#{port} (exceeds #{@open_timeout} seconds)"
344
+ end
345
+ end
341
346
  end
342
347
  private :open_socket
343
348
 
@@ -542,18 +547,22 @@ module Net
542
547
  def transfercmd(cmd, rest_offset = nil) # :nodoc:
543
548
  if @passive
544
549
  host, port = makepasv
545
- conn = open_socket(host, port)
546
- if @resume and rest_offset
547
- resp = sendcmd("REST " + rest_offset.to_s)
548
- if !resp.start_with?("3")
550
+ begin
551
+ conn = open_socket(host, port)
552
+ if @resume and rest_offset
553
+ resp = sendcmd("REST " + rest_offset.to_s)
554
+ if !resp.start_with?("3")
555
+ raise FTPReplyError, resp
556
+ end
557
+ end
558
+ resp = sendcmd(cmd)
559
+ # skip 2XX for some ftp servers
560
+ resp = getresp if resp.start_with?("2")
561
+ if !resp.start_with?("1")
549
562
  raise FTPReplyError, resp
550
563
  end
551
- end
552
- resp = sendcmd(cmd)
553
- # skip 2XX for some ftp servers
554
- resp = getresp if resp.start_with?("2")
555
- if !resp.start_with?("1")
556
- raise FTPReplyError, resp
564
+ ensure
565
+ conn.close if conn && $!
557
566
  end
558
567
  else
559
568
  sock = makeport
@@ -1045,10 +1054,11 @@ module Net
1045
1054
  TIME_PARSER = ->(value, local = false) {
1046
1055
  unless /\A(?<year>\d{4})(?<month>\d{2})(?<day>\d{2})
1047
1056
  (?<hour>\d{2})(?<min>\d{2})(?<sec>\d{2})
1048
- (?:\.(?<fractions>\d+))?/x =~ value
1057
+ (?:\.(?<fractions>\d{1,17}))?/x =~ value
1058
+ value = value[0, 97] + "..." if value.size > 100
1049
1059
  raise FTPProtoError, "invalid time-val: #{value}"
1050
1060
  end
1051
- usec = fractions.to_i * 10 ** (6 - fractions.to_s.size)
1061
+ usec = ".#{fractions}".to_r * 1_000_000 if fractions
1052
1062
  Time.public_send(local ? :local : :utc, year, month, day, hour, min, sec, usec)
1053
1063
  }
1054
1064
  FACT_PARSERS = Hash.new(CASE_DEPENDENT_PARSER)
@@ -1356,7 +1366,7 @@ module Net
1356
1366
  end
1357
1367
 
1358
1368
  #
1359
- # Returns +true+ iff the connection is closed.
1369
+ # Returns +true+ if and only if the connection is closed.
1360
1370
  #
1361
1371
  def closed?
1362
1372
  @sock == nil or @sock.closed?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-ftp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-22 00:00:00.000000000 Z
11
+ date: 2021-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-protocol
@@ -48,7 +48,6 @@ files:
48
48
  - ".github/workflows/test.yml"
49
49
  - ".gitignore"
50
50
  - Gemfile
51
- - Gemfile.lock
52
51
  - LICENSE.txt
53
52
  - README.md
54
53
  - Rakefile
@@ -78,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
77
  - !ruby/object:Gem::Version
79
78
  version: '0'
80
79
  requirements: []
81
- rubygems_version: 3.2.2
80
+ rubygems_version: 3.3.0.dev
82
81
  signing_key:
83
82
  specification_version: 4
84
83
  summary: Support for the File Transfer Protocol.
data/Gemfile.lock DELETED
@@ -1,23 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- net-ftp (0.1.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- power_assert (1.1.5)
10
- rake (13.0.1)
11
- test-unit (3.3.5)
12
- power_assert
13
-
14
- PLATFORMS
15
- ruby
16
-
17
- DEPENDENCIES
18
- net-ftp!
19
- rake
20
- test-unit
21
-
22
- BUNDLED WITH
23
- 2.1.4